core

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2021 License: Apache-2.0 Imports: 13 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BisectionChunkHash

func BisectionChunkHash(
	segmentStart *big.Int,
	segmentLength *big.Int,
	startHash common.Hash,
	endHash common.Hash,
) common.Hash

func DeliverMessagesAndWait

func DeliverMessagesAndWait(db ArbCoreInbox, messages []inbox.InboxMessage, previousInboxAcc common.Hash, lastBlockComplete bool) (bool, error)

func GetSingleMessage

func GetSingleMessage(lookup ArbOutputLookup, index *big.Int) (inbox.InboxMessage, error)

func GetSingleSend

func GetSingleSend(lookup ArbOutputLookup, index *big.Int) ([]byte, error)

func GetZeroOrOneLog

func GetZeroOrOneLog(lookup ArbOutputLookup, index *big.Int) (value.Value, error)

func IsAssertionValid

func IsAssertionValid(assertion *Assertion, execTracker *ExecutionTracker, targetInboxAcc [32]byte) (bool, error)

func ReorgAndWait

func ReorgAndWait(db ArbCoreInbox, reorgMessageCount *big.Int) error

Types

type ArbCore

type ArbCore interface {
	ArbCoreLookup
	ArbCoreInbox
	LogsCursor
	StartThread() bool
	StopThread()
	MachineIdle() bool
}

type ArbCoreInbox

type ArbCoreInbox interface {
	DeliverMessages(messages []inbox.InboxMessage, previousInboxAcc common.Hash, lastBlockComplete bool, reorgHeight *big.Int) bool
	MessagesStatus() (MessageStatus, error)
}

type ArbCoreLookup

type ArbCoreLookup interface {
	ArbOutputLookup

	GetInboxAcc(index *big.Int) (common.Hash, error)
	GetInboxAccPair(index1 *big.Int, index2 *big.Int) (common.Hash, common.Hash, error)

	MachineMessagesRead() *big.Int

	// GetExecutionCursor returns a cursor containing the machine after executing totalGasUsed
	// from the original machine
	GetExecutionCursor(totalGasUsed *big.Int) (ExecutionCursor, error)

	// Advance executes as much as it can without going over maxGas or
	// optionally until it reaches or goes over maxGas
	AdvanceExecutionCursor(executionCursor ExecutionCursor, maxGas *big.Int, goOverGas bool) error

	// TakeMachine takes ownership of machine such that ExecutionCursor will
	// no longer be able to advance.
	TakeMachine(executionCursor ExecutionCursor) (machine.Machine, error)
}

type ArbOutputLookup

type ArbOutputLookup interface {
	GetLogCount() (*big.Int, error)
	GetLogs(startIndex, count *big.Int) ([]value.Value, error)

	GetSendCount() (*big.Int, error)
	GetSends(startIndex, count *big.Int) ([][]byte, error)

	GetMessageCount() (*big.Int, error)
	GetMessages(startIndex, count *big.Int) ([]inbox.InboxMessage, error)

	GetMachineForSideload(uint64) (machine.Machine, error)
}

type Assertion

type Assertion struct {
	Before *ExecutionState
	After  *ExecutionState
}

func NewAssertionFromFields

func NewAssertionFromFields(a [2][3][32]byte, b [2][4]*big.Int) *Assertion

func (*Assertion) AfterExecutionHash

func (a *Assertion) AfterExecutionHash() common.Hash

func (*Assertion) BeforeExecutionHash

func (a *Assertion) BeforeExecutionHash() common.Hash

func (*Assertion) BytesFields

func (a *Assertion) BytesFields() [2][3][32]byte

func (*Assertion) CheckTime

func (a *Assertion) CheckTime(arbGasSpeedLimitPerBlock *big.Int) *big.Int

func (*Assertion) ExecutionHash

func (a *Assertion) ExecutionHash() common.Hash

func (*Assertion) IntFields

func (a *Assertion) IntFields() [2][4]*big.Int

type BigIntList

type BigIntList []*big.Int

func (BigIntList) Len

func (l BigIntList) Len() int

func (BigIntList) Less

func (l BigIntList) Less(i, j int) bool

func (BigIntList) Swap

func (l BigIntList) Swap(i, j int)

type Bisection

type Bisection struct {
	ChallengedSegment *ChallengeSegment
	Cuts              []Cut
}

type ChallengeKind

type ChallengeKind uint8
const (
	Uninitialized ChallengeKind = iota
	Execution
	StoppedShort
	NoChallenge
)

type ChallengeSegment

type ChallengeSegment struct {
	Start  *big.Int
	Length *big.Int
}

type Cut

type Cut interface {
	Equals(other Cut) bool
	CutHash() [32]byte
}

type ExecutionCursor

type ExecutionCursor interface {
	Clone() ExecutionCursor
	MachineHash() (common.Hash, error)
	TotalMessagesRead() *big.Int
	InboxAcc() common.Hash
	SendAcc() common.Hash
	LogAcc() common.Hash
	TotalGasConsumed() *big.Int
	TotalSteps() *big.Int
	TotalSendCount() *big.Int
	TotalLogCount() *big.Int
}

type ExecutionState

type ExecutionState struct {
	MachineHash       common.Hash
	InboxAcc          common.Hash
	TotalMessagesRead *big.Int
	TotalGasConsumed  *big.Int
	TotalSendCount    *big.Int
	TotalLogCount     *big.Int
	SendAcc           common.Hash
	LogAcc            common.Hash
}

func NewExecutionState

func NewExecutionState(c ExecutionCursor) *ExecutionState

func (*ExecutionState) CutHash

func (e *ExecutionState) CutHash() [32]byte

func (*ExecutionState) Equals

func (e *ExecutionState) Equals(other Cut) bool

func (*ExecutionState) IsPermanentlyBlocked

func (e *ExecutionState) IsPermanentlyBlocked() bool

func (*ExecutionState) RestHash

func (e *ExecutionState) RestHash() [32]byte

type ExecutionTracker

type ExecutionTracker struct {
	// contains filtered or unexported fields
}

func NewExecutionTracker

func NewExecutionTracker(lookup ArbCoreLookup, goOverGas bool, stopPointsArg []*big.Int) *ExecutionTracker

func NewExecutionTrackerWithInitialCursor

func NewExecutionTrackerWithInitialCursor(lookup ArbCoreLookup, goOverGas bool, stopPointsArg []*big.Int, initialCursor ExecutionCursor) *ExecutionTracker

func (*ExecutionTracker) GetExecutionCursor

func (e *ExecutionTracker) GetExecutionCursor(gasUsed *big.Int) (ExecutionCursor, error)

func (*ExecutionTracker) GetExecutionState

func (e *ExecutionTracker) GetExecutionState(gasUsed *big.Int) (*ExecutionState, *big.Int, error)

func (*ExecutionTracker) GetMachine

func (e *ExecutionTracker) GetMachine(gasUsed *big.Int) (machine.Machine, error)

type InMemoryOutputLookup

type InMemoryOutputLookup struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewInMemoryOutputLookup

func NewInMemoryOutputLookup() *InMemoryOutputLookup

func (*InMemoryOutputLookup) GetLog

func (as *InMemoryOutputLookup) GetLog(index uint64) (value.Value, error)

func (*InMemoryOutputLookup) GetLogCount

func (as *InMemoryOutputLookup) GetLogCount() (*big.Int, error)

func (*InMemoryOutputLookup) GetLogs

func (as *InMemoryOutputLookup) GetLogs(startIndex, count *big.Int) ([]value.Value, error)

func (*InMemoryOutputLookup) GetMessage

func (as *InMemoryOutputLookup) GetMessage(index uint64) (value.Value, error)

func (*InMemoryOutputLookup) GetMessageCount

func (as *InMemoryOutputLookup) GetMessageCount() (*big.Int, error)

func (*InMemoryOutputLookup) GetMessages

func (as *InMemoryOutputLookup) GetMessages(startIndex, count *big.Int) ([]inbox.InboxMessage, error)

func (*InMemoryOutputLookup) GetSendCount

func (as *InMemoryOutputLookup) GetSendCount() (*big.Int, error)

func (*InMemoryOutputLookup) GetSends

func (as *InMemoryOutputLookup) GetSends(startIndex, count *big.Int) ([][]byte, error)

func (*InMemoryOutputLookup) LogCount

func (as *InMemoryOutputLookup) LogCount() (uint64, error)

func (*InMemoryOutputLookup) MessageCount

func (as *InMemoryOutputLookup) MessageCount() (uint64, error)

func (*InMemoryOutputLookup) SaveLog

func (as *InMemoryOutputLookup) SaveLog(val value.Value) error

type LogConsumer

type LogConsumer interface {
	AddLogs(initialIndex *big.Int, avmLogs []value.Value) error
	DeleteLogs(avmLogs []value.Value) error
}

type LogReader

type LogReader struct {
	// contains filtered or unexported fields
}

func NewLogReader

func NewLogReader(consumer LogConsumer, cursor LogsCursor, cursorIndex *big.Int, maxCount *big.Int, sleepTime time.Duration) *LogReader

func (*LogReader) IsRunning

func (lr *LogReader) IsRunning() bool

func (*LogReader) Start

func (lr *LogReader) Start(parentCtx context.Context) <-chan error

func (*LogReader) Stop

func (lr *LogReader) Stop()

type LogsCursor

type LogsCursor interface {
	LogsCursorRequest(cursorIndex *big.Int, count *big.Int) error
	LogsCursorGetLogs(cursorIndex *big.Int) (*big.Int, []value.Value, []value.Value, error)
	LogsCursorCheckError(cursorIndex *big.Int) error
	LogsCursorConfirmReceived(cursorIndex *big.Int) (bool, error)
	LogsCursorPosition(cursorIndex *big.Int) (*big.Int, error)
}

type MessageStatus

type MessageStatus uint8
const (
	MessagesEmpty MessageStatus = iota
	MessagesReady
	MessagesSuccess
	MessagesNeedOlder
	MessagesError
)

type NodeID

type NodeID *big.Int

type NodeInfo

type NodeInfo struct {
	NodeNum       NodeID
	BlockProposed *common.BlockId
	Assertion     *Assertion
	InboxMaxCount *big.Int
	NodeHash      common.Hash
	AfterInboxAcc [32]byte
}

func (*NodeInfo) AfterState

func (n *NodeInfo) AfterState() *NodeState

func (*NodeInfo) InitialExecutionBisection

func (n *NodeInfo) InitialExecutionBisection() *Bisection

type NodeState

type NodeState struct {
	ProposedBlock *big.Int
	InboxMaxCount *big.Int
	*ExecutionState
}

type SimpleCut

type SimpleCut struct {
	// contains filtered or unexported fields
}

func NewSimpleCut

func NewSimpleCut(hash [32]byte) SimpleCut

func (SimpleCut) CutHash

func (c SimpleCut) CutHash() [32]byte

func (SimpleCut) Equals

func (c SimpleCut) Equals(other Cut) bool

func (SimpleCut) String

func (c SimpleCut) String() string

Jump to

Keyboard shortcuts

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