Documentation
¶
Index ¶
- Constants
- Variables
- func GetRollupID(l1Config config.L1Config, rollupAddr common.Address, ...) (uint32, error)
- func TryParseError(err error) (error, bool)
- type Batch
- type Block
- type BlockNumber
- type BlockNumberFinality
- func (b BlockNumberFinality) IsEmpty() bool
- func (b BlockNumberFinality) IsFinalized() bool
- func (BlockNumberFinality) JSONSchema() *jsonschema.Schema
- func (b BlockNumberFinality) String() string
- func (b *BlockNumberFinality) ToBlockNum() (*big.Int, error)
- func (d *BlockNumberFinality) UnmarshalText(data []byte) error
- type Client
- func (etherMan *Client) AddOrReplaceAuth(auth bind.TransactOpts) error
- func (etherMan *Client) CheckTxWasMined(ctx context.Context, txHash common.Hash) (bool, *types.Receipt, error)
- func (etherMan *Client) CurrentNonce(ctx context.Context, account common.Address) (uint64, error)
- func (etherMan *Client) EstimateGas(ctx context.Context, from common.Address, to *common.Address, value *big.Int, ...) (uint64, error)
- func (etherMan *Client) EthBlockByNumber(ctx context.Context, blockNumber uint64) (*types.Block, error)
- func (etherMan *Client) GetDAProtocolAddr() (common.Address, error)
- func (etherMan *Client) GetDAProtocolName() (string, error)
- func (etherMan *Client) GetFinalizedBlockNumber(ctx context.Context) (uint64, error)
- func (etherMan *Client) GetL1InfoRoot(indexL1InfoRoot uint32) (common.Hash, error)
- func (etherMan *Client) GetL2ChainID() (uint64, error)
- func (etherMan *Client) GetLatestBatchNumber() (uint64, error)
- func (etherMan *Client) GetLatestBlockHeader(ctx context.Context) (*types.Header, error)
- func (etherMan *Client) GetLatestBlockNumber(ctx context.Context) (uint64, error)
- func (etherMan *Client) GetLatestBlockTimestamp(ctx context.Context) (uint64, error)
- func (etherMan *Client) GetLatestVerifiedBatchNum() (uint64, error)
- func (etherMan *Client) GetRevertMessage(ctx context.Context, tx *types.Transaction) (string, error)
- func (etherMan *Client) GetSafeBlockNumber(ctx context.Context) (uint64, error)
- func (etherMan *Client) GetSendSequenceFee(numBatches uint64) (*big.Int, error)
- func (etherMan *Client) GetTrustedSequencerURL() (string, error)
- func (etherMan *Client) GetTx(ctx context.Context, txHash common.Hash) (*types.Transaction, bool, error)
- func (etherMan *Client) GetTxReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error)
- func (etherMan *Client) HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)
- func (etherMan *Client) LastAccInputHash() (common.Hash, error)
- func (etherMan *Client) LoadAuthFromKeyStore(path, password string) (*bind.TransactOpts, *ecdsa.PrivateKey, error)
- func (etherMan *Client) SendTx(ctx context.Context, tx *types.Transaction) error
- func (etherMan *Client) SignTx(ctx context.Context, sender common.Address, tx *types.Transaction) (*types.Transaction, error)
- func (etherMan *Client) TrustedSequencer() (common.Address, error)
- func (etherMan *Client) WaitTxToBeMined(ctx context.Context, tx *types.Transaction, timeout time.Duration) (bool, error)
- type EthClienter
- type EventOrder
- type ForcedBatch
- type ForkID
- type GlobalExitRoot
- type L1Config
- type OpNodeClienter
- type Order
- type PolygonZkEVMBatchData
- type RPCOpNodeDecorator
- type Sequence
- type SequenceBanana
- type SequencedBatch
- type SequencedForceBatch
- type VerifiedBatch
Constants ¶
const ( Safe = BlockNumber(-4) Finalized = BlockNumber(-3) Latest = BlockNumber(-2) Pending = BlockNumber(-1) Earliest = BlockNumber(0) )
const (
ExtraParamFieldName = "OpNodeURL"
)
Variables ¶
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 fork 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") // ErrMissingTrieNode means that a node is missing on the trie ErrMissingTrieNode = errors.New("missing trie node") // ErrNotFound is used when the object is not found ErrNotFound = errors.New("not found") // ErrPrivateKeyNotFound used when the provided sender does not have a private key registered to be used ErrPrivateKeyNotFound = errors.New("can't find sender private key to sign tx") )
var ( SafeBlock = BlockNumberFinality{"SafeBlock"} FinalizedBlock = BlockNumberFinality{"FinalizedBlock"} LatestBlock = BlockNumberFinality{"LatestBlock"} PendingBlock = BlockNumberFinality{"PendingBlock"} EarliestBlock = BlockNumberFinality{"EarliestBlock"} )
Functions ¶
func GetRollupID ¶
func TryParseError ¶
Types ¶
type Block ¶
type Block struct {
BlockNumber uint64
BlockHash common.Hash
ParentHash common.Hash
ForcedBatches []ForcedBatch
SequencedBatches [][]SequencedBatch
VerifiedBatches []VerifiedBatch
SequencedForceBatches [][]SequencedForceBatch
ForkIDs []ForkID
ReceivedAt time.Time
// GER data
GlobalExitRoots, L1InfoTree []GlobalExitRoot
}
Block struct
type BlockNumber ¶
type BlockNumber int64
type BlockNumberFinality ¶
type BlockNumberFinality struct {
// contains filtered or unexported fields
}
func NewBlockNumberFinality ¶ added in v0.0.2
func NewBlockNumberFinality(s string) BlockNumberFinality
func (BlockNumberFinality) IsEmpty ¶ added in v0.0.2
func (b BlockNumberFinality) IsEmpty() bool
func (BlockNumberFinality) IsFinalized ¶ added in v0.0.2
func (b BlockNumberFinality) IsFinalized() bool
func (BlockNumberFinality) JSONSchema ¶ added in v0.0.2
func (BlockNumberFinality) JSONSchema() *jsonschema.Schema
func (BlockNumberFinality) String ¶ added in v0.0.2
func (b BlockNumberFinality) String() string
func (*BlockNumberFinality) ToBlockNum ¶
func (b *BlockNumberFinality) ToBlockNum() (*big.Int, error)
func (*BlockNumberFinality) UnmarshalText ¶ added in v0.0.2
func (d *BlockNumberFinality) UnmarshalText(data []byte) error
UnmarshalText unmarshalls BlockNumberFinality from text.
type Client ¶
type Client struct {
EthClient ethereumClient
DAProtocol *idataavailabilityprotocol.Idataavailabilityprotocol
Contracts *contracts.Contracts
RollupID uint32
// contains filtered or unexported fields
}
Client is a simple implementation of EtherMan.
func NewClient ¶
func NewClient(cfg config.Config, l1Config config.L1Config, commonConfig aggkitcommon.Config) (*Client, error)
NewClient creates a new etherman.
func (*Client) AddOrReplaceAuth ¶
func (etherMan *Client) AddOrReplaceAuth(auth bind.TransactOpts) error
AddOrReplaceAuth adds an authorization or replace an existent one to the same account
func (*Client) CheckTxWasMined ¶
func (etherMan *Client) CheckTxWasMined(ctx context.Context, txHash common.Hash) (bool, *types.Receipt, error)
CheckTxWasMined check if a tx was already mined
func (*Client) CurrentNonce ¶
CurrentNonce returns the current nonce for the provided account
func (*Client) EstimateGas ¶
func (etherMan *Client) EstimateGas( ctx context.Context, from common.Address, to *common.Address, value *big.Int, data []byte, ) (uint64, error)
EstimateGas returns the estimated gas for the tx
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) GetDAProtocolAddr ¶
GetDAProtocolAddr returns the address of the data availability protocol
func (*Client) GetDAProtocolName ¶
GetDAProtocolName returns the name of the data availability protocol
func (*Client) GetFinalizedBlockNumber ¶
GetFinalizedBlockNumber gets the Finalized block number from the ethereum
func (*Client) GetL1InfoRoot ¶
GetL1InfoRoot gets the L1 info root from the SC
func (*Client) GetL2ChainID ¶
GetL2ChainID returns L2 Chain ID
func (*Client) GetLatestBatchNumber ¶
GetLatestBatchNumber function allows to retrieve the latest proposed batch in the smc
func (*Client) GetLatestBlockHeader ¶
GetLatestBlockHeader gets the latest block header from the ethereum
func (*Client) GetLatestBlockNumber ¶
GetLatestBlockNumber gets the latest block number from the ethereum
func (*Client) GetLatestBlockTimestamp ¶
GetLatestBlockTimestamp gets the latest block timestamp from the ethereum
func (*Client) GetLatestVerifiedBatchNum ¶
GetLatestVerifiedBatchNum gets latest verified batch from ethereum
func (*Client) GetRevertMessage ¶
func (etherMan *Client) GetRevertMessage(ctx context.Context, tx *types.Transaction) (string, error)
GetRevertMessage tries to get a revert message of a transaction
func (*Client) GetSafeBlockNumber ¶
GetSafeBlockNumber gets the safe block number from the ethereum
func (*Client) GetSendSequenceFee ¶
GetSendSequenceFee get super/trusted sequencer fee
func (*Client) GetTrustedSequencerURL ¶
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 ¶
HeaderByNumber returns a block header from the current canonical chain. If number is nil, the latest known header is returned.
func (*Client) LastAccInputHash ¶
LastAccInputHash gets the last acc input hash from the SC
func (*Client) LoadAuthFromKeyStore ¶
func (etherMan *Client) LoadAuthFromKeyStore(path, password string) (*bind.TransactOpts, *ecdsa.PrivateKey, error)
LoadAuthFromKeyStore loads an authorization from a key store file
func (*Client) SignTx ¶
func (etherMan *Client) SignTx( ctx context.Context, sender common.Address, tx *types.Transaction, ) (*types.Transaction, error)
SignTx tries to sign a transaction accordingly to the provided sender
func (*Client) TrustedSequencer ¶
TrustedSequencer gets trusted sequencer address
type EthClienter ¶ added in v0.1.0
type EthClienter interface {
ethereum.LogFilterer
ethereum.BlockNumberReader
ethereum.ChainReader
ethereum.ChainIDReader
bind.ContractBackend
Client() *ethrpc.Client
}
func NewRPCClient ¶ added in v0.1.0
func NewRPCClient(cfg ethermanconfig.RPCClientConfig) (EthClienter, error)
func NewRPCClientModeOp ¶ added in v0.1.0
func NewRPCClientModeOp(cfg ethermanconfig.RPCClientConfig) (EthClienter, error)
type EventOrder ¶
type EventOrder string
EventOrder is the type used to identify the events order
const ( // GlobalExitRootsOrder identifies a GlobalExitRoot event GlobalExitRootsOrder EventOrder = "GlobalExitRoots" // L1InfoTreeOrder identifies a L1InTree event L1InfoTreeOrder EventOrder = "L1InfoTreeOrder" // SequenceBatchesOrder identifies a VerifyBatch event SequenceBatchesOrder EventOrder = "SequenceBatches" // ForcedBatchesOrder identifies a ForcedBatches event ForcedBatchesOrder EventOrder = "ForcedBatches" // TrustedVerifyBatchOrder identifies a TrustedVerifyBatch event TrustedVerifyBatchOrder EventOrder = "TrustedVerifyBatch" // VerifyBatchOrder identifies a VerifyBatch event VerifyBatchOrder EventOrder = "VerifyBatch" // SequenceForceBatchesOrder identifies a SequenceForceBatches event SequenceForceBatchesOrder EventOrder = "SequenceForceBatches" // ForkIDsOrder identifies an updateZkevmVersion event ForkIDsOrder EventOrder = "forkIDs" )
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
MainnetExitRoot common.Hash
RollupExitRoot common.Hash
GlobalExitRoot common.Hash
Timestamp time.Time
PreviousBlockHash common.Hash
}
GlobalExitRoot struct
type L1Config ¶
type L1Config struct {
// Chain ID of the L1 network
L1ChainID uint64 `json:"chainId" mapstructure:"ChainID"`
// ZkEVMAddr Address of the L1 contract polygonZkEVMAddress
ZkEVMAddr common.Address `json:"polygonZkEVMAddress" mapstructure:"ZkEVMAddr"`
// RollupManagerAddr Address of the L1 contract
RollupManagerAddr common.Address `json:"polygonRollupManagerAddress" mapstructure:"RollupManagerAddr"`
// PolAddr Address of the L1 Pol token Contract
PolAddr common.Address `json:"polTokenAddress" mapstructure:"PolAddr"`
// GlobalExitRootManagerAddr Address of the L1 GlobalExitRootManager contract
GlobalExitRootManagerAddr common.Address `json:"polygonZkEVMGlobalExitRootAddress" mapstructure:"GlobalExitRootManagerAddr"` //nolint:lll
}
L1Config represents the configuration of the network used in L1
type OpNodeClienter ¶ added in v0.1.0
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 PolygonZkEVMBatchData ¶
type PolygonZkEVMBatchData struct {
Transactions []byte
GlobalExitRoot [32]byte
Timestamp uint64
MinForcedTimestamp uint64
}
PolygonZkEVMBatchData represents PolygonZkEVMBatchData
type RPCOpNodeDecorator ¶ added in v0.1.0
type RPCOpNodeDecorator struct {
OpNodeClient OpNodeClienter
// contains filtered or unexported fields
}
func NewRPCOpNodeDecorator ¶ added in v0.1.0
func NewRPCOpNodeDecorator(client EthClienter, opNodeClient OpNodeClienter) *RPCOpNodeDecorator
func (*RPCOpNodeDecorator) Client ¶ added in v0.1.0
func (f *RPCOpNodeDecorator) Client() *rpc.Client
func (*RPCOpNodeDecorator) HeaderByNumber ¶ added in v0.1.0
type Sequence ¶
type Sequence struct {
GlobalExitRoot, StateRoot, LocalExitRoot common.Hash
AccInputHash common.Hash
LastL2BLockTimestamp uint64
BatchL2Data []byte
IsSequenceTooBig bool
BatchNumber uint64
ForcedBatchTimestamp int64
PrevBlockHash common.Hash
LastCoinbase common.Address
}
Sequence represents an operation sent to the PoE smart contract to be processed.
type SequenceBanana ¶
type SequenceBanana struct {
Batches []Batch
OldAccInputHash common.Hash
AccInputHash common.Hash
L1InfoRoot common.Hash
MaxSequenceTimestamp uint64
CounterL1InfoRoot uint32
L2Coinbase common.Address
LastVirtualBatchNumber uint64
}
func NewSequenceBanana ¶
func NewSequenceBanana(batches []Batch, l2Coinbase common.Address) *SequenceBanana
func (*SequenceBanana) Len ¶
func (s *SequenceBanana) Len() int
func (*SequenceBanana) SetLastVirtualBatchNumber ¶
func (s *SequenceBanana) SetLastVirtualBatchNumber(batchNumber uint64)
type SequencedBatch ¶
type SequencedBatch struct {
BatchNumber uint64
L1InfoRoot *common.Hash
SequencerAddr common.Address
TxHash common.Hash
Nonce uint64
Coinbase common.Address
// Struct used in preEtrog forks
*PolygonZkEVMBatchData
// Struct used in Etrog
*polygonvalidiumetrog.PolygonRollupBaseEtrogBatchData
}
SequencedBatch represents virtual batch
type SequencedForceBatch ¶
type SequencedForceBatch struct {
BatchNumber uint64
Coinbase common.Address
TxHash common.Hash
Timestamp time.Time
Nonce uint64
polygonvalidiumetrog.PolygonRollupBaseEtrogBatchData
}
SequencedForceBatch is a sturct to track the ForceSequencedBatches event.