validator

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StringToBytes32

func StringToBytes32(input string) ([32]uint8, error)

StringToBytes32 converts a hexadecimal string to a [32]uint8 array. It returns the converted array and any error encountered during the conversion.

Types

type DisputeFactoryGameHelper

type DisputeFactoryGameHelper struct {
	DisputeGameFactoryCaller dispute.DisputeGameFactoryCaller // Caller for the dispute game factory contract.
	// contains filtered or unexported fields
}

DisputeFactoryGameHelper assists in interacting with the dispute game factory.

func NewDisputeGameFactoryHelper

func NewDisputeGameFactoryHelper(ctx context.Context, l1Client *ethclient.Client, disputeGameFactoryAddress common.Address) (*DisputeFactoryGameHelper, error)

NewDisputeGameFactoryHelper initializes a new DisputeFactoryGameHelper. It binds to the dispute game factory contract and returns a helper instance.

func (*DisputeFactoryGameHelper) GetDisputeGameCoordinatesFromGameIndex

func (df *DisputeFactoryGameHelper) GetDisputeGameCoordinatesFromGameIndex(gameIndex uint64) (*DisputeGameFactoryCoordinates, error)

GetDisputeGameCoordinatesFromGameIndex retrieves the coordinates of a dispute game by its index. It returns the coordinates including game type, index, proxy address, and timestamp.

func (*DisputeFactoryGameHelper) GetDisputeGameCount

func (df *DisputeFactoryGameHelper) GetDisputeGameCount() (uint64, error)

GetDisputeGameCount returns the total count of dispute games available in the factory.

func (*DisputeFactoryGameHelper) GetDisputeGameIteratorFromDisputeGameFactory

func (df *DisputeFactoryGameHelper) GetDisputeGameIteratorFromDisputeGameFactory() (*DisputeGameFactoryIterator, error)

GetDisputeGameIteratorFromDisputeGameFactory creates an iterator for the dispute games in the factory. It returns the iterator with the total number of games.

type DisputeGameData

type DisputeGameData struct {
	ProxyAddress  common.Address // The address of the dispute game proxy.
	RootClaim     [32]byte       // The root claim associated with the dispute game.
	L2blockNumber *big.Int       // The L2 block number related to the game.
	L2ChainID     *big.Int       // The L2 chain ID associated with the game.
	Status        GameStatus     // The current status of the game.
	CreatedAt     uint64         // Timestamp when the game was created.
	ResolvedAt    uint64         // Timestamp when the game was resolved.
}

DisputeGameData holds the details of a dispute game.

func (DisputeGameData) String

func (d DisputeGameData) String() string

String provides a string representation of DisputeGameData.

type DisputeGameFactoryCoordinates

type DisputeGameFactoryCoordinates struct {
	GameType  uint32 // The type of the dispute game.
	GameIndex uint64 // The index of the dispute game.
	// contains filtered or unexported fields
}

DisputeGameFactoryCoordinates holds the details of a dispute game.

type DisputeGameFactoryIterator

type DisputeGameFactoryIterator struct {
	DisputeGameFactoryCaller *dispute.DisputeGameFactoryCaller // Caller for the dispute game factory contract.

	DisputeGameFactoryCoordinates *DisputeGameFactoryCoordinates // Coordinates for the current dispute game.
	// contains filtered or unexported fields
}

DisputeGameFactoryIterator iterates through dispute games.

func (*DisputeGameFactoryIterator) Next

func (dgf *DisputeGameFactoryIterator) Next() bool

Next moves the iterator to the next dispute game. It returns true if there is a next game; otherwise, false.

func (*DisputeGameFactoryIterator) RefreshElements

func (dgf *DisputeGameFactoryIterator) RefreshElements() error

RefreshElements refreshes the game count for the iterator.

type EnrichedProvenWithdrawalEvent

type EnrichedProvenWithdrawalEvent struct {
	Event                     *WithdrawalProvenExtension1Event // The original withdrawal event.
	DisputeGame               *FaultDisputeGameProxy           // Associated dispute game.
	ExpectedRootClaim         [32]byte                         // Expected root claim for validation.
	Blacklisted               bool                             // Indicates if the game is blacklisted.
	WithdrawalHashPresentOnL2 bool                             // Indicates if the withdrawal hash is present on L2.
	Enriched                  bool                             // Indicates if the event is enriched.
}

EnrichedProvenWithdrawalEvent represents an enriched event for proven withdrawals.

func (*EnrichedProvenWithdrawalEvent) String

String provides a string representation of EnrichedProvenWithdrawalEvent.

type FaultDisputeGameHelper

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

FaultDisputeGameHelper assists in interacting with fault dispute games.

func NewFaultDisputeGameHelper

func NewFaultDisputeGameHelper(ctx context.Context, l1Client *ethclient.Client) (*FaultDisputeGameHelper, error)

NewFaultDisputeGameHelper initializes a new FaultDisputeGameHelper. It creates a cache for storing game proxies and returns the helper instance.

func (*FaultDisputeGameHelper) GetDisputeGameProxyFromAddress

func (fd *FaultDisputeGameHelper) GetDisputeGameProxyFromAddress(disputeGameProxyAddress common.Address) (FaultDisputeGameProxy, error)

GetDisputeGameProxyFromAddress retrieves the FaultDisputeGameProxy from the specified address. It fetches the game details and caches the result for future use.

type FaultDisputeGameProxy

type FaultDisputeGameProxy struct {
	FaultDisputeGame *dispute.FaultDisputeGame // The underlying fault dispute game.
	DisputeGameData  *DisputeGameData          // Data related to the dispute game.
}

FaultDisputeGameProxy represents a proxy for the fault dispute game.

func (*FaultDisputeGameProxy) RefreshState

func (fd *FaultDisputeGameProxy) RefreshState() error

RefreshState updates the state of the FaultDisputeGameProxy. It retrieves the current status and resolved timestamp of the game.

func (*FaultDisputeGameProxy) String

func (p *FaultDisputeGameProxy) String() string

String provides a string representation of the FaultDisputeGameProxy.

type GameStatus

type GameStatus uint8

GameStatus represents the status of a dispute game.

const (
	IN_PROGRESS     GameStatus = iota // The game is currently in progress and has not been resolved.
	CHALLENGER_WINS                   // The game has concluded, and the root claim was challenged successfully.
	DEFENDER_WINS                     // The game has concluded, and the root claim could not be contested.
)

Define constants for the GameStatus using iota.

func (GameStatus) String

func (gs GameStatus) String() string

String implements the Stringer interface for pretty printing the GameStatus.

type L2ToL1MessagePasserHelper

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

L2ToL1MessagePasserHelper assists in interacting with the L2 to L1 message passer.

func NewL2ToL1MessagePasserHelper

func NewL2ToL1MessagePasserHelper(ctx context.Context, l2Client *ethclient.Client) (*L2ToL1MessagePasserHelper, error)

NewL2ToL1MessagePasserHelper initializes a new L2ToL1MessagePasserHelper. It binds to the L2 to L1 message passer contract and returns the helper instance.

func (*L2ToL1MessagePasserHelper) WithdrawalExistsOnL2

func (l2l1 *L2ToL1MessagePasserHelper) WithdrawalExistsOnL2(withdrawalHash [32]byte) (bool, error)

WithdrawalExistsOnL2 checks if a withdrawal message with the given hash exists on L2. It returns true if the message exists, otherwise returns false along with any error encountered.

type OpNodeHelper

type OpNodeHelper struct {
	LatestKnownL2BlockNumber uint64 // The latest known L2 block number.
	// contains filtered or unexported fields
}

OpNodeHelper assists in interacting with the op-node

func NewOpNodeHelper

func NewOpNodeHelper(ctx context.Context, l2OpNodeClient *ethclient.Client, l2OpGethClient *ethclient.Client) (*OpNodeHelper, error)

NewOpNodeHelper initializes a new OpNodeHelper. It creates a cache for storing output roots and binds to the L2 node client.

func (*OpNodeHelper) GetLatestKnownL2BlockNumber added in v0.0.6

func (on *OpNodeHelper) GetLatestKnownL2BlockNumber() (uint64, error)

get latest known L2 block number

func (*OpNodeHelper) GetOutputRootFromCalculation

func (on *OpNodeHelper) GetOutputRootFromCalculation(blockNumber *big.Int) ([32]byte, error)

GetOutputRootFromCalculation retrieves the output root by calculating it from the given block number. It returns the calculated output root as a Bytes32 array.

func (*OpNodeHelper) GetOutputRootFromTrustedL2Node

func (on *OpNodeHelper) GetOutputRootFromTrustedL2Node(l2blockNumber *big.Int) ([32]byte, error)

GetOutputRootFromTrustedL2Node retrieves the output root for a given L2 block number from a trusted L2 node. It returns the output root as a Bytes32 array.

type OptimismPortal2Helper

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

OptimismPortal2Helper assists in interacting with the Optimism Portal 2.

func NewOptimismPortal2Helper

func NewOptimismPortal2Helper(ctx context.Context, l1Client *ethclient.Client, optimismPortalAddress common.Address) (*OptimismPortal2Helper, error)

NewOptimismPortal2Helper initializes a new OptimismPortal2Helper. It binds to the Optimism Portal 2 contract and returns the helper instance.

func (*OptimismPortal2Helper) GetDisputeGameFactoryAddress

func (op *OptimismPortal2Helper) GetDisputeGameFactoryAddress() (common.Address, error)

GetDisputeGameFactoryAddress retrieves the address of the dispute game factory. It returns the address along with any error encountered.

func (*OptimismPortal2Helper) GetProvenWithdrawalsEvents

func (op *OptimismPortal2Helper) GetProvenWithdrawalsEvents(start uint64, end *uint64) ([]WithdrawalProvenEvent, error)

GetProvenWithdrawalsEvents retrieves proven withdrawal events within the specified block range. It returns a slice of WithdrawalProvenEvent along with any error encountered.

func (*OptimismPortal2Helper) GetProvenWithdrawalsEventsIterartor

func (op *OptimismPortal2Helper) GetProvenWithdrawalsEventsIterartor(start uint64, end *uint64) (*l1.OptimismPortal2WithdrawalProvenIterator, error)

GetProvenWithdrawalsEventsIterartor creates an iterator for proven withdrawal events within the specified block range. It returns the iterator along with any error encountered.

func (*OptimismPortal2Helper) GetProvenWithdrawalsExtension1Events

func (op *OptimismPortal2Helper) GetProvenWithdrawalsExtension1Events(start uint64, end *uint64) ([]WithdrawalProvenExtension1Event, error)

GetProvenWithdrawalsExtension1Events retrieves proven withdrawal extension 1 events within the specified block range. It returns a slice of WithdrawalProvenExtension1Event along with any error encountered.

func (*OptimismPortal2Helper) GetProvenWithdrawalsExtension1EventsIterator added in v0.0.6

func (op *OptimismPortal2Helper) GetProvenWithdrawalsExtension1EventsIterator(start uint64, end *uint64) (*l1.OptimismPortal2WithdrawalProvenExtension1Iterator, error)

GetProvenWithdrawalsExtension1EventsIterator creates an iterator for proven withdrawal extension 1 events within the specified block range. It returns the iterator along with any error encountered.

func (*OptimismPortal2Helper) GetSubmittedProofsDataFromWithdrawalhash

func (op *OptimismPortal2Helper) GetSubmittedProofsDataFromWithdrawalhash(withdrawalHash [32]byte) ([]SubmittedProofData, error)

GetSubmittedProofsDataFromWithdrawalhash retrieves submitted proof data associated with the given withdrawal hash. It returns a slice of SubmittedProofData along with any error encountered.

func (*OptimismPortal2Helper) GetSubmittedProofsDataFromWithdrawalhashAndProofSubmitterAddress

func (op *OptimismPortal2Helper) GetSubmittedProofsDataFromWithdrawalhashAndProofSubmitterAddress(withdrawalHash [32]byte, proofSubmitterAddress common.Address) (*SubmittedProofData, error)

GetSubmittedProofsDataFromWithdrawalhashAndProofSubmitterAddress retrieves submitted proof data for the specified withdrawal hash and proof submitter address. It returns a pointer to SubmittedProofData along with any error encountered.

func (*OptimismPortal2Helper) IsGameBlacklisted

func (op *OptimismPortal2Helper) IsGameBlacklisted(disputeGameProxy *FaultDisputeGameProxy) (bool, error)

IsGameBlacklisted checks if a dispute game is blacklisted. It returns true if the game is blacklisted, otherwise returns false along with any error encountered.

type OutputResponse

type OutputResponse struct {
	Version    string `json:"version"`    // The version of the output.
	OutputRoot string `json:"outputRoot"` // The output root associated with the response.
}

OutputResponse represents the response structure for output-related data.

type ProvenWithdrawalValidator

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

ProvenWithdrawalValidator validates proven withdrawal events.

func NewWithdrawalValidator

func NewWithdrawalValidator(ctx context.Context, l1GethClient *ethclient.Client, l2OpGethClient *ethclient.Client, l2OpNodeClient *ethclient.Client, OptimismPortalAddress common.Address) (*ProvenWithdrawalValidator, error)

NewWithdrawalValidator initializes a new ProvenWithdrawalValidator. It binds necessary helpers and returns the validator instance.

func (*ProvenWithdrawalValidator) GetEnrichedWithdrawalEvent

func (wv *ProvenWithdrawalValidator) GetEnrichedWithdrawalEvent(withdrawalEvent *WithdrawalProvenExtension1Event) (*EnrichedProvenWithdrawalEvent, error)

GetEnrichedWithdrawalEvent retrieves an enriched withdrawal event based on the given withdrawal event. It returns the enriched event along with any error encountered.

func (*ProvenWithdrawalValidator) GetEnrichedWithdrawalsEvents

func (wv *ProvenWithdrawalValidator) GetEnrichedWithdrawalsEvents(start uint64, end *uint64) ([]EnrichedProvenWithdrawalEvent, error)

GetEnrichedWithdrawalsEvents retrieves enriched withdrawal events within the specified block range. It returns a slice of EnrichedProvenWithdrawalEvent along with any error encountered.

func (*ProvenWithdrawalValidator) GetEnrichedWithdrawalsEventsMap added in v0.0.6

func (wv *ProvenWithdrawalValidator) GetEnrichedWithdrawalsEventsMap(start uint64, end *uint64) (map[common.Hash]EnrichedProvenWithdrawalEvent, error)

GetEnrichedWithdrawalsEvents retrieves enriched withdrawal events within the specified block range. It returns a slice of EnrichedProvenWithdrawalEvent along with any error encountered.

func (*ProvenWithdrawalValidator) GetLatestL2Height added in v0.0.6

func (wv *ProvenWithdrawalValidator) GetLatestL2Height() uint64

func (*ProvenWithdrawalValidator) GetProvenWithdrawalsExtension1Events

func (wv *ProvenWithdrawalValidator) GetProvenWithdrawalsExtension1Events(start uint64, end *uint64) ([]WithdrawalProvenExtension1Event, error)

GetProvenWithdrawalsExtension1Events retrieves proven withdrawal extension 1 events within the specified block range. It returns a slice of WithdrawalProvenExtension1Event along with any error encountered.

func (*ProvenWithdrawalValidator) IsWithdrawalEventValid

func (wv *ProvenWithdrawalValidator) IsWithdrawalEventValid(enrichedWithdrawalEvent *EnrichedProvenWithdrawalEvent) (bool, error)

IsWithdrawalEventValid checks if the enriched withdrawal event is valid. It returns true if the event is valid, otherwise returns false.

func (*ProvenWithdrawalValidator) UpdateEnrichedWithdrawalEvent

func (wv *ProvenWithdrawalValidator) UpdateEnrichedWithdrawalEvent(event *EnrichedProvenWithdrawalEvent) error

UpdateEnrichedWithdrawalEvent updates the enriched withdrawal event with relevant data. It checks for blacklisting, validates root claims, and verifies withdrawal presence on L2.

type Raw

type Raw struct {
	BlockNumber uint64      // The block number in which the transaction is included.
	TxHash      common.Hash // The hash of the transaction.
}

Raw represents raw event data associated with a blockchain transaction.

func (Raw) String added in v0.0.6

func (r Raw) String() string

String provides a string representation of Raw.

type SubmittedProofData

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

SubmittedProofData holds data about a submitted proof.

func (*SubmittedProofData) String

func (p *SubmittedProofData) String() string

String provides a string representation of SubmittedProofData.

type Timestamp

type Timestamp uint64

Timestamp represents a Unix timestamp.

func (Timestamp) String

func (timestamp Timestamp) String() string

String converts a Timestamp to a formatted string representation. It returns the timestamp as a string in the format "2006-01-02 15:04:05 MST".

type ValidateProofWithdrawalState

type ValidateProofWithdrawalState int8

ValidateProofWithdrawalState represents the state of the proof validation.

const (
	INVALID_PROOF_FORGERY_DETECTED ValidateProofWithdrawalState = iota
	INVALID_PROPOSAL_FORGERY_DETECTED
	INVALID_PROPOSAL_INPROGRESS
	INVALID_PROPOSAL_CORRECTLY_RESOLVED
	PROOF_ON_BLACKLISTED_GAME
	VALID_PROOF
)

Constants representing various states of proof validation.

func (ValidateProofWithdrawalState) String

String provides a string representation of ValidateProofWithdrawalState.

type WithdrawalProvenEvent

type WithdrawalProvenEvent struct {
	WithdrawalHash [32]byte // Hash of the withdrawal.
	Raw            Raw      // Raw event data.
}

WithdrawalProvenEvent represents a withdrawal proven event.

func (WithdrawalProvenEvent) String

func (e WithdrawalProvenEvent) String() string

String provides a string representation of WithdrawalProvenEvent.

type WithdrawalProvenExtension1Event

type WithdrawalProvenExtension1Event struct {
	WithdrawalHash [32]byte       // Hash of the withdrawal.
	ProofSubmitter common.Address // Address of the proof submitter.
	Raw            Raw            // Raw event data.
}

WithdrawalProvenExtension1Event represents an event for a proven withdrawal.

func (WithdrawalProvenExtension1Event) String

String provides a string representation of WithdrawalProvenExtension1Event.

Jump to

Keyboard shortcuts

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