Documentation
¶
Overview ¶
Package evm implements the chain client for EVM chains.
Index ¶
- func ExplainRevert(err error) error
- func ExplainRevertData(data []byte) string
- type Client
- func (c *Client) BesuClientRouter(ctx context.Context, clientID string) (common.Address, error)
- func (c *Client) BesuClientState(ctx context.Context, clientID string) (besumsgs.IBesuLightClientMsgsClientState, error)
- func (c *Client) BesuConsensusStateHash(ctx context.Context, clientID string, height uint64) (common.Hash, error)
- func (c *Client) ChainID() string
- func (c *Client) FindAckTx(ctx context.Context, sourceClientID string, sequence uint64) (*v2.Tx, error)
- func (c *Client) FindRecvTx(ctx context.Context, destClientID string, sequence uint64) (*v2.Tx, error)
- func (c *Client) FindSendPackets(ctx context.Context, clientID string, sequences []uint64) ([]v2.PacketEvent, error)
- func (c *Client) FindTimeoutTx(ctx context.Context, sourceClientID string, sequence uint64) (*v2.Tx, error)
- func (c *Client) GetAttestationSet(ctx context.Context, clientID string) ([]string, uint8, error)
- func (c *Client) GetBlockHeader(ctx context.Context, height uint64) (v2.BlockHeader, error)
- func (c *Client) GetCommitment(ctx context.Context, height uint64, hashedPath [32]byte) ([32]byte, error)
- func (c *Client) GetCounterparty(ctx context.Context, clientID string) (string, error)
- func (c *Client) GetRouterProof(ctx context.Context, height uint64, slots []common.Hash) (RouterProof, error)
- func (c *Client) IsPacketCommitted(ctx context.Context, sourceClientID string, sequence uint64) (bool, error)
- func (c *Client) IsPacketReceived(ctx context.Context, destClientID string, sequence uint64) (bool, error)
- func (c *Client) LatestPacketSequence(ctx context.Context, clientID string, height uint64) (uint64, error)
- func (c *Client) PacketCommitments(ctx context.Context, clientID string, sequences []uint64, height uint64) ([]uint64, error)
- func (c *Client) PacketRelayExecuted(ctx context.Context, txHash string, kind v2.RelayKind, sequence uint64, ...) (bool, error)
- func (c *Client) PacketWriteAckStatus(ctx context.Context, recvTxHash string, sequence uint64, sourceClientID string, ...) (v2.WriteAckStatus, error)
- func (c *Client) RouterAddress() common.Address
- func (c *Client) SealedHeader(ctx context.Context, height uint64) (*besu.ParsedHeader, error)
- func (c *Client) SubscribeSendPackets(ctx context.Context, clientIDs []string, out chan<- v2.PacketEvent) (v2.Subscription, error)
- func (c *Client) TxHeight(ctx context.Context, rawTxHash []byte) (uint64, error)
- func (c *Client) TxPacketEvents(ctx context.Context, rawTxHash []byte) ([]v2.PacketEvent, error)
- func (c *Client) WaitForChain(ctx context.Context) error
- type ETHClient
- type RouterProof
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExplainRevert ¶
ExplainRevert adds decoded revert data to an RPC error. Any error code is accepted: Besu before 26.x reports reverts with -32000 rather than 3.
func ExplainRevertData ¶
ExplainRevertData decodes a revert reason, falling back to its raw hex data.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client implements chains.Client for EVM chains.
func NewWithClient ¶
func NewWithClients ¶
func (*Client) BesuClientRouter ¶
BesuClientRouter returns the router clientID's light client is bound to. It fails for a client deployed before ibc-contracts dfba365f, which has none.
func (*Client) BesuClientState ¶
func (c *Client) BesuClientState( ctx context.Context, clientID string, ) (besumsgs.IBesuLightClientMsgsClientState, error)
BesuClientState reads clientID's Besu light client state.
func (*Client) BesuConsensusStateHash ¶
func (c *Client) BesuConsensusStateHash(ctx context.Context, clientID string, height uint64) (common.Hash, error)
BesuConsensusStateHash returns the hash of the consensus state clientID stores at height. The contract reverts when it stores none.
func (*Client) FindRecvTx ¶
func (c *Client) FindRecvTx(ctx context.Context, destClientID string, sequence uint64) (*v2.Tx, error)
FindRecvTx looks for the WriteAcknowledgement event because the router emits no RecvPacket event; acks are written synchronously in the receive tx.
func (*Client) FindSendPackets ¶
func (c *Client) FindSendPackets( ctx context.Context, clientID string, sequences []uint64, ) ([]v2.PacketEvent, error)
FindSendPackets returns the SendPacket events for sequences on clientID. The block range is unbounded because clearing knows the sequences but not the heights they landed at, exactly as findPacketTx queries today.
func (*Client) FindTimeoutTx ¶
func (*Client) GetAttestationSet ¶
GetAttestationSet returns clientID's on-chain attestor addresses and minimum required signature count.
func (*Client) GetBlockHeader ¶
func (*Client) GetCommitment ¶
func (*Client) GetCounterparty ¶
GetCounterparty returns the client ID this chain's router has registered as clientID's on-chain counterparty.
func (*Client) GetRouterProof ¶
func (c *Client) GetRouterProof(ctx context.Context, height uint64, slots []common.Hash) (RouterProof, error)
GetRouterProof proves the router account and the requested storage slots at height via eth_getProof. The light client verifies the proofs, deriving each storage key from the packet itself.
func (*Client) IsPacketCommitted ¶
func (*Client) IsPacketReceived ¶
func (*Client) LatestPacketSequence ¶
func (c *Client) LatestPacketSequence(ctx context.Context, clientID string, height uint64) (uint64, error)
LatestPacketSequence returns the highest sequence ever assigned on clientID at height, read from the router's prevSequenceSends mapping because nextSequenceSend is internal and nothing exposes it. Sequences in use are 1..N, so zero means nothing has been sent on the client.
func (*Client) PacketCommitments ¶
func (c *Client) PacketCommitments( ctx context.Context, clientID string, sequences []uint64, height uint64, ) ([]uint64, error)
PacketCommitments returns the subset of sequences whose packet commitment is still live on clientID at height. It is all or nothing: a truncated set reads as "everything else settled", which writes off packets whose funds are still in escrow, so any failure returns nil rather than a partial slice.
func (*Client) PacketRelayExecuted ¶
func (*Client) PacketWriteAckStatus ¶
func (*Client) RouterAddress ¶
RouterAddress returns the ICS26 router address.
func (*Client) SealedHeader ¶
SealedHeader returns the sealed Besu header at height, or the head at v2.LatestBlock.
func (*Client) SubscribeSendPackets ¶
func (c *Client) SubscribeSendPackets( ctx context.Context, clientIDs []string, out chan<- v2.PacketEvent, ) (v2.Subscription, error)
SubscribeSendPackets streams SendPacket events for clientIDs to out. It is one shot: the subscription ends on the first transport, decode or header failure and does not reconnect.
func (*Client) TxPacketEvents ¶
type ETHClient ¶
type ETHClient interface {
bind.ContractBackend
BalanceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (*big.Int, error)
NonceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (uint64, error)
EstimateGasAtBlock(ctx context.Context, call ethereum.CallMsg, blockNumber *big.Int) (uint64, error)
TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error)
TransactionByHash(ctx context.Context, hash common.Hash) (*types.Transaction, bool, error)
StorageAt(ctx context.Context, account common.Address, key common.Hash, blockNumber *big.Int) ([]byte, error)
// GetProof is eth_getProof for account at blockNumber, or the head when
// nil: the account proof nodes and one storage proof per key, in the
// order of keys.
GetProof(
ctx context.Context,
account common.Address,
keys []common.Hash,
blockNumber *big.Int,
) (accountProof [][]byte, storageProofs [][][]byte, err error)
}
ETHClient go-ethereum methods used by Client and by the tx submitter.
type RouterProof ¶
RouterProof is an eth_getProof result for the router at one height: the account proof nodes against the block's state root and the storage proof nodes of each requested slot, in request order.