Documentation ¶
Overview ¶
Package core implements the Ethereum consensus protocol.
Index ¶
- Constants
- Variables
- func ApplyMessage(evm *vm.EVM, msg Message, gp *GasPool) ([]byte, uint64, bool, error)
- func ApplyTransaction(config *params.ChainConfig, bc ChainContext, author *common.Address, ...) (*types.Receipt, error)
- func CalcGasLimit(parent *types.Block, gasFloor, gasCeil uint64) uint64
- func CanTransfer(db vm.StateDB, addr common.Address, amount *big.Int) bool
- func GenerateChain(config *params.ChainConfig, parent *types.Block, engine consensus.Engine, ...) ([]*types.Block, []types.Receipts)
- 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, contractCreation, isEIP2028 bool) (uint64, error)
- func NewEVMContext(msg Message, header *types.Header, chain ChainContext, author *common.Address) vm.Context
- func NewExecutor(chainConfig *params.ChainConfig, chainContext ChainContext, vmCfg vm.Config)
- func SetupGenesisBlock(db ethdb.Database, genesis *Genesis) (*params.ChainConfig, common.Hash, error)
- func SetupGenesisBlockWithOverride(db ethdb.Database, genesis *Genesis, overrideSingularity *big.Int) (*params.ChainConfig, common.Hash, error)
- func Transfer(db vm.StateDB, sender, recipient common.Address, amount *big.Int)
- type BlockChain
- func (bc *BlockChain) BadBlocks() []*types.Block
- func (bc *BlockChain) Config() *params.ChainConfig
- func (bc *BlockChain) CurrentBlock() *types.Block
- func (bc *BlockChain) CurrentFastBlock() *types.Block
- func (bc *BlockChain) CurrentHeader() *types.Header
- func (bc *BlockChain) Engine() consensus.Engine
- func (bc *BlockChain) Export(w io.Writer) error
- func (bc *BlockChain) ExportN(w io.Writer, first uint64, last uint64) error
- func (bc *BlockChain) FastSyncCommitHead(hash common.Hash) error
- func (bc *BlockChain) GasLimit() uint64
- func (bc *BlockChain) Genesis() *types.Block
- func (bc *BlockChain) GetAccessControl() access_contoller.AccessControlProvider
- func (bc *BlockChain) GetAncestor(hash common.Hash, number, ancestor uint64, maxNonCanonical *uint64) (common.Hash, uint64)
- 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) GetBlockHashesFromHash(hash common.Hash, max uint64) []common.Hash
- func (bc *BlockChain) GetBlocksFromHash(hash common.Hash, n int) (blocks []*types.Block)
- func (bc *BlockChain) GetBody(hash common.Hash) *types.Body
- func (bc *BlockChain) GetBodyRLP(hash common.Hash) rlp.RawValue
- func (bc *BlockChain) GetCanonicalHash(number uint64) common.Hash
- func (bc *BlockChain) GetCommittedSeals(hash common.Hash) (uint64, types.ByzantineSeals)
- 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) GetReceiptsByHash(hash common.Hash) types.Receipts
- func (bc *BlockChain) GetTd(hash common.Hash, number uint64) *big.Int
- func (bc *BlockChain) GetTdByHash(hash common.Hash) *big.Int
- func (bc *BlockChain) GetTransactionLookup(hash common.Hash) *rawdb.LegacyTxLookupEntry
- func (bc *BlockChain) GetTransactions(number uint64) types.Transactions
- func (bc *BlockChain) GetUnclesInChain(block *types.Block, length int) []*types.Header
- func (bc *BlockChain) GetVMConfig() *vm.Config
- func (bc *BlockChain) HasBadBlock(hash common.Hash) bool
- 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) InsertChain(chain types.Blocks) (int, error)
- func (bc *BlockChain) InsertHeaderChain(chain []*types.Header, checkFreq int) (int, error)
- func (bc *BlockChain) InsertReceiptChain(blockChain types.Blocks, receiptChain []types.Receipts, ancientLimit uint64) (int, error)
- func (bc *BlockChain) Processor() Processor
- func (bc *BlockChain) Reset() error
- func (bc *BlockChain) ResetWithGenesisBlock(genesis *types.Block) error
- func (bc *BlockChain) Rollback(chain []common.Hash)
- func (bc *BlockChain) SetHead(head uint64) error
- 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) SubscribeBlockProcessingEvent(ch chan<- bool) 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) TrieNode(hash common.Hash) ([]byte, error)
- func (bc *BlockChain) Validator() Validator
- func (bc *BlockChain) WriteBlockWithState(block *types.Block, receipts []*types.Receipt, logs []*types.Log, ...) (status WriteStatus, err error)
- type BlockChainCache
- func (bcc *BlockChainCache) CommitBlock(block *types.Block)
- func (bcc *BlockChainCache) Execute(block *types.Block) (*types.Block, error)
- func (bcc *BlockChainCache) GetPendingBlock(hash common.Hash) *types.Block
- func (bcc *BlockChainCache) ReadBlock(sealHash common.Hash) *types.Block
- func (bcc *BlockChainCache) ReadReceipts(sealHash common.Hash) (uint64, []*types.Receipt)
- func (bcc *BlockChainCache) ReadStateDB(sealHash common.Hash) *state.StateDB
- func (bcc *BlockChainCache) StateDBString() string
- func (bcc *BlockChainCache) WriteBlock(block *types.Block) error
- func (bcc *BlockChainCache) WriteReceipts(sealHash common.Hash, usedGas uint64, receipts []*types.Receipt, ...)
- func (bcc *BlockChainCache) WriteSealBlock(sealHash common.Hash, block *types.Block)
- func (bcc *BlockChainCache) WriteStateDB(sealHash common.Hash, stateDB *state.StateDB, blockNum uint64)
- type BlockGen
- func (b *BlockGen) AddTx(tx *types.Transaction)
- func (b *BlockGen) AddTxWithChain(bc *BlockChain, tx *types.Transaction)
- func (b *BlockGen) AddUncheckedReceipt(receipt *types.Receipt)
- func (b *BlockGen) AddUncheckedTx(tx *types.Transaction)
- func (b *BlockGen) AddUncle(h *types.Header)
- 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) TxNonce(addr common.Address) uint64
- type BlockValidator
- type CacheConfig
- type ChainContext
- type ChainEvent
- type ChainHeadEvent
- type ChainIndexer
- func (c *ChainIndexer) AddCheckpoint(section uint64, shead common.Hash)
- func (c *ChainIndexer) AddChildIndexer(indexer *ChainIndexer)
- func (c *ChainIndexer) Close() 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
- type ChainIndexerChain
- type ChainSideEvent
- type DeleteBlockContentCallback
- type Executor
- type GasPool
- type Genesis
- type GenesisAccount
- type GenesisAlloc
- type GenesisMismatchError
- type HeaderChain
- func (hc *HeaderChain) Config() *params.ChainConfig
- func (hc *HeaderChain) CurrentHeader() *types.Header
- func (hc *HeaderChain) Engine() consensus.Engine
- func (hc *HeaderChain) GetAncestor(hash common.Hash, number, ancestor uint64, maxNonCanonical *uint64) (common.Hash, uint64)
- func (hc *HeaderChain) GetBlock(hash common.Hash, number uint64) *types.Block
- func (hc *HeaderChain) GetBlockHashesFromHash(hash common.Hash, max uint64) []common.Hash
- 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) GetTd(hash common.Hash, number uint64) *big.Int
- func (hc *HeaderChain) GetTdByHash(hash common.Hash) *big.Int
- func (hc *HeaderChain) HasHeader(hash common.Hash, number uint64) bool
- func (hc *HeaderChain) InsertHeaderChain(chain []*types.Header, writeHeader WhCallback, start time.Time) (int, error)
- func (hc *HeaderChain) SetCurrentHeader(head *types.Header)
- func (hc *HeaderChain) SetGenesis(head *types.Header)
- func (hc *HeaderChain) SetHead(head uint64, updateFn UpdateHeadBlocksCallback, ...)
- func (hc *HeaderChain) ValidateHeaderChain(chain []*types.Header, checkFreq int) (int, error)
- func (hc *HeaderChain) WriteHeader(header *types.Header) (status WriteStatus, err error)
- func (hc *HeaderChain) WriteTd(hash common.Hash, number uint64, td *big.Int) error
- type Message
- type NewMinedBlockEvent
- type NewTxsEvent
- type ParallelContext
- func (ctx *ParallelContext) AddGasPool(amount uint64)
- func (ctx *ParallelContext) AddPackedTx(tx *types.Transaction)
- func (ctx *ParallelContext) AddReceipt(receipt *types.Receipt)
- func (ctx *ParallelContext) CumulateBlockGasUsed(txGasUsed uint64)
- func (ctx *ParallelContext) GetBlockGasUsed() uint64
- func (ctx *ParallelContext) GetBlockGasUsedHolder() *uint64
- func (ctx *ParallelContext) GetBlockHash() common.Hash
- func (ctx *ParallelContext) GetGasPool() *GasPool
- func (ctx *ParallelContext) GetHeader() *types.Header
- func (ctx *ParallelContext) GetLogs() []*types.Log
- func (ctx *ParallelContext) GetPackedTxList() []*types.Transaction
- func (ctx *ParallelContext) GetReceipts() types.Receipts
- func (ctx *ParallelContext) GetResults() []*Result
- func (ctx *ParallelContext) GetState() *state.StateDB
- func (ctx *ParallelContext) GetTx(idx int) *types.Transaction
- func (ctx *ParallelContext) GetTxList() []*types.Transaction
- func (ctx *ParallelContext) SetBlockGasUsedHolder(blockGasUsedHolder *uint64)
- func (ctx *ParallelContext) SetResult(idx int, result *Result)
- func (ctx *ParallelContext) SetTxList(txs []*types.Transaction)
- type ParallelStateProcessor
- type PendingLogsEvent
- type Prefetcher
- type Processor
- type RemovedLogsEvent
- type Result
- type StateProcessor
- type StateTransition
- type TaskArgs
- type TxDag
- type TxPool
- func (pool *TxPool) AddLocal(tx *types.Transaction) error
- func (pool *TxPool) AddLocals(txs []*types.Transaction) []error
- func (pool *TxPool) AddRemote(tx *types.Transaction) errordeprecated
- func (pool *TxPool) AddRemoteSync(tx *types.Transaction) error
- func (pool *TxPool) AddRemotes(txs []*types.Transaction) []error
- func (pool *TxPool) AddRemotesSync(txs []*types.Transaction) []error
- func (pool *TxPool) CheckAndSetSender(blocks types.Blocks) (err error)
- func (pool *TxPool) Content() (map[common.Address]types.Transactions, map[common.Address]types.Transactions)
- func (pool *TxPool) GasPrice() *big.Int
- func (pool *TxPool) Get(hash common.Hash) *types.Transaction
- func (pool *TxPool) InitLightBlock(pb *types.LightBlock) bool
- func (pool *TxPool) Locals() []common.Address
- func (pool *TxPool) Nonce(addr common.Address) uint64
- func (pool *TxPool) Pending() (map[common.Address]types.Transactions, error)
- func (pool *TxPool) RemoveTx(hashs []common.Hash, outofbound bool)
- func (pool *TxPool) SetGasPrice(price *big.Int)
- func (pool *TxPool) Signer() types.Signer
- func (pool *TxPool) Stats() (int, int)
- func (pool *TxPool) Status(hashes []common.Hash) []TxStatus
- func (pool *TxPool) Stop()
- func (pool *TxPool) SubscribeNewTxsEvent(ch chan<- NewTxsEvent) event.Subscription
- func (pool *TxPool) SubscribeSyncTxsEvent(chan<- NewTxsEvent) event.Subscription
- func (pool *TxPool) SyncLimit(int) types.Transactions
- type TxPoolConfig
- type TxStatus
- type UpdateHeadBlocksCallback
- type Validator
- type WhCallback
- type WriteStatus
Examples ¶
Constants ¶
const ( TriesInMemory = 128 // BlockChainVersion ensures that an incompatible database forces a resync from scratch. // // Changelog: // // - Version 4 // The following incompatible database changes were added: // * the `BlockNumber`, `TxHash`, `TxIndex`, `BlockHash` and `Index` fields of log are deleted // * the `Bloom` field of receipt is deleted // * the `BlockIndex` and `TxIndex` fields of txlookup are deleted // - Version 5 // The following incompatible database changes were added: // * the `TxHash`, `GasCost`, and `ContractAddress` fields are no longer stored for a receipt // * the `TxHash`, `GasCost`, and `ContractAddress` fields are computed by looking up the // receipts' corresponding block // - Version 6 // The following incompatible database changes were added: // * Transaction lookup information stores the corresponding block number instead of block hash // - Version 7 // The following incompatible database changes were added: // * Use freezer as the ancient database to maintain all ancient data BlockChainVersion uint64 = 7 )
const SipeGenesisBlockExtraData = "0x" +
"54686520666972737420626c6f636b636861696e20617474657374617469" +
"6f6e2061636b6e6f776c656467656420627920636f7572743a0a32382f30" +
"362f3230313820e69dade5b79ee4ba92e88194e7bd91e6b395e999a2e987" +
"87e7bab3e4ba86e59fbae4ba8ee4bf9de585a8e7bd9142616f5175616e2e" +
"636f6de5ad98e582a8e79a84e585b3e994aee794b5e5ad90e8af81e68dae" +
"e5b9b6e5819ae587bae58fb8e6b395e588a4e4be8befbc8ce58cbae59d97" +
"e993bee794b5e5ad90e5ad98e8af81e79a84e6b395e5be8be69588e58a9b" +
"e9a696e6aca1e88eb7e5be97e689bfe8aea4efbc8ce5ae83e6a087e5bf97" +
"e79d80e58cbae59d97e993bee68a80e69cafe4b88ee4babae7b1bbe78eb0" +
"e8a18ce7a4bee4bc9ae8a784e58899e79a84e89e8de59088efbc8ce4b8ba" +
"e4bbb7e580bce4ba92e993bee7bd91e79a84e69e84e5bbbae5a5a0e5ae9a" +
"e4ba86e6a0b9e59fbae380820a32382f30362f323031382048616e677a68" +
"6f7520496e7465726e657420436f757274206d6164652074686520666972" +
"73742073656e74656e6365206261736564206f6e2074686520656c656374" +
"726f6e696320646174612065766964656e63652066726f6d2042616f5175" +
"616e2e636f6d2e2054686520626c6f636b636861696e2061747465737461" +
"74696f6e207468657265666f726520686173206265656e2061636b6e6f77" +
"6c6564676564206279206a7564696369616c2073797374656d20666f7220" +
"7468652066697273742074696d6520616e64206d65616e696e6766756c6c" +
"792073796d626f6c6973656420746865206d657267696e67206f6620626c" +
"6f636b636861696e20746563686e6f6c6f677920616e642063757272656e" +
"742068756d616e20736f63696574792072756c65732e204974206c616964" +
"2074686520666f756e646174696f6e20666f7220636f6e73747275637469" +
"6e672074686520696e7465726e6574206f662076616c75652e0a0a546865" +
"206f726967696e616c20466f756e646174696f6e20436f756e63696c3a0a" +
"48616e73656e2047616f2c204c656f2059752c20436861647769636b204c" +
"65652c205a68616f6c696e205969702c204b727a79737a746f6620506965" +
"63680a546865206f726967696e616c20546563686e6963616c2053746565" +
"72696e6720436f6d6d69747465653a204d6f726f205a68616e672c204a65" +
"616e205a68616e670a0a546865204e65777320686561646c696e65206f66" +
"20746865206461793a0a5554432b382030332f30312f323031392031303a" +
"3236414d204368616e6727652034206d616b657320776f726c642d666972" +
"7374206c616e64696e67206f6e206d6f6f6e27732066617220736964650a" +
"4c756e617220496d70616374204372617465723a20566f6e204bc3a1726d" +
"c3a16e0a436f6f7264696e617465733a2034352e35c2b053203137372e36" +
"c2b0450a46697273742070686f746f206f6620746865206d6f6f6e277320" +
"66617220736964653a0a646174613a696d6167652f6a7065673b62617365" +
"36342c2f396a2f34514159525868705a67414153556b7141416741414141" +
"41414141414141414141502f734142464564574e72655141424141514141" +
"41414b4141442f34514e746148523063446f764c32357a4c6d466b62324a" +
"6c4c6d4e7662533934595841764d5334774c7741385033687759574e725a" +
"585167596d566e6157343949752b377679496761575139496c6331545442" +
"4e63454e6c61476c49656e4a6c5533704f56474e3661324d355a43492f50" +
"69413865447034625842745a585268494868746247357a4f6e6739496d46" +
"6b62324a6c4f6d357a4f6d316c64474576496942344f6e68746348527250" +
"534a425a4739695a53425954564167513239795a5341314c6a5974597a45" +
"304e5341334f5334784e6a4d304f546b73494449774d5467764d4467764d" +
"544d744d5459364e4441364d6a496749434167494341674943492b494478" +
"795a475936556b5247494868746247357a4f6e4a6b5a6a30696148523063" +
"446f764c336433647935334d793576636d63764d546b354f5338774d6938" +
"794d6931795a47597463336c75644746344c57357a4979492b494478795a" +
"4759365247567a59334a706348527062323467636d526d4f6d4669623356" +
"3050534969494868746247357a4f6e68746345314e50534a6f644852774f" +
"693876626e4d7559575276596d5575593239744c336868634338784c6a41" +
"76625730764969423462577875637a707a64464a6c5a6a30696148523063" +
"446f764c32357a4c6d466b62324a6c4c6d4e7662533934595841764d5334" +
"774c334e556558426c4c314a6c63323931636d4e6c556d566d4979496765" +
"473173626e4d366547317750534a6f644852774f693876626e4d75595752" +
"76596d5575593239744c336868634338784c6a4176496942346258424e54" +
"547050636d6c6e6157356862455276593356745a57353053555139496e68" +
"746343356b615751364d6a45784e6a593251555977526a424752546b784d" +
"5546464f4467354d5451314d7a49784d444d334f44596949486874634531" +
"4e4f6b5276593356745a57353053555139496e68746343356b6157513651" +
"55593552544a44526b45774e7a677a4d5446464f54677751304d354e4559" +
"794e6b55774d7a51774e454969494868746345314e4f6b6c756333526862" +
"6d4e6c53555139496e687463433570615751365155593552544a44526a6b" +
"774e7a677a4d5446464f54677751304d354e4559794e6b55774d7a51774e" +
"4549694948687463447044636d5668644739795647397662443069515752" +
"76596d5567554768766447397a6147397749454e544e5342586157356b62" +
"33647a496a3467504868746345314e4f6b526c636d6c325a575247636d39" +
"7449484e30556d566d4f6d6c7563335268626d4e6c53555139496e687463" +
"433570615751364d6a63784e6a593251555977526a424752546b784d5546" +
"464f4467354d5451314d7a49784d444d334f44596949484e30556d566d4f" +
"6d5276593356745a57353053555139496e68746343356b615751364d6a45" +
"784e6a593251555977526a424752546b784d5546464f4467354d5451314d" +
"7a49784d444d334f4459694c7a3467504339795a4759365247567a59334a" +
"70634852706232342b49447776636d526d4f6c4a45526a3467504339344f" +
"6e68746347316c6447452b4944772f654842685932746c6443426c626d51" +
"39496e4969507a372f3767414f51575276596d55415a4d4141414141422f" +
"397341684141554542415a45686b6e4678636e4d6959664a6a49754a6959" +
"6d4a69342b4e5455314e54552b5245464251554642515552455245524552" +
"455245524552455245524552455245524552455245524552455245524552" +
"454152555a4753416349435959474359324a69416d4e6b51324b79733252" +
"455245516a56435245524552455245524552455245524552455245524552" +
"455245524552455245524552455245524552455245524552455245542f77" +
"41415243414541415141444153494141684542417845422f385141686741" +
"414177454241514541414141414141414141414141414149444151514642" +
"674542415145424141414141414141414141414141414141514143417841" +
"4141514d4441674d46425167414241634141414141415141524169457841" +
"3045535557454563594569457758776b6147783063486838544a43556851" +
"565970496a4d344b6930754a445577595241514542415145414167494441" +
"41414141414141414141424552494349544642555a4643412f2f61414177" +
"444151414345514d52414438412b4d5168436b374f6b776562444b663278" +
"2b2f37467978494677363976306e4732467a2b6f6e33572b7138584a4134" +
"356d42754352376c30396563382b61783575327868695933444f745a5943" +
"4e5672474a584a305636664d634d335a78615134684e3165415935626f56" +
"684b735437616a56514b37756c6b4d7354676d7a532f4b6545766f667655" +
"586e4954354d5a78794d4a5549534a5a4345495567684346494951685343" +
"4549556e314f492f78765143662f666b2b332f73587a5939362b68395a49" +
"773942306654436e673877397376786b7641424d6a74376768706b714275" +
"395966434854477059424a6b4e57466c4a4e61355a74466945736843454b" +
"515168436b72684564336a566a6c78534c4564374c6c425a577a62694249" +
"736559586278367a7a636b2f68697a355a6d78624b69785556307a2f3251" +
"36356c6e2f535358342f507966503076697843554a5a4a576a38536a4830" +
"75544a413547323478517a6c51666565516372733657455a3449695a6148" +
"6d446632657a4c7539637847585534634944596d614c577658344e32686a" +
"71726e34572f4b2f54342f4b78526877433872724f696e6b7a7938706a4b" +
"58693266713775505948504a64505664666b6a6b45635553514455746673" +
"2b763258683668507a426a7a346e65334d48543756313932575a50367566" +
"6d5758663234734f447a444b456e45774b44375062384a524f692b6f3953" +
"786a7a634f5168737842337477322f3841555342795a664c35473346724f" +
"7550727a6b64504e307773785452445853626f375266633965446166616a" +
"66526c7a6448666e682f4c786561503841636750482f696a2b3775312f46" +
"655971787a47424f776e6833465356425168434567495168534345495567" +
"6d78774f535168473869414f394b685366522f38413075554872546a4835" +
"635559597833422f745869694a59795073556d58714d6d6249637551764f" +
"56544a54457445593171346f4449726d756d4d69517956496f5168436745" +
"4951704243465848694567354c556b6663704a674f71526848395248636e" +
"6830346b576639724d4f4b504947356764447077544c4a2b45544e6c3330" +
"4667704c706e30323171334946766232376e5757474942496b37646e3253" +
"4b72626274556d48365871664a654d71776c656a7231596452484c6a4f4d" +
"53453859424f32622b48736c516a5839773475437641517454316e777a66" +
"4f75387a79534c346e326b32384a7165595a7a3342646e53395152486347" +
"335141416c4d6954442f44454d41315458636547713859794a414430466c" +
"6b695a467a556c585335656e3150585247375a497a6e4b386a3744336257" +
"43387462474a6c51423159644c6c5036543330576658726673795a394949" +
"58522f437a66742b495444302f4d513766454c4f78724b35554c72487032" +
"556c714476566836545039306669725973727a6b4c307836536631544863" +
"466f394a422f582f792f657271486d764c517657486f7a33794e2f772f65" +
"74506f6830794139794f6f75613868433975486f63522b655a505946622b" +
"6f3663573348744b756f654b2b6551766f763666436173663879582b6a78" +
"635a653866525855584666506f58305139447766756c3778394670394277" +
"48387335447462376c6452635638346866516e304846706b507757663047" +
"4c5849666372714c69766e304c336a364669482f6b502b564e2f53395038" +
"41756d2f64394664516331382b68652f2f41452f546a5758762b354a5030" +
"62462b6d636832682f6f72714c6d764456384d706745676752464b383132" +
"7a39486b50797a42504d4e39564f507033555164747248762b6164677975" +
"66486b6b386a516b654a792f77436e67694f575753596941412f67316174" +
"46305239503669424a4456532f77656f4574344163566f797469796f354d" +
"6b6f6d494c65476f6f3271334c484a6a6964306e42384f7632716b75687a" +
"797542334d456b2b6a7a794a6c4b4c6b38777255674d55705743714f6c6b" +
"626b42644b3046576e456f644944636c644f4c7073636441547a57417033" +
"5754496f78464162634562696c4254752b69476d78634b676b624a596c72" +
"424f4355457a67364a674f535545706b46574c4d793052694f7854415469" +
"4a51544e464145526f73327074716948354c51546f417445552b794c5564" +
"2b78534a756b7433466274354c64764a424b355135546d434e7167523172" +
"7074764a477771536272435658797973324649534a4356574d4668696f49" +
"705372454a4345684a696c4d5a6343716c4b6b4a45454a5353716c4b5568" +
"35414b64494171526974417754694a37466b594f72787838566b6b415478" +
"6956574d514c4a683249614c4742546a47363048697470336f5459516962" +
"30544144524c46797141447355544349437834716371584b53596b434751" +
"6464472f6b6e456c7a676d5849725161375361714c704530323552465256" +
"4f4f4151546d52354b686c454339567a76566b3361704b76537978494a42" +
"4d48556d6772585a44495a43593645774646724a424446316e6c71724c4e" +
"716b6c734378686f756a796962304344434d655a53484d59704346305359" +
"71524153796759705446564c4a4374423430594656414153622b43614a34" +
"705a5769465146524254774c6f615742566d33564b6b4b56315462754b79" +
"5652454932425a416771304168704d594872564f4f6e46335a574256496c" +
"7531476e4568302b6a6f2f693158513530436f4c4930343454304a4f724a" +
"6f2b6e534e584646334433726161713272484965686e72494d744852532f" +
"63753042444f6a546a6b4852635a6642502f446a72497271596f41347131" +
"59357830754d463946547934436754686a32724448336f52664c6a6f7952" +
"6f717a4d6c49354a524141516c4d65436f526f734b676d344643686e736d" +
"3755724d6c466b434568436f5136513053796d516b4c4b71517857676d51" +
"6b494371516b4b512b654631514b55536e4257324641797045734b4b6358" +
"4e6c6149653679513869725167347173413270393341456f61576a414255" +
"69542b43684355724d417268774f4b793072466c546342565233536c6f49" +
"7034745a3337554665424d6c554b556541564b43367930634f624a674572" +
"416969594d3346424f7457426a554a6f417154467571326c796d62334b54" +
"4e727165516b57695371694a304b777961703979676c416b3369514f4365" +
"504d4c446c54524149715649624968314d7847685670524458555358464b" +
"4b42534572634530716b454a6d43306b6a424b597175326a724347554544" +
"464b597664574b56686461434a6a775579437179706f70376b73766d4146" +
"534b324261365978424c73793277324264564d5a58305344754363486263" +
"643643724435716f47366a4a49374a42773771774469374c4c5234685668" +
"51574b54475147425968576a4679345130614942756e68474f6957394c4b" +
"6b61303134724c5268466b2b314b51593046452b47464b6e635167744467" +
"4c5153657859664e4a305a6c614554426e7567744465394d477373497275" +
"5a61416531314962646f76666d744a5035526445676543306e626f684e68" +
"4c614b706a49714d70456c68336f42492b61677151365339714c4a5a4746" +
"71636b6b5a476452546b556f474a55736f387547346d7872477475584e64" +
"414f34564651744b51354d57555a5046473359516669716736706a414f36" +
"47347151536b6f4b53526136514a636c4d706a524b536b456c52546c4631" +
"51684b51744d766d575478484e4c74634d6d694b746f74734e4553545542" +
"315552424166524b4a4777466445324f6c304e4b77614a6179723467374d" +
"7067675363436959796f64466b7251494e5a4b3479415773755546714770" +
"54527258514961644a6e4f52384e6c30695169474138584663555a4d4c36" +
"7270693867794b31463479656a4256787841385430433534304c6d696f34" +
"694f6179585649734b366f4a3442317a786d4352754e4b6c31574d714141" +
"2b354255424c75433456444963464f4a5a6d466c736e436b6f4343454567" +
"71635a474d5761694e394541675a336b4b6a6b6c4d433767305648733130" +
"4766424b624137566b6a757271746255634b7053524837564a6a37617259" +
"7939366c4c494843634d54785344733553454c646d723979576231556d45" +
"715a544351535353474575464d6c6b756155322f77424a6a49614573764a" +
"366a31664c674c5a634a6a7a33552b53334a724e7550596669736b426465" +
"66673957775a76316254776c395632376e5667664e6d5a706f6d69534650" +
"63316446534a417174734867474c75657856446e74555845533659546444" +
"5330534766564f493772466c5048485943493856574b43654d535251747a" +
"56576f7a5757517147494954514c304c686c6b6c686a65516b5255633131" +
"516d314251446975636b51766234716b5337384371745258644b4e64447a" +
"585444494a65473558435a426e657569734247544568794e65437958572b" +
"32394f315842654c61385677695a317172516b59327167726d455978634f" +
"364a78384f346c32344f6b47513349576562576c6967716b41732b69774d" +
"6462364c504d4556753453464456515941596e694757376a594c42505368" +
"574d446275556c474a7141706949334237706849783746676b4451715244" +
"6945693969743274593254303071706d6a3755686e386830436645753677" +
"694d695333616c4d41365171575a4959685955706e566b6f704458756b6d" +
"42494d51344b636c366170536c6c355056656a59636c6366676c7973764a" +
"6c4c71665435625849476e375376715358554d324b4f614f7a494843334b" +
"785a2b6e7a316b305a4e32704b707751566f4b4f35357172454652455246" +
"6c574a4242696464466b7178613456495345614571474f6172746a6b4730" +
"31396e5130766a65526342786f6e4a7233714f4d67436c6971754b684250" +
"416758484e6b3444467852317a7742446952634f38667839766d722b492b" +
"493169654b435566366b76454e7046693636593767435a436d6a4b517951" +
"795366583470786b656850626f67746a6b61725756595a42747578553344" +
"41477a657a4a495241446b714c75696461464d42486a37317a5266696e47" +
"586a775753615753416b496b3936704f4f3041784955795262354a74776c" +
"72513055674464376a5662475a46456b67774c5066526246694842725253" +
"4e4c4b7a6b304957526d43654253376e6574466747303878645157684a79" +
"5449696c696745477864495258525a733231466b6f53754344566b623656" +
"7155587173634f586f36517a6348575853354e7074324c597733436d6951" +
"772f464b5841436a6c794d526f5673637646494d344b7767684d414a3254" +
"4130597044354f4a32326f6e6a5435705763494c6738467468614c614a37" +
"56754567445647716550695961494b6b432f4e4d2f44515639765971654d" +
"73547a487956494861484b437144756b525a6c6f6d49796f6566324f6b2f" +
"4c51364145707052456751474a41515851596b5978496e63434e42795242" +
"774b466e31344c6c47536f693944386b2b504e356b694132375772494f75" +
"316d414a76785443424c74554836704d65514d353461707a495641655063" +
"687075556e486a4f615949786767536b3346626a6b537869784246466b38" +
"307a45776c574653326a4a544a774e74767238304a595342346a526c7368" +
"522b78536a4e366d347256556849786375344b69574c74577854695a4248" +
"4170524a694f50377531614a4f58485a7935715373706b6b6b4e75436173" +
"3647363569646a6b36703856727152695343784873564f514a4c2f704655" +
"356b394465793078416938545671715459354a43494f76305654496b3046" +
"57717062596755737359786b34754b4b523479456d30644a4e366e687753" +
"7a6b42625652387754426944644c494751695242344a764e32446b705a54" +
"54644c2f4d6b4d7a4734716b4c544979654b7734714d5352517243514377" +
"73736b624f6b4f6d456a453153355a62532b677564464d5a4769774c6a6d" +
"6e6a494d51624a443573794a4b714b6869334253596b55756e6744395670" +
"6853494938514e717079444567684b434b67684d4274484d496144304a69" +
"4c2b337a56537a4d4f314a413676645043514a414272564262756c614651" +
"617571593553334f6539546261547a6f566f6b776356487848334b4b6759" +
"6c6d626833716768476f31736c6850636550337132783668756179537732" +
"7a63456b454832373151793231633857497270386c43556953346f415651" +
"47385a42774c6356492b484e435141485a54322f4657324d6156424f7134" +
"6a686470596d654e3331484c6e3272706a4d435a694859436c5546544d30" +
"6153444774514e5541737834705833674756615835724a6e777337435465" +
"3952554263474a464470783972496930584955686b4553597a4c56483370" +
"70786c47704e395649354c754c364a72637450626b567a794c6c7a546d71" +
"53796267356f51667a4b523478456753346f61386b38524b68346a696f48" +
"4a744a6c594d79726a6b53484e5278556a753763446f5532376b34555153" +
"443855776b6579587a556c4a4557584c6b4f50634137534a5a564d6c676b" +
"414b2b39496332664673424149494e77706559344d433462526463346275" +
"3563306f7651684d5a414c697431686369716d4159574e4854536d7a326f" +
"6b4a2b5a4b446267726a50455233457346353356656f52413234716e6a6f" +
"764d6e6b6c4d76497574597a727167474470374b494c4e32716a6a337142" +
"344f4a564b7134335072645371506d7442646e5556774b4d6b6c50623468" +
"56316d34697353375757694a7633494b78724639566a526b2f7a53526b57" +
"5a2b777073636f6b316a596539425847485548784d6d4a6b61436c48584e" +
"444b496b6a536972697a5642314874373046654d326c573946704f77474a" +
"4f6f767a344a4a536f416267756539556e4c66346832565152754d504561" +
"673054596a756948763841426b67446e67496b73654b7041445a334b4c59" +
"795049456c766373794555424642566c7351436145734b704a544d532b70" +
"6453615045387a5869654a4b6d444b443478523763505a6c534e47705856" +
"6b6f7251466a5a53574f61457749476b6a516f78435559796937676e6238" +
"474c71496935304a747a577649416d4e72653375556a5373326c69732f49" +
"4b42673975584a615a2f75413851707a5275464259476755447a66744341" +
"51576374514b557a355138566c6b4348414a426669704c79334131346355" +
"7368756f6d6d5769787370487773316a386b6f305a474e45453155664e4d" +
"433072636543686d395277776f44753745344e587a546a69675a534c4336" +
"384c7165726c6e706150425a315856533669546d3267584f74794f646f51" +
"68435758554530564f4b6363316c70523645706758706f70416b47697275" +
"44714c5938685650435250636a5a2b704c516173676d6a4a2f7936617035" +
"6b56497550745752327969445931634b637043353769704d6d6439654846" +
"4a4358747853797147466973736548344a546f686d637356635a37636c77" +
"3141636933327034687930533342423136486e7437635661505541454e61" +
"6e65764a7835435152472f4432397171735a57356c474858716e4d493034" +
"6969356a6c496b2b696c4c4951474f696c504a734c364769734e72734578" +
"51646f597035457841656f5a31776a714d654a3930726142527a6571796c" +
"5447473571776249394f65336275656c484b7945336c4b45785236536632" +
"3058697736374e41754a58756d48714f5146797854794f6f397779327343" +
"6158393655784249463947586b2f32556e6661416255736e2f7441627852" +
"6c5855656f447569596c7944384548612f693046313573665534682b616f" +
"50557354317372467364354c45682b594b77354e6b586b34414861755139" +
"64696b4b53727a553833583434784f32704f69735775487175736c6e4c57" +
"6a6f46797253584c72463063676843464949516853586a4b696345674263" +
"346d79635a427a51566f79633153524a4536724e34564d65534a754b3856" +
"46627a445274466f6b5a32734b704a4d5274534573514b75677569556949" +
"6e69464a3369783157536d376764715277657a5253614e51736b64745233" +
"646c575137462b5866565a4b5148356263314a5861306477725777753330" +
"57776655505832397550776c4351684531754743542b5177414173706136" +
"6874506a305762786a756671754f576152444367344253546731317a3676" +
"396f39363535354a544c6c49684f44516843464149516853434549556768" +
"4346494951685343454955676843464949516853662f5a"
const SipeTestnetAllocData = "\xe4\xe3\x94\t\xea\xf1Ak\xcd\xcbE\xa8\a\u06bf\xda\u00bd\\\xf7C\xa9\xe5\x8d\f\x9f,\x9c\xd0Ft\xed\xea@\x00\x00\x00"
nolint: misspell
Variables ¶
var ( // ErrKnownBlock is returned when a block to import is already known locally. ErrKnownBlock = errors.New("block already known") // ErrGasLimitReached is returned by the gas pool if the amount of gas required // by a transaction is higher than what's left in the block. ErrGasLimitReached = errors.New("gas limit reached") // ErrBlacklistedHash is returned if a block to import is on the blacklist. ErrBlacklistedHash = errors.New("blacklisted hash") // ErrNonceTooHigh is returned if the nonce of a transaction is higher than the // next one expected based on the local chain. ErrNonceTooHigh = errors.New("nonce too high") // ErrNoGenesis is returned when there is no Genesis Block. ErrNoGenesis = errors.New("genesis not found in chain") )
var ( // ErrInvalidSender is returned if the transaction contains an invalid signature. ErrInvalidSender = errors.New("invalid sender") // ErrNonceTooLow is returned if the nonce of a transaction is lower than the // one present in the local chain. ErrNonceTooLow = errors.New("nonce too low") // ErrUnderpriced is returned if a transaction's gas price is below the minimum // configured for the transaction pool. ErrUnderpriced = errors.New("transaction underpriced") // ErrReplaceUnderpriced is returned if a transaction is attempted to be replaced // with a different one without the required price bump. ErrReplaceUnderpriced = errors.New("replacement transaction underpriced") // ErrInsufficientFunds is returned if the total cost of executing a transaction // is higher than the balance of the user's account. ErrInsufficientFunds = errors.New("insufficient funds for gas * price + value") // ErrIntrinsicGas is returned if the transaction is specified to use less gas // than required to start the invocation. ErrIntrinsicGas = errors.New("intrinsic gas too low") // ErrGasLimit is returned if a transaction's requested gas limit exceeds the // maximum allowance of the current block. ErrGasLimit = errors.New("exceeds block gas limit") // ErrNegativeValue is a sanity error to ensure noone is able to specify a // transaction with a negative value. ErrNegativeValue = errors.New("negative value") // ErrOversizedData is returned if the input data of a transaction is greater // than some meaningful limit a user might use. This is not a consensus error // making the transaction invalid, rather a DOS protection. ErrOversizedData = errors.New("oversized data") ErrTransactionFull = errors.New("the transaction pool is full") )
var BadHashes = map[common.Hash]bool{ common.HexToHash("05bef30ef572270f654746da22639a7a0c97dd97a7050b9e252391996aaeb689"): true, common.HexToHash("7d05d08cbc596a2e5e4f13b80a743e53e09221b5323c3a61946b20873e58583f"): true, }
BadHashes represent a set of manually tracked bad hashes (usually hard forks)
var DefaultTxPoolConfig = TxPoolConfig{ Journal: "transactions.rlp", Rejournal: time.Hour, PriceLimit: 0, PriceBump: 10, AccountSlots: 16, GlobalSlots: 4096, AccountQueue: 64, GlobalQueue: 1024, Lifetime: 3 * time.Hour, }
DefaultTxPoolConfig contains the default configurations for the transaction pool.
var (
ErrInsufficientBalanceForGas = errors.New("insufficient balance to pay for gas")
)
Functions ¶
func ApplyMessage ¶
ApplyMessage computes the new state by applying the given message against the old state within the environment.
ApplyMessage returns the bytes returned by any EVM execution (if it took place), the gas used (which includes gas refunds) and an error if it failed. An error always indicates a core error meaning that the message would always fail for that particular state and would never be accepted within a block.
func ApplyTransaction ¶
func ApplyTransaction(config *params.ChainConfig, bc ChainContext, author *common.Address, gp *GasPool, statedb *state.StateDB, header *types.Header, tx *types.Transaction, usedGas *uint64, cfg vm.Config) (*types.Receipt, error)
ApplyTransaction attempts to apply a transaction to the given state database and uses the input parameters for its environment. It returns the receipt for the transaction, gas used and an error if the transaction failed, indicating the block was invalid.
func CalcGasLimit ¶
CalcGasLimit computes the gas limit of the next block after parent. It aims to keep the baseline gas above the provided floor, and increase it towards the ceil if the blocks are full. If the ceil is exceeded, it will always decrease the gas allowance.
func CanTransfer ¶
CanTransfer checks whether there are enough funds in the address' account to make a transfer. This does not take the necessary gas in to account to make the transfer valid.
func GenerateChain ¶
func GenerateChain(config *params.ChainConfig, parent *types.Block, engine consensus.Engine, db ethdb.Database, n int, gen func(int, *BlockGen)) ([]*types.Block, []types.Receipts)
GenerateChain creates a chain of n blocks. The first block's parent will be the provided parent. db is used to store intermediate states and should contain the parent's state trie.
The generator function is called with a new block generator for every block. Any transactions and uncles added to the generator become part of the block. If gen is nil, the blocks will be empty and their coinbase will be the zero address.
Blocks created by GenerateChain do not contain valid proof of work values. Inserting them into BlockChain requires use of FakePow or a similar non-validating proof of work implementation.
Example ¶
var ( key1, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") key2, _ = crypto.HexToECDSA("8a1f9a8f95be41cd7ccb6168179afb4504aefe388d1e14474d32c45c72ce7b7a") key3, _ = crypto.HexToECDSA("49a7b37aa6f6645917e7b807e9d1c00d4fa71f18343b0d4122a4d2df64dd6fee") addr1 = crypto.PubkeyToAddress(key1.PublicKey) addr2 = crypto.PubkeyToAddress(key2.PublicKey) addr3 = crypto.PubkeyToAddress(key3.PublicKey) db = rawdb.NewMemoryDatabase() ) // Ensure that key1 has some funds in the genesis block. gspec := &Genesis{ Config: ¶ms.ChainConfig{HomesteadBlock: new(big.Int)}, Alloc: GenesisAlloc{addr1: {Balance: big.NewInt(1000000)}}, } genesis := gspec.MustCommit(db) // This call generates a chain of 5 blocks. The function runs for // each block and adds different features to gen based on the // block index. signer := types.HomesteadSigner{} chain, _ := GenerateChain(gspec.Config, genesis, ethash.NewFaker(), db, 5, func(i int, gen *BlockGen) { switch i { case 0: // In block 1, addr1 sends addr2 some ether. tx, _ := types.SignTx(types.NewTransaction(gen.TxNonce(addr1), addr2, big.NewInt(10000), params.TxGas, nil, nil), signer, key1) gen.AddTx(tx) case 1: // In block 2, addr1 sends some more ether to addr2. // addr2 passes it on to addr3. tx1, _ := types.SignTx(types.NewTransaction(gen.TxNonce(addr1), addr2, big.NewInt(1000), params.TxGas, nil, nil), signer, key1) tx2, _ := types.SignTx(types.NewTransaction(gen.TxNonce(addr2), addr3, big.NewInt(1000), params.TxGas, nil, nil), signer, key2) gen.AddTx(tx1) gen.AddTx(tx2) case 2: // Block 3 is empty but was mined by addr3. gen.SetCoinbase(addr3) gen.SetExtra([]byte("yeehaw")) case 3: // Block 4 includes blocks 2 and 3 as uncle headers (with modified extra data). b2 := gen.PrevBlock(1).Header() b2.Extra = []byte("foo") gen.AddUncle(b2) b3 := gen.PrevBlock(2).Header() b3.Extra = []byte("foo") gen.AddUncle(b3) } }) // Import the chain. This runs all block validation rules. blockchain, _ := NewBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil) defer blockchain.Stop() if i, err := blockchain.InsertChain(chain); err != nil { fmt.Printf("insert error (block %d): %v\n", chain[i].NumberU64(), err) return } state, _ := blockchain.State() fmt.Printf("last block: #%d\n", blockchain.CurrentBlock().Number()) fmt.Println("balance of addr1:", state.GetBalance(addr1)) fmt.Println("balance of addr2:", state.GetBalance(addr2)) fmt.Println("balance of addr3:", state.GetBalance(addr3))
Output: last block: #5 balance of addr1: 989000 balance of addr2: 10000 balance of addr3: 19687500000000001000
func GenesisBlockForTesting ¶
GenesisBlockForTesting creates and writes a block in which addr has the given wei balance.
func IntrinsicGas ¶
IntrinsicGas computes the 'intrinsic gas' for a message with the given data.
func NewEVMContext ¶
func NewEVMContext(msg Message, header *types.Header, chain ChainContext, author *common.Address) vm.Context
NewEVMContext creates a new context for use in the EVM.
func NewExecutor ¶
func NewExecutor(chainConfig *params.ChainConfig, chainContext ChainContext, vmCfg vm.Config)
func SetupGenesisBlock ¶
func SetupGenesisBlock(db ethdb.Database, genesis *Genesis) (*params.ChainConfig, common.Hash, error)
SetupGenesisBlock writes or updates the genesis block in db. The block that will be used is:
genesis == nil genesis != nil +------------------------------------------ db has no genesis | main-net default | genesis db has genesis | from DB | genesis (if compatible)
The stored chain configuration will be updated if it is compatible (i.e. does not specify a fork block below the local head block). In case of a conflict, the error is a *params.ConfigCompatError and the new, unwritten config is returned.
The returned chain configuration is never nil.
Types ¶
type BlockChain ¶
type BlockChain struct {
// contains filtered or unexported fields
}
BlockChain represents the canonical chain given a database with a genesis block. The Blockchain manages chain imports, reverts, chain reorganisations.
Importing blocks in to the block chain happens according to the set of rules defined by the two stage Validator. Processing of blocks is done using the Processor which processes the included transaction. The validation of the state is done in the second part of the Validator. Failing results in aborting of the import.
The BlockChain also helps in returning blocks from **any** chain included in the database as well as blocks that represents the canonical chain. It's important to note that GetBlock can return any block and does not need to be included in the canonical one where as GetBlockByNumber always represents the canonical chain.
func NewBlockChain ¶
func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, chainConfig *params.ChainConfig, engine consensus.Engine, vmConfig vm.Config, shouldPreserve func(block *types.Block) bool) (*BlockChain, error)
NewBlockChain returns a fully initialised block chain using information available in the database. It initialises the default Ethereum Validator and Processor.
func (*BlockChain) BadBlocks ¶
func (bc *BlockChain) BadBlocks() []*types.Block
BadBlocks returns a list of the last 'bad blocks' that the client has seen on the network
func (*BlockChain) Config ¶
func (bc *BlockChain) Config() *params.ChainConfig
Config retrieves the chain's fork configuration.
func (*BlockChain) CurrentBlock ¶
func (bc *BlockChain) CurrentBlock() *types.Block
CurrentBlock retrieves the current head block of the canonical chain. The block is retrieved from the blockchain's internal cache.
func (*BlockChain) CurrentFastBlock ¶
func (bc *BlockChain) CurrentFastBlock() *types.Block
CurrentFastBlock retrieves the current fast-sync head block of the canonical chain. The block is retrieved from the blockchain's internal cache.
func (*BlockChain) CurrentHeader ¶
func (bc *BlockChain) CurrentHeader() *types.Header
CurrentHeader retrieves the current head header of the canonical chain. The header is retrieved from the HeaderChain's internal cache.
func (*BlockChain) Engine ¶
func (bc *BlockChain) Engine() consensus.Engine
Engine retrieves the blockchain's consensus engine.
func (*BlockChain) Export ¶
func (bc *BlockChain) Export(w io.Writer) error
Export writes the active chain to the given writer.
func (*BlockChain) FastSyncCommitHead ¶
func (bc *BlockChain) FastSyncCommitHead(hash common.Hash) error
FastSyncCommitHead sets the current head block to the one defined by the hash irrelevant what the chain contents were prior.
func (*BlockChain) GasLimit ¶
func (bc *BlockChain) GasLimit() uint64
GasLimit returns the gas limit of the current HEAD block.
func (*BlockChain) Genesis ¶
func (bc *BlockChain) Genesis() *types.Block
Genesis retrieves the chain's genesis block.
func (*BlockChain) GetAccessControl ¶
func (bc *BlockChain) GetAccessControl() access_contoller.AccessControlProvider
func (*BlockChain) GetAncestor ¶
func (bc *BlockChain) GetAncestor(hash common.Hash, number, ancestor uint64, maxNonCanonical *uint64) (common.Hash, uint64)
GetAncestor retrieves the Nth ancestor of a given block. It assumes that either the given block or a close ancestor of it is canonical. maxNonCanonical points to a downwards counter limiting the number of blocks to be individually checked before we reach the canonical chain.
Note: ancestor == 0 returns the same block, 1 returns its parent and so on.
func (*BlockChain) GetBlock ¶
GetBlock retrieves a block from the database by hash and number, caching it if found.
func (*BlockChain) GetBlockByHash ¶
func (bc *BlockChain) GetBlockByHash(hash common.Hash) *types.Block
GetBlockByHash retrieves a block from the database by hash, caching it if found.
func (*BlockChain) GetBlockByNumber ¶
func (bc *BlockChain) GetBlockByNumber(number uint64) *types.Block
GetBlockByNumber retrieves a block from the database by number, caching it (associated with its hash) if found.
func (*BlockChain) GetBlockHashesFromHash ¶
GetBlockHashesFromHash retrieves a number of block hashes starting at a given hash, fetching towards the genesis block.
func (*BlockChain) GetBlocksFromHash ¶
GetBlocksFromHash returns the block corresponding to hash and up to n-1 ancestors. [deprecated by eth/62]
func (*BlockChain) GetBody ¶
func (bc *BlockChain) GetBody(hash common.Hash) *types.Body
GetBody retrieves a block body (transactions and uncles) from the database by hash, caching it if found.
func (*BlockChain) GetBodyRLP ¶
func (bc *BlockChain) GetBodyRLP(hash common.Hash) rlp.RawValue
GetBodyRLP retrieves a block body in RLP encoding from the database by hash, caching it if found.
func (*BlockChain) GetCanonicalHash ¶
func (bc *BlockChain) GetCanonicalHash(number uint64) common.Hash
GetCanonicalHash returns the canonical hash for a given block number
func (*BlockChain) GetCommittedSeals ¶
func (bc *BlockChain) GetCommittedSeals(hash common.Hash) (uint64, types.ByzantineSeals)
func (*BlockChain) GetHeader ¶
GetHeader retrieves a block header from the database by hash and number, caching it if found.
func (*BlockChain) GetHeaderByHash ¶
func (bc *BlockChain) GetHeaderByHash(hash common.Hash) *types.Header
GetHeaderByHash retrieves a block header from the database by hash, caching it if found.
func (*BlockChain) GetHeaderByNumber ¶
func (bc *BlockChain) GetHeaderByNumber(number uint64) *types.Header
GetHeaderByNumber retrieves a block header from the database by number, caching it (associated with its hash) if found.
func (*BlockChain) GetReceiptsByHash ¶
func (bc *BlockChain) GetReceiptsByHash(hash common.Hash) types.Receipts
GetReceiptsByHash retrieves the receipts for all transactions in a given block.
func (*BlockChain) GetTd ¶
GetTd retrieves a block's total difficulty in the canonical chain from the database by hash and number, caching it if found.
func (*BlockChain) GetTdByHash ¶
func (bc *BlockChain) GetTdByHash(hash common.Hash) *big.Int
GetTdByHash retrieves a block's total difficulty in the canonical chain from the database by hash, caching it if found.
func (*BlockChain) GetTransactionLookup ¶
func (bc *BlockChain) GetTransactionLookup(hash common.Hash) *rawdb.LegacyTxLookupEntry
GetTransactionLookup retrieves the lookup associate with the given transaction hash from the cache or database.
func (*BlockChain) GetTransactions ¶
func (bc *BlockChain) GetTransactions(number uint64) types.Transactions
GetTransactions retrieves a block's transactions from the database by number, caching it if found.
func (*BlockChain) GetUnclesInChain ¶
GetUnclesInChain retrieves all the uncles from a given block backwards until a specific distance is reached.
func (*BlockChain) GetVMConfig ¶
func (bc *BlockChain) GetVMConfig() *vm.Config
GetVMConfig returns the block chain VM config.
func (*BlockChain) HasBadBlock ¶
func (bc *BlockChain) HasBadBlock(hash common.Hash) bool
HasBadBlock returns whether the block with the hash is a bad block. dep: Istanbul
func (*BlockChain) HasBlock ¶
func (bc *BlockChain) HasBlock(hash common.Hash, number uint64) bool
HasBlock checks if a block is fully present in the database or not.
func (*BlockChain) HasBlockAndState ¶
func (bc *BlockChain) HasBlockAndState(hash common.Hash, number uint64) bool
HasBlockAndState checks if a block and associated state trie is fully present in the database or not, caching it if present.
func (*BlockChain) HasFastBlock ¶
func (bc *BlockChain) HasFastBlock(hash common.Hash, number uint64) bool
HasFastBlock checks if a fast block is fully present in the database or not.
func (*BlockChain) HasHeader ¶
func (bc *BlockChain) HasHeader(hash common.Hash, number uint64) bool
HasHeader checks if a block header is present in the database or not, caching it if present.
func (*BlockChain) HasState ¶
func (bc *BlockChain) HasState(hash common.Hash) bool
HasState checks if state trie is fully present in the database or not.
func (*BlockChain) InsertChain ¶
func (bc *BlockChain) InsertChain(chain types.Blocks) (int, error)
InsertChain attempts to insert the given batch of blocks in to the canonical chain or, otherwise, create a fork. If an error is returned it will return the index number of the failing block as well an error describing what went wrong.
After insertion is done, all accumulated events will be fired.
func (*BlockChain) InsertHeaderChain ¶
InsertHeaderChain attempts to insert the given header chain in to the local chain, possibly creating a reorg. If an error is returned, it will return the index number of the failing header as well an error describing what went wrong.
The verify parameter can be used to fine tune whether nonce verification should be done or not. The reason behind the optional check is because some of the header retrieval mechanisms already need to verify nonces, as well as because nonces can be verified sparsely, not needing to check each.
func (*BlockChain) InsertReceiptChain ¶
func (bc *BlockChain) InsertReceiptChain(blockChain types.Blocks, receiptChain []types.Receipts, ancientLimit uint64) (int, error)
InsertReceiptChain attempts to complete an already existing header chain with transaction and receipt data.
func (*BlockChain) Processor ¶
func (bc *BlockChain) Processor() Processor
Processor returns the current processor.
func (*BlockChain) Reset ¶
func (bc *BlockChain) Reset() error
Reset purges the entire blockchain, restoring it to its genesis state.
func (*BlockChain) ResetWithGenesisBlock ¶
func (bc *BlockChain) ResetWithGenesisBlock(genesis *types.Block) error
ResetWithGenesisBlock purges the entire blockchain, restoring it to the specified genesis state.
func (*BlockChain) Rollback ¶
func (bc *BlockChain) Rollback(chain []common.Hash)
Rollback is designed to remove a chain of links from the database that aren't certain enough to be valid.
func (*BlockChain) SetHead ¶
func (bc *BlockChain) SetHead(head uint64) error
SetHead rewinds the local chain to a new head. In the case of headers, everything above the new head will be deleted and the new one set. In the case of blocks though, the head may be further rewound if block bodies are missing (non-archive nodes after a fast sync).
func (*BlockChain) State ¶
func (bc *BlockChain) State() (*state.StateDB, error)
State returns a new mutable state based on the current HEAD block.
func (*BlockChain) StateAt ¶
StateAt returns a new mutable state based on a particular point in time.
func (*BlockChain) StateCache ¶
func (bc *BlockChain) StateCache() state.Database
StateCache returns the caching database underpinning the blockchain instance.
func (*BlockChain) Stop ¶
func (bc *BlockChain) Stop()
Stop stops the blockchain service. If any imports are currently in progress it will abort them using the procInterrupt.
func (*BlockChain) SubscribeBlockProcessingEvent ¶
func (bc *BlockChain) SubscribeBlockProcessingEvent(ch chan<- bool) event.Subscription
SubscribeBlockProcessingEvent registers a subscription of bool where true means block processing has started while false means it has stopped.
func (*BlockChain) SubscribeChainEvent ¶
func (bc *BlockChain) SubscribeChainEvent(ch chan<- ChainEvent) event.Subscription
SubscribeChainEvent registers a subscription of ChainEvent.
func (*BlockChain) SubscribeChainHeadEvent ¶
func (bc *BlockChain) SubscribeChainHeadEvent(ch chan<- ChainHeadEvent) event.Subscription
SubscribeChainHeadEvent registers a subscription of ChainHeadEvent.
func (*BlockChain) SubscribeChainSideEvent ¶
func (bc *BlockChain) SubscribeChainSideEvent(ch chan<- ChainSideEvent) event.Subscription
SubscribeChainSideEvent registers a subscription of ChainSideEvent.
func (*BlockChain) SubscribeLogsEvent ¶
func (bc *BlockChain) SubscribeLogsEvent(ch chan<- []*types.Log) event.Subscription
SubscribeLogsEvent registers a subscription of []*types.Log.
func (*BlockChain) SubscribeRemovedLogsEvent ¶
func (bc *BlockChain) SubscribeRemovedLogsEvent(ch chan<- RemovedLogsEvent) event.Subscription
SubscribeRemovedLogsEvent registers a subscription of RemovedLogsEvent.
func (*BlockChain) TrieNode ¶
func (bc *BlockChain) TrieNode(hash common.Hash) ([]byte, error)
TrieNode retrieves a blob of data associated with a trie node (or code hash) either from ephemeral in-memory cache, or from persistent storage.
func (*BlockChain) Validator ¶
func (bc *BlockChain) Validator() Validator
Validator returns the current validator.
func (*BlockChain) WriteBlockWithState ¶
func (bc *BlockChain) WriteBlockWithState(block *types.Block, receipts []*types.Receipt, logs []*types.Log, state *state.StateDB, emitHeadEvent bool) (status WriteStatus, err error)
WriteBlockWithState writes the block and all associated state to the database.
type BlockChainCache ¶
type BlockChainCache struct { *BlockChain // contains filtered or unexported fields }
func NewBlockChainCache ¶
func NewBlockChainCache(blockChain *BlockChain) *BlockChainCache
func (*BlockChainCache) CommitBlock ¶
func (bcc *BlockChainCache) CommitBlock(block *types.Block)
func (*BlockChainCache) GetPendingBlock ¶
func (bcc *BlockChainCache) GetPendingBlock(hash common.Hash) *types.Block
func (*BlockChainCache) ReadBlock ¶
func (bcc *BlockChainCache) ReadBlock(sealHash common.Hash) *types.Block
func (*BlockChainCache) ReadReceipts ¶
Read the Receipt collection from the cache map.
func (*BlockChainCache) ReadStateDB ¶
func (bcc *BlockChainCache) ReadStateDB(sealHash common.Hash) *state.StateDB
Read the StateDB instance from the cache map
func (*BlockChainCache) StateDBString ¶
func (bcc *BlockChainCache) StateDBString() string
func (*BlockChainCache) WriteBlock ¶
func (bcc *BlockChainCache) WriteBlock(block *types.Block) error
func (*BlockChainCache) WriteReceipts ¶
func (bcc *BlockChainCache) WriteReceipts(sealHash common.Hash, usedGas uint64, receipts []*types.Receipt, blockNum uint64)
Write Receipt to the cache
func (*BlockChainCache) WriteSealBlock ¶
func (bcc *BlockChainCache) WriteSealBlock(sealHash common.Hash, block *types.Block)
func (*BlockChainCache) WriteStateDB ¶
func (bcc *BlockChainCache) WriteStateDB(sealHash common.Hash, stateDB *state.StateDB, blockNum uint64)
Write a StateDB instance to the cache
type BlockGen ¶
type BlockGen struct {
// contains filtered or unexported fields
}
BlockGen creates blocks for testing. See GenerateChain for a detailed explanation.
func (*BlockGen) AddTx ¶
func (b *BlockGen) AddTx(tx *types.Transaction)
AddTx adds a transaction to the generated block. If no coinbase has been set, the block's coinbase is set to the zero address.
AddTx panics if the transaction cannot be executed. In addition to the protocol-imposed limitations (gas limit, etc.), there are some further limitations on the content of transactions that can be added. Notably, contract code relying on the BLOCKHASH instruction will panic during execution.
func (*BlockGen) AddTxWithChain ¶
func (b *BlockGen) AddTxWithChain(bc *BlockChain, tx *types.Transaction)
AddTxWithChain adds a transaction to the generated block. If no coinbase has been set, the block's coinbase is set to the zero address.
AddTxWithChain panics if the transaction cannot be executed. In addition to the protocol-imposed limitations (gas limit, etc.), there are some further limitations on the content of transactions that can be added. If contract code relies on the BLOCKHASH instruction, the block in chain will be returned.
func (*BlockGen) AddUncheckedReceipt ¶
AddUncheckedReceipt forcefully adds a receipts to the block without a backing transaction.
AddUncheckedReceipt will cause consensus failures when used during real chain processing. This is best used in conjunction with raw block insertion.
func (*BlockGen) AddUncheckedTx ¶
func (b *BlockGen) AddUncheckedTx(tx *types.Transaction)
AddUncheckedTx forcefully adds a transaction to the block without any validation.
AddUncheckedTx will cause consensus failures when used during real chain processing. This is best used in conjunction with raw block insertion.
func (*BlockGen) OffsetTime ¶
OffsetTime modifies the time instance of a block, implicitly changing its associated difficulty. It's useful to test scenarios where forking is not tied to chain length directly.
func (*BlockGen) PrevBlock ¶
PrevBlock returns a previously generated block by number. It panics if num is greater or equal to the number of the block being generated. For index -1, PrevBlock returns the parent block given to GenerateChain.
func (*BlockGen) SetCoinbase ¶
SetCoinbase sets the coinbase of the generated block. It can be called at most once.
func (*BlockGen) SetDifficulty ¶
SetDifficulty sets the difficulty field of the generated block. This method is useful for Clique tests where the difficulty does not depend on time. For the ethash tests, please use OffsetTime, which implicitly recalculates the diff.
func (*BlockGen) SetNonce ¶
func (b *BlockGen) SetNonce(nonce types.BlockNonce)
SetNonce sets the nonce field of the generated block.
type BlockValidator ¶
type BlockValidator struct {
// contains filtered or unexported fields
}
BlockValidator is responsible for validating block headers, uncles and processed state.
BlockValidator implements Validator.
func NewBlockValidator ¶
func NewBlockValidator(config *params.ChainConfig, blockchain *BlockChain, engine consensus.Engine) *BlockValidator
NewBlockValidator returns a new block validator which is safe for re-use
func (*BlockValidator) ValidateBody ¶
func (v *BlockValidator) ValidateBody(block *types.Block) error
ValidateBody validates the given block's uncles and verifies the block header's transaction and uncle roots. The headers are assumed to be already validated at this point.
func (*BlockValidator) ValidateState ¶
func (v *BlockValidator) ValidateState(block *types.Block, statedb *state.StateDB, receipts types.Receipts, usedGas uint64) error
ValidateState validates the various changes that happen after a state transition, such as amount of used gas, the receipt roots and the state root itself. ValidateState returns a database batch if the validation was a success otherwise nil and an error is returned.
type CacheConfig ¶
type CacheConfig struct { TrieCleanLimit int // Memory allowance (MB) to use for caching trie nodes in memory TrieCleanNoPrefetch bool // Whether to disable heuristic state prefetching for followup blocks TrieDirtyLimit int // Memory limit (MB) at which to start flushing dirty trie nodes to disk TrieDirtyDisabled bool // Whether to disable trie write caching and GC altogether (archive node) TrieTimeLimit time.Duration // Time limit after which to flush the current in-memory trie to disk }
CacheConfig contains the configuration values for the trie caching/pruning that's resident in a blockchain.
type ChainContext ¶
type ChainContext interface { // Engine retrieves the chain's consensus engine. Engine() consensus.Engine // GetHeader returns the hash corresponding to their hash. GetHeader(common.Hash, uint64) *types.Header }
ChainContext supports retrieving headers and consensus parameters from the current blockchain to be used during transaction processing.
type ChainHeadEvent ¶
type ChainIndexer ¶
type ChainIndexer struct {
// contains filtered or unexported fields
}
ChainIndexer does a post-processing job for equally sized sections of the canonical chain (like BlooomBits and CHT structures). A ChainIndexer is connected to the blockchain through the event system by starting a ChainHeadEventLoop in a goroutine.
Further child ChainIndexers can be added which use the output of the parent section indexer. These child indexers receive new head notifications only after an entire section has been finished or in case of rollbacks that might affect already finished sections.
func NewChainIndexer ¶
func NewChainIndexer(chainDb ethdb.Database, indexDb ethdb.Database, backend ChainIndexerBackend, section, confirm uint64, throttling time.Duration, kind string) *ChainIndexer
NewChainIndexer creates a new chain indexer to do background processing on chain segments of a given size after certain number of confirmations passed. The throttling parameter might be used to prevent database thrashing.
func (*ChainIndexer) AddCheckpoint ¶
func (c *ChainIndexer) AddCheckpoint(section uint64, shead common.Hash)
AddCheckpoint adds a checkpoint. Sections are never processed and the chain is not expected to be available before this point. The indexer assumes that the backend has sufficient information available to process subsequent sections.
Note: knownSections == 0 and storedSections == checkpointSections until syncing reaches the checkpoint
func (*ChainIndexer) AddChildIndexer ¶
func (c *ChainIndexer) AddChildIndexer(indexer *ChainIndexer)
AddChildIndexer adds a child ChainIndexer that can use the output of this one
func (*ChainIndexer) Close ¶
func (c *ChainIndexer) Close() error
Close tears down all goroutines belonging to the indexer and returns any error that might have occurred internally.
func (*ChainIndexer) SectionHead ¶
func (c *ChainIndexer) SectionHead(section uint64) common.Hash
SectionHead retrieves the last block hash of a processed section from the index database.
func (*ChainIndexer) Sections ¶
func (c *ChainIndexer) Sections() (uint64, uint64, common.Hash)
Sections returns the number of processed sections maintained by the indexer and also the information about the last header indexed for potential canonical verifications.
func (*ChainIndexer) Start ¶
func (c *ChainIndexer) Start(chain ChainIndexerChain)
Start creates a goroutine to feed chain head events into the indexer for cascading background processing. Children do not need to be started, they are notified about new events by their parents.
type ChainIndexerBackend ¶
type ChainIndexerBackend interface { // Reset initiates the processing of a new chain segment, potentially terminating // any partially completed operations (in case of a reorg). Reset(ctx context.Context, section uint64, prevHead common.Hash) error // Process crunches through the next header in the chain segment. The caller // will ensure a sequential order of headers. Process(ctx context.Context, header *types.Header) error // Commit finalizes the section metadata and stores it into the database. Commit() error }
ChainIndexerBackend defines the methods needed to process chain segments in the background and write the segment results into the database. These can be used to create filter blooms or CHTs.
type ChainIndexerChain ¶
type ChainIndexerChain interface { // CurrentHeader retrieves the latest locally known header. CurrentHeader() *types.Header // SubscribeChainHeadEvent subscribes to new head header notifications. SubscribeChainHeadEvent(ch chan<- ChainHeadEvent) event.Subscription }
ChainIndexerChain interface is used for connecting the indexer to a blockchain
type ChainSideEvent ¶
type DeleteBlockContentCallback ¶
type DeleteBlockContentCallback func(ethdb.KeyValueWriter, common.Hash, uint64)
DeleteBlockContentCallback is a callback function that is called by SetHead before each header is deleted.
type Executor ¶
type Executor struct {
// contains filtered or unexported fields
}
func GetExecutor ¶
func GetExecutor() *Executor
func (*Executor) ExecuteTransactions ¶
func (exe *Executor) ExecuteTransactions(ctx *ParallelContext) error
type GasPool ¶
type GasPool uint64
GasPool tracks the amount of gas available during execution of the transactions in a block. The zero value is a pool with zero gas available.
type Genesis ¶
type Genesis struct { Config *params.ChainConfig `json:"config"` Nonce uint64 `json:"nonce"` Timestamp uint64 `json:"timestamp"` ExtraData []byte `json:"extraData"` GasLimit uint64 `json:"gasLimit" gencodec:"required"` Difficulty *big.Int `json:"difficulty" gencodec:"required"` Mixhash common.Hash `json:"mixHash"` Coinbase common.Address `json:"coinbase"` Alloc GenesisAlloc `json:"alloc" gencodec:"required"` // These fields are used for consensus tests. Please don't use them // in actual genesis blocks. Number uint64 `json:"number"` GasUsed uint64 `json:"gasUsed"` ParentHash common.Hash `json:"parentHash"` }
Genesis specifies the header fields, state of a genesis block. It also defines hard fork switch-over blocks through the chain configuration.
func DefaultGenesisBlock ¶
func DefaultGenesisBlock() *Genesis
// DefaultGenesisBlock returns the Ethereum main net genesis block.
func DefaultGenesisBlock() *Genesis { return &Genesis{ Config: params.MainnetChainConfig, Nonce: 66, ExtraData: hexutil.MustDecode("0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa"), GasLimit: 5000, Difficulty: big.NewInt(1200), Alloc: decodePrealloc(mainnetAllocData), } }
DefaultGenesisBlock returns the Ethereum main net genesis block.
func DefaultTestnetGenesisBlock ¶
func DefaultTestnetGenesisBlock() *Genesis
DefaultTestnetGenesisBlock returns the Ropsten network genesis block.
func DeveloperGenesisBlock ¶
DeveloperGenesisBlock returns the 'geth --dev' genesis block. Note, this must be seeded with the
func (*Genesis) Commit ¶
Commit writes the block and state of a genesis specification to the database. The block is committed as the canonical head block.
func (Genesis) MarshalJSON ¶
func (*Genesis) MustCommit ¶
MustCommit writes the genesis block and state to db, panicking on error. The block is committed as the canonical head block.
func (*Genesis) ToBlock ¶
ToBlock creates the genesis block and writes state of a genesis specification to the given database (or discards it if nil).
func (*Genesis) UnmarshalJSON ¶
type GenesisAccount ¶
type GenesisAccount struct { Code []byte `json:"code,omitempty"` Storage map[common.Hash]common.Hash `json:"storage,omitempty"` Balance *big.Int `json:"balance" gencodec:"required"` Nonce uint64 `json:"nonce,omitempty"` PrivateKey []byte `json:"secretKey,omitempty"` // for tests }
GenesisAccount is an account in the state of the genesis block.
func (GenesisAccount) MarshalJSON ¶
func (g GenesisAccount) MarshalJSON() ([]byte, error)
func (*GenesisAccount) UnmarshalJSON ¶
func (g *GenesisAccount) UnmarshalJSON(input []byte) error
type GenesisAlloc ¶
type GenesisAlloc map[common.Address]GenesisAccount
GenesisAlloc specifies the initial state that is part of the genesis block.
func (*GenesisAlloc) UnmarshalJSON ¶
func (ga *GenesisAlloc) UnmarshalJSON(data []byte) error
type GenesisMismatchError ¶
GenesisMismatchError is raised when trying to overwrite an existing genesis block with an incompatible one.
func (*GenesisMismatchError) Error ¶
func (e *GenesisMismatchError) Error() string
type HeaderChain ¶
type HeaderChain struct {
// contains filtered or unexported fields
}
HeaderChain implements the basic block header chain logic that is shared by core.BlockChain and light.LightChain. It is not usable in itself, only as a part of either structure. It is not thread safe either, the encapsulating chain structures should do the necessary mutex locking/unlocking.
func NewHeaderChain ¶
func NewHeaderChain(chainDb ethdb.Database, config *params.ChainConfig, engine consensus.Engine, procInterrupt func() bool) (*HeaderChain, error)
NewHeaderChain creates a new HeaderChain structure.
getValidator should return the parent's validator procInterrupt points to the parent's interrupt semaphore wg points to the parent's shutdown wait group
func (*HeaderChain) Config ¶
func (hc *HeaderChain) Config() *params.ChainConfig
Config retrieves the header chain's chain configuration.
func (*HeaderChain) CurrentHeader ¶
func (hc *HeaderChain) CurrentHeader() *types.Header
CurrentHeader retrieves the current head header of the canonical chain. The header is retrieved from the HeaderChain's internal cache.
func (*HeaderChain) Engine ¶
func (hc *HeaderChain) Engine() consensus.Engine
Engine retrieves the header chain's consensus engine.
func (*HeaderChain) GetAncestor ¶
func (hc *HeaderChain) GetAncestor(hash common.Hash, number, ancestor uint64, maxNonCanonical *uint64) (common.Hash, uint64)
GetAncestor retrieves the Nth ancestor of a given block. It assumes that either the given block or a close ancestor of it is canonical. maxNonCanonical points to a downwards counter limiting the number of blocks to be individually checked before we reach the canonical chain.
Note: ancestor == 0 returns the same block, 1 returns its parent and so on.
func (*HeaderChain) GetBlock ¶
GetBlock implements consensus.ChainReader, and returns nil for every input as a header chain does not have blocks available for retrieval.
func (*HeaderChain) GetBlockHashesFromHash ¶
GetBlockHashesFromHash retrieves a number of block hashes starting at a given hash, fetching towards the genesis block.
func (*HeaderChain) GetBlockNumber ¶
func (hc *HeaderChain) GetBlockNumber(hash common.Hash) *uint64
GetBlockNumber retrieves the block number belonging to the given hash from the cache or database
func (*HeaderChain) GetCanonicalHash ¶
func (hc *HeaderChain) GetCanonicalHash(number uint64) common.Hash
func (*HeaderChain) GetHeader ¶
GetHeader retrieves a block header from the database by hash and number, caching it if found.
func (*HeaderChain) GetHeaderByHash ¶
func (hc *HeaderChain) GetHeaderByHash(hash common.Hash) *types.Header
GetHeaderByHash retrieves a block header from the database by hash, caching it if found.
func (*HeaderChain) GetHeaderByNumber ¶
func (hc *HeaderChain) GetHeaderByNumber(number uint64) *types.Header
GetHeaderByNumber retrieves a block header from the database by number, caching it (associated with its hash) if found.
func (*HeaderChain) GetTd ¶
GetTd retrieves a block's total difficulty in the canonical chain from the database by hash and number, caching it if found.
func (*HeaderChain) GetTdByHash ¶
func (hc *HeaderChain) GetTdByHash(hash common.Hash) *big.Int
GetTdByHash retrieves a block's total difficulty in the canonical chain from the database by hash, caching it if found.
func (*HeaderChain) HasHeader ¶
func (hc *HeaderChain) HasHeader(hash common.Hash, number uint64) bool
HasHeader checks if a block header is present in the database or not.
func (*HeaderChain) InsertHeaderChain ¶
func (hc *HeaderChain) InsertHeaderChain(chain []*types.Header, writeHeader WhCallback, start time.Time) (int, error)
InsertHeaderChain attempts to insert the given header chain in to the local chain, possibly creating a reorg. If an error is returned, it will return the index number of the failing header as well an error describing what went wrong.
The verify parameter can be used to fine tune whether nonce verification should be done or not. The reason behind the optional check is because some of the header retrieval mechanisms already need to verfy nonces, as well as because nonces can be verified sparsely, not needing to check each.
func (*HeaderChain) SetCurrentHeader ¶
func (hc *HeaderChain) SetCurrentHeader(head *types.Header)
SetCurrentHeader sets the current head header of the canonical chain.
func (*HeaderChain) SetGenesis ¶
func (hc *HeaderChain) SetGenesis(head *types.Header)
SetGenesis sets a new genesis block header for the chain
func (*HeaderChain) SetHead ¶
func (hc *HeaderChain) SetHead(head uint64, updateFn UpdateHeadBlocksCallback, delFn DeleteBlockContentCallback)
SetHead rewinds the local chain to a new head. Everything above the new head will be deleted and the new one set.
func (*HeaderChain) ValidateHeaderChain ¶
func (*HeaderChain) WriteHeader ¶
func (hc *HeaderChain) WriteHeader(header *types.Header) (status WriteStatus, err error)
WriteHeader writes a header into the local chain, given that its parent is already known. If the total difficulty of the newly inserted header becomes greater than the current known TD, the canonical chain is re-routed.
Note: This method is not concurrent-safe with inserting blocks simultaneously into the chain, as side effects caused by reorganisations cannot be emulated without the real blocks. Hence, writing headers directly should only be done in two scenarios: pure-header mode of operation (light clients), or properly separated header/block phases (non-archive clients).
type Message ¶
type Message interface { From() common.Address //FromFrontier() (common.Address, error) To() *common.Address GasPrice() *big.Int Gas() uint64 Value() *big.Int Nonce() uint64 CheckNonce() bool Data() []byte }
Message represents a message sent to a contract.
type NewMinedBlockEvent ¶
NewMinedBlockEvent is posted when a block has been imported.
type NewTxsEvent ¶
type NewTxsEvent struct{ Txs []*types.Transaction }
NewTxsEvent is posted when a batch of transactions enter the transaction pool.
type ParallelContext ¶
type ParallelContext struct {
// contains filtered or unexported fields
}
func NewParallelContext ¶
func (*ParallelContext) AddGasPool ¶
func (ctx *ParallelContext) AddGasPool(amount uint64)
func (*ParallelContext) AddPackedTx ¶
func (ctx *ParallelContext) AddPackedTx(tx *types.Transaction)
func (*ParallelContext) AddReceipt ¶
func (ctx *ParallelContext) AddReceipt(receipt *types.Receipt)
func (*ParallelContext) CumulateBlockGasUsed ¶
func (ctx *ParallelContext) CumulateBlockGasUsed(txGasUsed uint64)
func (*ParallelContext) GetBlockGasUsed ¶
func (ctx *ParallelContext) GetBlockGasUsed() uint64
func (*ParallelContext) GetBlockGasUsedHolder ¶
func (ctx *ParallelContext) GetBlockGasUsedHolder() *uint64
func (*ParallelContext) GetBlockHash ¶
func (ctx *ParallelContext) GetBlockHash() common.Hash
func (*ParallelContext) GetGasPool ¶
func (ctx *ParallelContext) GetGasPool() *GasPool
func (*ParallelContext) GetHeader ¶
func (ctx *ParallelContext) GetHeader() *types.Header
func (*ParallelContext) GetLogs ¶
func (ctx *ParallelContext) GetLogs() []*types.Log
func (*ParallelContext) GetPackedTxList ¶
func (ctx *ParallelContext) GetPackedTxList() []*types.Transaction
func (*ParallelContext) GetReceipts ¶
func (ctx *ParallelContext) GetReceipts() types.Receipts
func (*ParallelContext) GetResults ¶
func (ctx *ParallelContext) GetResults() []*Result
func (*ParallelContext) GetState ¶
func (ctx *ParallelContext) GetState() *state.StateDB
func (*ParallelContext) GetTx ¶
func (ctx *ParallelContext) GetTx(idx int) *types.Transaction
func (*ParallelContext) GetTxList ¶
func (ctx *ParallelContext) GetTxList() []*types.Transaction
func (*ParallelContext) SetBlockGasUsedHolder ¶
func (ctx *ParallelContext) SetBlockGasUsedHolder(blockGasUsedHolder *uint64)
func (*ParallelContext) SetResult ¶
func (ctx *ParallelContext) SetResult(idx int, result *Result)
func (*ParallelContext) SetTxList ¶
func (ctx *ParallelContext) SetTxList(txs []*types.Transaction)
type ParallelStateProcessor ¶
type ParallelStateProcessor struct {
// contains filtered or unexported fields
}
func NewParallelStateProcessor ¶
func NewParallelStateProcessor(config *params.ChainConfig, bc *BlockChain, engine consensus.Engine) *ParallelStateProcessor
type PendingLogsEvent ¶
PendingLogsEvent is posted pre mining and notifies of pending logs.
type Prefetcher ¶
type Prefetcher interface { // Prefetch processes the state changes according to the Ethereum rules by running // the transaction messages using the statedb, but any changes are discarded. The // only goal is to pre-cache transaction signatures and state trie nodes. Prefetch(block *types.Block, statedb *state.StateDB, cfg vm.Config, interrupt *uint32) }
Prefetcher is an interface for pre-caching transaction signatures and state.
type Processor ¶
type Processor interface { // Process processes the state changes according to the Ethereum rules by running // the transaction messages using the statedb and applying any rewards to both // the processor (coinbase) and any included uncles. Process(block *types.Block, statedb *state.StateDB, cfg vm.Config) (*types.Header, types.Receipts, []*types.Log, uint64, error) }
Processor is an interface for processing blocks using a given initial state.
type RemovedLogsEvent ¶
RemovedLogsEvent is posted when a reorg happens
type StateProcessor ¶
type StateProcessor struct {
// contains filtered or unexported fields
}
StateProcessor is a basic Processor, which takes care of transitioning state from one point to another.
StateProcessor implements Processor.
func NewStateProcessor ¶
func NewStateProcessor(config *params.ChainConfig, bc *BlockChain, engine consensus.Engine) *StateProcessor
NewStateProcessor initialises a new StateProcessor.
func (*StateProcessor) Process ¶
func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg vm.Config) (*types.Header, types.Receipts, []*types.Log, uint64, error)
Process processes the state changes according to the Ethereum rules by running the transaction messages using the statedb and applying any rewards to both the processor (coinbase) and any included uncles.
Process returns the receipts and logs accumulated during the process and returns the amount of gas that was used in the process. If any of the transactions failed to execute due to insufficient gas it will return an error.
type StateTransition ¶
type StateTransition struct {
// contains filtered or unexported fields
}
The State Transitioning Model
A state transition is a change made when a transaction is applied to the current world state The state transitioning model does all the necessary work to work out a valid new state root.
1) Nonce handling 2) Pre pay gas 3) Create a new state object if the recipient is \0*32 4) Value transfer == If contract creation ==
4a) Attempt to run transaction data 4b) If valid, use result as code for the new state object
== end == 5) Run Script section 6) Derive new state root
func NewStateTransition ¶
func NewStateTransition(evm *vm.EVM, msg Message, gp *GasPool) *StateTransition
NewStateTransition initialises and returns a new state transition object.
func (*StateTransition) TransitionDb ¶
func (st *StateTransition) TransitionDb() (ret []byte, usedGas uint64, failed bool, err error)
TransitionDb will transition the state by applying the current message and returning the result including the used gas. It returns an error if failed. An error indicates a consensus issue.
type TxDag ¶
type TxDag struct {
// contains filtered or unexported fields
}
func (*TxDag) IsContract ¶
func (*TxDag) MakeDagGraph ¶
type TxPool ¶
type TxPool struct {
// contains filtered or unexported fields
}
TxPool contains all currently known transactions. Transactions enter the pool when they are received from the network or submitted locally. They exit the pool when they are included in the blockchain.
The pool separates processable transactions (which can be applied to the current state) and future transactions. Transactions move between those two states over time as they are received and processed.
func NewTxPool ¶
func NewTxPool(config TxPoolConfig, chainconfig *params.ChainConfig, chain blockChain) *TxPool
NewTxPool creates a new transaction pool to gather, sort and filter inbound transactions from the network.
func (*TxPool) AddLocal ¶
func (pool *TxPool) AddLocal(tx *types.Transaction) error
AddLocal enqueues a single local transaction into the pool if it is valid. This is a convenience wrapper aroundd AddLocals.
func (*TxPool) AddLocals ¶
func (pool *TxPool) AddLocals(txs []*types.Transaction) []error
AddLocals enqueues a batch of transactions into the pool if they are valid, marking the senders as a local ones, ensuring they go around the local pricing constraints.
This method is used to add transactions from the RPC API and performs synchronous pool reorganization and event propagation.
func (*TxPool) AddRemote
deprecated
func (pool *TxPool) AddRemote(tx *types.Transaction) error
AddRemote enqueues a single transaction into the pool if it is valid. This is a convenience wrapper around AddRemotes.
Deprecated: use AddRemotes
func (*TxPool) AddRemoteSync ¶
func (pool *TxPool) AddRemoteSync(tx *types.Transaction) error
func (*TxPool) AddRemotes ¶
func (pool *TxPool) AddRemotes(txs []*types.Transaction) []error
AddRemotes enqueues a batch of transactions into the pool if they are valid. If the senders are not among the locally tracked ones, full pricing constraints will apply.
This method is used to add transactions from the p2p network and does not wait for pool reorganization and internal event propagation.
func (*TxPool) AddRemotesSync ¶
func (pool *TxPool) AddRemotesSync(txs []*types.Transaction) []error
This is like AddRemotes, but waits for pool reorganization. Tests use this method.
func (*TxPool) CheckAndSetSender ¶
func (*TxPool) Content ¶
func (pool *TxPool) Content() (map[common.Address]types.Transactions, map[common.Address]types.Transactions)
Content retrieves the data content of the transaction pool, returning all the pending as well as queued transactions, grouped by account and sorted by nonce.
func (*TxPool) Get ¶
func (pool *TxPool) Get(hash common.Hash) *types.Transaction
Get returns a transaction if it is contained in the pool and nil otherwise.
func (*TxPool) InitLightBlock ¶
func (pool *TxPool) InitLightBlock(pb *types.LightBlock) bool
func (*TxPool) Nonce ¶
Nonce returns the next nonce of an account, with all transactions executable by the pool already applied on top.
func (*TxPool) Pending ¶
Pending retrieves all currently processable transactions, grouped by origin account and sorted by nonce. The returned transaction set is a copy and can be freely modified by calling code.
func (*TxPool) SetGasPrice ¶
SetGasPrice updates the minimum price required by the transaction pool for a new transaction, and drops all transactions below this threshold.
func (*TxPool) Stats ¶
Stats retrieves the current pool stats, namely the number of pending and the number of queued (non-executable) transactions.
func (*TxPool) Status ¶
Status returns the status (unknown/pending/queued) of a batch of transactions identified by their hashes.
func (*TxPool) SubscribeNewTxsEvent ¶
func (pool *TxPool) SubscribeNewTxsEvent(ch chan<- NewTxsEvent) event.Subscription
SubscribeNewTxsEvent registers a subscription of NewTxsEvent and starts sending event to the given channel.
func (*TxPool) SubscribeSyncTxsEvent ¶
func (pool *TxPool) SubscribeSyncTxsEvent(chan<- NewTxsEvent) event.Subscription
type TxPoolConfig ¶
type TxPoolConfig struct { Locals []common.Address // Addresses that should be treated by default as local NoLocals bool // Whether local transaction handling should be disabled Journal string // Journal of local transactions to survive node restarts Rejournal time.Duration // Time interval to regenerate the local transaction journal PriceLimit uint64 // Minimum gas price to enforce for acceptance into the pool PriceBump uint64 // Minimum price bump percentage to replace an already existing transaction (nonce) AccountSlots uint64 // Number of executable transaction slots guaranteed per account GlobalSlots uint64 // Maximum number of executable transaction slots for all accounts AccountQueue uint64 // Maximum number of non-executable transaction slots permitted per account GlobalQueue uint64 // Maximum number of non-executable transaction slots for all accounts Lifetime time.Duration // Maximum amount of time non-executable transaction are queued }
TxPoolConfig are the configuration parameters of the transaction pool.
type TxStatus ¶
type TxStatus uint
TxStatus is the current status of a transaction as seen by the pool.
type UpdateHeadBlocksCallback ¶
type UpdateHeadBlocksCallback func(ethdb.KeyValueWriter, *types.Header)
UpdateHeadBlocksCallback is a callback function that is called by SetHead before head header is updated.
type Validator ¶
type Validator interface { // ValidateBody validates the given block's content. ValidateBody(block *types.Block) error // ValidateState validates the given statedb and optionally the receipts and // gas used. ValidateState(block *types.Block, state *state.StateDB, receipts types.Receipts, usedGas uint64) error }
Validator is an interface which defines the standard for block validation. It is only responsible for validating block contents, as the header validation is done by the specific consensus engines.
type WhCallback ¶
WhCallback is a callback function for inserting individual headers. A callback is used for two reasons: first, in a LightChain, status should be processed and light chain events sent, while in a BlockChain this is not necessary since chain events are sent after inserting blocks. Second, the header writes should be protected by the parent chain mutex individually.
type WriteStatus ¶
type WriteStatus byte
WriteStatus status of write
const ( NonStatTy WriteStatus = iota CanonStatTy SideStatTy )
Source Files ¶
- block_validator.go
- blockchain.go
- blockchain_cache.go
- blockchain_insert.go
- blocks.go
- chain_indexer.go
- chain_makers.go
- error.go
- events.go
- evm.go
- gaspool.go
- gen_genesis.go
- gen_genesis_account.go
- genesis.go
- genesis_alloc.go
- headerchain.go
- parallel_context.go
- parallel_executor.go
- parallel_state_processor.go
- parallel_tx_dag.go
- state_prefetcher.go
- state_processor.go
- state_transition.go
- tx_cacher.go
- tx_journal.go
- tx_list.go
- tx_lookup.go
- tx_noncer.go
- tx_pool.go
- tx_pool_shared.go
- tx_processor.go
- types.go
Directories ¶
Path | Synopsis |
---|---|
crypto/hibe/hibe_amd64/hibe
Package hibe implements the cryptosystem described in the paper "Hierarchical Identity Based Encyprtion with Constant Size Ciphertext" by Boneh, Boyen, and Goh.
|
Package hibe implements the cryptosystem described in the paper "Hierarchical Identity Based Encyprtion with Constant Size Ciphertext" by Boneh, Boyen, and Goh. |
crypto/hibe/hibe_amd64/hibe/bn256
Package bn256 implements a particular bilinear group at the 128-bit security level.
|
Package bn256 implements a particular bilinear group at the 128-bit security level. |
crypto/hibe/hibe_noamd64/hibe
Package hibe implements the cryptosystem described in the paper "Hierarchical Identity Based Encyprtion with Constant Size Ciphertext" by Boneh, Boyen, and Goh.
|
Package hibe implements the cryptosystem described in the paper "Hierarchical Identity Based Encyprtion with Constant Size Ciphertext" by Boneh, Boyen, and Goh. |
crypto/hibe/hibe_noamd64/hibe/bn256
Package bn256 implements a particular bilinear group.
|
Package bn256 implements a particular bilinear group. |
crypto/tls
Package tls partially implements TLS 1.2, as specified in RFC 5246, and TLS 1.3, as specified in RFC 8446.
|
Package tls partially implements TLS 1.2, as specified in RFC 5246, and TLS 1.3, as specified in RFC 8446. |
Provides support for dealing with EVM assembly instructions (e.g., disassembling them).
|
Provides support for dealing with EVM assembly instructions (e.g., disassembling them). |
Package bloombits implements bloom filtering on batches of data.
|
Package bloombits implements bloom filtering on batches of data. |
Package forkid implements EIP-2124 (https://eips.ethereum.org/EIPS/eip-2124).
|
Package forkid implements EIP-2124 (https://eips.ethereum.org/EIPS/eip-2124). |
Package rawdb contains a collection of low level database accessors.
|
Package rawdb contains a collection of low level database accessors. |
Package state provides a caching layer atop the Ethereum state trie.
|
Package state provides a caching layer atop the Ethereum state trie. |
Package types contains data types related to Ethereum consensus.
|
Package types contains data types related to Ethereum consensus. |
Package vm implements the Ethereum Virtual Machine.
|
Package vm implements the Ethereum Virtual Machine. |
runtime
Package runtime provides a basic execution model for executing EVM code.
|
Package runtime provides a basic execution model for executing EVM code. |