etherman

package
v0.0.1-RC2 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2022 License: GPL-3.0 Imports: 31 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	//ErrGasRequiredExceedsAllowance gas required exceeds the allowance
	ErrGasRequiredExceedsAllowance = errors.New("gas required exceeds allowance")
	//ErrContentLengthTooLarge content length is too large
	ErrContentLengthTooLarge = errors.New("content length too large")
	//ErrTimestampMustBeInsideRange Timestamp must be inside range
	ErrTimestampMustBeInsideRange = errors.New("Timestamp must be inside range")
	//ErrInsufficientAllowance insufficient allowance
	ErrInsufficientAllowance = errors.New("insufficient allowance")
	//ErrBothGasPriceAndMaxFeeGasAreSpecified both gasPrice and (maxFeePerGas or maxPriorityFeePerGas) specified
	ErrBothGasPriceAndMaxFeeGasAreSpecified = errors.New("both gasPrice and (maxFeePerGas or maxPriorityFeePerGas) specified")
	//ErrMaxFeeGasAreSpecifiedButLondonNotActive maxFeePerGas or maxPriorityFeePerGas specified but london is not active yet
	ErrMaxFeeGasAreSpecifiedButLondonNotActive = errors.New("maxFeePerGas or maxPriorityFeePerGas specified but london is not active yet")
	//ErrNoSigner no signer to authorize the transaction with
	ErrNoSigner = errors.New("no signer to authorize the transaction with")
)
View Source
var (

	// ErrNotFound is used when the object is not found
	ErrNotFound = errors.New("Not found")
	// ErrIsReadOnlyMode is used when the EtherMan client is in read-only mode.
	ErrIsReadOnlyMode = errors.New("Etherman client in read-only mode: no account configured to send transactions to L1. " +
		"Please check the [Etherman] PrivateKeyPath and PrivateKeyPassword configuration.")
)

Functions

func SequencedBatchesSigHash

func SequencedBatchesSigHash() common.Hash

SequencedBatchesSigHash returns the hash for the `SequenceBatches` event.

func VerifyBatchesSigHash

func VerifyBatchesSigHash() common.Hash

VerifyBatchesSigHash returns the hash for the `VerifyBatches` event.

Types

type Block

type Block struct {
	BlockNumber           uint64
	BlockHash             common.Hash
	ParentHash            common.Hash
	GlobalExitRoots       []GlobalExitRoot
	ForcedBatches         []ForcedBatch
	SequencedBatches      [][]SequencedBatch
	VerifiedBatches       []VerifiedBatch
	SequencedForceBatches [][]SequencedForceBatch
	ReceivedAt            time.Time
}

Block struct

type Client

type Client struct {
	EtherClient           ethClienter
	PoE                   *proofofefficiency.Proofofefficiency
	GlobalExitRootManager *globalexitrootmanager.Globalexitrootmanager
	Matic                 *matic.Matic
	SCAddresses           []common.Address

	GasProviders externalGasProviders
	// contains filtered or unexported fields
}

Client is a simple implementation of EtherMan.

func NewClient

func NewClient(cfg Config, auth *bind.TransactOpts) (*Client, error)

NewClient creates a new etherman.

func NewSimulatedEtherman

func NewSimulatedEtherman(cfg Config, auth *bind.TransactOpts) (etherman *Client, ethBackend *backends.SimulatedBackend, maticAddr common.Address, br *bridge.Bridge, err error)

NewSimulatedEtherman creates an etherman that uses a simulated blockchain. It's important to notice that the ChainID of the auth must be 1337. The address that holds the auth will have an initial balance of 10 ETH

func (*Client) ApproveMatic

func (etherMan *Client) ApproveMatic(ctx context.Context, maticAmount *big.Int, to common.Address) (*types.Transaction, error)

ApproveMatic function allow to approve tokens in matic smc

func (*Client) EstimateGasForVerifyBatches

func (etherMan *Client) EstimateGasForVerifyBatches(lastVerifiedBatch, newVerifiedBatch uint64, finalProof *pb.FinalProof) (uint64, error)

EstimateGasForVerifyBatches estimates gas for verify batches smart contract call.

func (*Client) EstimateGasSequenceBatches

func (etherMan *Client) EstimateGasSequenceBatches(sequences []ethmanTypes.Sequence) (*types.Transaction, error)

EstimateGasSequenceBatches estimates gas for sending batches

func (*Client) EthBlockByNumber

func (etherMan *Client) EthBlockByNumber(ctx context.Context, blockNumber uint64) (*types.Block, error)

EthBlockByNumber function retrieves the ethereum block information by ethereum block number.

func (*Client) GetL2ChainID

func (etherMan *Client) GetL2ChainID() (uint64, error)

GetL2ChainID returns L2 Chain ID

func (*Client) GetLastBatchTimestamp

func (etherMan *Client) GetLastBatchTimestamp() (uint64, error)

GetLastBatchTimestamp function allows to retrieve the lastTimestamp value in the smc

func (*Client) GetLatestBatchNumber

func (etherMan *Client) GetLatestBatchNumber() (uint64, error)

GetLatestBatchNumber function allows to retrieve the latest proposed batch in the smc

func (*Client) GetLatestBlockNumber

func (etherMan *Client) GetLatestBlockNumber(ctx context.Context) (uint64, error)

GetLatestBlockNumber gets the latest block number from the ethereum

func (*Client) GetLatestBlockTimestamp

func (etherMan *Client) GetLatestBlockTimestamp(ctx context.Context) (uint64, error)

GetLatestBlockTimestamp gets the latest block timestamp from the ethereum

func (*Client) GetLatestVerifiedBatchNum

func (etherMan *Client) GetLatestVerifiedBatchNum() (uint64, error)

GetLatestVerifiedBatchNum gets latest verified batch from ethereum

func (*Client) GetPublicAddress

func (etherMan *Client) GetPublicAddress() (common.Address, error)

GetPublicAddress returns eth client public address

func (*Client) GetRollupInfoByBlockRange

func (etherMan *Client) GetRollupInfoByBlockRange(ctx context.Context, fromBlock uint64, toBlock *uint64) ([]Block, map[common.Hash][]Order, error)

GetRollupInfoByBlockRange function retrieves the Rollup information that are included in all this ethereum blocks from block x to block y.

func (*Client) GetSendSequenceFee

func (etherMan *Client) GetSendSequenceFee() (*big.Int, error)

GetSendSequenceFee get super/trusted sequencer fee

func (*Client) GetTrustedSequencerURL

func (etherMan *Client) GetTrustedSequencerURL() (string, error)

GetTrustedSequencerURL Gets the trusted sequencer url from rollup smc

func (*Client) GetTx

func (etherMan *Client) GetTx(ctx context.Context, txHash common.Hash) (*types.Transaction, bool, error)

GetTx function get ethereum tx

func (*Client) GetTxReceipt

func (etherMan *Client) GetTxReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error)

GetTxReceipt function gets ethereum tx receipt

func (*Client) HeaderByNumber

func (etherMan *Client) HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)

HeaderByNumber returns a block header from the current canonical chain. If number is nil, the latest known header is returned.

func (*Client) IsReadOnly

func (c *Client) IsReadOnly() bool

IsReadOnly returns whether the EtherMan client is in read-only mode. Call this before trying to access the `auth` field.

func (*Client) SequenceBatches

func (etherMan *Client) SequenceBatches(ctx context.Context, sequences []ethmanTypes.Sequence, gasLimit uint64, gasPrice, nonce *big.Int) (*types.Transaction, error)

SequenceBatches send sequences of batches to the ethereum

func (*Client) TrustedSequencer

func (etherMan *Client) TrustedSequencer() (common.Address, error)

TrustedSequencer gets trusted sequencer address

func (*Client) VerifyBatches

func (etherMan *Client) VerifyBatches(ctx context.Context, lastVerifiedBatch, newVerifiedBatch uint64, finalProof *pb.FinalProof, gasLimit uint64, gasPrice, nonce *big.Int) (*types.Transaction, error)

VerifyBatches function allows the aggregator send the final proof to L1.

func (*Client) WaitTxToBeMined

func (etherMan *Client) WaitTxToBeMined(ctx context.Context, tx *types.Transaction, timeout time.Duration) error

WaitTxToBeMined waits for an L1 tx to be mined. It will return error if the tx is reverted or timeout is exceeded

type Config

type Config struct {
	URL       string `mapstructure:"URL"`
	L1ChainID uint64 `mapstructure:"L1ChainID"`

	PoEAddr                   common.Address `mapstructure:"PoEAddr"`
	MaticAddr                 common.Address `mapstructure:"MaticAddr"`
	GlobalExitRootManagerAddr common.Address `mapstructure:"GlobalExitRootManagerAddr"`

	PrivateKeyPath     string `mapstructure:"PrivateKeyPath"`
	PrivateKeyPassword string `mapstructure:"PrivateKeyPassword"`

	MultiGasProvider bool `mapstructure:"MultiGasProvider"`
	Etherscan        etherscan.Config
}

Config represents the configuration of the etherman

type EventOrder

type EventOrder string

EventOrder is the the type used to identify the events order

const (
	// GlobalExitRootsOrder identifies a GlobalExitRoot event
	GlobalExitRootsOrder EventOrder = "GlobalExitRoots"
	// SequenceBatchesOrder identifies a VerifyBatch event
	SequenceBatchesOrder EventOrder = "SequenceBatches"
	// ForcedBatchesOrder identifies a ForcedBatches event
	ForcedBatchesOrder EventOrder = "ForcedBatches"
	// VerifyBatchOrder identifies a VerifyBatch event
	VerifyBatchOrder EventOrder = "VerifyBatch"
	// SequenceForceBatchesOrder identifies a SequenceForceBatches event
	SequenceForceBatchesOrder EventOrder = "SequenceForceBatches"
)

type ForcedBatch

type ForcedBatch struct {
	BlockNumber       uint64
	ForcedBatchNumber uint64
	Sequencer         common.Address
	GlobalExitRoot    common.Hash
	RawTxsData        []byte
	ForcedAt          time.Time
}

ForcedBatch represents a ForcedBatch

type GlobalExitRoot

type GlobalExitRoot struct {
	BlockNumber     uint64
	Timestamp       time.Time
	MainnetExitRoot common.Hash
	RollupExitRoot  common.Hash
	GlobalExitRoot  common.Hash
}

GlobalExitRoot struct

type Order

type Order struct {
	Name EventOrder
	Pos  int
}

Order contains the event order to let the synchronizer store the information following this order.

type SequencedBatch

type SequencedBatch struct {
	BatchNumber uint64
	Coinbase    common.Address
	TxHash      common.Hash
	Nonce       uint64
	proofofefficiency.ProofOfEfficiencyBatchData
}

SequencedBatch represents virtual batch

type SequencedForceBatch

type SequencedForceBatch struct {
	BatchNumber uint64
	Coinbase    common.Address
	TxHash      common.Hash
	Timestamp   time.Time
	Nonce       uint64
	proofofefficiency.ProofOfEfficiencyForceBatchData
}

SequencedForceBatch is a sturct to track the ForceSequencedBatches event.

type VerifiedBatch

type VerifiedBatch struct {
	BlockNumber uint64
	BatchNumber uint64
	Aggregator  common.Address
	StateRoot   common.Hash
	TxHash      common.Hash
}

VerifiedBatch represents a VerifiedBatch

Directories

Path Synopsis
smartcontracts

Jump to

Keyboard shortcuts

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