github.com/0xPolygon/supernets2-node@v0.0.0-20230711153321-2fe574524eaa/jsonrpc/types/interfaces.go (about)

     1  package types
     2  
     3  import (
     4  	"context"
     5  	"math/big"
     6  	"time"
     7  
     8  	"github.com/0xPolygon/supernets2-node/pool"
     9  	"github.com/0xPolygon/supernets2-node/state"
    10  	"github.com/0xPolygon/supernets2-node/state/runtime"
    11  	"github.com/ethereum/go-ethereum/common"
    12  	"github.com/ethereum/go-ethereum/core/types"
    13  	"github.com/jackc/pgx/v4"
    14  )
    15  
    16  // PoolInterface contains the methods required to interact with the tx pool.
    17  type PoolInterface interface {
    18  	AddTx(ctx context.Context, tx types.Transaction, ip string) error
    19  	GetGasPrice(ctx context.Context) (uint64, error)
    20  	GetNonce(ctx context.Context, address common.Address) (uint64, error)
    21  	GetPendingTxHashesSince(ctx context.Context, since time.Time) ([]common.Hash, error)
    22  	GetPendingTxs(ctx context.Context, limit uint64) ([]pool.Transaction, error)
    23  	CountPendingTransactions(ctx context.Context) (uint64, error)
    24  	GetTxByHash(ctx context.Context, hash common.Hash) (*pool.Transaction, error)
    25  }
    26  
    27  // StateInterface gathers the methods required to interact with the state.
    28  type StateInterface interface {
    29  	PrepareWebSocket()
    30  	BeginStateTransaction(ctx context.Context) (pgx.Tx, error)
    31  	DebugTransaction(ctx context.Context, transactionHash common.Hash, traceConfig state.TraceConfig, dbTx pgx.Tx) (*runtime.ExecutionResult, error)
    32  	EstimateGas(transaction *types.Transaction, senderAddress common.Address, l2BlockNumber *uint64, dbTx pgx.Tx) (uint64, []byte, error)
    33  	GetBalance(ctx context.Context, address common.Address, root common.Hash) (*big.Int, error)
    34  	GetCode(ctx context.Context, address common.Address, root common.Hash) ([]byte, error)
    35  	GetL2BlockByHash(ctx context.Context, hash common.Hash, dbTx pgx.Tx) (*types.Block, error)
    36  	GetL2BlockByNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (*types.Block, error)
    37  	BatchNumberByL2BlockNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (uint64, error)
    38  	GetL2BlockHashesSince(ctx context.Context, since time.Time, dbTx pgx.Tx) ([]common.Hash, error)
    39  	GetL2BlockHeaderByNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (*types.Header, error)
    40  	GetL2BlockTransactionCountByHash(ctx context.Context, hash common.Hash, dbTx pgx.Tx) (uint64, error)
    41  	GetL2BlockTransactionCountByNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (uint64, error)
    42  	GetLastVirtualizedL2BlockNumber(ctx context.Context, dbTx pgx.Tx) (uint64, error)
    43  	GetLastConsolidatedL2BlockNumber(ctx context.Context, dbTx pgx.Tx) (uint64, error)
    44  	GetLastL2Block(ctx context.Context, dbTx pgx.Tx) (*types.Block, error)
    45  	GetLastL2BlockNumber(ctx context.Context, dbTx pgx.Tx) (uint64, error)
    46  	GetLogs(ctx context.Context, fromBlock uint64, toBlock uint64, addresses []common.Address, topics [][]common.Hash, blockHash *common.Hash, since *time.Time, dbTx pgx.Tx) ([]*types.Log, error)
    47  	GetNonce(ctx context.Context, address common.Address, root common.Hash) (uint64, error)
    48  	GetStorageAt(ctx context.Context, address common.Address, position *big.Int, root common.Hash) (*big.Int, error)
    49  	GetSyncingInfo(ctx context.Context, dbTx pgx.Tx) (state.SyncingInfo, error)
    50  	GetTransactionByHash(ctx context.Context, transactionHash common.Hash, dbTx pgx.Tx) (*types.Transaction, error)
    51  	GetTransactionByL2BlockHashAndIndex(ctx context.Context, blockHash common.Hash, index uint64, dbTx pgx.Tx) (*types.Transaction, error)
    52  	GetTransactionByL2BlockNumberAndIndex(ctx context.Context, blockNumber uint64, index uint64, dbTx pgx.Tx) (*types.Transaction, error)
    53  	GetTransactionReceipt(ctx context.Context, transactionHash common.Hash, dbTx pgx.Tx) (*types.Receipt, error)
    54  	IsL2BlockConsolidated(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (bool, error)
    55  	IsL2BlockVirtualized(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (bool, error)
    56  	ProcessUnsignedTransaction(ctx context.Context, tx *types.Transaction, senderAddress common.Address, l2BlockNumber *uint64, noZKEVMCounters bool, dbTx pgx.Tx) (*runtime.ExecutionResult, error)
    57  	RegisterNewL2BlockEventHandler(h state.NewL2BlockEventHandler)
    58  	GetLastVirtualBatchNum(ctx context.Context, dbTx pgx.Tx) (uint64, error)
    59  	GetLastVerifiedBatch(ctx context.Context, dbTx pgx.Tx) (*state.VerifiedBatch, error)
    60  	GetLastBatchNumber(ctx context.Context, dbTx pgx.Tx) (uint64, error)
    61  	GetBatchByNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.Batch, error)
    62  	GetTransactionsByBatchNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (txs []types.Transaction, err error)
    63  	GetVirtualBatch(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.VirtualBatch, error)
    64  	GetVerifiedBatch(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.VerifiedBatch, error)
    65  	GetExitRootByGlobalExitRoot(ctx context.Context, ger common.Hash, dbTx pgx.Tx) (*state.GlobalExitRoot, error)
    66  }