types

package
v1.13.3 Latest Latest
Warning

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

Go to latest
Published: May 15, 2025 License: MIT Imports: 12 Imported by: 4

Documentation

Index

Constants

View Source
const (
	PrefixLookup           = 1
	PrefixChainIDExtension = 2
	PrefixChecksum         = 3
)
View Source
const RevisionAny = ^Revision(0)

RevisionAny is used as indicator to ignore the revision during lookups. This is used in the cross-safe queries, where there will only ever be a single derived block per derived block number, but where the revision is still tracked to match the local-safe DB block replacements. We use the max-uint64 value, since this is reserved, and will not be allowed to decode/encode.

Variables

View Source
var (
	// ErrOutOfOrder happens when you try to add data to the DB,
	// but it does not actually fit onto the latest data (by being too old or new).
	ErrOutOfOrder = errors.New("data out of order")
	// ErrDataCorruption happens when the underlying DB has some I/O issue
	ErrDataCorruption = errors.New("data corruption")
	// ErrNotExact happens when we search the DB, know the data may be there, but is not (e.g. different revision)
	ErrNotExact = errors.New("missed data")
	// ErrSkipped happens when we try to retrieve data that is not available (pruned)
	// It may also happen if we erroneously skip data, that was not considered a conflict, if the DB is corrupted.
	ErrSkipped = errors.New("skipped data")
	// ErrFuture happens when data is just not yet available
	ErrFuture = errors.New("future data")
	// ErrIneffective happens when data is accepted as compatible, but did not change anything.
	// This happens when a node is deriving an L2 block we already know of being derived from the given source,
	// but without path to skip forward to newer source blocks without doing the known derivation work first.
	ErrIneffective = errors.New("ineffective data")
	// ErrConflict happens when we know for sure that there is different canonical data
	ErrConflict = errors.New("conflicting data")
	// ErrAwaitReplacementBlock happens when we know for sure that a replacement block is needed before progress can be made.
	ErrAwaitReplacementBlock = errors.New("awaiting replacement block")
	// ErrStop can be used in iterators to indicate iteration has to stop
	ErrStop = errors.New("iter stop")
	// ErrOutOfScope is when data is accessed, but access is not allowed, because of a limited scope.
	// E.g. when limiting scope to L2 blocks derived from a specific subset of the L1 chain.
	ErrOutOfScope = errors.New("out of scope")
	// ErrPreviousToFirst is when you try to get the previous block of the first block
	// E.g. when calling PreviousDerivedFrom on the first L1 block in the DB.
	ErrPreviousToFirst = errors.New("cannot get parent of first block in the database")
	// ErrUnknownChain is when a chain is unknown, not in the dependency set.
	ErrUnknownChain = errors.New("unknown chain")
	// ErrNoRPCSource happens when a sub-service needs an RPC data source, but is not configured with one.
	ErrNoRPCSource = errors.New("no RPC client configured")
	// ErrUninitialized happens when a chain database is not initialized yet
	ErrUninitialized = errors.New("uninitialized chain database")
)
View Source
var ExecutingMessageEventTopic = crypto.Keccak256Hash([]byte("ExecutingMessage(bytes32,(address,uint256,uint256,uint256,uint256))"))

Functions

func EncodeAccessList added in v1.12.2

func EncodeAccessList(accesses []Access) []common.Hash

func LogToMessagePayload added in v1.9.5

func LogToMessagePayload(l *ethTypes.Log) []byte

LogToMessagePayload is the data that is hashed to get the payloadHash it is the concatenation of the log's topics and data the implementation is based on the interop messaging spec

func PayloadHashToLogHash added in v1.9.5

func PayloadHashToLogHash(payloadHash common.Hash, addr common.Address) common.Hash

PayloadHashToLogHash converts the payload hash to the log hash it is the concatenation of the log's address and the hash of the log's payload, which is then hashed again. This is the hash that is stored in the log storage. The logHash can then be used to traverse from the executing message to the log the referenced initiating message.

Types

type Access added in v1.12.2

type Access struct {
	BlockNumber uint64
	Timestamp   uint64
	LogIndex    uint32
	ChainID     eth.ChainID
	Checksum    MessageChecksum
}

Access represents access to a message, parsed from an access-list

func ParseAccess added in v1.12.2

func ParseAccess(entries []common.Hash) ([]common.Hash, Access, error)

ParseAccess parses some access-list entries into an Access, and returns the remaining entries. This process can be repeated until no entries are left, to parse an access-list.

func (Access) MarshalJSON added in v1.12.2

func (a Access) MarshalJSON() ([]byte, error)

func (*Access) UnmarshalJSON added in v1.12.2

func (a *Access) UnmarshalJSON(input []byte) error

type BlockReplacement added in v1.11.0

type BlockReplacement struct {
	Replacement eth.BlockRef `json:"replacement"`
	Invalidated common.Hash  `json:"invalidated"`
}

type BlockSeal added in v1.9.5

type BlockSeal struct {
	Hash      common.Hash
	Number    uint64
	Timestamp uint64
}

func BlockSealFromRef added in v1.9.5

func BlockSealFromRef(ref eth.BlockRef) BlockSeal

func (BlockSeal) ForceWithParent added in v1.9.5

func (s BlockSeal) ForceWithParent(parent eth.BlockID) eth.BlockRef

func (BlockSeal) ID added in v1.9.5

func (s BlockSeal) ID() eth.BlockID

func (BlockSeal) MustWithParent added in v1.9.5

func (s BlockSeal) MustWithParent(parent eth.BlockID) eth.BlockRef

func (BlockSeal) String added in v1.9.5

func (s BlockSeal) String() string

func (BlockSeal) WithParent added in v1.9.5

func (s BlockSeal) WithParent(parent eth.BlockID) (eth.BlockRef, error)

type ChainIndex added in v1.9.5

type ChainIndex uint32

ChainIndex represents the lifetime of a chain in a dependency set. Warning: JSON-encoded as string, in base-10.

func (ChainIndex) MarshalText added in v1.9.5

func (ci ChainIndex) MarshalText() ([]byte, error)

func (ChainIndex) String added in v1.9.5

func (ci ChainIndex) String() string

func (*ChainIndex) UnmarshalText added in v1.9.5

func (ci *ChainIndex) UnmarshalText(data []byte) error

type ChecksumArgs added in v1.12.2

type ChecksumArgs struct {
	BlockNumber uint64
	LogIndex    uint32
	Timestamp   uint64
	ChainID     eth.ChainID
	LogHash     common.Hash
}

func (ChecksumArgs) Access added in v1.12.2

func (args ChecksumArgs) Access() Access

func (ChecksumArgs) Checksum added in v1.12.2

func (args ChecksumArgs) Checksum() MessageChecksum

func (ChecksumArgs) Query added in v1.12.2

func (args ChecksumArgs) Query() ContainsQuery

type ContainsQuery added in v1.11.0

type ContainsQuery struct {
	Timestamp uint64
	BlockNum  uint64
	LogIdx    uint32
	Checksum  MessageChecksum
}

ContainsQuery contains all the information needed to check a message against a chain's database, to determine if it is valid (ie all invariants hold).

type DerivedBlockRefPair added in v1.11.0

type DerivedBlockRefPair struct {
	Source  eth.BlockRef `json:"source"`
	Derived eth.BlockRef `json:"derived"`
}

DerivedBlockRefPair is a pair of block refs, where Derived (L2) is derived from Source (L1).

func (*DerivedBlockRefPair) IDs added in v1.11.0

func (refs *DerivedBlockRefPair) IDs() DerivedIDPair

func (*DerivedBlockRefPair) Seals added in v1.11.0

func (DerivedBlockRefPair) String added in v1.13.0

func (refs DerivedBlockRefPair) String() string

type DerivedBlockSealPair added in v1.11.0

type DerivedBlockSealPair struct {
	Source  BlockSeal `json:"source"`
	Derived BlockSeal `json:"derived"`
}

DerivedBlockSealPair is a pair of block seals, where Derived (L2) is derived from Source (L1).

func (*DerivedBlockSealPair) IDs added in v1.11.0

func (seals *DerivedBlockSealPair) IDs() DerivedIDPair

func (DerivedBlockSealPair) String added in v1.13.0

func (seals DerivedBlockSealPair) String() string

type DerivedIDPair added in v1.11.0

type DerivedIDPair struct {
	Source  eth.BlockID `json:"source"`
	Derived eth.BlockID `json:"derived"`
}

DerivedIDPair is a pair of block IDs, where Derived (L2) is derived from Source (L1).

func (DerivedIDPair) String added in v1.13.0

func (ids DerivedIDPair) String() string

type ExecutingDescriptor added in v1.12.0

type ExecutingDescriptor struct {
	// Timestamp is the timestamp of the executing message
	Timestamp uint64

	// Timeout, requests verification to still hold at Timestamp+Timeout (incl.). Defaults to 0.
	// I.e. Timestamp is used as lower-bound validity, and Timeout defines the span to the upper-bound.
	Timeout uint64
}

func (*ExecutingDescriptor) AccessCheck added in v1.12.2

func (ed *ExecutingDescriptor) AccessCheck(expiryWindow uint64, initMsgTimestamp uint64) error

func (ExecutingDescriptor) MarshalJSON added in v1.12.0

func (ed ExecutingDescriptor) MarshalJSON() ([]byte, error)

func (*ExecutingDescriptor) UnmarshalJSON added in v1.12.0

func (ed *ExecutingDescriptor) UnmarshalJSON(input []byte) error

type ExecutingMessage added in v1.9.3

type ExecutingMessage struct {
	Chain     ChainIndex // same as ChainID for now, but will be indirect, i.e. translated to full ID, later
	BlockNum  uint64
	LogIdx    uint32
	Timestamp uint64
	Hash      common.Hash // LogHash (hash of msgHash and origin address)
}

func (*ExecutingMessage) String added in v1.9.5

func (s *ExecutingMessage) String() string

type Identifier

type Identifier struct {
	Origin      common.Address
	BlockNumber uint64
	LogIndex    uint32
	Timestamp   uint64
	ChainID     eth.ChainID // flat, not a pointer, to make Identifier safe as map key
}

func (Identifier) ChecksumArgs added in v1.12.2

func (id Identifier) ChecksumArgs(msgHash common.Hash) ChecksumArgs

func (Identifier) MarshalJSON

func (id Identifier) MarshalJSON() ([]byte, error)

func (*Identifier) UnmarshalJSON

func (id *Identifier) UnmarshalJSON(input []byte) error

type ManagedEvent added in v1.11.0

type ManagedEvent struct {
	Reset                  *string              `json:"reset,omitempty"`
	UnsafeBlock            *eth.BlockRef        `json:"unsafeBlock,omitempty"`
	DerivationUpdate       *DerivedBlockRefPair `json:"derivationUpdate,omitempty"`
	ExhaustL1              *DerivedBlockRefPair `json:"exhaustL1,omitempty"`
	ReplaceBlock           *BlockReplacement    `json:"replaceBlock,omitempty"`
	DerivationOriginUpdate *eth.BlockRef        `json:"derivationOriginUpdate,omitempty"`
}

ManagedEvent is an event sent by the managed node to the supervisor, to share an update. One of the fields will be non-null; different kinds of updates may be sent.

type Message added in v1.9.1

type Message struct {
	Identifier  Identifier  `json:"identifier"`
	PayloadHash common.Hash `json:"payloadHash"`
}

func (*Message) Access added in v1.12.2

func (m *Message) Access() Access

func (*Message) Checksum added in v1.12.2

func (m *Message) Checksum() MessageChecksum

func (*Message) DecodeEvent added in v1.13.3

func (m *Message) DecodeEvent(topics []common.Hash, data []byte) error

func (*Message) ToCheckSumArgs added in v1.12.2

func (m *Message) ToCheckSumArgs() ChecksumArgs

type MessageChecksum added in v1.12.2

type MessageChecksum common.Hash

MessageChecksum represents a message checksum, as used for access-list checks.

func (MessageChecksum) MarshalText added in v1.12.2

func (mc MessageChecksum) MarshalText() ([]byte, error)

func (MessageChecksum) String added in v1.12.2

func (mc MessageChecksum) String() string

func (*MessageChecksum) UnmarshalText added in v1.12.2

func (mc *MessageChecksum) UnmarshalText(data []byte) error

type ReferenceView added in v1.9.5

type ReferenceView struct {
	Local eth.BlockID `json:"local"`
	Cross eth.BlockID `json:"cross"`
}

func (ReferenceView) String added in v1.9.5

func (v ReferenceView) String() string

type Revision added in v1.13.0

type Revision uint64

func (Revision) Any added in v1.13.0

func (r Revision) Any() bool

func (Revision) Cmp added in v1.13.0

func (r Revision) Cmp(blockNum uint64) int

Cmp returns: 0 if the revision matches any block number 1 if the revision is higher than the given number 0 if the revision is equal than the given number -1 if the revision is lower than the given number

func (Revision) Number added in v1.13.0

func (r Revision) Number() uint64

Number returns the block-number, where the revision started (i.e. the invalidated/replacement block height)

func (Revision) String added in v1.13.0

func (r Revision) String() string

type SafetyLevel

type SafetyLevel string
const (
	// Finalized is CrossSafe, with the additional constraint that every
	// dependency is derived only from finalized L1 input data.
	// This matches RPC label "finalized".
	Finalized SafetyLevel = "finalized"
	// CrossSafe is as safe as LocalSafe, with all its dependencies
	// also fully verified to be reproducible from L1.
	// This matches RPC label "safe".
	CrossSafe SafetyLevel = "safe"
	// LocalSafe is verified to be reproducible from L1,
	// without any verified cross-L2 dependencies.
	// This does not have an RPC label.
	LocalSafe SafetyLevel = "local-safe"
	// CrossUnsafe is as safe as LocalUnsafe,
	// but with verified cross-L2 dependencies that are at least CrossUnsafe.
	// This does not have an RPC label.
	CrossUnsafe SafetyLevel = "cross-unsafe"
	// LocalUnsafe is the safety of the tip of the chain. This matches RPC label "unsafe".
	LocalUnsafe SafetyLevel = "unsafe"
	// Invalid is the safety of when the message or block is not matching the expected data.
	Invalid SafetyLevel = "invalid"
)

func (SafetyLevel) MarshalText

func (lvl SafetyLevel) MarshalText() ([]byte, error)

func (SafetyLevel) String

func (lvl SafetyLevel) String() string

func (*SafetyLevel) UnmarshalText

func (lvl *SafetyLevel) UnmarshalText(text []byte) error

func (SafetyLevel) Validate added in v1.11.0

func (lvl SafetyLevel) Validate() bool

Validate returns true if the SafetyLevel is one of the recognized levels

Jump to

Keyboard shortcuts

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