Versions in this module Expand all Collapse all v0 v0.0.2 Oct 1, 2024 v0.0.1 Jun 25, 2024 Changes in this version + const BlockChainVersion + var DefaultCacheConfig = &CacheConfig + var ErrFeeCapTooLow = errors.New("max fee per gas less than block base fee") + var ErrFeeCapVeryHigh = errors.New("max fee per gas higher than 2^256-1") + var ErrGasLimitReached = errors.New("gas limit reached") + var ErrGasUintOverflow = errors.New("gas uint64 overflow") + var ErrInsufficientFunds = errors.New("insufficient funds for gas * price + value") + var ErrInsufficientFundsForTransfer = errors.New("insufficient funds for transfer") + var ErrIntrinsicGas = errors.New("intrinsic gas too low") + var ErrKnownBlock = errors.New("block already known") + var ErrMaxInitCodeSizeExceeded = errors.New("max initcode size exceeded") + var ErrNoGenesis = errors.New("genesis not found in chain") + var ErrNonceMax = errors.New("nonce has max value") + var ErrNonceTooHigh = errors.New("nonce too high") + var ErrNonceTooLow = errors.New("nonce too low") + var ErrRefuseToCorruptArchiver = errors.New(...) + var ErrSenderNoEOA = errors.New("sender not an eoa") + var ErrTipAboveFeeCap = errors.New("max priority fee per gas higher than max fee per gas") + var ErrTipVeryHigh = errors.New("max priority fee per gas higher than 2^256-1") + var ErrTxTypeNotSupported = types.ErrTxTypeNotSupported + var TestCallbacks = dummy.ConsensusCallbacks + func ApplyTransaction(config *params.ChainConfig, bc ChainContext, author *common.Address, ...) (*types.Receipt, error) + func CalcGasLimit(parentGasUsed, parentGasLimit, gasFloor, gasCeil uint64) uint64 + func CanTransfer(db vm.StateDB, addr common.Address, amount *big.Int) bool + func CanTransferMC(db vm.StateDB, addr common.Address, to common.Address, coinID common.Hash, ...) bool + func GenerateChain(config *params.ChainConfig, parent *types.Block, engine consensus.Engine, ...) ([]*types.Block, []types.Receipts, error) + func GenerateChainWithGenesis(genesis *Genesis, engine consensus.Engine, n int, gap uint64, ...) (ethdb.Database, []*types.Block, []types.Receipts, error) + func GenesisBlockForTesting(db ethdb.Database, addr common.Address, balance *big.Int) *types.Block + func GetHashFn(ref *types.Header, chain ChainContext) func(n uint64) common.Hash + func IntrinsicGas(data []byte, accessList types.AccessList, isContractCreation bool, ...) (uint64, error) + func NewDELTABlockContext(header *types.Header, chain ChainContext, author *common.Address) vm.BlockContext + func NewDELTATxContext(msg *Message) vm.TxContext + func ReadBlockByHash(db ethdb.Reader, hash common.Hash) *types.Block + func SetupGenesisBlock(db ethdb.Database, triedb *trie.Database, genesis *Genesis, ...) (*params.ChainConfig, common.Hash, error) + func TestAcceptBlockIdenticalStateRoot(t *testing.T, ...) + func TestAcceptNonCanonicalBlock(t *testing.T, ...) + func TestBuildOnVariousStages(t *testing.T, ...) + func TestEmptyBlocks(t *testing.T, ...) + func TestGenerateChainInvalidBlockFee(t *testing.T, ...) + func TestInsertChainAcceptSingleBlock(t *testing.T, ...) + func TestInsertChainInvalidBlockFee(t *testing.T, ...) + func TestInsertChainValidBlockFee(t *testing.T, ...) + func TestInsertLongForkedChain(t *testing.T, ...) + func TestReorgReInsert(t *testing.T, ...) + func TestReprocessAcceptBlockIdenticalStateRoot(t *testing.T, ...) + func TestSetPreferenceRewind(t *testing.T, ...) + func Transfer(db vm.StateDB, sender, recipient common.Address, amount *big.Int) + func TransferMultiCoin(db vm.StateDB, sender, recipient common.Address, coinID common.Hash, ...) + type BadBlockReason struct + ChainConfig *params.ChainConfig + Error string + Hash common.Hash + Number uint64 + Receipts types.Receipts + func (b *BadBlockReason) String() string + type BlockChain struct + func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis *Genesis, ...) (*BlockChain, error) + func (bc *BlockChain) Accept(block *types.Block) error + func (bc *BlockChain) BadBlocks() ([]*types.Block, []*BadBlockReason) + func (bc *BlockChain) CleanBlockRootsAboveLastAccepted() error + func (bc *BlockChain) Config() *params.ChainConfig + func (bc *BlockChain) CurrentBlock() *types.Header + func (bc *BlockChain) CurrentHeader() *types.Header + func (bc *BlockChain) DrainAcceptorQueue() + func (bc *BlockChain) Engine() consensus.Engine + func (bc *BlockChain) Export(w io.Writer) error + func (bc *BlockChain) ExportCallback(callback func(block *types.Block) error, first uint64, last uint64) error + func (bc *BlockChain) ExportN(w io.Writer, first uint64, last uint64) error + func (bc *BlockChain) GasLimit() uint64 + func (bc *BlockChain) Genesis() *types.Block + func (bc *BlockChain) GetBlock(hash common.Hash, number uint64) *types.Block + func (bc *BlockChain) GetBlockByHash(hash common.Hash) *types.Block + func (bc *BlockChain) GetBlockByNumber(number uint64) *types.Block + func (bc *BlockChain) GetBlocksFromHash(hash common.Hash, n int) (blocks []*types.Block) + func (bc *BlockChain) GetBody(hash common.Hash) *types.Body + func (bc *BlockChain) GetCanonicalHash(number uint64) common.Hash + func (bc *BlockChain) GetHeader(hash common.Hash, number uint64) *types.Header + func (bc *BlockChain) GetHeaderByHash(hash common.Hash) *types.Header + func (bc *BlockChain) GetHeaderByNumber(number uint64) *types.Header + func (bc *BlockChain) GetLogs(hash common.Hash, number uint64) [][]*types.Log + func (bc *BlockChain) GetReceiptsByHash(hash common.Hash) types.Receipts + func (bc *BlockChain) GetTransactionLookup(hash common.Hash) *rawdb.LegacyTxLookupEntry + func (bc *BlockChain) GetVMConfig() *vm.Config + func (bc *BlockChain) HasBlock(hash common.Hash, number uint64) bool + func (bc *BlockChain) HasBlockAndState(hash common.Hash, number uint64) bool + func (bc *BlockChain) HasFastBlock(hash common.Hash, number uint64) bool + func (bc *BlockChain) HasHeader(hash common.Hash, number uint64) bool + func (bc *BlockChain) HasState(hash common.Hash) bool + func (bc *BlockChain) InitializeSnapshots() + func (bc *BlockChain) InsertBlock(block *types.Block) error + func (bc *BlockChain) InsertBlockManual(block *types.Block, writes bool) error + func (bc *BlockChain) InsertChain(chain types.Blocks) (int, error) + func (bc *BlockChain) LastAcceptedBlock() *types.Block + func (bc *BlockChain) LastConsensusAcceptedBlock() *types.Block + func (bc *BlockChain) Processor() Processor + func (bc *BlockChain) Reject(block *types.Block) error + func (bc *BlockChain) RemoveRejectedBlocks(start, end uint64) error + func (bc *BlockChain) ResetToStateSyncedBlock(block *types.Block) error + func (bc *BlockChain) SenderCacher() *TxSenderCacher + func (bc *BlockChain) SetPreference(block *types.Block) error + func (bc *BlockChain) Snapshots() *snapshot.Tree + func (bc *BlockChain) State() (*state.StateDB, error) + func (bc *BlockChain) StateAt(root common.Hash) (*state.StateDB, error) + func (bc *BlockChain) StateCache() state.Database + func (bc *BlockChain) Stop() + func (bc *BlockChain) SubscribeAcceptedLogsEvent(ch chan<- []*types.Log) event.Subscription + func (bc *BlockChain) SubscribeAcceptedTransactionEvent(ch chan<- NewTxsEvent) event.Subscription + func (bc *BlockChain) SubscribeBlockProcessingEvent(ch chan<- bool) event.Subscription + func (bc *BlockChain) SubscribeChainAcceptedEvent(ch chan<- ChainEvent) event.Subscription + func (bc *BlockChain) SubscribeChainEvent(ch chan<- ChainEvent) event.Subscription + func (bc *BlockChain) SubscribeChainHeadEvent(ch chan<- ChainHeadEvent) event.Subscription + func (bc *BlockChain) SubscribeChainSideEvent(ch chan<- ChainSideEvent) event.Subscription + func (bc *BlockChain) SubscribeLogsEvent(ch chan<- []*types.Log) event.Subscription + func (bc *BlockChain) SubscribeRemovedLogsEvent(ch chan<- RemovedLogsEvent) event.Subscription + func (bc *BlockChain) TrieDB() *trie.Database + func (bc *BlockChain) TrieNode(hash common.Hash) ([]byte, error) + func (bc *BlockChain) ValidateCanonicalChain() error + func (bc *BlockChain) Validator() Validator + type BlockGen struct + func (b *BlockGen) AddTx(tx *types.Transaction) + func (b *BlockGen) AddTxWithChain(bc *BlockChain, tx *types.Transaction) + func (b *BlockGen) AddTxWithVMConfig(tx *types.Transaction, config vm.Config) + func (b *BlockGen) AddUncheckedReceipt(receipt *types.Receipt) + func (b *BlockGen) AddUncheckedTx(tx *types.Transaction) + func (b *BlockGen) AddUncle(h *types.Header) + func (b *BlockGen) BaseFee() *big.Int + func (b *BlockGen) GetBalance(addr common.Address) *big.Int + func (b *BlockGen) Number() *big.Int + func (b *BlockGen) OffsetTime(seconds int64) + func (b *BlockGen) PrevBlock(index int) *types.Block + func (b *BlockGen) SetCoinbase(addr common.Address) + func (b *BlockGen) SetDifficulty(diff *big.Int) + func (b *BlockGen) SetExtra(data []byte) + func (b *BlockGen) SetNonce(nonce types.BlockNonce) + func (b *BlockGen) SetOnBlockGenerated(onBlockGenerated func(*types.Block)) + func (b *BlockGen) Timestamp() uint64 + func (b *BlockGen) TxNonce(addr common.Address) uint64 + type BlockValidator struct + func NewBlockValidator(config *params.ChainConfig, blockchain *BlockChain, engine consensus.Engine) *BlockValidator + func (v *BlockValidator) ValidateBody(block *types.Block) error + func (v *BlockValidator) ValidateState(block *types.Block, statedb *state.StateDB, receipts types.Receipts, ...) error + type BloomIndexer struct + func (b *BloomIndexer) Commit() error + func (b *BloomIndexer) Process(ctx context.Context, header *types.Header) error + func (b *BloomIndexer) Prune(threshold uint64) error + func (b *BloomIndexer) Reset(ctx context.Context, section uint64, lastSectionHead common.Hash) error + type BoundedBuffer struct + func NewBoundedBuffer[K any](size int, callback func(K) error) *BoundedBuffer[K] + func (b *BoundedBuffer[K]) Insert(h K) error + func (b *BoundedBuffer[K]) Last() (K, bool) + type BufferFIFOCache struct + func (f *BufferFIFOCache[K, V]) Get(key K) (V, bool) + func (f *BufferFIFOCache[K, V]) Put(key K, val V) + type CacheConfig struct + AcceptedCacheSize int + AcceptorQueueLimit int + AllowMissingTries bool + CommitInterval uint64 + PopulateMissingTries *uint64 + PopulateMissingTriesParallelism int + Preimages bool + Pruning bool + SnapshotDelayInit bool + SnapshotLimit int + SnapshotNoBuild bool + SnapshotVerify bool + SnapshotWait bool + TrieCleanJournal string + TrieCleanLimit int + TrieCleanRejournal time.Duration + TrieDirtyCommitTarget int + TrieDirtyLimit int + TxLookupLimit uint64 + type ChainContext interface + Engine func() consensus.Engine + GetHeader func(common.Hash, uint64) *types.Header + type ChainEvent struct + Block *types.Block + Hash common.Hash + Logs []*types.Log + type ChainHeadEvent struct + Block *types.Block + type ChainIndexer struct + func NewBloomIndexer(db ethdb.Database, size, confirms uint64) *ChainIndexer + func NewChainIndexer(chainDb ethdb.Database, indexDb ethdb.Database, backend ChainIndexerBackend, ...) *ChainIndexer + func (c *ChainIndexer) AddCheckpoint(section uint64, shead common.Hash) + func (c *ChainIndexer) AddChildIndexer(indexer *ChainIndexer) + func (c *ChainIndexer) Close() error + func (c *ChainIndexer) Prune(threshold uint64) error + func (c *ChainIndexer) SectionHead(section uint64) common.Hash + func (c *ChainIndexer) Sections() (uint64, uint64, common.Hash) + func (c *ChainIndexer) Start(chain ChainIndexerChain) + type ChainIndexerBackend interface + Commit func() error + Process func(ctx context.Context, header *types.Header) error + Prune func(threshold uint64) error + Reset func(ctx context.Context, section uint64, prevHead common.Hash) error + type ChainIndexerChain interface + CurrentHeader func() *types.Header + SubscribeChainHeadEvent func(ch chan<- ChainHeadEvent) event.Subscription + type ChainSideEvent struct + Block *types.Block + type ChainTest struct + Name string + type ExecutionResult struct + Err error + ReturnData []byte + UsedGas uint64 + func ApplyMessage(delta *vm.DELTA, msg *Message, gp *GasPool) (*ExecutionResult, error) + func (result *ExecutionResult) Failed() bool + func (result *ExecutionResult) Return() []byte + func (result *ExecutionResult) Revert() []byte + func (result *ExecutionResult) Unwrap() error + type FIFOCache interface + Get func(K) (V, bool) + Put func(K, V) + func NewFIFOCache[K comparable, V any](limit int) FIFOCache[K, V] + type GasPool uint64 + func (gp *GasPool) AddGas(amount uint64) *GasPool + func (gp *GasPool) Gas() uint64 + func (gp *GasPool) SetGas(gas uint64) + func (gp *GasPool) String() string + func (gp *GasPool) SubGas(amount uint64) error + type Genesis struct + Alloc GenesisAlloc + BaseFee *big.Int + Coinbase common.Address + Config *params.ChainConfig + Difficulty *big.Int + ExtraData []byte + GasLimit uint64 + GasUsed uint64 + Mixhash common.Hash + Nonce uint64 + Number uint64 + ParentHash common.Hash + Timestamp uint64 + func (g *Genesis) Commit(db ethdb.Database, triedb *trie.Database) (*types.Block, error) + func (g *Genesis) MustCommit(db ethdb.Database) *types.Block + func (g *Genesis) ToBlock() *types.Block + func (g *Genesis) UnmarshalJSON(input []byte) error + func (g Genesis) MarshalJSON() ([]byte, error) + type GenesisAccount struct + Balance *big.Int + Code []byte + MCBalance GenesisMultiCoinBalance + Nonce uint64 + PrivateKey []byte + Storage map[common.Hash]common.Hash + func (g *GenesisAccount) UnmarshalJSON(input []byte) error + func (g GenesisAccount) MarshalJSON() ([]byte, error) + type GenesisAlloc map[common.Address]GenesisAccount + func (ga *GenesisAlloc) UnmarshalJSON(data []byte) error + type GenesisMismatchError struct + New common.Hash + Stored common.Hash + func (e *GenesisMismatchError) Error() string + type GenesisMultiCoinBalance map[common.Hash]*big.Int + type HeaderChain struct + func NewHeaderChain(chainDb ethdb.Database, config *params.ChainConfig, cacheConfig *CacheConfig, ...) (*HeaderChain, error) + func (hc *HeaderChain) Config() *params.ChainConfig + func (hc *HeaderChain) CurrentHeader() *types.Header + func (hc *HeaderChain) Engine() consensus.Engine + func (hc *HeaderChain) GetBlock(hash common.Hash, number uint64) *types.Block + func (hc *HeaderChain) GetBlockNumber(hash common.Hash) *uint64 + func (hc *HeaderChain) GetCanonicalHash(number uint64) common.Hash + func (hc *HeaderChain) GetHeader(hash common.Hash, number uint64) *types.Header + func (hc *HeaderChain) GetHeaderByHash(hash common.Hash) *types.Header + func (hc *HeaderChain) GetHeaderByNumber(number uint64) *types.Header + func (hc *HeaderChain) HasHeader(hash common.Hash, number uint64) bool + func (hc *HeaderChain) SetCurrentHeader(head *types.Header) + func (hc *HeaderChain) SetGenesis(head *types.Header) + type Message struct + AccessList types.AccessList + Data []byte + From common.Address + GasFeeCap *big.Int + GasLimit uint64 + GasPrice *big.Int + GasTipCap *big.Int + Nonce uint64 + SkipAccountChecks bool + To *common.Address + Value *big.Int + func TransactionToMessage(tx *types.Transaction, s types.Signer, baseFee *big.Int) (*Message, error) + type NewTxPoolHeadEvent struct + Head *types.Header + type NewTxPoolReorgEvent struct + Head *types.Header + type NewTxsEvent struct + Txs []*types.Transaction + type NoOpFIFOCache struct + func (f *NoOpFIFOCache[K, V]) Get(_ K) (V, bool) + func (f *NoOpFIFOCache[K, V]) Put(_ K, _ V) + type Prefetcher interface + Prefetch func(block *types.Block, statedb *state.StateDB, cfg vm.Config, ...) + type Processor interface + Process func(block *types.Block, parent *types.Header, statedb *state.StateDB, ...) (types.Receipts, []*types.Log, uint64, error) + type RemovedLogsEvent struct + Logs []*types.Log + type StateProcessor struct + func NewStateProcessor(config *params.ChainConfig, bc *BlockChain, engine consensus.Engine) *StateProcessor + func (p *StateProcessor) Process(block *types.Block, parent *types.Header, statedb *state.StateDB, ...) (types.Receipts, []*types.Log, uint64, error) + type StateTransition struct + func NewStateTransition(delta *vm.DELTA, msg *Message, gp *GasPool) *StateTransition + func (st *StateTransition) TransitionDb() (*ExecutionResult, error) + type TrieDB interface + Cap func(limit common.StorageSize) error + Commit func(root common.Hash, report bool) error + Dereference func(root common.Hash) error + Size func() (common.StorageSize, common.StorageSize) + type TrieWriter interface + AcceptTrie func(block *types.Block) error + InsertTrie func(block *types.Block) error + RejectTrie func(block *types.Block) error + Shutdown func() error + func NewTrieWriter(db TrieDB, config *CacheConfig) TrieWriter + type TxSenderCacher struct + func NewTxSenderCacher(threads int) *TxSenderCacher + func (cacher *TxSenderCacher) Recover(signer types.Signer, txs []*types.Transaction) + func (cacher *TxSenderCacher) Shutdown() + type Validator interface + ValidateBody func(block *types.Block) error + ValidateState func(block *types.Block, state *state.StateDB, receipts types.Receipts, ...) error