eth

package
v0.3.6-alpha Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2021 License: AGPL-3.0 Imports: 46 Imported by: 1

Documentation

Index

Constants

View Source
const (
	RetrieveCanonicalBlockHashByNumber = `` /* 162-byte string literal not displayed */

	RetrieveCanonicalHeaderByNumber = `` /* 161-byte string literal not displayed */

	RetrieveTD = `SELECT td FROM eth.header_cids
			WHERE header_cids.block_hash = $1`
	RetrieveRPCTransaction = `` /* 243-byte string literal not displayed */

	RetrieveCodeHashByLeafKeyAndBlockHash = `` /* 478-byte string literal not displayed */

	RetrieveCodeByMhKey = `SELECT data FROM public.blocks WHERE key = $1`
)
View Source
const (
	RetrieveHeadersByHashesPgStr = `` /* 166-byte string literal not displayed */

	RetrieveHeadersByBlockNumberPgStr = `` /* 148-byte string literal not displayed */

	RetrieveHeaderByHashPgStr = `` /* 146-byte string literal not displayed */

	RetrieveUnclesByHashesPgStr = `` /* 164-byte string literal not displayed */

	RetrieveUnclesByBlockHashPgStr = `` /* 242-byte string literal not displayed */

	RetrieveUnclesByBlockNumberPgStr = `` /* 244-byte string literal not displayed */

	RetrieveUncleByHashPgStr = `` /* 144-byte string literal not displayed */

	RetrieveTransactionsByHashesPgStr = `` /* 176-byte string literal not displayed */

	RetrieveTransactionsByBlockHashPgStr = `` /* 321-byte string literal not displayed */

	RetrieveTransactionsByBlockNumberPgStr = `` /* 323-byte string literal not displayed */

	RetrieveTransactionByHashPgStr = `` /* 156-byte string literal not displayed */

	RetrieveReceiptsByTxHashesPgStr = `` /* 269-byte string literal not displayed */

	RetrieveReceiptsByBlockHashPgStr = `` /* 423-byte string literal not displayed */

	RetrieveReceiptsByBlockNumberPgStr = `` /* 395-byte string literal not displayed */

	RetrieveReceiptByTxHashPgStr = `` /* 249-byte string literal not displayed */

	RetrieveAccountByLeafKeyAndBlockHashPgStr = `` /* 608-byte string literal not displayed */

	RetrieveAccountByLeafKeyAndBlockNumberPgStr = `` /* 598-byte string literal not displayed */

	RetrieveStorageLeafByAddressHashAndLeafKeyAndBlockNumberPgStr = `` /* 784-byte string literal not displayed */

	RetrieveStorageLeafByAddressHashAndLeafKeyAndBlockHashPgStr = `` /* 810-byte string literal not displayed */

)
View Source
const APIName = "eth"

APIName is the namespace for the watcher's eth api

View Source
const APIVersion = "0.0.1"

APIVersion is the version of the watcher's eth api

Variables

This section is empty.

Functions

func ChainConfig

func ChainConfig(chainID uint64) (*params.ChainConfig, error)

ChainConfig returns the appropriate ethereum chain config for the provided chain id

func DoCall added in v0.3.9

func DoCall(ctx context.Context, b *Backend, args CallArgs, blockNrOrHash rpc.BlockNumberOrHash, overrides map[common.Address]account, timeout time.Duration, globalGasCap *big.Int) ([]byte, uint64, bool, error)

func LoadConfig added in v0.3.9

func LoadConfig(chainConfigPath string) (*params.ChainConfig, error)

LoadConfig loads chain config from json file

func RPCMarshalBlock

func RPCMarshalBlock(block *types.Block, inclTx bool, fullTx bool) (map[string]interface{}, error)

RPCMarshalBlock converts the given block to the RPC output which depends on fullTx. If inclTx is true transactions are returned. When fullTx is true the returned block contains full transaction details, otherwise it will only contain transaction hashes.

func RPCMarshalBlockWithUncleHashes added in v0.3.9

func RPCMarshalBlockWithUncleHashes(block *types.Block, uncleHashes []common.Hash, inclTx bool, fullTx bool) (map[string]interface{}, error)

RPCMarshalBlockWithUncleHashes marshals the block with the provided uncle hashes

func RPCMarshalHeader

func RPCMarshalHeader(head *types.Header) map[string]interface{}

RPCMarshalHeader converts the given header to the RPC output. This function is eth/internal so we have to make our own version here...

func ReceiptModelsContainsCID

func ReceiptModelsContainsCID(rcts []eth.ReceiptModel, cid string) bool

ListContainsBytes used to check if a list of byte arrays contains a particular byte array

func ResolveToNodeType

func ResolveToNodeType(nodeType int) sdtypes.NodeType

func TearDownDB

func TearDownDB(db *postgres.DB)

TearDownDB is used to tear down the watcher dbs after tests

func TxModelsContainsCID

func TxModelsContainsCID(txs []eth.TxModel, cid string) bool

TxModelsContainsCID used to check if a list of TxModels contains a specific cid string

Types

type AccountResult added in v0.3.9

type AccountResult struct {
	Address      common.Address  `json:"address"`
	AccountProof []string        `json:"accountProof"`
	Balance      *hexutil.Big    `json:"balance"`
	CodeHash     common.Hash     `json:"codeHash"`
	Nonce        hexutil.Uint64  `json:"nonce"`
	StorageHash  common.Hash     `json:"storageHash"`
	StorageProof []StorageResult `json:"storageProof"`
}

AccountResult struct for GetProof

type Backend

type Backend struct {
	// underlying postgres db
	DB *postgres.DB

	// postgres db interfaces
	Retriever     *CIDRetriever
	Fetcher       *IPLDFetcher
	IPLDRetriever *IPLDRetriever

	// ethereum interfaces
	EthDB         ethdb.Database
	StateDatabase state.Database

	Config *Config
}

func NewEthBackend

func NewEthBackend(db *postgres.DB, c *Config) (*Backend, error)

func (*Backend) BlockByHash

func (b *Backend) BlockByHash(ctx context.Context, hash common.Hash) (*types.Block, error)

BlockByHash returns the requested block. When fullTx is true all transactions in the block are returned in full detail, otherwise only the transaction hash is returned.

func (*Backend) BlockByNumber

func (b *Backend) BlockByNumber(ctx context.Context, blockNumber rpc.BlockNumber) (*types.Block, error)

BlockByNumber returns the requested canonical block.

func (*Backend) BlockByNumberOrHash added in v0.3.9

func (b *Backend) BlockByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*types.Block, error)

BlockByNumberOrHash returns block by number or hash

func (*Backend) BloomStatus added in v0.3.9

func (b *Backend) BloomStatus() (uint64, uint64)

func (*Backend) ChainDb added in v0.3.9

func (b *Backend) ChainDb() ethdb.Database

ChainDb returns the backend's underlying chain database

func (*Backend) CurrentBlock added in v0.3.9

func (b *Backend) CurrentBlock() (*types.Block, error)

CurrentBlock returns the current block

func (*Backend) Engine added in v0.3.9

func (b *Backend) Engine() consensus.Engine

Engine satisfied the ChainContext interface

func (*Backend) GetAccountByHash added in v0.3.9

func (b *Backend) GetAccountByHash(ctx context.Context, address common.Address, hash common.Hash) (*state.Account, error)

GetAccountByHash returns the account object for the provided address at the block with the provided hash

func (*Backend) GetAccountByNumber added in v0.3.9

func (b *Backend) GetAccountByNumber(ctx context.Context, address common.Address, blockNumber rpc.BlockNumber) (*state.Account, error)

GetAccountByNumber returns the account object for the provided address at the canonical block at the provided height

func (*Backend) GetAccountByNumberOrHash added in v0.3.9

func (b *Backend) GetAccountByNumberOrHash(ctx context.Context, address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (*state.Account, error)

GetAccountByNumberOrHash returns the account object for the provided address at the block corresponding to the provided number or hash

func (*Backend) GetCanonicalHash added in v0.3.9

func (b *Backend) GetCanonicalHash(number uint64) (common.Hash, error)

GetCanonicalHash gets the canonical hash for the provided number, if there is one

func (*Backend) GetCanonicalHeader added in v0.3.9

func (b *Backend) GetCanonicalHeader(number uint64) (string, []byte, error)

GetCanonicalHeader gets the canonical header for the provided number, if there is one

func (*Backend) GetCodeByHash added in v0.3.9

func (b *Backend) GetCodeByHash(ctx context.Context, address common.Address, hash common.Hash) ([]byte, error)

GetCodeByHash returns the byte code for the contract deployed at the provided address at the block with the provided hash

func (*Backend) GetCodeByNumber added in v0.3.9

func (b *Backend) GetCodeByNumber(ctx context.Context, address common.Address, blockNumber rpc.BlockNumber) ([]byte, error)

GetCodeByNumber returns the byte code for the contract deployed at the provided address at the canonical block with the provided block number

func (*Backend) GetCodeByNumberOrHash added in v0.3.9

func (b *Backend) GetCodeByNumberOrHash(ctx context.Context, address common.Address, blockNrOrHash rpc.BlockNumberOrHash) ([]byte, error)

GetCodeByNumberOrHash returns the byte code for the contract deployed at the provided address at the block with the provided hash or block number

func (*Backend) GetEVM added in v0.3.9

func (b *Backend) GetEVM(ctx context.Context, msg core.Message, state *state.StateDB, header *types.Header) (*vm.EVM, error)

GetEVM constructs and returns a vm.EVM

func (*Backend) GetHeader added in v0.3.9

func (b *Backend) GetHeader(hash common.Hash, height uint64) *types.Header

GetHeader satisfied the ChainContext interface

func (*Backend) GetLogs

func (b *Backend) GetLogs(ctx context.Context, hash common.Hash) ([][]*types.Log, error)

GetLogs returns all the logs for the given block hash

func (*Backend) GetReceipts added in v0.3.9

func (b *Backend) GetReceipts(ctx context.Context, hash common.Hash) (types.Receipts, error)

GetReceipts retrieves receipts for provided block hash

func (*Backend) GetStorageByHash added in v0.3.9

func (b *Backend) GetStorageByHash(ctx context.Context, address common.Address, key, hash common.Hash) (hexutil.Bytes, error)

GetStorageByHash returns the storage value for the provided contract address an storage key at the block corresponding to the provided hash

func (*Backend) GetStorageByNumber added in v0.3.9

func (b *Backend) GetStorageByNumber(ctx context.Context, address common.Address, key common.Hash, blockNumber rpc.BlockNumber) (hexutil.Bytes, error)

GetStorageByNumber returns the storage value for the provided contract address an storage key at the block corresponding to the provided number

func (*Backend) GetStorageByNumberOrHash added in v0.3.9

func (b *Backend) GetStorageByNumberOrHash(ctx context.Context, address common.Address, key common.Hash, blockNrOrHash rpc.BlockNumberOrHash) (hexutil.Bytes, error)

GetStorageByNumberOrHash returns the storage value for the provided contract address an storage key at the block corresponding to the provided number or hash

func (*Backend) GetTd

func (b *Backend) GetTd(blockHash common.Hash) (*big.Int, error)

GetTd gets the total difficulty at the given block hash

func (*Backend) GetTransaction

func (b *Backend) GetTransaction(ctx context.Context, txHash common.Hash) (*types.Transaction, common.Hash, uint64, uint64, error)

GetTransaction retrieves a tx by hash It also returns the blockhash, blocknumber, and tx index associated with the transaction

func (*Backend) HeaderByHash added in v0.3.9

func (b *Backend) HeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error)

HeaderByHash gets the header for the provided block hash

func (*Backend) HeaderByNumber

func (b *Backend) HeaderByNumber(ctx context.Context, blockNumber rpc.BlockNumber) (*types.Header, error)

HeaderByNumber gets the canonical header for the provided block number

func (*Backend) HeaderByNumberOrHash added in v0.3.9

func (b *Backend) HeaderByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*types.Header, error)

HeaderByNumberOrHash gets the header for the provided block hash or number

func (*Backend) RPCGasCap added in v0.3.9

func (b *Backend) RPCGasCap() *big.Int

RPCGasCap returns the configured gas cap for the rpc server

func (*Backend) ServiceFilter added in v0.3.9

func (b *Backend) ServiceFilter(ctx context.Context, session *bloombits.MatcherSession)

func (*Backend) StateAndHeaderByNumber added in v0.3.9

func (b *Backend) StateAndHeaderByNumber(ctx context.Context, number rpc.BlockNumber) (*state.StateDB, *types.Header, error)

StateAndHeaderByNumber returns the statedb and header for a provided block number

func (*Backend) StateAndHeaderByNumberOrHash added in v0.3.9

func (b *Backend) StateAndHeaderByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*state.StateDB, *types.Header, error)

StateAndHeaderByNumberOrHash returns the statedb and header for the provided block number or hash

func (*Backend) SubscribeChainEvent added in v0.3.9

func (b *Backend) SubscribeChainEvent(ch chan<- core.ChainEvent) event.Subscription

func (*Backend) SubscribeLogsEvent added in v0.3.9

func (b *Backend) SubscribeLogsEvent(ch chan<- []*types.Log) event.Subscription

func (*Backend) SubscribeNewTxsEvent added in v0.3.9

func (b *Backend) SubscribeNewTxsEvent(chan<- core.NewTxsEvent) event.Subscription

func (*Backend) SubscribePendingLogsEvent added in v0.3.9

func (b *Backend) SubscribePendingLogsEvent(ch chan<- []*types.Log) event.Subscription

func (*Backend) SubscribeRemovedLogsEvent added in v0.3.9

func (b *Backend) SubscribeRemovedLogsEvent(ch chan<- core.RemovedLogsEvent) event.Subscription

type CIDRetriever

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

CIDRetriever satisfies the CIDRetriever interface for ethereum

func NewCIDRetriever

func NewCIDRetriever(db *postgres.DB) *CIDRetriever

NewCIDRetriever returns a pointer to a new CIDRetriever which supports the CIDRetriever interface

func (*CIDRetriever) Retrieve

func (ecr *CIDRetriever) Retrieve(filter SubscriptionSettings, blockNumber int64) ([]CIDWrapper, bool, error)

Retrieve is used to retrieve all of the CIDs which conform to the passed StreamFilters

func (*CIDRetriever) RetrieveBlockByHash

func (ecr *CIDRetriever) RetrieveBlockByHash(blockHash common.Hash) (eth.HeaderModel, []eth.UncleModel, []eth.TxModel, []eth.ReceiptModel, error)

RetrieveBlockByHash returns all of the CIDs needed to compose an entire block, for a given block hash

func (*CIDRetriever) RetrieveBlockByNumber

func (ecr *CIDRetriever) RetrieveBlockByNumber(blockNumber int64) (eth.HeaderModel, []eth.UncleModel, []eth.TxModel, []eth.ReceiptModel, error)

RetrieveBlockByNumber returns all of the CIDs needed to compose an entire block, for a given block number

func (*CIDRetriever) RetrieveFirstBlockNumber

func (ecr *CIDRetriever) RetrieveFirstBlockNumber() (int64, error)

RetrieveFirstBlockNumber is used to retrieve the first block number in the db

func (*CIDRetriever) RetrieveHeaderCIDByHash

func (ecr *CIDRetriever) RetrieveHeaderCIDByHash(tx *sqlx.Tx, blockHash common.Hash) (eth.HeaderModel, error)

RetrieveHeaderCIDByHash returns the header for the given block hash

func (*CIDRetriever) RetrieveHeaderCIDs

func (ecr *CIDRetriever) RetrieveHeaderCIDs(tx *sqlx.Tx, blockNumber int64) ([]eth.HeaderModel, error)

RetrieveHeaderCIDs retrieves and returns all of the header cids at the provided blockheight

func (*CIDRetriever) RetrieveLastBlockNumber

func (ecr *CIDRetriever) RetrieveLastBlockNumber() (int64, error)

RetrieveLastBlockNumber is used to retrieve the latest block number in the db

func (*CIDRetriever) RetrieveRctCIDs

func (ecr *CIDRetriever) RetrieveRctCIDs(tx *sqlx.Tx, rctFilter ReceiptFilter, blockNumber int64, blockHash *common.Hash, trxIds []int64) ([]eth.ReceiptModel, error)

RetrieveRctCIDs retrieves and returns all of the rct cids at the provided blockheight or block hash that conform to the provided filter parameters and correspond to the provided tx ids

func (*CIDRetriever) RetrieveRctCIDsByHeaderID

func (ecr *CIDRetriever) RetrieveRctCIDsByHeaderID(tx *sqlx.Tx, rctFilter ReceiptFilter, headerID int64, trxIds []int64) ([]eth.ReceiptModel, error)

RetrieveRctCIDsByHeaderID retrieves and returns all of the rct cids at the provided header ID that conform to the provided filter parameters and correspond to the provided tx ids

func (*CIDRetriever) RetrieveReceiptCIDsByTxIDs

func (ecr *CIDRetriever) RetrieveReceiptCIDsByTxIDs(tx *sqlx.Tx, txIDs []int64) ([]eth.ReceiptModel, error)

RetrieveReceiptCIDsByTxIDs retrieves receipt CIDs by their associated tx IDs

func (*CIDRetriever) RetrieveStateCIDs

func (ecr *CIDRetriever) RetrieveStateCIDs(tx *sqlx.Tx, stateFilter StateFilter, headerID int64) ([]eth.StateNodeModel, error)

RetrieveStateCIDs retrieves and returns all of the state node cids at the provided header ID that conform to the provided filter parameters

func (*CIDRetriever) RetrieveStorageCIDs

func (ecr *CIDRetriever) RetrieveStorageCIDs(tx *sqlx.Tx, storageFilter StorageFilter, headerID int64) ([]eth.StorageNodeWithStateKeyModel, error)

RetrieveStorageCIDs retrieves and returns all of the storage node cids at the provided header id that conform to the provided filter parameters

func (*CIDRetriever) RetrieveTxCIDs

func (ecr *CIDRetriever) RetrieveTxCIDs(tx *sqlx.Tx, txFilter TxFilter, headerID int64) ([]eth.TxModel, error)

RetrieveTxCIDs retrieves and returns all of the trx cids at the provided blockheight that conform to the provided filter parameters also returns the ids for the returned transaction cids

func (*CIDRetriever) RetrieveTxCIDsByHeaderID

func (ecr *CIDRetriever) RetrieveTxCIDsByHeaderID(tx *sqlx.Tx, headerID int64) ([]eth.TxModel, error)

RetrieveTxCIDsByHeaderID retrieves all tx CIDs for the given header id

func (*CIDRetriever) RetrieveUncleCIDsByHeaderID

func (ecr *CIDRetriever) RetrieveUncleCIDsByHeaderID(tx *sqlx.Tx, headerID int64) ([]eth.UncleModel, error)

RetrieveUncleCIDsByHeaderID retrieves and returns all of the uncle cids for the provided header

type CIDWrapper added in v0.3.9

type CIDWrapper struct {
	BlockNumber  *big.Int
	Header       eth.HeaderModel
	Uncles       []eth.UncleModel
	Transactions []eth.TxModel
	Receipts     []eth.ReceiptModel
	StateNodes   []eth.StateNodeModel
	StorageNodes []eth.StorageNodeWithStateKeyModel
}

CIDWrapper is used to direct fetching of IPLDs from IPFS Returned by CIDRetriever Passed to IPLDFetcher

type CallArgs added in v0.3.9

type CallArgs struct {
	From                 *common.Address   `json:"from"`
	To                   *common.Address   `json:"to"`
	Gas                  *hexutil.Uint64   `json:"gas"`
	GasPrice             *hexutil.Big      `json:"gasPrice"`
	MaxFeePerGas         *hexutil.Big      `json:"maxFeePerGas"`
	MaxPriorityFeePerGas *hexutil.Big      `json:"maxPriorityFeePerGas"`
	Value                *hexutil.Big      `json:"value"`
	Data                 *hexutil.Bytes    `json:"data"`
	AccessList           *types.AccessList `json:"accessList,omitempty"`
	Input                *hexutil.Bytes    `json:"input"`
}

CallArgs represents the arguments for a call.

type Config added in v0.3.9

type Config struct {
	ChainConfig   *params.ChainConfig
	VmConfig      vm.Config
	DefaultSender *common.Address
	RPCGasCap     *big.Int
}

type Fetcher

type Fetcher interface {
	Fetch(cids CIDWrapper) (*IPLDs, error)
}

Fetcher interface for substituting mocks in tests

type FilterBackend added in v0.3.9

type FilterBackend interface {
	ChainDb() ethdb.Database
	HeaderByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*types.Header, error)
	HeaderByHash(ctx context.Context, blockHash common.Hash) (*types.Header, error)
	GetReceipts(ctx context.Context, blockHash common.Hash) (types.Receipts, error)
	GetLogs(ctx context.Context, blockHash common.Hash) ([][]*types.Log, error)

	SubscribeNewTxsEvent(chan<- core.NewTxsEvent) event.Subscription
	SubscribeChainEvent(ch chan<- core.ChainEvent) event.Subscription
	SubscribeRemovedLogsEvent(ch chan<- core.RemovedLogsEvent) event.Subscription
	SubscribeLogsEvent(ch chan<- []*types.Log) event.Subscription
	SubscribePendingLogsEvent(ch chan<- []*types.Log) event.Subscription

	BloomStatus() (uint64, uint64)
	ServiceFilter(ctx context.Context, session *bloombits.MatcherSession)
}

FilterBackend is the geth interface we need to satisfy to use their filters

type Filterer

type Filterer interface {
	Filter(filter SubscriptionSettings, payload eth.ConvertedPayload) (*IPLDs, error)
}

Filterer interface for substituing mocks in tests

type HeaderFilter

type HeaderFilter struct {
	Off    bool
	Uncles bool
}

HeaderFilter contains filter settings for headers

type IPLDFetcher

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

IPLDFetcher satisfies the IPLDFetcher interface for ethereum It interfaces directly with PG-IPFS

func NewIPLDFetcher

func NewIPLDFetcher(db *postgres.DB) *IPLDFetcher

NewIPLDFetcher creates a pointer to a new IPLDFetcher

func (*IPLDFetcher) Fetch

func (f *IPLDFetcher) Fetch(cids CIDWrapper) (*IPLDs, error)

Fetch is the exported method for fetching and returning all the IPLDS specified in the CIDWrapper

func (*IPLDFetcher) FetchHeader

func (f *IPLDFetcher) FetchHeader(tx *sqlx.Tx, c eth.HeaderModel) (ipfs.BlockModel, error)

FetchHeaders fetches headers

func (*IPLDFetcher) FetchRcts

func (f *IPLDFetcher) FetchRcts(tx *sqlx.Tx, cids []eth.ReceiptModel) ([]ipfs.BlockModel, error)

FetchRcts fetches receipts

func (*IPLDFetcher) FetchState

func (f *IPLDFetcher) FetchState(tx *sqlx.Tx, cids []eth.StateNodeModel) ([]StateNode, error)

FetchState fetches state nodes

func (*IPLDFetcher) FetchStorage

func (f *IPLDFetcher) FetchStorage(tx *sqlx.Tx, cids []eth.StorageNodeWithStateKeyModel) ([]StorageNode, error)

FetchStorage fetches storage nodes

func (*IPLDFetcher) FetchTrxs

func (f *IPLDFetcher) FetchTrxs(tx *sqlx.Tx, cids []eth.TxModel) ([]ipfs.BlockModel, error)

FetchTrxs fetches transactions

func (*IPLDFetcher) FetchUncles

func (f *IPLDFetcher) FetchUncles(tx *sqlx.Tx, cids []eth.UncleModel) ([]ipfs.BlockModel, error)

FetchUncles fetches uncles

type IPLDRetriever added in v0.3.9

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

func NewIPLDRetriever added in v0.3.9

func NewIPLDRetriever(db *postgres.DB) *IPLDRetriever

func (*IPLDRetriever) RetrieveAccountByAddressAndBlockHash added in v0.3.9

func (r *IPLDRetriever) RetrieveAccountByAddressAndBlockHash(address common.Address, hash common.Hash) (string, []byte, error)

RetrieveAccountByAddressAndBlockHash returns the cid and rlp bytes for the account corresponding to the provided address and block hash TODO: ensure this handles deleted accounts appropriately

func (*IPLDRetriever) RetrieveAccountByAddressAndBlockNumber added in v0.3.9

func (r *IPLDRetriever) RetrieveAccountByAddressAndBlockNumber(address common.Address, number uint64) (string, []byte, error)

RetrieveAccountByAddressAndBlockNumber returns the cid and rlp bytes for the account corresponding to the provided address and block number This can return a non-canonical account

func (*IPLDRetriever) RetrieveHeaderByHash added in v0.3.9

func (r *IPLDRetriever) RetrieveHeaderByHash(hash common.Hash) (string, []byte, error)

RetrieveHeaderByHash returns the cid and rlp bytes for the header corresponding to the provided block hash

func (*IPLDRetriever) RetrieveHeadersByBlockNumber added in v0.3.9

func (r *IPLDRetriever) RetrieveHeadersByBlockNumber(number uint64) ([]string, [][]byte, error)

RetrieveHeadersByBlockNumber returns the cids and rlp bytes for the headers corresponding to the provided block number This can return more than one result since there can be more than one header (non-canonical headers)

func (*IPLDRetriever) RetrieveHeadersByHashes added in v0.3.9

func (r *IPLDRetriever) RetrieveHeadersByHashes(hashes []common.Hash) ([]string, [][]byte, error)

RetrieveHeadersByHashes returns the cids and rlp bytes for the headers corresponding to the provided block hashes

func (*IPLDRetriever) RetrieveReceiptByHash added in v0.3.9

func (r *IPLDRetriever) RetrieveReceiptByHash(hash common.Hash) (string, []byte, error)

RetrieveReceiptByHash returns the cid and rlp bytes for the receipt corresponding to the provided tx hash

func (*IPLDRetriever) RetrieveReceiptsByBlockHash added in v0.3.9

func (r *IPLDRetriever) RetrieveReceiptsByBlockHash(hash common.Hash) ([]string, [][]byte, []common.Hash, error)

RetrieveReceiptsByBlockHash returns the cids and rlp bytes for the receipts corresponding to the provided block hash

func (*IPLDRetriever) RetrieveReceiptsByBlockNumber added in v0.3.9

func (r *IPLDRetriever) RetrieveReceiptsByBlockNumber(number uint64) ([]string, [][]byte, error)

RetrieveReceiptsByBlockNumber returns the cids and rlp bytes for the receipts corresponding to the provided block hash

func (*IPLDRetriever) RetrieveReceiptsByTxHashes added in v0.3.9

func (r *IPLDRetriever) RetrieveReceiptsByTxHashes(hashes []common.Hash) ([]string, [][]byte, error)

RetrieveReceiptsByTxHashes returns the cids and rlp bytes for the receipts corresponding to the provided tx hashes

func (*IPLDRetriever) RetrieveStorageAtByAddressAndStorageKeyAndBlockNumber added in v0.3.9

func (r *IPLDRetriever) RetrieveStorageAtByAddressAndStorageKeyAndBlockNumber(address common.Address, storageLeafKey common.Hash, number uint64) (string, []byte, error)

RetrieveStorageAtByAddressAndStorageKeyAndBlockNumber returns the cid and rlp bytes for the storage value corresponding to the provided address, storage key, and block number This can retrun a non-canonical value

func (*IPLDRetriever) RetrieveStorageAtByAddressAndStorageSlotAndBlockHash added in v0.3.9

func (r *IPLDRetriever) RetrieveStorageAtByAddressAndStorageSlotAndBlockHash(address common.Address, key, hash common.Hash) (string, []byte, []byte, error)

RetrieveStorageAtByAddressAndStorageSlotAndBlockHash returns the cid and rlp bytes for the storage value corresponding to the provided address, storage slot, and block hash

func (*IPLDRetriever) RetrieveTransactionByTxHash added in v0.3.9

func (r *IPLDRetriever) RetrieveTransactionByTxHash(hash common.Hash) (string, []byte, error)

RetrieveTransactionByTxHash returns the cid and rlp bytes for the transaction corresponding to the provided tx hash

func (*IPLDRetriever) RetrieveTransactionsByBlockHash added in v0.3.9

func (r *IPLDRetriever) RetrieveTransactionsByBlockHash(hash common.Hash) ([]string, [][]byte, error)

RetrieveTransactionsByBlockHash returns the cids and rlp bytes for the transactions corresponding to the provided block hash

func (*IPLDRetriever) RetrieveTransactionsByBlockNumber added in v0.3.9

func (r *IPLDRetriever) RetrieveTransactionsByBlockNumber(number uint64) ([]string, [][]byte, error)

RetrieveTransactionsByBlockNumber returns the cids and rlp bytes for the transactions corresponding to the provided block number

func (*IPLDRetriever) RetrieveTransactionsByHashes added in v0.3.9

func (r *IPLDRetriever) RetrieveTransactionsByHashes(hashes []common.Hash) ([]string, [][]byte, error)

RetrieveTransactionsByHashes returns the cids and rlp bytes for the transactions corresponding to the provided tx hashes

func (*IPLDRetriever) RetrieveUncleByHash added in v0.3.9

func (r *IPLDRetriever) RetrieveUncleByHash(hash common.Hash) (string, []byte, error)

RetrieveUncleByHash returns the cid and rlp bytes for the uncle corresponding to the provided uncle hash

func (*IPLDRetriever) RetrieveUnclesByBlockHash added in v0.3.9

func (r *IPLDRetriever) RetrieveUnclesByBlockHash(hash common.Hash) ([]string, [][]byte, error)

RetrieveUnclesByBlockHash returns the cids and rlp bytes for the uncles corresponding to the provided block hash (of non-omner root block)

func (*IPLDRetriever) RetrieveUnclesByBlockNumber added in v0.3.9

func (r *IPLDRetriever) RetrieveUnclesByBlockNumber(number uint64) ([]string, [][]byte, error)

RetrieveUnclesByBlockNumber returns the cids and rlp bytes for the uncles corresponding to the provided block number (of non-omner root block)

func (*IPLDRetriever) RetrieveUnclesByHashes added in v0.3.9

func (r *IPLDRetriever) RetrieveUnclesByHashes(hashes []common.Hash) ([]string, [][]byte, error)

RetrieveUnclesByHashes returns the cids and rlp bytes for the uncles corresponding to the provided uncle hashes

type IPLDs added in v0.3.9

type IPLDs struct {
	BlockNumber     *big.Int
	TotalDifficulty *big.Int
	Header          ipfs.BlockModel
	Uncles          []ipfs.BlockModel
	Transactions    []ipfs.BlockModel
	Receipts        []ipfs.BlockModel
	StateNodes      []StateNode
	StorageNodes    []StorageNode
}

IPLDs is used to package raw IPLD block data fetched from IPFS and returned by the server Returned by IPLDFetcher and ResponseFilterer

type PublicEthAPI

type PublicEthAPI struct {
	// Local db backend
	B *Backend
	// contains filtered or unexported fields
}

PublicEthAPI is the eth namespace API

func NewPublicEthAPI

func NewPublicEthAPI(b *Backend, client *rpc.Client, supportsStateDiff bool) *PublicEthAPI

NewPublicEthAPI creates a new PublicEthAPI with the provided underlying Backend

func (*PublicEthAPI) BlockNumber

func (pea *PublicEthAPI) BlockNumber() hexutil.Uint64

BlockNumber returns the block number of the chain head.

func (*PublicEthAPI) Call added in v0.3.9

func (pea *PublicEthAPI) Call(ctx context.Context, args CallArgs, blockNrOrHash rpc.BlockNumberOrHash, overrides *map[common.Address]account) (hexutil.Bytes, error)

Call executes the given transaction on the state for the given block number.

Additionally, the caller can specify a batch of contract for fields overriding.

Note, this function doesn't make and changes in the state/blockchain and is useful to execute and retrieve values.

func (*PublicEthAPI) ChainId added in v0.3.9

func (pea *PublicEthAPI) ChainId() hexutil.Uint64

ChainId is the EIP-155 replay-protection chain id for the current ethereum chain config.

func (*PublicEthAPI) GetBalance added in v0.3.9

func (pea *PublicEthAPI) GetBalance(ctx context.Context, address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (*hexutil.Big, error)

GetBalance returns the amount of wei for the given address in the state of the given block number. The rpc.LatestBlockNumber and rpc.PendingBlockNumber meta block numbers are also allowed.

func (*PublicEthAPI) GetBlockByHash

func (pea *PublicEthAPI) GetBlockByHash(ctx context.Context, hash common.Hash, fullTx bool) (map[string]interface{}, error)

GetBlockByHash returns the requested block. When fullTx is true all transactions in the block are returned in full detail, otherwise only the transaction hash is returned.

func (*PublicEthAPI) GetBlockByNumber

func (pea *PublicEthAPI) GetBlockByNumber(ctx context.Context, number rpc.BlockNumber, fullTx bool) (map[string]interface{}, error)

GetBlockByNumber returns the requested canonical block.

  • When blockNr is -1 the chain head is returned.
  • We cannot support pending block calls since we do not have an active miner
  • When fullTx is true all transactions in the block are returned, otherwise only the transaction hash is returned.

func (*PublicEthAPI) GetBlockTransactionCountByHash added in v0.3.9

func (pea *PublicEthAPI) GetBlockTransactionCountByHash(ctx context.Context, blockHash common.Hash) *hexutil.Uint

GetBlockTransactionCountByHash returns the number of transactions in the block with the given hash.

func (*PublicEthAPI) GetBlockTransactionCountByNumber added in v0.3.9

func (pea *PublicEthAPI) GetBlockTransactionCountByNumber(ctx context.Context, blockNr rpc.BlockNumber) *hexutil.Uint

GetBlockTransactionCountByNumber returns the number of transactions in the block with the given block number.

func (*PublicEthAPI) GetCode added in v0.3.9

func (pea *PublicEthAPI) GetCode(ctx context.Context, address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (hexutil.Bytes, error)

GetCode returns the code stored at the given address in the state for the given block number.

func (*PublicEthAPI) GetHeaderByHash added in v0.3.9

func (pea *PublicEthAPI) GetHeaderByHash(ctx context.Context, hash common.Hash) map[string]interface{}

GetHeaderByHash returns the requested header by hash.

func (*PublicEthAPI) GetHeaderByNumber

func (pea *PublicEthAPI) GetHeaderByNumber(ctx context.Context, number rpc.BlockNumber) (map[string]interface{}, error)

GetHeaderByNumber returns the requested canonical block header. * When blockNr is -1 the chain head is returned. * We cannot support pending block calls since we do not have an active miner

func (*PublicEthAPI) GetLogs

func (pea *PublicEthAPI) GetLogs(ctx context.Context, crit filters.FilterCriteria) ([]*types.Log, error)

GetLogs returns logs matching the given argument that are stored within the state.

https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getlogs

func (*PublicEthAPI) GetProof added in v0.3.9

func (pea *PublicEthAPI) GetProof(ctx context.Context, address common.Address, storageKeys []string, blockNrOrHash rpc.BlockNumberOrHash) (*AccountResult, error)

GetProof returns the Merkle-proof for a given account and optionally some storage keys.

func (*PublicEthAPI) GetRawTransactionByBlockHashAndIndex added in v0.3.9

func (pea *PublicEthAPI) GetRawTransactionByBlockHashAndIndex(ctx context.Context, blockHash common.Hash, index hexutil.Uint) hexutil.Bytes

GetRawTransactionByBlockHashAndIndex returns the bytes of the transaction for the given block hash and index.

func (*PublicEthAPI) GetRawTransactionByBlockNumberAndIndex added in v0.3.9

func (pea *PublicEthAPI) GetRawTransactionByBlockNumberAndIndex(ctx context.Context, blockNr rpc.BlockNumber, index hexutil.Uint) hexutil.Bytes

GetRawTransactionByBlockNumberAndIndex returns the bytes of the transaction for the given block number and index.

func (*PublicEthAPI) GetRawTransactionByHash added in v0.3.9

func (pea *PublicEthAPI) GetRawTransactionByHash(ctx context.Context, hash common.Hash) (hexutil.Bytes, error)

GetRawTransactionByHash returns the bytes of the transaction for the given hash.

func (*PublicEthAPI) GetStorageAt added in v0.3.9

func (pea *PublicEthAPI) GetStorageAt(ctx context.Context, address common.Address, key string, blockNrOrHash rpc.BlockNumberOrHash) (hexutil.Bytes, error)

GetStorageAt returns the storage from the state at the given address, key and block number. The rpc.LatestBlockNumber and rpc.PendingBlockNumber meta block numbers are also allowed.

func (*PublicEthAPI) GetTransactionByBlockHashAndIndex added in v0.3.9

func (pea *PublicEthAPI) GetTransactionByBlockHashAndIndex(ctx context.Context, blockHash common.Hash, index hexutil.Uint) *RPCTransaction

GetTransactionByBlockHashAndIndex returns the transaction for the given block hash and index.

func (*PublicEthAPI) GetTransactionByBlockNumberAndIndex added in v0.3.9

func (pea *PublicEthAPI) GetTransactionByBlockNumberAndIndex(ctx context.Context, blockNr rpc.BlockNumber, index hexutil.Uint) *RPCTransaction

GetTransactionByBlockNumberAndIndex returns the transaction for the given block number and index.

func (*PublicEthAPI) GetTransactionByHash

func (pea *PublicEthAPI) GetTransactionByHash(ctx context.Context, hash common.Hash) (*RPCTransaction, error)

GetTransactionByHash returns the transaction for the given hash eth ipld-eth-server cannot currently handle pending/tx_pool txs

func (*PublicEthAPI) GetTransactionCount added in v0.3.9

func (pea *PublicEthAPI) GetTransactionCount(ctx context.Context, address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (*hexutil.Uint64, error)

GetTransactionCount returns the number of transactions the given address has sent for the given block number

func (*PublicEthAPI) GetTransactionReceipt added in v0.3.9

func (pea *PublicEthAPI) GetTransactionReceipt(ctx context.Context, hash common.Hash) (map[string]interface{}, error)

GetTransactionReceipt returns the transaction receipt for the given transaction hash.

func (*PublicEthAPI) GetUncleByBlockHashAndIndex added in v0.3.9

func (pea *PublicEthAPI) GetUncleByBlockHashAndIndex(ctx context.Context, blockHash common.Hash, index hexutil.Uint) (map[string]interface{}, error)

GetUncleByBlockHashAndIndex returns the uncle block for the given block hash and index. When fullTx is true all transactions in the block are returned in full detail, otherwise only the transaction hash is returned.

func (*PublicEthAPI) GetUncleByBlockNumberAndIndex added in v0.3.9

func (pea *PublicEthAPI) GetUncleByBlockNumberAndIndex(ctx context.Context, blockNr rpc.BlockNumber, index hexutil.Uint) (map[string]interface{}, error)

GetUncleByBlockNumberAndIndex returns the uncle block for the given block hash and index. When fullTx is true all transactions in the block are returned in full detail, otherwise only the transaction hash is returned.

func (*PublicEthAPI) GetUncleCountByBlockHash added in v0.3.9

func (pea *PublicEthAPI) GetUncleCountByBlockHash(ctx context.Context, blockHash common.Hash) *hexutil.Uint

GetUncleCountByBlockHash returns number of uncles in the block for the given block hash

func (*PublicEthAPI) GetUncleCountByBlockNumber added in v0.3.9

func (pea *PublicEthAPI) GetUncleCountByBlockNumber(ctx context.Context, blockNr rpc.BlockNumber) *hexutil.Uint

GetUncleCountByBlockNumber returns number of uncles in the block for the given block number

type RPCReceipt added in v0.3.9

type RPCReceipt struct {
	BlockHash        *common.Hash    `json:"blockHash"`
	BlockNumber      *hexutil.Big    `json:"blockNumber"`
	TransactionHash  *common.Hash    `json:"transactionHash"`
	TransactionIndex *hexutil.Uint64 `json:"transactionIndex"`
	From             common.Address  `json:"from"`
	To               *common.Address `json:"to"`
	GasUsed          hexutil.Uint64  `json:"gasUsed"`
	CumulativeGsUsed hexutil.Uint64  `json:"cumulativeGasUsed"`
	ContractAddress  *common.Address `json:"contractAddress"`
	Logs             []*types.Log    `json:"logs"`
	Bloom            types.Bloom     `json:"logsBloom"`
	Root             []byte          `json:"root"`
	Status           uint64          `json:"status"`
}

RPCReceipt represents a receipt that will serialize to the RPC representation of a receipt

type RPCTransaction

type RPCTransaction struct {
	BlockHash        *common.Hash      `json:"blockHash"`
	BlockNumber      *hexutil.Big      `json:"blockNumber"`
	From             common.Address    `json:"from"`
	Gas              hexutil.Uint64    `json:"gas"`
	GasPrice         *hexutil.Big      `json:"gasPrice"`
	GasFeeCap        *hexutil.Big      `json:"maxFeePerGas,omitempty"`
	GasTipCap        *hexutil.Big      `json:"maxPriorityFeePerGas,omitempty"`
	Hash             common.Hash       `json:"hash"`
	Input            hexutil.Bytes     `json:"input"`
	Nonce            hexutil.Uint64    `json:"nonce"`
	To               *common.Address   `json:"to"`
	TransactionIndex *hexutil.Uint64   `json:"transactionIndex"`
	Value            *hexutil.Big      `json:"value"`
	Type             hexutil.Uint64    `json:"type"`
	Accesses         *types.AccessList `json:"accessList,omitempty"`
	ChainID          *hexutil.Big      `json:"chainId,omitempty"`
	V                *hexutil.Big      `json:"v"`
	R                *hexutil.Big      `json:"r"`
	S                *hexutil.Big      `json:"s"`
}

RPCTransaction represents a transaction that will serialize to the RPC representation of a transaction

func NewRPCTransaction

func NewRPCTransaction(tx *types.Transaction, blockHash common.Hash, blockNumber uint64, index uint64, baseFee *big.Int) *RPCTransaction

NewRPCTransaction returns a transaction that will serialize to the RPC representation, with the given location metadata set (if available).

func NewRPCTransactionFromBlockHash

func NewRPCTransactionFromBlockHash(b *types.Block, hash common.Hash) *RPCTransaction

NewRPCTransactionFromBlockHash returns a transaction that will serialize to the RPC representation.

type ReceiptFilter

type ReceiptFilter struct {
	Off bool
	// TODO: change this so that we filter for receipts first and we always return the corresponding transaction
	MatchTxs     bool     // turn on to retrieve receipts that pair with retrieved transactions
	LogAddresses []string // receipt contains logs from the provided addresses
	Topics       [][]string
}

ReceiptFilter contains filter settings for receipts

type ResponseFilterer

type ResponseFilterer struct{}

ResponseFilterer satisfies the ResponseFilterer interface for ethereum

func NewResponseFilterer

func NewResponseFilterer() *ResponseFilterer

NewResponseFilterer creates a new Filterer satisfying the ResponseFilterer interface

func (*ResponseFilterer) Filter

func (s *ResponseFilterer) Filter(filter SubscriptionSettings, payload eth.ConvertedPayload) (*IPLDs, error)

Filter is used to filter through eth data to extract and package requested data into a Payload

type Retriever

type Retriever interface {
	RetrieveFirstBlockNumber() (int64, error)
	RetrieveLastBlockNumber() (int64, error)
	Retrieve(filter SubscriptionSettings, blockNumber int64) ([]CIDWrapper, bool, error)
}

Retriever interface for substituting mocks in tests

type StateFilter

type StateFilter struct {
	Off               bool
	Addresses         []string // is converted to state key by taking its keccak256 hash
	IntermediateNodes bool
}

StateFilter contains filter settings for state

type StateNode added in v0.3.9

type StateNode struct {
	Type         sdtypes.NodeType
	StateLeafKey common.Hash
	Path         []byte
	IPLD         ipfs.BlockModel
}

type StorageFilter

type StorageFilter struct {
	Off               bool
	Addresses         []string
	StorageKeys       []string // need to be the hashs key themselves not slot position
	IntermediateNodes bool
}

StorageFilter contains filter settings for storage

type StorageNode added in v0.3.9

type StorageNode struct {
	Type           sdtypes.NodeType
	StateLeafKey   common.Hash
	StorageLeafKey common.Hash
	Path           []byte
	IPLD           ipfs.BlockModel
}

type StorageResult added in v0.3.9

type StorageResult struct {
	Key   string       `json:"key"`
	Value *hexutil.Big `json:"value"`
	Proof []string     `json:"proof"`
}

StorageResult for GetProof

type SubscriptionSettings

type SubscriptionSettings struct {
	BackFill      bool
	BackFillOnly  bool
	Start         *big.Int
	End           *big.Int // set to 0 or a negative value to have no ending block
	HeaderFilter  HeaderFilter
	TxFilter      TxFilter
	ReceiptFilter ReceiptFilter
	StateFilter   StateFilter
	StorageFilter StorageFilter
}

SubscriptionSettings config is used by a subscriber to specify what eth data to stream from the watcher

func NewEthSubscriptionConfig

func NewEthSubscriptionConfig() (*SubscriptionSettings, error)

Init is used to initialize a EthSubscription struct with env variables

type TxFilter

type TxFilter struct {
	Off bool
	Src []string
	Dst []string
}

TxFilter contains filter settings for txs

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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