arbitrum

package
v0.0.0-...-b65f49c Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2024 License: GPL-3.0 Imports: 42 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultArchiveNodeMaxRecreateStateDepth    = 30 * 1000 * 1000
	DefaultNonArchiveNodeMaxRecreateStateDepth = 0 // don't recreate state
	UninitializedMaxRecreateStateDepth         = -2
	InfiniteMaxRecreateStateDepth              = -1
)

Variables

View Source
var DefaultConfig = Config{
	RPCGasCap:               ethconfig.Defaults.RPCGasCap,
	RPCTxFeeCap:             ethconfig.Defaults.RPCTxFeeCap,
	TxAllowUnprotected:      true,
	RPCEVMTimeout:           ethconfig.Defaults.RPCEVMTimeout,
	BloomBitsBlocks:         params.BloomBitsBlocks * 4,
	BloomConfirms:           params.BloomConfirms,
	FilterLogCacheSize:      32,
	FilterTimeout:           5 * time.Minute,
	FeeHistoryMaxBlockCount: 1024,
	ClassicRedirect:         "",
	MaxRecreateStateDepth:   UninitializedMaxRecreateStateDepth,
	AllowMethod:             []string{},
	ArbDebug: ArbDebugConfig{
		BlockRangeBound:   256,
		TimeoutQueueBound: 512,
	},
}
View Source
var DefaultRecordingDatabaseConfig = RecordingDatabaseConfig{
	TrieDirtyCache: 1024,
	TrieCleanCache: 16,
}
View Source
var (
	ErrDepthLimitExceeded = errors.New("state recreation l2 gas depth limit exceeded")
)

Functions

func AdvanceStateByBlock

func AdvanceStateByBlock(ctx context.Context, bc *core.BlockChain, state *state.StateDB, targetHeader *types.Header, blockToRecreate uint64, prevBlockHash common.Hash, logFunc StateBuildingLogFunction) (*state.StateDB, *types.Block, error)

func AdvanceStateUpToBlock

func AdvanceStateUpToBlock(ctx context.Context, bc *core.BlockChain, state *state.StateDB, targetHeader *types.Header, lastAvailableHeader *types.Header, logFunc StateBuildingLogFunction) (*state.StateDB, error)

func ConfigAddOptions

func ConfigAddOptions(prefix string, f *flag.FlagSet)

func CreateFallbackClient

func CreateFallbackClient(fallbackClientUrl string, fallbackClientTimeout time.Duration) (types.FallbackClient, error)

func EstimateGas

func EstimateGas(ctx context.Context, b ethapi.Backend, args TransactionArgs, blockNrOrHash rpc.BlockNumberOrHash, overrides *ethapi.StateOverride, gasCap uint64) (hexutil.Uint64, error)

func NewRevertReason

func NewRevertReason(result *core.ExecutionResult) error

func RecordingDatabaseConfigAddOptions

func RecordingDatabaseConfigAddOptions(prefix string, f *flag.FlagSet)

func SendConditionalTransactionRPC

func SendConditionalTransactionRPC(ctx context.Context, rpc *rpc.Client, tx *types.Transaction, options *arbitrum_types.ConditionalOptions) error

func StateAndHeaderFromHeader

func StateAndHeaderFromHeader(ctx context.Context, chainDb ethdb.Database, bc *core.BlockChain, maxRecreateStateDepth int64, header *types.Header, err error) (*state.StateDB, *types.Header, error)

func SubmitConditionalTransaction

func SubmitConditionalTransaction(ctx context.Context, b *APIBackend, tx *types.Transaction, options *arbitrum_types.ConditionalOptions) (common.Hash, error)

Types

type APIBackend

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

func (*APIBackend) AccountManager

func (a *APIBackend) AccountManager() *accounts.Manager

func (*APIBackend) BlockByHash

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

func (*APIBackend) BlockByNumber

func (a *APIBackend) BlockByNumber(ctx context.Context, number rpc.BlockNumber) (*types.Block, error)

func (*APIBackend) BlockByNumberOrHash

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

func (*APIBackend) BlockChain

func (a *APIBackend) BlockChain() *core.BlockChain

func (*APIBackend) BloomStatus

func (a *APIBackend) BloomStatus() (uint64, uint64)

Filter API

func (*APIBackend) ChainConfig

func (a *APIBackend) ChainConfig() *params.ChainConfig

func (*APIBackend) ChainDb

func (a *APIBackend) ChainDb() ethdb.Database

func (*APIBackend) CurrentBlock

func (a *APIBackend) CurrentBlock() *types.Header

func (*APIBackend) CurrentHeader

func (a *APIBackend) CurrentHeader() *types.Header

func (*APIBackend) Engine

func (a *APIBackend) Engine() consensus.Engine

func (*APIBackend) ExtRPCEnabled

func (a *APIBackend) ExtRPCEnabled() bool

func (*APIBackend) FallbackClient

func (b *APIBackend) FallbackClient() types.FallbackClient

func (*APIBackend) FeeHistory

func (a *APIBackend) FeeHistory(
	ctx context.Context,
	blocks uint64,
	newestBlock rpc.BlockNumber,
	rewardPercentiles []float64,
) (*big.Int, [][]*big.Int, []*big.Int, []float64, error)

func (*APIBackend) GetAPIs

func (a *APIBackend) GetAPIs(filterSystem *filters.FilterSystem) []rpc.API

func (*APIBackend) GetArbitrumNode

func (a *APIBackend) GetArbitrumNode() interface{}

func (*APIBackend) GetBody

func (a *APIBackend) GetBody(ctx context.Context, hash common.Hash, number rpc.BlockNumber) (*types.Body, error)

func (*APIBackend) GetEVM

func (a *APIBackend) GetEVM(ctx context.Context, msg *core.Message, state *state.StateDB, header *types.Header, vmConfig *vm.Config, blockCtx *vm.BlockContext) *vm.EVM

func (*APIBackend) GetLogs

func (a *APIBackend) GetLogs(ctx context.Context, hash common.Hash, number uint64) ([][]*types.Log, error)

func (*APIBackend) GetPoolNonce

func (a *APIBackend) GetPoolNonce(ctx context.Context, addr common.Address) (uint64, error)

func (*APIBackend) GetPoolTransaction

func (a *APIBackend) GetPoolTransaction(txHash common.Hash) *types.Transaction

func (*APIBackend) GetPoolTransactions

func (a *APIBackend) GetPoolTransactions() (types.Transactions, error)

func (*APIBackend) GetReceipts

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

func (*APIBackend) GetTd

func (a *APIBackend) GetTd(ctx context.Context, hash common.Hash) *big.Int

func (*APIBackend) GetTransaction

func (a *APIBackend) GetTransaction(ctx context.Context, txHash common.Hash) (bool, *types.Transaction, common.Hash, uint64, uint64, error)

func (*APIBackend) HeaderByHash

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

func (*APIBackend) HeaderByNumber

func (a *APIBackend) HeaderByNumber(ctx context.Context, number rpc.BlockNumber) (*types.Header, error)

func (*APIBackend) HeaderByNumberOrHash

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

func (*APIBackend) PendingBlockAndReceipts

func (b *APIBackend) PendingBlockAndReceipts() (*types.Block, types.Receipts)

func (*APIBackend) RPCEVMTimeout

func (a *APIBackend) RPCEVMTimeout() time.Duration

func (*APIBackend) RPCGasCap

func (a *APIBackend) RPCGasCap() uint64

func (*APIBackend) RPCTxFeeCap

func (a *APIBackend) RPCTxFeeCap() float64

func (*APIBackend) SendConditionalTx

func (a *APIBackend) SendConditionalTx(ctx context.Context, signedTx *types.Transaction, options *arbitrum_types.ConditionalOptions) error

func (*APIBackend) SendTx

func (a *APIBackend) SendTx(ctx context.Context, signedTx *types.Transaction) error

Transaction pool API

func (*APIBackend) ServiceFilter

func (a *APIBackend) ServiceFilter(ctx context.Context, session *bloombits.MatcherSession)

func (*APIBackend) SetHead

func (a *APIBackend) SetHead(number uint64)

Blockchain API

func (*APIBackend) SetSyncBackend

func (a *APIBackend) SetSyncBackend(sync SyncProgressBackend) error

func (*APIBackend) StateAndHeaderByNumber

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

func (*APIBackend) StateAndHeaderByNumberOrHash

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

func (*APIBackend) StateAtBlock

func (a *APIBackend) StateAtBlock(ctx context.Context, block *types.Block, reexec uint64, base *state.StateDB, checkLive bool, preferDisk bool) (statedb *state.StateDB, release tracers.StateReleaseFunc, err error)

func (*APIBackend) StateAtTransaction

func (a *APIBackend) StateAtTransaction(ctx context.Context, block *types.Block, txIndex int, reexec uint64) (*core.Message, vm.BlockContext, *state.StateDB, tracers.StateReleaseFunc, error)

func (*APIBackend) Stats

func (a *APIBackend) Stats() (pending int, queued int)

func (*APIBackend) SubscribeChainEvent

func (a *APIBackend) SubscribeChainEvent(ch chan<- core.ChainEvent) event.Subscription

func (*APIBackend) SubscribeChainHeadEvent

func (a *APIBackend) SubscribeChainHeadEvent(ch chan<- core.ChainHeadEvent) event.Subscription

func (*APIBackend) SubscribeChainSideEvent

func (a *APIBackend) SubscribeChainSideEvent(ch chan<- core.ChainSideEvent) event.Subscription

func (*APIBackend) SubscribeLogsEvent

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

func (*APIBackend) SubscribeNewTxsEvent

func (a *APIBackend) SubscribeNewTxsEvent(ch chan<- core.NewTxsEvent) event.Subscription

func (*APIBackend) SubscribePendingLogsEvent

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

func (*APIBackend) SubscribeRemovedLogsEvent

func (a *APIBackend) SubscribeRemovedLogsEvent(ch chan<- core.RemovedLogsEvent) event.Subscription

func (*APIBackend) SuggestGasTipCap

func (a *APIBackend) SuggestGasTipCap(ctx context.Context) (*big.Int, error)

func (*APIBackend) SyncProgress

func (a *APIBackend) SyncProgress() ethereum.SyncProgress

func (*APIBackend) SyncProgressMap

func (a *APIBackend) SyncProgressMap() map[string]interface{}

General Ethereum API

func (*APIBackend) TxPoolContent

func (a *APIBackend) TxPoolContent() (map[common.Address][]*types.Transaction, map[common.Address][]*types.Transaction)

func (*APIBackend) TxPoolContentFrom

func (a *APIBackend) TxPoolContentFrom(addr common.Address) ([]*types.Transaction, []*types.Transaction)

func (*APIBackend) UnprotectedAllowed

func (a *APIBackend) UnprotectedAllowed() bool

type ArbDebugConfig

type ArbDebugConfig struct {
	BlockRangeBound   uint64 `koanf:"block-range-bound"`
	TimeoutQueueBound uint64 `koanf:"timeout-queue-bound"`
}

type ArbInterface

type ArbInterface interface {
	PublishTransaction(ctx context.Context, tx *types.Transaction, options *arbitrum_types.ConditionalOptions) error
	BlockChain() *core.BlockChain
	ArbNode() interface{}
}

type ArbTransactionAPI

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

func NewArbTransactionAPI

func NewArbTransactionAPI(b *APIBackend) *ArbTransactionAPI

func (*ArbTransactionAPI) SendRawTransactionConditional

func (s *ArbTransactionAPI) SendRawTransactionConditional(ctx context.Context, input hexutil.Bytes, options *arbitrum_types.ConditionalOptions) (common.Hash, error)

type Backend

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

func NewBackend

func NewBackend(stack *node.Node, config *Config, chainDb ethdb.Database, publisher ArbInterface, filterConfig filters.Config) (*Backend, *filters.FilterSystem, error)

func (*Backend) APIBackend

func (b *Backend) APIBackend() *APIBackend

func (*Backend) APIs

func (b *Backend) APIs() []rpc.API

func (*Backend) AccountManager

func (b *Backend) AccountManager() *accounts.Manager

func (*Backend) ArbInterface

func (b *Backend) ArbInterface() ArbInterface

func (*Backend) BlockChain

func (b *Backend) BlockChain() *core.BlockChain

func (*Backend) BloomIndexer

func (b *Backend) BloomIndexer() *core.ChainIndexer

func (*Backend) ChainDb

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

func (*Backend) Engine

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

func (*Backend) EnqueueL2Message

func (b *Backend) EnqueueL2Message(ctx context.Context, tx *types.Transaction, options *arbitrum_types.ConditionalOptions) error

func (*Backend) ResetWithGenesisBlock

func (b *Backend) ResetWithGenesisBlock(gb *types.Block)

func (*Backend) Stack

func (b *Backend) Stack() *node.Node

func (*Backend) Start

func (b *Backend) Start() error

TODO: this is used when registering backend as lifecycle in stack

func (*Backend) Stop

func (b *Backend) Stop() error

func (*Backend) SubscribeNewTxsEvent

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

type Config

type Config struct {
	// RPCGasCap is the global gas cap for eth-call variants.
	RPCGasCap uint64 `koanf:"gas-cap"`

	// RPCTxFeeCap is the global transaction fee(price * gaslimit) cap for
	// send-transction variants. The unit is ether.
	RPCTxFeeCap float64 `koanf:"tx-fee-cap"`

	TxAllowUnprotected bool `koanf:"tx-allow-unprotected"`

	// RPCEVMTimeout is the global timeout for eth-call.
	RPCEVMTimeout time.Duration `koanf:"evm-timeout"`

	// Parameters for the bloom indexer
	BloomBitsBlocks uint64 `koanf:"bloom-bits-blocks"`
	BloomConfirms   uint64 `koanf:"bloom-confirms"`

	// Parameters for the filter system
	FilterLogCacheSize int           `koanf:"filter-log-cache-size"`
	FilterTimeout      time.Duration `koanf:"filter-timeout"`

	// FeeHistoryMaxBlockCount limits the number of historical blocks a fee history request may cover
	FeeHistoryMaxBlockCount uint64 `koanf:"feehistory-max-block-count"`

	ArbDebug ArbDebugConfig `koanf:"arbdebug"`

	ClassicRedirect        string        `koanf:"classic-redirect"`
	ClassicRedirectTimeout time.Duration `koanf:"classic-redirect-timeout"`
	MaxRecreateStateDepth  int64         `koanf:"max-recreate-state-depth"`

	AllowMethod []string `koanf:"allow-method"`
}

type PublicNetAPI

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

PublicNetAPI offers network related RPC methods

func NewPublicNetAPI

func NewPublicNetAPI(networkVersion uint64) *PublicNetAPI

NewPublicNetAPI creates a new net API instance.

func (*PublicNetAPI) Version

func (s *PublicNetAPI) Version() string

Version returns the current ethereum protocol version.

type PublicTxPoolAPI

type PublicTxPoolAPI struct{}

PublicNetAPI offers network related RPC methods

func NewPublicTxPoolAPI

func NewPublicTxPoolAPI() *PublicTxPoolAPI

NewPublicNetAPI creates a new net API instance.

func (*PublicTxPoolAPI) Content

func (s *PublicTxPoolAPI) Content() map[string]map[string]map[string]*struct{}

Version returns the current ethereum protocol version.

type RecordingChainContext

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

func (*RecordingChainContext) Engine

func (*RecordingChainContext) GetHeader

func (r *RecordingChainContext) GetHeader(hash common.Hash, num uint64) *types.Header

func (*RecordingChainContext) GetMinBlockNumberAccessed

func (r *RecordingChainContext) GetMinBlockNumberAccessed() uint64

type RecordingDatabase

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

func NewRecordingDatabase

func NewRecordingDatabase(config *RecordingDatabaseConfig, ethdb ethdb.Database, blockchain *core.BlockChain) *RecordingDatabase

func (*RecordingDatabase) Dereference

func (r *RecordingDatabase) Dereference(header *types.Header)

func (*RecordingDatabase) GetOrRecreateState

func (r *RecordingDatabase) GetOrRecreateState(ctx context.Context, header *types.Header, logFunc StateBuildingLogFunction) (*state.StateDB, error)

func (*RecordingDatabase) PreimagesFromRecording

func (r *RecordingDatabase) PreimagesFromRecording(chainContextIf core.ChainContext, recordingDb *RecordingKV) (map[common.Hash][]byte, error)

func (*RecordingDatabase) PrepareRecording

func (r *RecordingDatabase) PrepareRecording(ctx context.Context, lastBlockHeader *types.Header, logFunc StateBuildingLogFunction) (*state.StateDB, core.ChainContext, *RecordingKV, error)

func (*RecordingDatabase) ReferenceCount

func (r *RecordingDatabase) ReferenceCount() int64

func (*RecordingDatabase) StateFor

func (r *RecordingDatabase) StateFor(header *types.Header) (*state.StateDB, error)

Normal geth state.New + Reference is not atomic vs Dereference. This one is. This function does not recreate a state

func (*RecordingDatabase) WriteStateToDatabase

func (r *RecordingDatabase) WriteStateToDatabase(header *types.Header) error

type RecordingDatabaseConfig

type RecordingDatabaseConfig struct {
	TrieDirtyCache int `koanf:"trie-dirty-cache"`
	TrieCleanCache int `koanf:"trie-clean-cache"`
}

type RecordingKV

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

func (*RecordingKV) Close

func (db *RecordingKV) Close() error

func (*RecordingKV) Compact

func (db *RecordingKV) Compact(start []byte, limit []byte) error

func (*RecordingKV) Delete

func (db *RecordingKV) Delete(key []byte) error

func (*RecordingKV) EnableBypass

func (db *RecordingKV) EnableBypass()

func (*RecordingKV) Get

func (db *RecordingKV) Get(key []byte) ([]byte, error)

func (*RecordingKV) GetRecordedEntries

func (db *RecordingKV) GetRecordedEntries() map[common.Hash][]byte

func (*RecordingKV) Has

func (db *RecordingKV) Has(key []byte) (bool, error)

func (*RecordingKV) NewBatch

func (db *RecordingKV) NewBatch() ethdb.Batch

func (*RecordingKV) NewBatchWithSize

func (db *RecordingKV) NewBatchWithSize(size int) ethdb.Batch

func (*RecordingKV) NewIterator

func (db *RecordingKV) NewIterator(prefix []byte, start []byte) ethdb.Iterator

func (*RecordingKV) NewSnapshot

func (db *RecordingKV) NewSnapshot() (ethdb.Snapshot, error)

func (*RecordingKV) Put

func (db *RecordingKV) Put(key []byte, value []byte) error

func (*RecordingKV) Release

func (db *RecordingKV) Release()

func (*RecordingKV) Stat

func (db *RecordingKV) Stat(property string) (string, error)

type StateBuildingLogFunction

type StateBuildingLogFunction func(targetHeader, header *types.Header, hasState bool)

type StateForHeaderFunction

type StateForHeaderFunction func(header *types.Header) (*state.StateDB, StateReleaseFunc, error)

type StateReleaseFunc

type StateReleaseFunc tracers.StateReleaseFunc
var NoopStateRelease StateReleaseFunc = func() {}

func FindLastAvailableState

func FindLastAvailableState(ctx context.Context, bc *core.BlockChain, stateFor StateForHeaderFunction, targetHeader *types.Header, logFunc StateBuildingLogFunction, maxDepthInL2Gas int64) (*state.StateDB, *types.Header, StateReleaseFunc, error)

finds last available state and header checking it first for targetHeader then looking backwards if maxDepthInL2Gas is positive, it constitutes a limit for cumulative l2 gas used of the traversed blocks else if maxDepthInL2Gas is -1, the traversal depth is not limited otherwise only targetHeader state is checked and no search is performed

type SyncProgressBackend

type SyncProgressBackend interface {
	SyncProgressMap() map[string]interface{}
	SafeBlockNumber(ctx context.Context) (uint64, error)
	FinalizedBlockNumber(ctx context.Context) (uint64, error)
}

type TransactionArgs

type TransactionArgs = ethapi.TransactionArgs

Jump to

Keyboard shortcuts

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