It turns out that "standard" BSC nodes based on Geth, do not propagate
new block hashes and blocks, at least towards Erigon nodes. This is a
workaround
---------
Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local>
The Read method of math package used in randomAddress function is not
thread safe, instead I've used crand package which is used by matic and
is a fork of thread safe crypto package.
Embedded CL is not supported for Gnosis Chain, so it makes sense to set
`externalcl` to true by default for it.
Also, this PR sets `terminalTotalDifficultyPassed` for Gnosis Chain &
Chiado (see https://docs.gnosischain.com/updates/20221210-merge).
So there is an issue with tracing certain blocks/transactions on
Polygon, for example:
```
> '{"method": "trace_transaction","params":["0xb198d93f640343a98f90d93aa2b74b4fc5c64f3a649f1608d2bfd1004f9dee0e"],"id":1,"jsonrpc":"2.0"}'
```
gives the error `first run for txIndex 1 error: insufficient funds for
gas * price + value: address 0x10AD27A96CDBffC90ab3b83bF695911426A69f5E
have 16927727762862809 want 17594166808296934`
The reason is that this transaction is from the author of the block,
which doesn't have enough ETH to pay for the gas fee + tx value if he's
not the block author receiving transactions fees.
The issue is that currently the APIs are using `ethash.NewFaker()`
Engine for running traces, etc. which doesn't know how to get the author
for a specific block (which is consensus dependant); as it was noting in
several TODO comments.
The fix is to pass the Engine to the BaseAPI, which can then be used to
create the right Block Context. I chose to split the current Engine
interface in 2, with Reader and Writer, so that the BaseAPI only
receives the Reader one, which might be safer (even though it's only
used for getting the block Author).
This PR includes changes required for delhi hard fork schedule at block
`29638656` on mumbai testnet. It changes few major parameters.
1. Sprint length - the number of bor blocks post which a new validator
mines has been reduced from 64 to 16.
2. Block time - the block time which was increased earlier for some
experiments to 5 seconds has been reduced to 2 seconds (along with
backup multiplier and producer delay).
3. Base fee denominator - this fields has been increased from 8 to 16 to
smoothen the effect of EIP 1559.
In context of https://github.com/ledgerwatch/erigon/issues/5694, this PR
adds some fixes and improvement in the mining flow. Also, a relevant
change in txpool (present in erigon-lib) is made here:
https://github.com/ledgerwatch/erigon-lib/pull/737
#### Changes in triggering mining in `startMining()`
The mining module didn't honour the block time as a simple 3 second
timer and a notifier from txpool was used to trigger mining. This would
cause inconsistencies, at least with the bor consensus. Hence, a geth
like approach is used instead for simplicity. A new head channel
subscription is added in the `startMining()` loop which would notify the
addition of new block. Hence, this would make sure that the block time
is being honoured. Moreover, the fixed 3 second timer is replaced by the
`miner.recommit` value set using flags.
#### Changes in the arrangement of calls made post mining
When all the mining stages are completed, erigon writes all the data in
a cache. It then processes the block through all the stages as it would
process a block received from P2P. In this case, some of the stages
aren't really required. Like the block header and body download stage is
not required as the block was mined locally. Even execution stage is not
required as it already went through it in the mining stages.
Now, we encountered an issue where the chain was halted and kept mining
the same block again and again (liveness issue). The root cause is
because of an error in a stage of it's parent block. This stage turns
out to be the 4th stage which is "Block body download" stage. This stage
tries to download the block body from peers using the headers. As, we
mined this block locally we don't really need to download anything (or
process anything again). Hence, it reaches out to the cache which we
store for the block body.
Interestingly that cache turned out to be empty for some blocks. This
was because post mining, before adding block header and body to a cache,
we call the broadcast method which starts the staged sync. So,
technically it’s a bit uncertain at any stage if the block header and
body has been written or not.(see
[this](https://github.com/ledgerwatch/erigon/blob/devel/eth/backend.go#L553-L572)).
To achieve complete certainty, we rearranged the calls with the write to
cache being called first and broadcast next. This pretty much solves the
issue as now we’re sure that we’d always have a block body in the cache
when we reach the body download stage.
#### Misc changes
This PR also adds some logs in bor consensus.
BaseFee is required in AuRa headers when
[EIP-1559](https://eips.ethereum.org/EIPS/eip-1559) is activated.
Also:
- Basic AuRa header verification
- Extract some common RLP methods
- Tiny log clean-up
This fixes the following panic for Gnosis Chain on the validator switch
at block 9186425:
```
panic: method 'getValidators' not found
goroutine 90 [running]:
github.com/ledgerwatch/erigon/consensus/aura.(*ValidatorSafeContract).getListSyscall(0x14000ed9358, 0xd40004bf620)
github.com/ledgerwatch/erigon/consensus/aura/validators.go:634 +0x258
github.com/ledgerwatch/erigon/consensus/aura.(*ValidatorSafeContract).epochSet(0x16?, 0x20?, 0x8c2c79, {0xd4002d77180, 0x25f, 0x25f}, 0x11400fac7ee8?)
github.com/ledgerwatch/erigon/consensus/aura/validators.go:453 +0xdc
github.com/ledgerwatch/erigon/consensus/aura.(*ValidatorContract).epochSet(0x140006ae980?, 0x38?, 0x6f9d00000000c28e?, {0xd4002d77180?, 0x108acc108?, 0x40?}, 0x14000618000?)
```
Previously "in-memory" MDBX instances for fork validation and mining
were created inside `os.TempDir()`. We should create them inside
Erigon's datadir so that the file permissions and the disk are the same
as for the main database.
Prerequisite: https://github.com/ledgerwatch/erigon-lib/pull/676.
* Test GnosisGenesisStateRoot
* Delete obsolete allocations
* SysCallContract shouldn't increase nonce of SystemAddress
* Max gas limit in SysCallContract
* Restore error swallowing for Bor
* General cleanup and fixes
* Cleaning part 2
* cleanup part 3
* Refactored staterunner to have a handler function
* Fixed linting
* Cleanup part 4
* Changed the initialization of the require package and updated .golangci.yml
* Fixed lint errors from golangci-lint
* deleted state_recon_1.go
* fixed build error
* Added ReadHeaderTimeouts for httpServer
* made changes to golangci
* Reset golangci.yml
* Consensus tests update 11
* Add GrayGlacier fork
* Wire currentRandom from tests into PREVRANDAO
* Serenity engine
* Support insertion of PoS blocks in MockSentry
* Introduce marshallTypedTransactionsAsRlpStrings arg into (*Block) RawBody()
* Revert "Introduce marshallTypedTransactionsAsRlpStrings arg into (*Block) RawBody()"
This reverts commit 903fca572be03c7de33318ce177a03a4be34927b.
* Post-merge fix
* Don't wait for Beacon Chain in tests
* Skip powToPosBlockRejection transition test
* ForkChoice in insertPoSBlocks
* Add withPosDownloader arg to MockWithEverything in order to fix TestPoSDownloader
* evm t8n tool to use ExecuteBlockEphemerally api (#4512)
* fix to set V, R, S in legacy transaction
* fix to dump post-execution alloc for evm t8n
* close tx in evm t8n
* populate current difficulty and gas used in output result
- update the ExecutionResult to include corresponding info (like
Difficulty/GasUsed)
* initial attempt at migrating 'evm t8n' to use ExecuteBlockEphemerally
* using ExecutionResult in ExecuteBlockEphemerally
* bypass validations and integrate with EphemeralExecResult
* fixing output of 'evm t8n'
- remaining bits are "stateRoot" in results.txt and "balance" field for one account in
alloc.txt (for testdata=1)
* get ExecuteBlockEphemerally to accept getTracer lambda
* fix build failure
* test cases for evm t8n
* more test cases for evm t8n
* fix stateRoot computation in evm t8n
* remove reward argument, as EBE itself takes care of it
* final cleanups for migration to using ExecuteBlockEphemerally
* change EBEforBSC to match EBE
* fix linter issues
* manually revert an unwanted diff
* avoid calculating ReceiptHash twice
* linter check
* minor correction
* remove unnecessary logic in EBEforBsc
* fix integration tests
* fix build
* Revert "evm t8n tool to use ExecuteBlockEphemerally api (#4512)"
This reverts commit db93d2ea37.
* Fix compilation
Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro.local>
* fix to set V, R, S in legacy transaction
* fix to dump post-execution alloc for evm t8n
* close tx in evm t8n
* populate current difficulty and gas used in output result
- update the ExecutionResult to include corresponding info (like
Difficulty/GasUsed)
* initial attempt at migrating 'evm t8n' to use ExecuteBlockEphemerally
* using ExecutionResult in ExecuteBlockEphemerally
* bypass validations and integrate with EphemeralExecResult
* fixing output of 'evm t8n'
- remaining bits are "stateRoot" in results.txt and "balance" field for one account in
alloc.txt (for testdata=1)
* get ExecuteBlockEphemerally to accept getTracer lambda
* fix build failure
* test cases for evm t8n
* more test cases for evm t8n
* fix stateRoot computation in evm t8n
* remove reward argument, as EBE itself takes care of it
* final cleanups for migration to using ExecuteBlockEphemerally
* change EBEforBSC to match EBE
* fix linter issues
* manually revert an unwanted diff
* avoid calculating ReceiptHash twice
* linter check
* minor correction
* remove unnecessary logic in EBEforBsc
* Configure consensus engine with context of stage if engine will do async work
* Change API to make setting of context for AsyncEngine multithreaded-safe
* Ensure lock gets inherited by reference
* Fix linter errors
* Print more info on ErrUnauthorizedSigner
* Authorize Clique even when wrapped into Serenity
* Revert "Print more info on ErrUnauthorizedSigner"
This reverts commit b0ab83ffbed45d6beeb8ba30a6ea576b2003ab26.
* Authorize Parlia even when wrapped into Serenity
* consensus/clique: remove race condition
* consensus/clique: fix one more signer data race
Co-authored-by: Gary Rong <garyrong0905@gmail.com>
Co-authored-by: Harry Kalodner <harry.kalodner@gmail.com>
Co-authored-by: Gary Rong <garyrong0905@gmail.com>
* Update stageloop.go
* Print
* Consider snapshot headers as parlia checkpoints
* Not fail after not loading snapshot
* Lazy snapshots
* Print number of validators
* More printing
* Use epoch instead of checkpoint interval
* Reduce logging
* Fix compilation
* Remove trace jump dest
* Fix lint
* Not store snapshots every epoch
* Separate snapshot for verification and finalisation
Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro.local>
Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local>
Most places that used this method were cutting off the 1st byte.
Refactor this idea to a common place.
* better naming: MarshalPubkey matches existing UnmarshalPubkey
* "Std" suffix for the ANSI standard encoding without cut off
* docs
* implemented bor consensus
* add bor flags to default
* change bucket into snapshot to clique
* enable stateSync
* bypass reciept checks
* fix receipt calculation and bor logs
* fix: contract call wrt bor
* Update mumbai config
* Add: bor-mainnet flag and config
* Add bor consensus to integration
* use header coinbase in block context
* london fork mumbai changes
* fix genesis error
* Jaipur fork for mumbai
* add sysCall to verifyHeader
* added bor related rpc method implementation
* added bor specific rpc extensions
* fixes in snapshot implementation, major refactor for bor rpc
* modify consensus specific db path for bor
* fix: remove parallel compute for get root hash rpc method
* Added bor-receipt flow
* Use turbo-bor-lib and bor tables
* Use bor table in RPC snapshot
* Update README.md
* Update README.md
* Update README.md
* Update README.md
* update rpc readme
* link rpc docs in readme
* Update Readme
* Update Readme
* move erigon namespace rpc methods to eth
* rm: erigon namespace
* rm: erigon namespace, update list of available rpc methods, add example
* fix: binary name in rpc readme
* fix: max db size
* Add london to bor-mainnet
* updated node.go
* add system req to readme
* golang version fix readme
* added networknames in correct place
* nil
* ran gofmt
* erigon
* fixed fake.go
* dont need turbor-lib
* old readme
* fixing readme
* half
* other half
* changed return
* fixing return
* fixed return
* fixed flags
* gofmt
* merge with devel
* latest erigon-lib
* fixed context.coinbase
* took out syscall
* fixed params in hash
* bor type now is consensus.Engine
* parlia is consensus.Engine
* missing arg and repeated importation
* repeated importation
* fixed eth_receipts.go
* deleted duplicate issuance
* part of consensus.Engine type
* added eth_api issuance
* networkname
* added erigon_system file
* fork struct taken out
* added erigon block
* getLogByHash for erigonImpl
* gofmt
* fixed lint
* ops
* gofmt
* gofmt
* added APIImple functions
* fixed clique test
* took out print
* fixed state added balance
* fixed README
* fixed rpcDaemon README
* fixed integration README
* updated blockchain.go
* lint
* added bor back into blockchain.go
* took out comment
* lint
* updated daemon
* updated wtb
* removed duplicate
* removed VerifyHeaders
* prevent use of wrong Transfer
* fixed state_processor.go
* fixed state_transition.go
* fixed headers
* returning err
* error handling in bor read tx look up
* put for txLookUp
* dealing with error
* lint
* traces
* more traces
* fixed receipt in execution
* getTrasanction receipt for bor or others
* nil
* lint
* ops
* deleted syscall
* took out else
* Merge branch 'devel
* tests syscalls
* changed borReceipt to receipt
* reset header algos
* arguments fix
* took out prefixes
* lint
* erigon-named
* borReceiptKey = blocknumber
* reverts e3b60c2e159d03efcb855f7ab3da5a098dd60c33.
* correct hashing tx
* dont need it here
* lint
* added txlookup for bor
* change to uint256
* outputs for isBor
* wrapper
* added isBor and isParlia
* isBor
* fixed BorTransfer
* not readBody
* correct prefix
* added blockNum
* added readStorageBody
* readStorageBody
* lint
* got rid of unnecessary bor_receipt func
* onlny if bor
* use clone
* append
* writeToSlice
* added isBor flag
* fixed writeToSlice
* normal sorting
* lint
* Reset erigon-snapshots
* Move bor prefix into if
Co-authored-by: Krishna Upadhyaya <krishnau1604@gmail.com>
Co-authored-by: Manav Darji <manavdarji.india@gmail.com>
Co-authored-by: Uttam Singh <uttamkhanduja@yahoo.in>
Co-authored-by: Giulio Rebuffo <giulio.rebuffo@gmail.com>
Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro.local>
* migrated consensus and chain config files for bsc support
* migrated more files from bsc
* fixed consensus crashing
* updated erigon lib for parlia snapshot prefix
* added staticpeers for bsc
* [+] added system contracts
[*] fixed bug with loading snapshot
[+] enabled gas bailout
[+] added fix to prevent syncing more than 1000 headers (for testing only)
[*] fixed bug with crashing sender recover sometimes
* migrated system contract calls
* [*] fixed bug with returning mutable balance object
[+] migrated lightclient contracts from bsc
[*] fixed parlia consensus config param
* [*] fixed tendermint deps
* [+] added some logs
* [+] enabled bsc forks
[*] fixed syscalls from coinbase
[*] more logging
* Fix call sys contract gas calculation
* [*] fixed executing system transactions
* [*] enabled receipt hash, gas and bloom filter checks
* [-] removed some logging scripts
[*] set header checkpoint to 10 million blocks (for testing forks)
* [*] fixed bug with commiting dirty inter block state state after system transaction execution
[-] removed some extra logs and comments
* [+] added chapel and rialto testnet support
* [*] fixed chapel allocs
* [-] removed 6 mil block limit for headers sync
* Fix hardforks on chapel and other testnets
* [*] fixed header sync issue after merge
* [*] tiny code cleanup
* [-] removed some comments
* [*] increased mdbx map size to 4 TB
* [*] increased max chaindata size to 6 tb
* [*] bring more compatibility with origin erigon and some code cleanup
* [+] added support of validator mode for BSC chain
* [*] enable private key load for bsc, rialto and chapel chains
* [*] fixed running BSC validator node
* Fix the branch list
* [*] tiny fixes for linter
* [*] formatted imports for core and parlia packages
* [*] fixed import rules in other files
* Revert "[*] formatted imports for core and parlia packages"
This reverts commit c764b58b34fedc2b14d69458583ba0dad114f227.
* [*] changed import rules in more packages
* [*] fixed type mismatch in hack command
* [*] fixed crash on new epoch, enabled bootstrap flags
* [*] fixed linter errors
* [*] fixed missing err check for syscalls
* [*] now BSC implementation is fully compatible with erigon original sources
* Revert "Add chain config and CLI changes for Binance Smart Chain support (#3131)"
This reverts commit 3d048b7f1a.
* Revert "Add Parlia consensus engine for Binance Smart Chain support (#3086)"
This reverts commit ee99f17fbe.
* [*] fixed several issues after merge
* [*] fixed integration compilation
* Revert "Fix the branch list"
This reverts commit 8150ca57e5f2707a84a9f6a1c5b809b7cc84547b.
* [-] removed receipt repair migration
* [*] fixed parlia fork numbers output
* [*] bring more devel compatibility, fixed bsc address list for access list calculation
* [*] fixed bug with commiting state transition for bad blocks in BSC
* [*] fixed bsc changes apply for integration command and updated config print for parlia
* [*] fixed bug with applying bsc forks for chapel and rialto testnet chains
[*] let's use finalize and assemble for mining to let consensus know for what it's finalizing block
* Fix compilation errors in hack.go
* Fix lint
* reset changes in erigon-snapshots to devel
* Remove unrelated changes
* Fix embed
* Remove more unrelated changes
* Remove more unrelated changes
* Restore clique and aura miner config
* Refactor interfaces not to use slice pointers
* Refactor parlia functions to return tx and receipt instead of dealing with slices
* Fix for header panic
* Fix lint, restore system contract addresses
* Remove more unrelated changes, unify GatherForks
Co-authored-by: Dmitry Ivanov <convexman18@gmail.com>
Co-authored-by: j75689 <j75689@gmail.com>
Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local>
Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro.local>
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* Squashed 'interfaces/' content from commit e5b1945d0
git-subtree-dir: interfaces
git-subtree-split: e5b1945d02da7a7f00e2289034ee90a6edd60184
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* (EIP-4399) MixDigest is utilized for RANDOM
* Add GetTd to ChainHeaderReader
* Remove unused VerifyHeaders from consensus consensus
* Introduce params.MaxGasLimit
* Serenity engine: fall back to eth1 engine before the Merge
* Serenity engine in CreateConsensusEngine
* ethOne -> eth1Engine
* Add Parlia consensus engine for Binance Smart Chain support
* Leave RamanujanBlock as nil in params/config.go
* Run `go fmt` on files needing it
* Add comment for PoSA
* Remove empty branches and ineffectual assignments in parlia.go
* Remove commented imports
* Fix compilation error
* Remove EIP155Signer in transaction_signing.go
* Fix compilation issue
* Fix go fmt issues
* Remove Ramanujan from print statement
* Remove references to EthAPIBackend approach
* Fix Finalize method across consensus engines
* Run go fmt
* More linting
* Remove more changes
* remove a comment
* Remove unneeded hashing function
* Remove bytes check and fix actual vs expected mistake
* Move ETL to erigon-lib
* Update link in the readme
* go mod tidy
* Use common/chan.go from erigon-lib
* Clean up
* Fix lint
* Fix test
* Fix compilation
Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro.local>
* remove ctx from state writer interface
* call me baby
* save
* save
* can process block 1
* can process block 1
* can process block 1
* can process block 1
* save
* save
* parse logs logic
* cleans
* cleans
* cleans
* handle chain flag in integration
* handle chain flag in integration
* handle chain flag in integration
* save
* save
* merge devel
* save
* noopWriter - one is enough
* chain spec parser
* chain spec parser
* embed
* embed
* embed
* embed
* embed
* embed
* embed
* clean
* clean
* correct alloc after reset state
* correct alloc after reset state
* correct alloc after reset state
* integration reset state now does re-apply genesis and chainConfig
* eips summary
* eips summary
* eips summary
* implemented crash reporting for all goroutine panics that aren't handled explicitly
* implemented crash reporting for all goroutine panics that aren't handled explicitly
* changed node defaults back to originals after testing
* implemented panic handling for all goroutines that don't explicitly handle them, outputting the stack trace to a file in crashreports
* handling panics on all goroutines gracefully
* updated missing call
* error assignment
* implemented suggestions
* path.Join added
* implemented Evgeny's suggestions
* changed path.Join to filepath.Join for cross-platform
* added err check
* updated RecoverStackTrace to LogPanic
* updated closures
* removed call of common.Go to some goroutines
* updated scope capture
* removed testing files
* reverted back to original method, I feel like its less intrusive
* update filename for clarity
* Upgrade tests to 9.0.1
* Fix gas limit rule
* Clean up output
* Update testdata
* Fix tip assigment
* Fix genesis discrepancy
* Skip typeTwo berlin test
Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro.local>
* validate body
* validate body
* save
* save
* body deliveries messages handling into staged sync
* body deliveries messages handling into staged sync
* body deliveries messages handling into staged sync
* body deliveries messages handling into staged sync
* body deliveries messages handling into staged sync
* penalize right after verifyUncles and stop, don't batch
* penalize right after verifyUncles and stop, don't batch
* penalize right after verifyUncles and stop, don't batch
* penalize right after verifyUncles and stop, don't batch
* penalize right after verifyUncles and stop, don't batch
* penalize right after verifyUncles and stop, don't batch
* penalize right after verifyUncles and stop, don't batch
* penalize right after verifyUncles and stop, don't batch
* penalize right after verifyUncles and stop, don't batch
* Where I am at
* Refactoring of transaction types
* More refactoring
* Use Homested signer in rpc daemon
* Unified signer
* Continue unified signer
* A bit more
* Fixes and down the rabbit hole...
* More tx pool fixes
* More refactoring fixes
* More fixes'
* more fixes
* More fixes
* More compile fixes
* More RLP hand-writing
* Finish RLP encoding/decoding of transactions
* Fixes to header encoding, start on protocol packets
* Transaction decoding
* Use DecodeTransaction function
* Decoding BlockBodyPacket
* Encode and decode for pool txs
* Start fixing tests
* Introduce SigningHash
* Fixes to SignHash
* RLP encoding fixes
* Fixes for encoding/decoding
* More test fixes
* Fix more tests
* More test fixes
* More test fixes
* Fix core tests
* More fixes for signer
* Fix for tx
* Fixes to string encoding/size
* Fix eip2930 test
* Fix rest of ./tests
* More fixes
* Fix compilation
* More test fixes
* More test fixes
* Test fixes
* More fixes
* Reuse EncodingSize in EncodeRLP for accessList
* Rearrange things in dynamic fee tx
* Add MarshalBinary
* More fixes
* Make V,R,S non-pointers
* More NPE fixes
* More fixes
* Receipt fixes
* Fix core/types
* Fix ./eth
* More compile fixes for tests
* More test fixes
* More test fixes
* Try to see lint errors better
* Try to see lint errors better
* Fix lint
* Debugging eip1559 test
* Fix TestEIP1559Transition test
* Fix NewBlockPacket encoding/decoding
* Fix calculation of TxHash
* Fix perf problem with senders
* Update aleut config values
* Try adding static peers
* Add staticpeers to defaul flags
* Change aleut networkID
* Fix test
Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro.local>
Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local>
This PR implements the following modifications
- Don't shortcut check if block is present, thus avoid disk lookup
- Don't check hash ancestry in early-check (it's still done in parallel checker)
- Don't check time.Now for every single header
Charts and background info can be found here: https://github.com/holiman/headerimport/blob/main/README.md
With these changes, writing 1M headers goes down to from 80s to 62s.
# Conflicts:
# consensus/ethash/consensus.go
# core/rawdb/freezer_table.go
This PR adds re-written difficulty calculators, which are based on uint256. It also adds a fuzzer + oss-fuzz integration for the new fuzzer. It does differential fuzzing between the new and old calculators.
Note: this PR does not actually enable the new calculators.
# Conflicts:
# consensus/ethash/consensus_test.go
* consensus/ethash: only use *reflect.SliceHeader, not reflect.SliceHeader. See comment here: https://github.com/golang/go/issues/40397\#issuecomment-663748689
* consensus/ethash: pr feedback from @mdempsky, makes a copy of dest such that is not mutated
* consensus/ethash: remove noop assign
* consensus/ethash: apply same fix to another location
Co-authored-by: Péter Szilágyi <peterke@gmail.com>
Co-authored-by: Martin Holst Swende <martin@swende.se>
* State cache init
* More code
* Fix lint
* More tests
* More tests
* More tests
* Fix test
* Transformations
* remove writeQueue, before fixing the tests
* Fix tests
* Add more tests, incarnation to the code items
* Fix lint
* Fix lint
* Remove shards prototype, add incarnation to the state reader code
* Clean up and replace cache in call_traces stage
* fix flaky test
* Save changes
* Readers to use addrHash, writes - addresses
* Fix lint
* Fix lint
* More accurate tracking of size
* Optimise for smaller write batches
* Attempt to integrate state cache into Execution stage
* cacheSize to default flags
* Print correct cache sizes and batch sizes
* cacheSize in the integration
* Fix tests
* Fix lint
* Remove print
* Fix exec stage
* Fix test
* Refresh sequence on write
* No double increment
* heap.Remove
* Try to fix alignment
* Refactoring, adding hashItems
* More changes
* Fix compile errors
* Fix lint
* Wrapping cached reader
* Wrap writer into cached writer
* Turn state cache off by default
* Fix plain state writer
* Fix for code/storage mixup
* Fix tests
* Fix clique test
* Better fix for the tests
* Add test and fix some more
* Fix compile error|
* More functions
* Fixes
* Fix for the tests
* sepatate DeletedFlag and AbsentFlag
* Minor fixes
* Test refactoring
* More changes
* Fix some tests
* More test fixes
* More test fixes
* Fix lint
* Move blockchain_test to be able to use stagedsync
* More fixes
* Fixes and cleanup
* Fix tests in turbo/stages
* Fix lint
* Fix lint
* Intemediate
* Fix tests
* Intemediate
* More fixes
* Compilation fixes
* More fixes
* Fix compile errors
* More test fixes
* More fixes
* More test fixes
* Fix compile error
* Fixes
* Fix
* Fix
* More fixes
* Fixes
* More fixes and cleanup
* Further fix
* Check gas used and bloom with header
Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local>