arbbridge

package
v0.7.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 24, 2020 License: Apache-2.0 Imports: 8 Imported by: 16

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleBlockchainEvents

func HandleBlockchainEvents(
	ctx context.Context,
	client ArbAuthClient,
	startBlockId *common.BlockId,
	startLogIndex uint,
	contract ContractWatcher,
) (context.Context, <-chan Event)

func WaitForBalance

func WaitForBalance(ctx context.Context, client ArbClient, tokenAddress common.Address, userAddress common.Address) error

Types

type ArbAuthClient

type ArbAuthClient interface {
	ArbClient
	Address() common.Address
	NewArbFactory(address common.Address) (ArbFactory, error)
	NewRollup(address common.Address) (ArbRollup, error)
	NewGlobalInbox(address common.Address, rollupAddress common.Address) (GlobalInbox, error)
	NewChallengeFactory(address common.Address) (ChallengeFactory, error)
	NewExecutionChallenge(address common.Address) (ExecutionChallenge, error)
	NewInboxTopChallenge(address common.Address) (InboxTopChallenge, error)
	NewIERC20(address common.Address) (IERC20, error)
}

type ArbClient

type ArbClient interface {
	ChainTimeGetter
	SubscribeBlockHeaders(ctx context.Context, startBlockId *common.BlockId) (<-chan MaybeBlockId, error)
	SubscribeBlockHeadersAfter(ctx context.Context, prevBlockId *common.BlockId) (<-chan MaybeBlockId, error)

	NewArbFactoryWatcher(address common.Address) (ArbFactoryWatcher, error)
	NewRollupWatcher(address common.Address) (ArbRollupWatcher, error)
	NewGlobalInboxWatcher(address common.Address, rollupAddress common.Address) (GlobalInboxWatcher, error)
	NewExecutionChallengeWatcher(address common.Address) (ExecutionChallengeWatcher, error)
	NewInboxTopChallengeWatcher(address common.Address) (InboxTopChallengeWatcher, error)
	NewIERC20Watcher(address common.Address) (IERC20Watcher, error)
	GetBalance(ctx context.Context, account common.Address) (*big.Int, error)
}

type ArbClientStressTest added in v0.7.3

type ArbClientStressTest struct {
	ArbClient
	// contains filtered or unexported fields
}

func NewStressTestClient added in v0.7.3

func NewStressTestClient(client ArbClient, reorgInterval time.Duration) *ArbClientStressTest

func (*ArbClientStressTest) SubscribeBlockHeaders added in v0.7.3

func (st *ArbClientStressTest) SubscribeBlockHeaders(ctx context.Context, startBlockId *common.BlockId) (<-chan MaybeBlockId, error)

func (*ArbClientStressTest) SubscribeBlockHeadersAfter added in v0.7.3

func (st *ArbClientStressTest) SubscribeBlockHeadersAfter(ctx context.Context, prevBlockId *common.BlockId) (<-chan MaybeBlockId, error)

type ArbFactory

type ArbFactory interface {
	ArbFactoryWatcher
	CreateRollup(
		ctx context.Context,
		vmState common.Hash,
		params valprotocol.ChainParams,
		owner common.Address,
	) (common.Address, *common.BlockId, error)
}

type ArbFactoryWatcher

type ArbFactoryWatcher interface {
	GlobalInboxAddress() (common.Address, error)
	ChallengeFactoryAddress() (common.Address, error)
}

type ArbRollup

type ArbRollup interface {
	ArbRollupWatcher
	PlaceStake(ctx context.Context, stakeAmount *big.Int, proof1 []common.Hash, proof2 []common.Hash) ([]Event, error)
	RecoverStakeConfirmed(ctx context.Context, proof []common.Hash) ([]Event, error)
	RecoverStakeOld(ctx context.Context, staker common.Address, proof []common.Hash) ([]Event, error)
	RecoverStakeMooted(ctx context.Context, nodeHash common.Hash, staker common.Address, latestConfirmedProof []common.Hash, stakerProof []common.Hash) ([]Event, error)
	RecoverStakePassedDeadline(ctx context.Context, stakerAddress common.Address, deadlineTicks *big.Int, disputableNodeHashVal common.Hash, childType uint64, vmProtoStateHash common.Hash, proof []common.Hash) ([]Event, error)
	MoveStake(ctx context.Context, proof1 []common.Hash, proof2 []common.Hash) ([]Event, error)
	PruneLeaves(ctx context.Context, params []valprotocol.PruneParams) ([]Event, error)
	MakeAssertion(
		ctx context.Context,
		prevPrevLeafHash common.Hash,
		prevDataHash common.Hash,
		prevDeadline common.TimeTicks,
		prevChildType valprotocol.ChildType,
		beforeState *valprotocol.VMProtoData,
		assertionParams *valprotocol.AssertionParams,
		assertion *valprotocol.ExecutionAssertionStub,
		stakerProof []common.Hash,
		validBlock *common.BlockId,
	) ([]Event, error)
	Confirm(ctx context.Context, opp *valprotocol.ConfirmOpportunity) ([]Event, error)
	StartChallenge(
		ctx context.Context,
		asserterAddress common.Address,
		challengerAddress common.Address,
		prevNode common.Hash,
		disputableDeadline *big.Int,
		asserterPosition valprotocol.ChildType,
		challengerPosition valprotocol.ChildType,
		asserterVMProtoHash common.Hash,
		challengerVMProtoHash common.Hash,
		asserterProof []common.Hash,
		challengerProof []common.Hash,
		asserterNodeHash common.Hash,
		challengerDataHash common.Hash,
		challengerPeriodTicks common.TimeTicks,
	) ([]Event, error)
}

type ArbRollupWatcher

type ArbRollupWatcher interface {
	ContractWatcher

	GetAllEvents(ctx context.Context, fromBlock *big.Int, toBlock *big.Int) ([]Event, error)

	GetParams(ctx context.Context) (valprotocol.ChainParams, error)
	InboxAddress(ctx context.Context) (common.Address, error)
	GetCreationInfo(ctx context.Context) (common.Hash, ChainInfo, common.Hash, *big.Int, error)
	GetVersion(ctx context.Context) (string, error)
	IsStaked(address common.Address) (bool, error)
	VerifyArbChain(ctx context.Context, machHash common.Hash) error
}

type AssertedEvent

type AssertedEvent struct {
	ChainInfo
	PrevLeafHash     common.Hash
	AssertionParams  *valprotocol.AssertionParams
	MaxInboxTop      common.Hash
	MaxInboxCount    *big.Int
	NumGas           uint64
	AfterMachineHash common.Hash
	AfterInboxHash   common.Hash
	LastMessageHash  common.Hash
	MessageCount     uint64
	LastLogHash      common.Hash
	LogCount         uint64
}

type AsserterTimeoutEvent

type AsserterTimeoutEvent struct {
	ChainInfo
}

type ChainInfo

type ChainInfo struct {
	BlockId  *common.BlockId
	LogIndex uint
}

func (ChainInfo) Cmp added in v0.7.0

func (c ChainInfo) Cmp(o ChainInfo) int

func (ChainInfo) GetChainInfo

func (c ChainInfo) GetChainInfo() ChainInfo

type ChainTimeGetter added in v0.6.0

type ChainTimeGetter interface {
	BlockIdForHeight(ctx context.Context, height *common.TimeBlocks) (*common.BlockId, error)
	TimestampForBlockHash(ctx context.Context, hash common.Hash) (*big.Int, error)
}

type Challenge

type Challenge interface {
	TimeoutChallenge(
		ctx context.Context,
	) error
}

type ChallengeCompletedEvent

type ChallengeCompletedEvent struct {
	ChainInfo
	Winner            common.Address
	Loser             common.Address
	ChallengeContract common.Address
}

type ChallengeFactory

type ChallengeFactory interface {
	CreateChallenge(
		ctx context.Context,
		asserter common.Address,
		challenger common.Address,
		challengePeriod common.TimeTicks,
		challengeHash common.Hash,
		challengeType *big.Int,
	) (common.Address, error)
}

type ChallengeStartedEvent

type ChallengeStartedEvent struct {
	ChainInfo
	Asserter          common.Address
	Challenger        common.Address
	ChallengeType     valprotocol.ChildType
	ChallengeContract common.Address
}

type ChallengerTimeoutEvent

type ChallengerTimeoutEvent struct {
	ChainInfo
}

type ConfirmedAssertionEvent

type ConfirmedAssertionEvent struct {
	ChainInfo
	LogsAccHash []common.Hash
}

type ConfirmedEvent

type ConfirmedEvent struct {
	ChainInfo
	NodeHash common.Hash
}

type ContinueChallengeEvent

type ContinueChallengeEvent struct {
	ChainInfo
	SegmentIndex *big.Int
	Deadline     common.TimeTicks
}

type ContractWatcher

type ContractWatcher interface {
	GetEvents(ctx context.Context, blockId *common.BlockId, timestamp *big.Int) ([]Event, error)
}

type Event

type Event interface {
	GetChainInfo() ChainInfo
}

func MergeEventsUnsafe added in v0.6.5

func MergeEventsUnsafe(events1 []Event, events2 []Event) []Event

MergeEventsUnsafe assumes that both sets of events are disjoint and come from the same chain state rather than from two different states caused by a reorg

type ExecutionBisectionEvent

type ExecutionBisectionEvent struct {
	ChainInfo
	AssertionHashes []common.Hash
	Deadline        common.TimeTicks
}

type ExecutionChallenge

type ExecutionChallenge interface {
	Challenge

	BisectAssertion(
		ctx context.Context,
		assertions []*valprotocol.ExecutionAssertionStub,
		totalSteps uint64,
	) error

	OneStepProof(
		ctx context.Context,
		assertion *valprotocol.ExecutionAssertionStub,
		proof []byte,
	) error

	OneStepProofWithMessage(
		ctx context.Context,
		assertion *valprotocol.ExecutionAssertionStub,
		proof []byte,
		msg inbox.InboxMessage,
	) error

	ChooseSegment(
		ctx context.Context,
		assertionToChallenge uint16,
		assertionHashes []common.Hash,
	) error
}

type ExecutionChallengeWatcher

type ExecutionChallengeWatcher interface {
	ContractWatcher
}

type GlobalInbox

type GlobalInbox interface {
	GlobalInboxWatcher
	GlobalInboxSender
}

type GlobalInboxSender added in v0.7.3

type GlobalInboxSender interface {
	SendL2Message(
		ctx context.Context,
		data []byte,
	) (MessageDeliveredEvent, error)

	// SendL2MessageNoWait calls SendL2Message without
	// blocking while waiting for the receipt. This behavior is different from
	// the other ArbBridge methods. At some point other methods should be
	// updated to behave this way once we can be confident that it will not
	// create any security problems
	SendL2MessageNoWait(
		ctx context.Context,
		data []byte,
	) (common.Hash, error)

	DepositEthMessage(
		ctx context.Context,
		destination common.Address,
		value *big.Int,
	) error
	DepositERC20Message(
		ctx context.Context,
		tokenAddress common.Address,
		destination common.Address,
		value *big.Int,
	) error
	DepositERC721Message(
		ctx context.Context,
		tokenAddress common.Address,
		destination common.Address,
		value *big.Int,
	) error
}

type GlobalInboxWatcher added in v0.6.5

type GlobalInboxWatcher interface {
	ContractWatcher

	GetDeliveredEvents(
		ctx context.Context,
		fromBlock *big.Int,
		toBlock *big.Int,
	) ([]MessageDeliveredEvent, error)

	GetDeliveredEventsInBlock(
		ctx context.Context,
		blockId *common.BlockId,
		timestamp *big.Int,
	) ([]MessageDeliveredEvent, error)

	GetERC20Balance(
		ctx context.Context,
		user common.Address,
		tokenContract common.Address,
	) (*big.Int, error)

	GetEthBalance(
		ctx context.Context,
		user common.Address,
	) (*big.Int, error)
}

type IERC20 added in v0.7.0

type IERC20 interface {
	Approve(ctx context.Context, spender common.Address, amount *big.Int) error
}

type IERC20Watcher added in v0.7.0

type IERC20Watcher interface {
	BalanceOf(ctx context.Context, account common.Address) (*big.Int, error)
	Allowance(ctx context.Context, owner, spender common.Address) (*big.Int, error)
}

type InboxTopBisectionEvent

type InboxTopBisectionEvent struct {
	ChainInfo
	ChainHashes []common.Hash
	TotalLength *big.Int
	Deadline    common.TimeTicks
}

type InboxTopChallenge

type InboxTopChallenge interface {
	Challenge

	Bisect(
		ctx context.Context,
		chainHashes []common.Hash,
		chainLength *big.Int,
	) error

	OneStepProof(
		ctx context.Context,
		lowerHashA common.Hash,
		value common.Hash,
	) error

	ChooseSegment(
		ctx context.Context,
		assertionToChallenge uint16,
		chainHashes []common.Hash,
		chainLength uint64,
	) error
}

type InboxTopChallengeWatcher

type InboxTopChallengeWatcher interface {
	ContractWatcher
}

type InitiateChallengeEvent

type InitiateChallengeEvent struct {
	ChainInfo
	Deadline common.TimeTicks
}

type MaybeBlockId

type MaybeBlockId struct {
	BlockId   *common.BlockId
	Timestamp *big.Int
	Err       error
}

type MaybeEvent

type MaybeEvent struct {
	Event Event
	Err   error
}

type MessageDeliveredEvent

type MessageDeliveredEvent struct {
	ChainInfo
	Message inbox.InboxMessage
}

type MessagesBisectionEvent

type MessagesBisectionEvent struct {
	ChainInfo
	ChainHashes   []common.Hash
	SegmentHashes []common.Hash
	TotalLength   *big.Int
	Deadline      common.TimeTicks
}

type NewTimeEvent

type NewTimeEvent struct {
	ChainInfo
}

type OneStepProofEvent

type OneStepProofEvent struct {
	ChainInfo
}

type PrunedEvent

type PrunedEvent struct {
	ChainInfo
	Leaf common.Hash
}

type StakeCreatedEvent

type StakeCreatedEvent struct {
	ChainInfo
	Staker   common.Address
	NodeHash common.Hash
}

type StakeMovedEvent

type StakeMovedEvent struct {
	ChainInfo
	Staker   common.Address
	Location common.Hash
}

type StakeRefundedEvent

type StakeRefundedEvent struct {
	ChainInfo
	Staker common.Address
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL