etherman

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2023 License: GPL-3.0 Imports: 24 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrNotFound is used when the object is not found
	ErrNotFound = errors.New("Not found")
)

Functions

This section is empty.

Types

type Batch

type Batch struct {
	BatchNumber    uint64
	Coinbase       common.Address
	BatchL2Data    []byte
	Timestamp      time.Time
	GlobalExitRoot common.Hash
}

Batch struct

type Block

type Block struct {
	ID                    uint64
	BlockNumber           uint64
	BlockHash             common.Hash
	ParentHash            common.Hash
	NetworkID             uint
	GlobalExitRoots       []GlobalExitRoot
	ForcedBatches         []ForcedBatch
	SequencedBatches      [][]SequencedBatch
	VerifiedBatches       []VerifiedBatch
	SequencedForceBatches [][]SequencedForceBatch
	Deposits              []Deposit
	Claims                []Claim
	Tokens                []TokenWrapped
	ReceivedAt            time.Time
}

Block struct

type Claim

type Claim struct {
	Index              uint
	OriginalNetwork    uint
	OriginalAddress    common.Address
	Amount             *big.Int
	DestinationAddress common.Address
	BlockID            uint64
	BlockNumber        uint64
	NetworkID          uint
	TxHash             common.Hash
}

Claim struct

type Client

type Client struct {
	EtherClient           ethClienter
	PoE                   *proofofefficiency.Proofofefficiency
	Bridge                *bridge.Bridge
	GlobalExitRootManager *globalexitrootmanager.Globalexitrootmanager
	SCAddresses           []common.Address
}

Client is a simple implementation of EtherMan.

func NewClient

func NewClient(cfg Config, PoEAddr, bridgeAddr, globalExitRootManAddr common.Address) (*Client, error)

NewClient creates a new etherman.

func NewL2Client

func NewL2Client(url string, bridgeAddr common.Address) (*Client, error)

NewL2Client creates a new etherman for L2.

func NewSimulatedEtherman

func NewSimulatedEtherman(cfg Config, auth *bind.TransactOpts) (etherman *Client, ethBackend *backends.SimulatedBackend, maticAddr common.Address, mockBridge *mockbridge.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) 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) GetLatestBatchNumber

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

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

func (*Client) GetNetworkID

func (etherMan *Client) GetNetworkID(ctx context.Context) (uint, error)

GetNetworkID gets the network ID of the dedicated chain.

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) 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.

type Config

type Config struct {
	L1URL  string   `mapstructure:"L1URL"`
	L2URLs []string `mapstructure:"L2URLs"`
}

Config represents the configuration of the etherman

type Deposit

type Deposit struct {
	LeafType           uint8
	OriginalNetwork    uint
	OriginalAddress    common.Address
	Amount             *big.Int
	DestinationNetwork uint
	DestinationAddress common.Address
	DepositCount       uint
	BlockID            uint64
	BlockNumber        uint64
	NetworkID          uint
	TxHash             common.Hash
	Metadata           []byte
}

Deposit struct

type EventOrder

type EventOrder string

EventOrder is the the type used to identify the events order

const (
	// GlobalExitRootsOrder identifies a GlobalExitRoot event
	GlobalExitRootsOrder EventOrder = "GlobalExitRoot"
	// SequenceBatchesOrder identifies a VerifyBatch event
	SequenceBatchesOrder EventOrder = "SequenceBatches"
	// TrustedVerifyBatchOrder identifies a TrustedVerifyBatch event
	TrustedVerifyBatchOrder EventOrder = "TrustedVerifyBatch"
	// SequenceForceBatchesOrder identifies a SequenceForceBatches event
	SequenceForceBatchesOrder EventOrder = "SequenceForceBatches"
	// ForcedBatchesOrder identifies a ForcedBatches event
	ForcedBatchesOrder EventOrder = "ForcedBatches"
	// DepositsOrder identifies a Deposits event
	DepositsOrder EventOrder = "Deposit"
	// ClaimsOrder identifies a Claims event
	ClaimsOrder EventOrder = "Claim"
	// TokensOrder identifies a TokenWrapped event
	TokensOrder EventOrder = "TokenWrapped"
)

type ForcedBatch

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

ForcedBatch represents a ForcedBatch

type GlobalExitRoot

type GlobalExitRoot struct {
	BlockID        uint64
	BlockNumber    uint64
	ExitRoots      []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
	Sequencer   common.Address
	TxHash      common.Hash
	proofofefficiency.ProofOfEfficiencyBatchData
}

SequencedBatch represents virtual batches

type SequencedForceBatch

type SequencedForceBatch struct {
	BatchNumber uint64
	Sequencer   common.Address
	TxHash      common.Hash
	Timestamp   time.Time
	proofofefficiency.ProofOfEfficiencyForcedBatchData
}

SequencedForceBatch is a sturct to track the ForceSequencedBatches event.

type TokenMetadata

type TokenMetadata struct {
	Name     string
	Symbol   string
	Decimals uint8
}

TokenMetadata is a metadata of ERC20 token.

type TokenWrapped

type TokenWrapped struct {
	TokenMetadata
	OriginalNetwork      uint
	OriginalTokenAddress common.Address
	WrappedTokenAddress  common.Address
	BlockID              uint64
	BlockNumber          uint64
	NetworkID            uint
}

TokenWrapped struct

type VerifiedBatch

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

VerifiedBatch represents a VerifiedBatch

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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