evm

package
v0.0.48 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventTypeSendFunds         = "sendFunds"
	EventTypeRevertUniversalTx = "revertUniversalTx"
)

Event type constants matching gateway method names in chain config.

View Source
const (
	EventTypeFinalizeUniversalTx = "finalizeUniversalTx"
	EventTypeFundsRescued        = "fundsRescued"
)

Vault event type constants matching vault method names in chain config.

Variables

This section is empty.

Functions

func FetchVaultAddress

func FetchVaultAddress(ctx context.Context, rpcClient *RPCClient, gatewayAddress ethcommon.Address) (ethcommon.Address, error)

FetchVaultAddress calls the gateway's vault() public getter to retrieve the vault address.

func ParseEvent

func ParseEvent(log *types.Log, eventType string, chainID string, logger zerolog.Logger) (event *store.Event)

ParseEvent parses a log into a store.Event based on the event type. eventType should be one of: sendFunds, revertUniversalTx, finalizeUniversalTx, fundsRescued.

A panic in the decoders is contained here rather than allowed to unwind. Log data is supplied by an RPC and the listener runs on a background goroutine, so an unrecovered panic would take down every chain and the TSS node with it. A log we cannot decode is skipped like any other undecodable one.

Types

type ChainMetaOracle

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

ChainMetaOracle handles fetching and reporting gas prices

func NewChainMetaOracle

func NewChainMetaOracle(
	rpcClient *RPCClient,
	pushSigner *pushsigner.Signer,
	chainID string,
	gasPriceIntervalSeconds int,
	gasPriceMarkupPercent int,
	logger zerolog.Logger,
) *ChainMetaOracle

NewChainMetaOracle creates a new gas oracle

func (*ChainMetaOracle) Start

func (g *ChainMetaOracle) Start(ctx context.Context) error

Start begins fetching and voting on gas prices

func (*ChainMetaOracle) Stop

func (g *ChainMetaOracle) Stop()

Stop stops the gas oracle

type Client

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

Client implements the ChainClient interface for EVM chains

func NewClient

func NewClient(
	config *uregistrytypes.ChainConfig,
	database *db.DB,
	chainConfig *config.ChainSpecificConfig,
	pushSigner *pushsigner.Signer,
	allowZeroConfirmations bool,
	logger zerolog.Logger,
) (*Client, error)

NewClient creates a new EVM chain client

func (*Client) ChainID

func (c *Client) ChainID() string

ChainID returns the chain ID string

func (*Client) ExecuteRead added in v0.0.45

ExecuteRead implements common.ChainReader for EVM chains. All validators must produce byte-identical results, so every query runs at the height pinned in the request; execution is gated until that height has min_confirmations confirmations so a reorg cannot invalidate the read.

func (*Client) GetConfig

func (c *Client) GetConfig() *uregistrytypes.ChainConfig

GetConfig returns the registry chain config

func (*Client) GetReadRequestHandler added in v0.0.45

func (c *Client) GetReadRequestHandler() (common.ReadRequestHandler, error)

GetReadRequestHandler returns the read request handler for this chain

func (*Client) GetTxBuilder

func (c *Client) GetTxBuilder() (common.TxBuilder, error)

GetTxBuilder returns the TxBuilder for this chain

func (*Client) IsHealthy

func (c *Client) IsHealthy() bool

IsHealthy checks if the EVM chain RPC client is healthy

func (*Client) Start

func (c *Client) Start(ctx context.Context) error

Start initializes and starts the EVM chain client

func (*Client) Stop

func (c *Client) Stop() error

Stop gracefully shuts down the EVM chain client

type EventConfirmer

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

EventConfirmer periodically checks pending events and marks them as CONFIRMED once their transactions are confirmed on-chain.

func NewEventConfirmer

func NewEventConfirmer(
	rpcClient *RPCClient,
	database *db.DB,
	chainID string,
	pollIntervalSeconds int,
	fastConfirmations uint64,
	standardConfirmations uint64,
	logger zerolog.Logger,
) *EventConfirmer

NewEventConfirmer creates a new event confirmer

func (*EventConfirmer) Start

func (ec *EventConfirmer) Start(ctx context.Context) error

Start begins checking and confirming events

func (*EventConfirmer) Stop

func (ec *EventConfirmer) Stop()

Stop stops the event confirmer

type EventListener

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

EventListener listens for gateway and vault events on EVM chains and stores them in the database

func NewEventListener

func NewEventListener(
	rpcClient *RPCClient,
	gatewayAddress string,
	vaultAddress string,
	chainID string,
	gatewayMethods []*uregistrytypes.GatewayMethods,
	vaultMethods []*uregistrytypes.VaultMethods,
	database *db.DB,
	eventPollingSeconds int,
	eventStartFrom *int64,
	logger zerolog.Logger,
) (*EventListener, error)

NewEventListener creates a new EVM event listener

func (*EventListener) IsRunning

func (el *EventListener) IsRunning() bool

IsRunning returns whether the listener is currently running

func (*EventListener) Start

func (el *EventListener) Start(ctx context.Context) error

Start begins listening for gateway events

func (*EventListener) Stop

func (el *EventListener) Stop() error

Stop gracefully stops the event listener

type RPCClient

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

RPCClient provides EVM-specific RPC operations

func NewRPCClient

func NewRPCClient(rpcURLs []string, expectedChainID int64, logger zerolog.Logger) (*RPCClient, error)

NewRPCClient creates a new EVM RPC client from RPC URLs and validates chain ID

func (*RPCClient) BroadcastTransaction

func (rc *RPCClient) BroadcastTransaction(ctx context.Context, tx *types.Transaction) (string, error)

BroadcastTransaction broadcasts a signed transaction and returns the transaction hash

func (*RPCClient) CallContract

func (rc *RPCClient) CallContract(ctx context.Context, contractAddr ethcommon.Address, data []byte, blockNumber *big.Int) ([]byte, error)

CallContract calls a contract method and returns the result

func (*RPCClient) CallContractWithFrom

func (rc *RPCClient) CallContractWithFrom(ctx context.Context, from, contractAddr ethcommon.Address, data []byte, value *big.Int, blockNumber *big.Int) ([]byte, error)

CallContractWithFrom simulates a contract call as if from the given address (eth_call). No private key needed - use for simulation to check if a tx would pass or fail.

func (*RPCClient) Close

func (rc *RPCClient) Close()

Close closes all RPC connections

func (*RPCClient) FilterLogs

func (rc *RPCClient) FilterLogs(ctx context.Context, query ethereum.FilterQuery) ([]types.Log, error)

FilterLogs fetches logs matching the filter query

func (*RPCClient) GetBalance

func (rc *RPCClient) GetBalance(ctx context.Context, address ethcommon.Address) (*big.Int, error)

GetBalance fetches the native token balance for an address at the latest block.

func (*RPCClient) GetBalanceAt added in v0.0.45

func (rc *RPCClient) GetBalanceAt(ctx context.Context, address ethcommon.Address, blockNumber *big.Int) (*big.Int, error)

GetBalanceAt fetches the native token balance for an address at a specific block.

func (*RPCClient) GetFinalizedNonce

func (rc *RPCClient) GetFinalizedNonce(ctx context.Context, address ethcommon.Address, blockNum *big.Int) (uint64, error)

GetFinalizedNonce returns the finalized nonce at a block.

func (*RPCClient) GetGasPrice

func (rc *RPCClient) GetGasPrice(ctx context.Context) (*big.Int, error)

GetGasPrice fetches the current gas price

func (*RPCClient) GetHeaderByNumber added in v0.0.45

func (rc *RPCClient) GetHeaderByNumber(ctx context.Context, blockNumber *big.Int) (*types.Header, error)

GetHeaderByNumber fetches a block header by number.

func (*RPCClient) GetLatestBlock

func (rc *RPCClient) GetLatestBlock(ctx context.Context) (uint64, error)

GetLatestBlock returns the latest block number

func (*RPCClient) GetPendingNonce

func (rc *RPCClient) GetPendingNonce(ctx context.Context, address ethcommon.Address) (uint64, error)

GetPendingNonce returns the pending nonce (next nonce the chain will accept for this account).

func (*RPCClient) GetStorageAt added in v0.0.45

func (rc *RPCClient) GetStorageAt(ctx context.Context, address ethcommon.Address, slot ethcommon.Hash, blockNumber *big.Int) ([]byte, error)

GetStorageAt fetches a storage slot value for a contract at a specific block.

func (*RPCClient) GetTransactionByHash

func (rc *RPCClient) GetTransactionByHash(ctx context.Context, txHash ethcommon.Hash) (*types.Transaction, bool, error)

GetTransactionByHash returns a transaction by its hash.

func (*RPCClient) GetTransactionReceipt

func (rc *RPCClient) GetTransactionReceipt(ctx context.Context, txHash ethcommon.Hash) (*Receipt, error)

GetTransactionReceipt fetches a transaction receipt in a single raw call, reading the OP-Stack l1Fee alongside the standard fields. Returns (nil, nil) if the tx is not found (receipt is null).

func (*RPCClient) IsHealthy

func (rc *RPCClient) IsHealthy(ctx context.Context) bool

IsHealthy checks if any RPC in the pool is healthy by pinging it

type Receipt added in v0.0.48

type Receipt struct {
	Status            uint64
	BlockNumber       uint64
	GasUsed           uint64
	EffectiveGasPrice *big.Int // nil if the receipt omits the field (pre-London / non-compliant RPC)
	L1Fee             *big.Int // OP-Stack L1 data fee; 0 on non-OP chains
}

Receipt holds the transaction-receipt fields the universal client needs, including the OP-Stack L1 data fee that go-ethereum's typed receipt omits.

type RevertInstructions

type RevertInstructions struct {
	RevertRecipient ethcommon.Address
	RevertMsg       []byte
}

RevertInstructions represents the struct for revert instruction in contracts Matches: struct RevertInstructions { address revertRecipient; bytes revertMsg; }

type TxBuilder

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

TxBuilder implements TxBuilder for EVM chains using the Vault contract.

func NewTxBuilder

func NewTxBuilder(
	rpcClient *RPCClient,
	chainID string,
	chainIDInt int64,
	gatewayAddress string,
	vaultAddress ethcommon.Address,
	logger zerolog.Logger,
) (*TxBuilder, error)

NewTxBuilder creates a new EVM transaction builder for Vault + Gateway. The vault address is provided by the caller (fetched from the gateway by the client).

func (*TxBuilder) BroadcastFundMigrationTx

func (tb *TxBuilder) BroadcastFundMigrationTx(ctx context.Context, req *common.UnsignedSigningReq, data *common.FundMigrationData, signature []byte) (string, error)

BroadcastFundMigrationTx assembles and broadcasts a signed fund migration transaction.

func (*TxBuilder) BroadcastOutboundSigningRequest

func (tb *TxBuilder) BroadcastOutboundSigningRequest(
	ctx context.Context,
	req *common.UnsignedSigningReq,
	data *uetypes.OutboundCreatedEvent,
	signature []byte,
) (string, error)

BroadcastOutboundSigningRequest assembles and broadcasts a signed transaction

func (*TxBuilder) GetFundMigrationSigningRequest

func (tb *TxBuilder) GetFundMigrationSigningRequest(ctx context.Context, data *common.FundMigrationData, nonce uint64) (*common.UnsignedSigningReq, error)

GetFundMigrationSigningRequest builds the native transfer sweeping the old TSS balance to the current one. The amount is pinned on chain, so this makes no RPC call and stays reproducible after the sweep has already landed.

func (*TxBuilder) GetGasFeeUsed

func (tb *TxBuilder) GetGasFeeUsed(ctx context.Context, txHash string) (string, error)

GetGasFeeUsed returns the gas fee used by a transaction on the EVM chain: L2 execution (gasUsed * effectiveGasPrice) plus the OP-Stack L1 data fee (0 on non-OP chains). Errors when the fee cannot be determined so callers retry rather than record an under-reported fee.

func (*TxBuilder) GetNextNonce

func (tb *TxBuilder) GetNextNonce(ctx context.Context, signerAddress string, useFinalized bool) (uint64, error)

GetNextNonce returns the next nonce for the signer.

func (*TxBuilder) GetOutboundSigningRequest

func (tb *TxBuilder) GetOutboundSigningRequest(
	ctx context.Context,
	data *uetypes.OutboundCreatedEvent,
	nonce uint64,
) (*common.UnsignedSigningReq, error)

GetOutboundSigningRequest creates a signing request from outbound event data. EVM doesn't consume data.SigningDeadline — deadlines are SVM-only; EVM relies on nonce-based finality.

func (*TxBuilder) IsAlreadyExecuted

func (tb *TxBuilder) IsAlreadyExecuted(ctx context.Context, txID string) (bool, int64, error)

IsAlreadyExecuted returns (false, 0, nil) for EVM. EVM uses nonce-based replay protection (checked via GetNextNonce in the broadcaster); the cluster-time signal is SVM-only.

func (*TxBuilder) VerifyBroadcastedTx

func (tb *TxBuilder) VerifyBroadcastedTx(ctx context.Context, txHash string) (found bool, blockHeight uint64, confirmations uint64, status uint8, err error)

VerifyBroadcastedTx checks the status of a broadcasted transaction on the EVM chain.

Jump to

Keyboard shortcuts

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