mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 14:46:42 +00:00
Fix typos
This commit is contained in:
parent
fa86416ce9
commit
ff6bb7ac13
30 changed files with 58 additions and 58 deletions
|
|
@ -218,7 +218,7 @@ type txLookup struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// BlockChain represents the canonical chain given a database with a genesis
|
// BlockChain represents the canonical chain given a database with a genesis
|
||||||
// block. The Blockchain manages chain imports, reverts, chain reorganisations.
|
// block. The Blockchain manages chain imports, reverts, chain reorganizations.
|
||||||
//
|
//
|
||||||
// Importing blocks in to the block chain happens according to the set of rules
|
// 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
|
// defined by the two stage Validator. Processing of blocks is done using the
|
||||||
|
|
@ -287,8 +287,8 @@ type BlockChain struct {
|
||||||
lastForkReadyAlert time.Time // Last time there was a fork readiness print out
|
lastForkReadyAlert time.Time // Last time there was a fork readiness print out
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewBlockChain returns a fully initialised block chain using information
|
// NewBlockChain returns a fully initialized block chain using information
|
||||||
// available in the database. It initialises the default Ethereum Validator
|
// available in the database. It initializes the default Ethereum Validator
|
||||||
// and Processor.
|
// and Processor.
|
||||||
func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis *Genesis, overrides *ChainOverrides, engine consensus.Engine, vmConfig vm.Config, txLookupLimit *uint64) (*BlockChain, error) {
|
func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis *Genesis, overrides *ChainOverrides, engine consensus.Engine, vmConfig vm.Config, txLookupLimit *uint64) (*BlockChain, error) {
|
||||||
if cacheConfig == nil {
|
if cacheConfig == nil {
|
||||||
|
|
@ -916,7 +916,7 @@ func (bc *BlockChain) setHeadBeyondRoot(head uint64, time uint64, root common.Ha
|
||||||
rootNumber uint64 // (no root == always 0)
|
rootNumber uint64 // (no root == always 0)
|
||||||
|
|
||||||
// Retrieve the last pivot block to short circuit rollbacks beyond it
|
// Retrieve the last pivot block to short circuit rollbacks beyond it
|
||||||
// and the current freezer limit to start nuking it's underflown.
|
// and the current freezer limit to start nuking it's underflow.
|
||||||
pivot = rawdb.ReadLastPivotNumber(bc.db)
|
pivot = rawdb.ReadLastPivotNumber(bc.db)
|
||||||
)
|
)
|
||||||
updateFn := func(db ethdb.KeyValueWriter, header *types.Header) (*types.Header, bool) {
|
updateFn := func(db ethdb.KeyValueWriter, header *types.Header) (*types.Header, bool) {
|
||||||
|
|
@ -967,7 +967,7 @@ func (bc *BlockChain) setHeadBeyondRoot(head uint64, time uint64, root common.Ha
|
||||||
headHeader = bc.CurrentBlock()
|
headHeader = bc.CurrentBlock()
|
||||||
headNumber = headHeader.Number.Uint64()
|
headNumber = headHeader.Number.Uint64()
|
||||||
)
|
)
|
||||||
// If setHead underflown the freezer threshold and the block processing
|
// If setHead underflow the freezer threshold and the block processing
|
||||||
// intent afterwards is full block importing, delete the chain segment
|
// intent afterwards is full block importing, delete the chain segment
|
||||||
// between the stateful-block and the sethead target.
|
// between the stateful-block and the sethead target.
|
||||||
var wipe bool
|
var wipe bool
|
||||||
|
|
@ -1085,7 +1085,7 @@ func (bc *BlockChain) ResetWithGenesisBlock(genesis *types.Block) error {
|
||||||
}
|
}
|
||||||
defer bc.chainmu.Unlock()
|
defer bc.chainmu.Unlock()
|
||||||
|
|
||||||
// Prepare the genesis block and reinitialise the chain
|
// Prepare the genesis block and reinitialize the chain
|
||||||
batch := bc.db.NewBatch()
|
batch := bc.db.NewBatch()
|
||||||
rawdb.WriteBlock(batch, genesis)
|
rawdb.WriteBlock(batch, genesis)
|
||||||
if err := batch.Write(); err != nil {
|
if err := batch.Write(); err != nil {
|
||||||
|
|
@ -1596,7 +1596,7 @@ func (bc *BlockChain) writeBlockAndSetHead(block *types.Block, receipts []*types
|
||||||
}
|
}
|
||||||
currentBlock := bc.CurrentBlock()
|
currentBlock := bc.CurrentBlock()
|
||||||
|
|
||||||
// Reorganise the chain if the parent is not the head block
|
// Reorganize the chain if the parent is not the head block
|
||||||
if block.ParentHash() != currentBlock.Hash() {
|
if block.ParentHash() != currentBlock.Hash() {
|
||||||
if err := bc.reorg(currentBlock, block.Header()); err != nil {
|
if err := bc.reorg(currentBlock, block.Header()); err != nil {
|
||||||
return NonStatTy, err
|
return NonStatTy, err
|
||||||
|
|
@ -1661,7 +1661,7 @@ func (bc *BlockChain) InsertChain(chain types.Blocks) (int, error) {
|
||||||
//
|
//
|
||||||
// This method is split out so that import batches that require re-injecting
|
// This method is split out so that import batches that require re-injecting
|
||||||
// historical blocks can do so without releasing the lock, which could lead to
|
// historical blocks can do so without releasing the lock, which could lead to
|
||||||
// racey behaviour. If a sidechain import is in progress, and the historic state
|
// racey behavior. If a sidechain import is in progress, and the historic state
|
||||||
// is imported, but then new canon-head is added before the actual sidechain
|
// is imported, but then new canon-head is added before the actual sidechain
|
||||||
// completes, then the historic state could be pruned again
|
// completes, then the historic state could be pruned again
|
||||||
func (bc *BlockChain) insertChain(chain types.Blocks, setHead bool, makeWitness bool) (*stateless.Witness, int, error) {
|
func (bc *BlockChain) insertChain(chain types.Blocks, setHead bool, makeWitness bool) (*stateless.Witness, int, error) {
|
||||||
|
|
|
||||||
|
|
@ -785,7 +785,7 @@ func testLongShallowSetHead(t *testing.T, snapshots bool) {
|
||||||
// Tests a sethead for a long canonical chain with frozen blocks where a recent
|
// Tests a sethead for a long canonical chain with frozen blocks where a recent
|
||||||
// block - older than the ancient limit - was already committed to disk and then
|
// block - older than the ancient limit - was already committed to disk and then
|
||||||
// sethead was called. In this case we expect the full chain to be rolled back
|
// sethead was called. In this case we expect the full chain to be rolled back
|
||||||
// to the committed block. Since the ancient limit was underflown, everything
|
// to the committed block. Since the ancient limit was underflow, everything
|
||||||
// needs to be deleted onwards to avoid creating a gap.
|
// needs to be deleted onwards to avoid creating a gap.
|
||||||
func TestLongDeepSetHead(t *testing.T) { testLongDeepSetHead(t, false) }
|
func TestLongDeepSetHead(t *testing.T) { testLongDeepSetHead(t, false) }
|
||||||
func TestLongDeepSetHeadWithSnapshots(t *testing.T) { testLongDeepSetHead(t, true) }
|
func TestLongDeepSetHeadWithSnapshots(t *testing.T) { testLongDeepSetHead(t, true) }
|
||||||
|
|
@ -883,7 +883,7 @@ func testLongSnapSyncedShallowSetHead(t *testing.T, snapshots bool) {
|
||||||
// Tests a sethead for a long canonical chain with frozen blocks where the fast
|
// Tests a sethead for a long canonical chain with frozen blocks where the fast
|
||||||
// sync pivot point - older than the ancient limit - was already committed, after
|
// sync pivot point - older than the ancient limit - was already committed, after
|
||||||
// which sethead was called. In this case we expect the full chain to be rolled
|
// which sethead was called. In this case we expect the full chain to be rolled
|
||||||
// back to the committed block. Since the ancient limit was underflown, everything
|
// back to the committed block. Since the ancient limit was underflow, everything
|
||||||
// needs to be deleted onwards to avoid creating a gap.
|
// needs to be deleted onwards to avoid creating a gap.
|
||||||
func TestLongSnapSyncedDeepSetHead(t *testing.T) { testLongSnapSyncedDeepSetHead(t, false) }
|
func TestLongSnapSyncedDeepSetHead(t *testing.T) { testLongSnapSyncedDeepSetHead(t, false) }
|
||||||
func TestLongSnapSyncedDeepSetHeadWithSnapshots(t *testing.T) { testLongSnapSyncedDeepSetHead(t, true) }
|
func TestLongSnapSyncedDeepSetHeadWithSnapshots(t *testing.T) { testLongSnapSyncedDeepSetHead(t, true) }
|
||||||
|
|
@ -1085,7 +1085,7 @@ func testLongOldForkedShallowSetHead(t *testing.T, snapshots bool) {
|
||||||
// chain, where a recent block - older than the ancient limit - was already committed
|
// chain, where a recent block - older than the ancient limit - was already committed
|
||||||
// to disk and then sethead was called. In this case we expect the canonical full
|
// to disk and then sethead was called. In this case we expect the canonical full
|
||||||
// chain to be rolled back to the committed block. Since the ancient limit was
|
// chain to be rolled back to the committed block. Since the ancient limit was
|
||||||
// underflown, everything needs to be deleted onwards to avoid creating a gap. The
|
// underflow, everything needs to be deleted onwards to avoid creating a gap. The
|
||||||
// side chain is nuked by the freezer.
|
// side chain is nuked by the freezer.
|
||||||
func TestLongOldForkedDeepSetHead(t *testing.T) { testLongOldForkedDeepSetHead(t, false) }
|
func TestLongOldForkedDeepSetHead(t *testing.T) { testLongOldForkedDeepSetHead(t, false) }
|
||||||
func TestLongOldForkedDeepSetHeadWithSnapshots(t *testing.T) { testLongOldForkedDeepSetHead(t, true) }
|
func TestLongOldForkedDeepSetHeadWithSnapshots(t *testing.T) { testLongOldForkedDeepSetHead(t, true) }
|
||||||
|
|
@ -1189,7 +1189,7 @@ func testLongOldForkedSnapSyncedShallowSetHead(t *testing.T, snapshots bool) {
|
||||||
// was already committed to disk and then sethead was called. In this test scenario
|
// was already committed to disk and then sethead was called. In this test scenario
|
||||||
// the side chain is below the committed block. In this case we expect the canonical
|
// the side chain is below the committed block. In this case we expect the canonical
|
||||||
// full chain to be rolled back to the committed block. Since the ancient limit was
|
// full chain to be rolled back to the committed block. Since the ancient limit was
|
||||||
// underflown, everything needs to be deleted onwards to avoid creating a gap. The
|
// underflow, everything needs to be deleted onwards to avoid creating a gap. The
|
||||||
// side chain is nuked by the freezer.
|
// side chain is nuked by the freezer.
|
||||||
func TestLongOldForkedSnapSyncedDeepSetHead(t *testing.T) {
|
func TestLongOldForkedSnapSyncedDeepSetHead(t *testing.T) {
|
||||||
testLongOldForkedSnapSyncedDeepSetHead(t, false)
|
testLongOldForkedSnapSyncedDeepSetHead(t, false)
|
||||||
|
|
|
||||||
|
|
@ -183,7 +183,7 @@ func testHeaderChainImport(chain []*types.Header, blockchain *BlockChain) error
|
||||||
if err := blockchain.engine.VerifyHeader(blockchain, header); err != nil {
|
if err := blockchain.engine.VerifyHeader(blockchain, header); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// Manually insert the header into the database, but don't reorganise (allows subsequent testing)
|
// Manually insert the header into the database, but don't reorganize (allows subsequent testing)
|
||||||
blockchain.chainmu.MustLock()
|
blockchain.chainmu.MustLock()
|
||||||
rawdb.WriteHeader(blockchain.db, header)
|
rawdb.WriteHeader(blockchain.db, header)
|
||||||
blockchain.chainmu.Unlock()
|
blockchain.chainmu.Unlock()
|
||||||
|
|
@ -521,7 +521,7 @@ func testBrokenChain(t *testing.T, full bool, scheme string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tests that reorganising a long difficult chain after a short easy one
|
// Tests that reorganizing a long difficult chain after a short easy one
|
||||||
// overwrites the canonical numbers and links in the database.
|
// overwrites the canonical numbers and links in the database.
|
||||||
func TestReorgLongHeaders(t *testing.T) {
|
func TestReorgLongHeaders(t *testing.T) {
|
||||||
testReorgLong(t, false, rawdb.HashScheme)
|
testReorgLong(t, false, rawdb.HashScheme)
|
||||||
|
|
@ -536,7 +536,7 @@ func testReorgLong(t *testing.T, full bool, scheme string) {
|
||||||
testReorg(t, []int64{0, 0, -9}, []int64{0, 0, 0, -9}, 393280+params.GenesisDifficulty.Int64(), full, scheme)
|
testReorg(t, []int64{0, 0, -9}, []int64{0, 0, 0, -9}, 393280+params.GenesisDifficulty.Int64(), full, scheme)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tests that reorganising a short difficult chain after a long easy one
|
// Tests that reorganizing a short difficult chain after a long easy one
|
||||||
// overwrites the canonical numbers and links in the database.
|
// overwrites the canonical numbers and links in the database.
|
||||||
func TestReorgShortHeaders(t *testing.T) {
|
func TestReorgShortHeaders(t *testing.T) {
|
||||||
testReorgShort(t, false, rawdb.HashScheme)
|
testReorgShort(t, false, rawdb.HashScheme)
|
||||||
|
|
@ -913,7 +913,7 @@ func testLightVsFastVsFullChainHeads(t *testing.T, scheme string) {
|
||||||
assert(t, "light", light, height/2, 0, 0)
|
assert(t, "light", light, height/2, 0, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tests that chain reorganisations handle transaction removals and reinsertions.
|
// Tests that chain reorganizations handle transaction removals and reinsertions.
|
||||||
func TestChainTxReorgs(t *testing.T) {
|
func TestChainTxReorgs(t *testing.T) {
|
||||||
testChainTxReorgs(t, rawdb.HashScheme)
|
testChainTxReorgs(t, rawdb.HashScheme)
|
||||||
testChainTxReorgs(t, rawdb.PathScheme)
|
testChainTxReorgs(t, rawdb.PathScheme)
|
||||||
|
|
|
||||||
|
|
@ -439,7 +439,7 @@ func (m *singleMatcherInstance) cleanMapIndices() {
|
||||||
m.mapIndices = m.mapIndices[:j]
|
m.mapIndices = m.mapIndices[:j]
|
||||||
}
|
}
|
||||||
|
|
||||||
// matchAny combinines a set of matchers and returns a match for every position
|
// matchAny combines a set of matchers and returns a match for every position
|
||||||
// where any of the underlying matchers signaled a match. A zero-length matchAny
|
// where any of the underlying matchers signaled a match. A zero-length matchAny
|
||||||
// acts as a "wild card" that signals a potential match at every position.
|
// acts as a "wild card" that signals a potential match at every position.
|
||||||
type matchAny []matcher
|
type matchAny []matcher
|
||||||
|
|
|
||||||
|
|
@ -121,7 +121,7 @@ func (fm *FilterMapsMatcherBackend) GetLogByLvIndex(ctx context.Context, lvIndex
|
||||||
return fm.f.getLogByLvIndex(lvIndex)
|
return fm.f.getLogByLvIndex(lvIndex)
|
||||||
}
|
}
|
||||||
|
|
||||||
// synced signals to the matcher that has triggered a synchronisation that it
|
// synced signals to the matcher that has triggered a synchronization that it
|
||||||
// has been finished and the log index is consistent with the chain head passed
|
// has been finished and the log index is consistent with the chain head passed
|
||||||
// as a parameter.
|
// as a parameter.
|
||||||
//
|
//
|
||||||
|
|
|
||||||
|
|
@ -240,7 +240,7 @@ func (hc *HeaderChain) WriteHeaders(headers []*types.Header) (int, error) {
|
||||||
// header as the chain head.
|
// header as the chain head.
|
||||||
//
|
//
|
||||||
// Note: This method is not concurrent-safe with inserting blocks simultaneously
|
// Note: This method is not concurrent-safe with inserting blocks simultaneously
|
||||||
// into the chain, as side effects caused by reorganisations cannot be emulated
|
// into the chain, as side effects caused by reorganizations cannot be emulated
|
||||||
// without the real blocks. Hence, writing headers directly should only be done
|
// without the real blocks. Hence, writing headers directly should only be done
|
||||||
// in two scenarios: pure-header mode of operation (light clients), or properly
|
// in two scenarios: pure-header mode of operation (light clients), or properly
|
||||||
// separated header/block phases (non-archive clients).
|
// separated header/block phases (non-archive clients).
|
||||||
|
|
@ -308,7 +308,7 @@ func (hc *HeaderChain) ValidateHeaderChain(chain []*types.Header) (int, error) {
|
||||||
return 0, nil
|
return 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// InsertHeaderChain inserts the given headers and does the reorganisations.
|
// InsertHeaderChain inserts the given headers and does the reorganizations.
|
||||||
//
|
//
|
||||||
// The validity of the headers is NOT CHECKED by this method, i.e. they need to be
|
// The validity of the headers is NOT CHECKED by this method, i.e. they need to be
|
||||||
// validated by ValidateHeaderChain before calling InsertHeaderChain.
|
// validated by ValidateHeaderChain before calling InsertHeaderChain.
|
||||||
|
|
|
||||||
|
|
@ -432,7 +432,7 @@ func DeleteBlockLvPointers(db ethdb.KeyValueStore, blocks common.Range[uint64],
|
||||||
}
|
}
|
||||||
|
|
||||||
// FilterMapsRange is a storage representation of the block range covered by the
|
// FilterMapsRange is a storage representation of the block range covered by the
|
||||||
// filter maps structure and the corresponting log value index range.
|
// filter maps structure and the corresponding log value index range.
|
||||||
type FilterMapsRange struct {
|
type FilterMapsRange struct {
|
||||||
Version uint32
|
Version uint32
|
||||||
HeadIndexed bool
|
HeadIndexed bool
|
||||||
|
|
|
||||||
|
|
@ -382,7 +382,7 @@ func TestFreezerCloseSync(t *testing.T) {
|
||||||
f, _ := newFreezerForTesting(t, map[string]freezerTableConfig{"a": {noSnappy: true}, "b": {noSnappy: true}})
|
f, _ := newFreezerForTesting(t, map[string]freezerTableConfig{"a": {noSnappy: true}, "b": {noSnappy: true}})
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
|
|
||||||
// Now, close and sync. This mimics the behaviour if the node is shut down,
|
// Now, close and sync. This mimics the behavior if the node is shut down,
|
||||||
// just as the chain freezer is writing.
|
// just as the chain freezer is writing.
|
||||||
// 1: thread-1: chain treezer writes, via freezeRange (holds lock)
|
// 1: thread-1: chain treezer writes, via freezeRange (holds lock)
|
||||||
// 2: thread-2: Close called, waits for write to finish
|
// 2: thread-2: Close called, waits for write to finish
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@ func copyFrom(srcPath, destPath string, offset uint64, before func(f *os.File) e
|
||||||
// openFreezerFileForAppend opens a freezer table file and seeks to the end
|
// openFreezerFileForAppend opens a freezer table file and seeks to the end
|
||||||
func openFreezerFileForAppend(filename string) (*os.File, error) {
|
func openFreezerFileForAppend(filename string) (*os.File, error) {
|
||||||
// Open the file without the O_APPEND flag
|
// Open the file without the O_APPEND flag
|
||||||
// because it has differing behaviour during Truncate operations
|
// because it has differing behavior during Truncate operations
|
||||||
// on different OS's
|
// on different OS's
|
||||||
file, err := os.OpenFile(filename, os.O_RDWR|os.O_CREATE, 0644)
|
file, err := os.OpenFile(filename, os.O_RDWR|os.O_CREATE, 0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ var (
|
||||||
// the bloom offsets are runtime constants which determines which part of the
|
// the bloom offsets are runtime constants which determines which part of the
|
||||||
// account/storage hash the hasher functions looks at, to determine the
|
// account/storage hash the hasher functions looks at, to determine the
|
||||||
// bloom key for an account/slot. This is randomized at init(), so that the
|
// bloom key for an account/slot. This is randomized at init(), so that the
|
||||||
// global population of nodes do not all display the exact same behaviour with
|
// global population of nodes do not all display the exact same behavior with
|
||||||
// regards to bloom content
|
// regards to bloom content
|
||||||
bloomAccountHasherOffset = 0
|
bloomAccountHasherOffset = 0
|
||||||
bloomStorageHasherOffset = 0
|
bloomStorageHasherOffset = 0
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
// weightedIterator is an iterator with an assigned weight. It is used to prioritise
|
// weightedIterator is an iterator with an assigned weight. It is used to prioritize
|
||||||
// which account or storage slot is the correct one if multiple iterators find the
|
// which account or storage slot is the correct one if multiple iterators find the
|
||||||
// same one (modified in multiple consecutive blocks).
|
// same one (modified in multiple consecutive blocks).
|
||||||
type weightedIterator struct {
|
type weightedIterator struct {
|
||||||
|
|
|
||||||
|
|
@ -233,7 +233,7 @@ func (s *stateObject) setState(key common.Hash, value common.Hash, origin common
|
||||||
s.dirtyStorage[key] = value
|
s.dirtyStorage[key] = value
|
||||||
}
|
}
|
||||||
|
|
||||||
// finalise moves all dirty storage slots into the pending area to be hashed or
|
// finalize moves all dirty storage slots into the pending area to be hashed or
|
||||||
// committed later. It is invoked at the end of every transaction.
|
// committed later. It is invoked at the end of every transaction.
|
||||||
func (s *stateObject) finalise() {
|
func (s *stateObject) finalise() {
|
||||||
slotsToPrefetch := make([]common.Hash, 0, len(s.dirtyStorage))
|
slotsToPrefetch := make([]common.Hash, 0, len(s.dirtyStorage))
|
||||||
|
|
|
||||||
|
|
@ -733,8 +733,8 @@ func (s *StateDB) GetRefund() uint64 {
|
||||||
return s.refund
|
return s.refund
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finalise finalises the state by removing the destructed objects and clears
|
// Finalize finalizes the state by removing the destructed objects and clears
|
||||||
// the journal as well as the refunds. Finalise, however, will not push any updates
|
// the journal as well as the refunds. Finalize, however, will not push any updates
|
||||||
// into the tries just yet. Only IntermediateRoot or Commit will do that.
|
// into the tries just yet. Only IntermediateRoot or Commit will do that.
|
||||||
func (s *StateDB) Finalise(deleteEmptyObjects bool) {
|
func (s *StateDB) Finalise(deleteEmptyObjects bool) {
|
||||||
addressesToPrefetch := make([]common.Address, 0, len(s.journal.dirties))
|
addressesToPrefetch := make([]common.Address, 0, len(s.journal.dirties))
|
||||||
|
|
@ -780,7 +780,7 @@ func (s *StateDB) Finalise(deleteEmptyObjects bool) {
|
||||||
// It is called in between transactions to get the root hash that
|
// It is called in between transactions to get the root hash that
|
||||||
// goes into transaction receipts.
|
// goes into transaction receipts.
|
||||||
func (s *StateDB) IntermediateRoot(deleteEmptyObjects bool) common.Hash {
|
func (s *StateDB) IntermediateRoot(deleteEmptyObjects bool) common.Hash {
|
||||||
// Finalise all the dirty storage states and write them into the tries
|
// Finalize all the dirty storage states and write them into the tries
|
||||||
s.Finalise(deleteEmptyObjects)
|
s.Finalise(deleteEmptyObjects)
|
||||||
|
|
||||||
// If there was a trie prefetcher operating, terminate it async so that the
|
// If there was a trie prefetcher operating, terminate it async so that the
|
||||||
|
|
|
||||||
|
|
@ -216,7 +216,7 @@ func (test *stateTest) run() bool {
|
||||||
for i, action := range actions {
|
for i, action := range actions {
|
||||||
if i%test.chunk == 0 && i != 0 {
|
if i%test.chunk == 0 && i != 0 {
|
||||||
if byzantium {
|
if byzantium {
|
||||||
state.Finalise(true) // call finalise at the transaction boundary
|
state.Finalise(true) // call finalize at the transaction boundary
|
||||||
} else {
|
} else {
|
||||||
state.IntermediateRoot(true) // call intermediateRoot at the transaction boundary
|
state.IntermediateRoot(true) // call intermediateRoot at the transaction boundary
|
||||||
}
|
}
|
||||||
|
|
@ -224,7 +224,7 @@ func (test *stateTest) run() bool {
|
||||||
action.fn(action, state)
|
action.fn(action, state)
|
||||||
}
|
}
|
||||||
if byzantium {
|
if byzantium {
|
||||||
state.Finalise(true) // call finalise at the transaction boundary
|
state.Finalise(true) // call finalize at the transaction boundary
|
||||||
} else {
|
} else {
|
||||||
state.IntermediateRoot(true) // call intermediateRoot at the transaction boundary
|
state.IntermediateRoot(true) // call intermediateRoot at the transaction boundary
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -196,7 +196,7 @@ func TestCopy(t *testing.T) {
|
||||||
ccopy.updateStateObject(copyObj)
|
ccopy.updateStateObject(copyObj)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finalise the changes on all concurrently
|
// Finalize the changes on all concurrently
|
||||||
finalise := func(wg *sync.WaitGroup, db *StateDB) {
|
finalise := func(wg *sync.WaitGroup, db *StateDB) {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
db.Finalise(true)
|
db.Finalise(true)
|
||||||
|
|
@ -320,7 +320,7 @@ func TestSnapshotRandom(t *testing.T) {
|
||||||
//
|
//
|
||||||
// A new state is created and all actions are applied to it. Several snapshots are taken
|
// A new state is created and all actions are applied to it. Several snapshots are taken
|
||||||
// in between actions. The test then reverts each snapshot. For each snapshot the actions
|
// in between actions. The test then reverts each snapshot. For each snapshot the actions
|
||||||
// leading up to it are replayed on a fresh, empty state. The behaviour of all public
|
// leading up to it are replayed on a fresh, empty state. The behavior of all public
|
||||||
// accessor methods on the reverted state must match the return value of the equivalent
|
// accessor methods on the reverted state must match the return value of the equivalent
|
||||||
// methods on the replayed state.
|
// methods on the replayed state.
|
||||||
type snapshotTest struct {
|
type snapshotTest struct {
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ type statePrefetcher struct {
|
||||||
chain *HeaderChain // Canonical block chain
|
chain *HeaderChain // Canonical block chain
|
||||||
}
|
}
|
||||||
|
|
||||||
// newStatePrefetcher initialises a new statePrefetcher.
|
// newStatePrefetcher initializes a new statePrefetcher.
|
||||||
func newStatePrefetcher(config *params.ChainConfig, chain *HeaderChain) *statePrefetcher {
|
func newStatePrefetcher(config *params.ChainConfig, chain *HeaderChain) *statePrefetcher {
|
||||||
return &statePrefetcher{
|
return &statePrefetcher{
|
||||||
config: config,
|
config: config,
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ type StateProcessor struct {
|
||||||
chain *HeaderChain // Canonical header chain
|
chain *HeaderChain // Canonical header chain
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewStateProcessor initialises a new StateProcessor.
|
// NewStateProcessor initializes a new StateProcessor.
|
||||||
func NewStateProcessor(config *params.ChainConfig, chain *HeaderChain) *StateProcessor {
|
func NewStateProcessor(config *params.ChainConfig, chain *HeaderChain) *StateProcessor {
|
||||||
return &StateProcessor{
|
return &StateProcessor{
|
||||||
config: config,
|
config: config,
|
||||||
|
|
|
||||||
|
|
@ -241,7 +241,7 @@ type stateTransition struct {
|
||||||
evm *vm.EVM
|
evm *vm.EVM
|
||||||
}
|
}
|
||||||
|
|
||||||
// newStateTransition initialises and returns a new state transition object.
|
// newStateTransition initializes and returns a new state transition object.
|
||||||
func newStateTransition(evm *vm.EVM, msg *Message, gp *GasPool) *stateTransition {
|
func newStateTransition(evm *vm.EVM, msg *Message, gp *GasPool) *stateTransition {
|
||||||
return &stateTransition{
|
return &stateTransition{
|
||||||
gp: gp,
|
gp: gp,
|
||||||
|
|
@ -580,7 +580,7 @@ func (st *stateTransition) validateAuthorization(auth *types.SetCodeAuthorizatio
|
||||||
return authority, fmt.Errorf("%w: %v", ErrAuthorizationInvalidSignature, err)
|
return authority, fmt.Errorf("%w: %v", ErrAuthorizationInvalidSignature, err)
|
||||||
}
|
}
|
||||||
// Check the authority account
|
// Check the authority account
|
||||||
// 1) doesn't have code or has exisiting delegation
|
// 1) doesn't have code or has existing delegation
|
||||||
// 2) matches the auth's nonce
|
// 2) matches the auth's nonce
|
||||||
//
|
//
|
||||||
// Note it is added to the access list even if the authorization is invalid.
|
// Note it is added to the access list even if the authorization is invalid.
|
||||||
|
|
|
||||||
|
|
@ -134,7 +134,7 @@ func newBlobTxMeta(id uint64, size uint64, storageSize uint32, tx *types.Transac
|
||||||
//
|
//
|
||||||
// Blob transactions are special snowflakes that are designed for a very specific
|
// Blob transactions are special snowflakes that are designed for a very specific
|
||||||
// purpose (rollups) and are expected to adhere to that specific use case. These
|
// purpose (rollups) and are expected to adhere to that specific use case. These
|
||||||
// behavioural expectations allow us to design a transaction pool that is more robust
|
// behavioral expectations allow us to design a transaction pool that is more robust
|
||||||
// (i.e. resending issues) and more resilient to DoS attacks (e.g. replace-flush
|
// (i.e. resending issues) and more resilient to DoS attacks (e.g. replace-flush
|
||||||
// attacks) than the generic tx pool. These improvements will also mean, however,
|
// attacks) than the generic tx pool. These improvements will also mean, however,
|
||||||
// that we enforce a significantly more aggressive strategy on entering and exiting
|
// that we enforce a significantly more aggressive strategy on entering and exiting
|
||||||
|
|
@ -193,7 +193,7 @@ func newBlobTxMeta(id uint64, size uint64, storageSize uint32, tx *types.Transac
|
||||||
// are immediately evicted from the pool since they are contained in the
|
// are immediately evicted from the pool since they are contained in the
|
||||||
// including block. Blobs however are not included in the execution chain,
|
// including block. Blobs however are not included in the execution chain,
|
||||||
// so a mini reorg cannot re-pool "lost" blob transactions. To support reorgs,
|
// so a mini reorg cannot re-pool "lost" blob transactions. To support reorgs,
|
||||||
// blobs are retained on disk until they are finalised.
|
// blobs are retained on disk until they are finalized.
|
||||||
//
|
//
|
||||||
// - Blobs can arrive via flashbots. Blocks might contain blob transactions we
|
// - Blobs can arrive via flashbots. Blocks might contain blob transactions we
|
||||||
// have never seen on the network. Since we cannot recover them from blocks
|
// have never seen on the network. Since we cannot recover them from blocks
|
||||||
|
|
@ -288,7 +288,7 @@ func newBlobTxMeta(id uint64, size uint64, storageSize uint32, tx *types.Transac
|
||||||
//
|
//
|
||||||
// priority = min(deltaBasefee, deltaBlobfee, 0)
|
// priority = min(deltaBasefee, deltaBlobfee, 0)
|
||||||
//
|
//
|
||||||
// Optimisation tradeoffs:
|
// Optimization tradeoffs:
|
||||||
//
|
//
|
||||||
// - Eviction relies on 3 fee minimums per account (exec tip, exec cap and blob
|
// - Eviction relies on 3 fee minimums per account (exec tip, exec cap and blob
|
||||||
// cap). Maintaining these values across all transactions from the account is
|
// cap). Maintaining these values across all transactions from the account is
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type txMetadata struct {
|
type txMetadata struct {
|
||||||
id uint64 // the billy id of transction
|
id uint64 // the billy id of transaction
|
||||||
size uint64 // the RLP encoded size of transaction (blobs are included)
|
size uint64 // the RLP encoded size of transaction (blobs are included)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -814,7 +814,7 @@ func TestPostponing(t *testing.T) {
|
||||||
if pool.all.Count() != len(txs) {
|
if pool.all.Count() != len(txs) {
|
||||||
t.Errorf("total transaction mismatch: have %d, want %d", pool.all.Count(), len(txs))
|
t.Errorf("total transaction mismatch: have %d, want %d", pool.all.Count(), len(txs))
|
||||||
}
|
}
|
||||||
// Reduce the balance of the account, and check that transactions are reorganised
|
// Reduce the balance of the account, and check that transactions are reorganized
|
||||||
for _, addr := range accs {
|
for _, addr := range accs {
|
||||||
testAddBalance(pool, addr, big.NewInt(-1))
|
testAddBalance(pool, addr, big.NewInt(-1))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -109,7 +109,7 @@ func (m *SortedMap) Forward(threshold uint64) types.Transactions {
|
||||||
|
|
||||||
// Filter iterates over the list of transactions and removes all of them for which
|
// Filter iterates over the list of transactions and removes all of them for which
|
||||||
// the specified function evaluates to true.
|
// the specified function evaluates to true.
|
||||||
// Filter, as opposed to 'filter', re-initialises the heap after the operation is done.
|
// Filter, as opposed to 'filter', re-initializes the heap after the operation is done.
|
||||||
// If you want to do several consecutive filterings, it's therefore better to first
|
// If you want to do several consecutive filterings, it's therefore better to first
|
||||||
// do a .filter(func1) followed by .Filter(func2) or reheap()
|
// do a .filter(func1) followed by .Filter(func2) or reheap()
|
||||||
func (m *SortedMap) Filter(filter func(*types.Transaction) bool) types.Transactions {
|
func (m *SortedMap) Filter(filter func(*types.Transaction) bool) types.Transactions {
|
||||||
|
|
|
||||||
|
|
@ -481,7 +481,7 @@ func (p *TxPool) Status(hash common.Hash) TxStatus {
|
||||||
// Sync is a helper method for unit tests or simulator runs where the chain events
|
// Sync is a helper method for unit tests or simulator runs where the chain events
|
||||||
// are arriving in quick succession, without any time in between them to run the
|
// are arriving in quick succession, without any time in between them to run the
|
||||||
// internal background reset operations. This method will run an explicit reset
|
// internal background reset operations. This method will run an explicit reset
|
||||||
// operation to ensure the pool stabilises, thus avoiding flakey behavior.
|
// operation to ensure the pool stabilizes, thus avoiding flakey behavior.
|
||||||
//
|
//
|
||||||
// Note, this method is only used for testing and is susceptible to DoS vectors.
|
// Note, this method is only used for testing and is susceptible to DoS vectors.
|
||||||
// In production code, the pool is meant to reset on a separate thread.
|
// In production code, the pool is meant to reset on a separate thread.
|
||||||
|
|
|
||||||
|
|
@ -429,7 +429,7 @@ func (b *Block) BlobGasUsed() *uint64 {
|
||||||
return blobGasUsed
|
return blobGasUsed
|
||||||
}
|
}
|
||||||
|
|
||||||
// ExecutionWitness returns the verkle execution witneess + proof for a block
|
// ExecutionWitness returns the verkle execution witness + proof for a block
|
||||||
func (b *Block) ExecutionWitness() *ExecutionWitness { return b.witness }
|
func (b *Block) ExecutionWitness() *ExecutionWitness { return b.witness }
|
||||||
|
|
||||||
// Size returns the true RLP encoded storage size of the block, either by encoding
|
// Size returns the true RLP encoded storage size of the block, either by encoding
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ type Log struct {
|
||||||
// index of the log in the block
|
// index of the log in the block
|
||||||
Index uint `json:"logIndex" rlp:"-"`
|
Index uint `json:"logIndex" rlp:"-"`
|
||||||
|
|
||||||
// The Removed field is true if this log was reverted due to a chain reorganisation.
|
// The Removed field is true if this log was reverted due to a chain reorganization.
|
||||||
// You must pay attention to this field if you receive logs through a filter query.
|
// You must pay attention to this field if you receive logs through a filter query.
|
||||||
Removed bool `json:"removed" rlp:"-"`
|
Removed bool `json:"removed" rlp:"-"`
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,9 +25,9 @@ import (
|
||||||
// Contract represents an ethereum contract in the state database. It contains
|
// Contract represents an ethereum contract in the state database. It contains
|
||||||
// the contract code, calling arguments. Contract implements ContractRef
|
// the contract code, calling arguments. Contract implements ContractRef
|
||||||
type Contract struct {
|
type Contract struct {
|
||||||
// caller is the result of the caller which initialised this
|
// caller is the result of the caller which initialized this
|
||||||
// contract. However, when the "call method" is delegated this
|
// contract. However, when the "call method" is delegated this
|
||||||
// value needs to be initialised to that of the caller's caller.
|
// value needs to be initialized to that of the caller's caller.
|
||||||
caller common.Address
|
caller common.Address
|
||||||
address common.Address
|
address common.Address
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@ type EVM struct {
|
||||||
// chain rules contains the chain rules for the current epoch
|
// chain rules contains the chain rules for the current epoch
|
||||||
chainRules params.Rules
|
chainRules params.Rules
|
||||||
|
|
||||||
// virtual machine configuration options used to initialise the evm
|
// virtual machine configuration options used to initialize the evm
|
||||||
Config Config
|
Config Config
|
||||||
|
|
||||||
// global (to this context) ethereum virtual machine used throughout
|
// global (to this context) ethereum virtual machine used throughout
|
||||||
|
|
@ -226,7 +226,7 @@ func (evm *EVM) Call(caller common.Address, addr common.Address, input []byte, g
|
||||||
if isPrecompile {
|
if isPrecompile {
|
||||||
ret, gas, err = RunPrecompiledContract(p, input, gas, evm.Config.Tracer)
|
ret, gas, err = RunPrecompiledContract(p, input, gas, evm.Config.Tracer)
|
||||||
} else {
|
} else {
|
||||||
// Initialise a new contract and set the code that is to be used by the EVM.
|
// Initialize a new contract and set the code that is to be used by the EVM.
|
||||||
code := evm.resolveCode(addr)
|
code := evm.resolveCode(addr)
|
||||||
if len(code) == 0 {
|
if len(code) == 0 {
|
||||||
ret, err = nil, nil // gas is unchanged
|
ret, err = nil, nil // gas is unchanged
|
||||||
|
|
@ -290,7 +290,7 @@ func (evm *EVM) CallCode(caller common.Address, addr common.Address, input []byt
|
||||||
if p, isPrecompile := evm.precompile(addr); isPrecompile {
|
if p, isPrecompile := evm.precompile(addr); isPrecompile {
|
||||||
ret, gas, err = RunPrecompiledContract(p, input, gas, evm.Config.Tracer)
|
ret, gas, err = RunPrecompiledContract(p, input, gas, evm.Config.Tracer)
|
||||||
} else {
|
} else {
|
||||||
// Initialise a new contract and set the code that is to be used by the EVM.
|
// Initialize a new contract and set the code that is to be used by the EVM.
|
||||||
// The contract is a scoped environment for this execution context only.
|
// The contract is a scoped environment for this execution context only.
|
||||||
contract := NewContract(caller, caller, value, gas, evm.jumpDests)
|
contract := NewContract(caller, caller, value, gas, evm.jumpDests)
|
||||||
contract.SetCallCode(evm.resolveCodeHash(addr), evm.resolveCode(addr))
|
contract.SetCallCode(evm.resolveCodeHash(addr), evm.resolveCode(addr))
|
||||||
|
|
@ -333,7 +333,7 @@ func (evm *EVM) DelegateCall(originCaller common.Address, caller common.Address,
|
||||||
if p, isPrecompile := evm.precompile(addr); isPrecompile {
|
if p, isPrecompile := evm.precompile(addr); isPrecompile {
|
||||||
ret, gas, err = RunPrecompiledContract(p, input, gas, evm.Config.Tracer)
|
ret, gas, err = RunPrecompiledContract(p, input, gas, evm.Config.Tracer)
|
||||||
} else {
|
} else {
|
||||||
// Initialise a new contract and make initialise the delegate values
|
// Initialize a new contract and make initialize the delegate values
|
||||||
//
|
//
|
||||||
// Note: The value refers to the original value from the parent call.
|
// Note: The value refers to the original value from the parent call.
|
||||||
contract := NewContract(originCaller, caller, value, gas, evm.jumpDests)
|
contract := NewContract(originCaller, caller, value, gas, evm.jumpDests)
|
||||||
|
|
@ -385,7 +385,7 @@ func (evm *EVM) StaticCall(caller common.Address, addr common.Address, input []b
|
||||||
if p, isPrecompile := evm.precompile(addr); isPrecompile {
|
if p, isPrecompile := evm.precompile(addr); isPrecompile {
|
||||||
ret, gas, err = RunPrecompiledContract(p, input, gas, evm.Config.Tracer)
|
ret, gas, err = RunPrecompiledContract(p, input, gas, evm.Config.Tracer)
|
||||||
} else {
|
} else {
|
||||||
// Initialise a new contract and set the code that is to be used by the EVM.
|
// Initialize a new contract and set the code that is to be used by the EVM.
|
||||||
// The contract is a scoped environment for this execution context only.
|
// The contract is a scoped environment for this execution context only.
|
||||||
contract := NewContract(caller, addr, new(uint256.Int), gas, evm.jumpDests)
|
contract := NewContract(caller, addr, new(uint256.Int), gas, evm.jumpDests)
|
||||||
contract.SetCallCode(evm.resolveCodeHash(addr), evm.resolveCode(addr))
|
contract.SetCallCode(evm.resolveCodeHash(addr), evm.resolveCode(addr))
|
||||||
|
|
@ -492,7 +492,7 @@ func (evm *EVM) create(caller common.Address, code []byte, gas uint64, value *ui
|
||||||
}
|
}
|
||||||
evm.Context.Transfer(evm.StateDB, caller, address, value)
|
evm.Context.Transfer(evm.StateDB, caller, address, value)
|
||||||
|
|
||||||
// Initialise a new contract and set the code that is to be used by the EVM.
|
// Initialize a new contract and set the code that is to be used by the EVM.
|
||||||
// The contract is a scoped environment for this execution context only.
|
// The contract is a scoped environment for this execution context only.
|
||||||
contract := NewContract(caller, address, value, gas, evm.jumpDests)
|
contract := NewContract(caller, address, value, gas, evm.jumpDests)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -99,6 +99,6 @@ type StateDB interface {
|
||||||
|
|
||||||
AccessEvents() *state.AccessEvents
|
AccessEvents() *state.AccessEvents
|
||||||
|
|
||||||
// Finalise must be invoked at the end of a transaction
|
// Finalize must be invoked at the end of a transaction
|
||||||
Finalise(bool)
|
Finalise(bool)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,7 @@ type EVMInterpreter struct {
|
||||||
|
|
||||||
// NewEVMInterpreter returns a new instance of the Interpreter.
|
// NewEVMInterpreter returns a new instance of the Interpreter.
|
||||||
func NewEVMInterpreter(evm *EVM) *EVMInterpreter {
|
func NewEVMInterpreter(evm *EVM) *EVMInterpreter {
|
||||||
// If jump table was not initialised we set the default one.
|
// If jump table was not initialized we set the default one.
|
||||||
var table *JumpTable
|
var table *JumpTable
|
||||||
switch {
|
switch {
|
||||||
case evm.chainRules.IsVerkle:
|
case evm.chainRules.IsVerkle:
|
||||||
|
|
@ -189,7 +189,7 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) (
|
||||||
Stack: stack,
|
Stack: stack,
|
||||||
Contract: contract,
|
Contract: contract,
|
||||||
}
|
}
|
||||||
// For optimisation reason we're using uint64 as the program counter.
|
// For optimization reason we're using uint64 as the program counter.
|
||||||
// It's theoretically possible to go above 2^64. The YP defines the PC
|
// It's theoretically possible to go above 2^64. The YP defines the PC
|
||||||
// to be uint256. Practically much less so feasible.
|
// to be uint256. Practically much less so feasible.
|
||||||
pc = uint64(0) // program counter
|
pc = uint64(0) // program counter
|
||||||
|
|
|
||||||
|
|
@ -332,7 +332,7 @@ func (p *Program) MemToStorage(memStart, memSize, startSlot int) *Program {
|
||||||
return p
|
return p
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReturnViaCodeCopy utilises CODECOPY to place the given data in the bytecode of
|
// ReturnViaCodeCopy utilizes CODECOPY to place the given data in the bytecode of
|
||||||
// p, loads into memory (offset 0) and returns the code.
|
// p, loads into memory (offset 0) and returns the code.
|
||||||
// This is a typical "constructor".
|
// This is a typical "constructor".
|
||||||
// Note: since all indexing is calculated immediately, the preceding bytecode
|
// Note: since all indexing is calculated immediately, the preceding bytecode
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue