Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix genesis block gingerbread fields #2245

Merged
merged 10 commits into from
Feb 1, 2024

Conversation

piersy
Copy link
Contributor

@piersy piersy commented Feb 1, 2024

Description

This PR fixes the way the the gasLimit and gasPriceMinimum are retrieved from state such that for all non genesis blocks the value returned is the value present in the state of the parent block, and for the genesis block the value returned is the value present in the state of the genesis block (because the genesis has no parent). Prior to this fix requesting the gasLimit or gasPrice minimum for the genesis block would result in an error because we would try to get the state for the genesis block's parent which of course did not exist.

It also removes a restriction in the mycelo genesis package (used by e2e tests) that prevented us from setting the gingerbread activation block to zero. This restriction was in place because originally it was not possible to set the baseFeeOpCodeActivationBlock (AKA the gingerbread block) to zero in the GasPriceMinimum contract but the contract was later updated to allow this.

It also updates all e2e tests that were setting the gingerbread block to 1 to now use 0.

These fixes fix a number of flakily failing eth compatibility and gingerbread tests, that would fail if run on the genesis block.

 TestSendCelo
 TestTraceSendCeloViaGoldToken
 TestCallTraceTransactionNativeTransfer
 TestPrestateTransactionNativeTransfer
 TestEpochBlockMarshaling
 TestStartStopValidators
 TestBlockTracingConcurrentMapAccess
 TestBlockTracingSequentialAccess
 TestRPCDynamicTxGasPriceWithBigFeeCap
 TestRPCDynamicTxGasPriceWithState
 TestRPCDynamicTxGasPriceWithoutState
 TestEthersJSCompatibility
 TestEthersJSCompatibilityDisableAfterGingerbread
 TestTransferCELO
 TestTransferERC20

Tested

Two end to end tests have been added to verify the new behaviour

Backwards compatibility

This is non backwards compatible, since it is changing the gasLimit and baseFee values that people will see on the genesis block when running in eth compatibility mode. They will now see the values defined in the genesis state rather than zero.

Copy link

github-actions bot commented Feb 1, 2024

Coverage from tests in ./e2e_test/... for ./consensus/istanbul/... at commit c4e31a0

coverage: 50.7% of statements across all listed packages
coverage:  63.2% of statements in consensus/istanbul
coverage:  42.7% of statements in consensus/istanbul/announce
coverage:  55.7% of statements in consensus/istanbul/backend
coverage:   0.0% of statements in consensus/istanbul/backend/backendtest
coverage:  24.3% of statements in consensus/istanbul/backend/internal/replica
coverage:  65.0% of statements in consensus/istanbul/core
coverage:  50.0% of statements in consensus/istanbul/db
coverage:   0.0% of statements in consensus/istanbul/proxy
coverage:  64.2% of statements in consensus/istanbul/uptime
coverage:  51.8% of statements in consensus/istanbul/validator
coverage:  79.2% of statements in consensus/istanbul/validator/random

Copy link

github-actions bot commented Feb 1, 2024

5883 passed, 1 failed, 45 skipped

Test failures:
  TestPriorityClient: geth

    les_test.go:121: Initializing geth: [--networkid=42 init ./testdata/clique.json] 
    test_cmd.go:262: (stderr:31) INFO [02-01|17:29:46.678] Maximum peer count                       ETH=175 LES=0 total=175
    test_cmd.go:262: (stderr:31) INFO [02-01|17:29:46.680] Set global gas inflation rate            rate=1.300
    test_cmd.go:262: (stderr:31) INFO [02-01|17:29:46.680] Set global gas cap                       cap=25,000,000
    test_cmd.go:262: (stderr:31) INFO [02-01|17:29:46.680] Allocated cache and file handles         database=/tmp/geth-test1616202212/celo/chaindata cache=16.00MiB handles=16
    test_cmd.go:262: (stderr:31) INFO [02-01|17:29:46.735] Writing custom genesis block 
    test_cmd.go:262: (stderr:31) INFO [02-01|17:29:46.735] Persisted trie from memory database      nodes=4 size=566.00B time="60.908µs" gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=-82.00B
    test_cmd.go:262: (stderr:31) INFO [02-01|17:29:46.736] Successfully wrote genesis state         database=chaindata                               hash=9195f2..122dcd
    test_cmd.go:262: (stderr:31) INFO [02-01|17:29:46.736] Allocated cache and file handles         database=/tmp/geth-test1616202212/celo/lightchaindata cache=16.00MiB handles=16
    test_cmd.go:262: (stderr:31) INFO [02-01|17:29:46.765] Writing custom genesis block 
    test_cmd.go:262: (stderr:31) INFO [02-01|17:29:46.765] Persisted trie from memory database      nodes=4 size=566.00B time="31.665µs" gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=-82.00B
    test_cmd.go:262: (stderr:31) INFO [02-01|17:29:46.766] Successfully wrote genesis state         database=lightchaindata                          hash=9195f2..122dcd
    test_cmd.go:262: (stderr:31) INFO [02-01|17:29:46.766] Allocated cache and file handles         database=/tmp/geth-test1616202212/celo/lightestchaindata cache=16.00MiB handles=16
    test_cmd.go:262: (stderr:31) INFO [02-01|17:29:46.778] Writing custom genesis block 
    test_cmd.go:262: (stderr:31) INFO [02-01|17:29:46.778] Persisted trie from memory database      nodes=4 size=566.00B time="41.035µs" gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=-82.00B
    test_cmd.go:262: (stderr:31) INFO [02-01|17:29:46.779] Successfully wrote genesis state         database=lightestchaindata                       hash=9195f2..122dcd
    les_test.go:130: Importing keys to geth
    test_cmd.go:262: (stderr:32) INFO [02-01|17:29:46.824] Maximum peer count                       ETH=175 LES=0 total=175
    test_cmd.go:262: (stderr:32) INFO [02-01|17:29:46.826] Set global gas inflation rate            rate=1.300
    test_cmd.go:262: (stderr:32) INFO [02-01|17:29:46.826] Set global gas cap                       cap=25,000,000
    les_test.go:99: Starting lightserver with rpc: [--networkid=42 --port=0 --ipcpath geth-1.ipc --allow-insecure-unlock --datadir /tmp/geth-test1616202212 --password ./testdata/password.txt --unlock 0x02f0d131f1f97aef08aec6e3291b957d9efe7105 --mine --miner.validator 0x02f0d131f1f97aef08aec6e3291b957d9efe7105 --tx-fee-recipient 0x02f0d131f1f97aef08aec6e3291b957d9efe7105 --light.serve=100 --light.maxpeers=1 --nodiscover --nat=extip:127.0.0.1 --verbosity=4]
    test_cmd.go:262: (stderr:33) INFO [02-01|17:29:47.067] Maximum peer count                       ETH=175 LES=1 total=176
    test_cmd.go:262: (stderr:33) DEBUG[02-01|17:29:47.069] FS scan times                            list="217.816µs" set="3.202µs" diff="2.593µs"
    test_cmd.go:262: (stderr:33) WARN [02-01|17:29:47.069] LES server cannot serve old transaction status and cannot connect below les/4 protocol version if transaction lookup index is limited 
    test_cmd.go:262: (stderr:33) DEBUG[02-01|17:29:47.069] Sanitizing Go's GC trigger               percent=100
    test_cmd.go:262: (stderr:33) INFO [02-01|17:29:47.069] Set global gas inflation rate            rate=1.300
    test_cmd.go:262: (stderr:33) INFO [02-01|17:29:47.069] Set global gas cap                       cap=25,000,000
    test_cmd.go:262: (stderr:33) INFO [02-01|17:29:47.069] Allocated trie memory caches             clean=154.00MiB dirty=256.00MiB
    test_cmd.go:262: (stderr:33) INFO [02-01|17:29:47.070] Allocated cache and file handles         database=/tmp/geth-test1616202212/celo/chaindata cache=512.00MiB handles=524,288
    test_cmd.go:262: (stderr:33) DEBUG[02-01|17:29:50.406] Chain freezer table opened               database=/tmp/geth-test1616202212/celo/chaindata/ancient table=diffs items=0 size=0.00B
    test_cmd.go:262: (stderr:33) DEBUG[02-01|17:29:50.778] Chain freezer table opened               database=/tmp/geth-test1616202212/celo/chaindata/ancient table=headers items=0 size=0.00B
    test_cmd.go:262: (stderr:33) DEBUG[02-01|17:29:51.428] Chain freezer table opened               database=/tmp/geth-test1616202212/celo/chaindata/ancient table=hashes  items=0 size=0.00B
    test_cmd.go:262: (stderr:33) DEBUG[02-01|17:29:51.516] Chain freezer table opened               database=/tmp/geth-test1616202212/celo/chaindata/ancient table=bodies  items=0 size=0.00B
    test_cmd.go:262: (stderr:33) DEBUG[02-01|17:29:51.878] Chain freezer table opened               database=/tmp/geth-test1616202212/celo/chaindata/ancient table=receipts items=0 size=0.00B
    test_cmd.go:262: (stderr:33) INFO [02-01|17:29:51.879] Opened ancient database                  database=/tmp/geth-test1616202212/celo/chaindata/ancient readonly=false
    les_test.go:115: lightserver rpc connect to /tmp/geth-test1616202212/geth-1.ipc: dial unix /tmp/geth-test1616202212/geth-1.ipc: connect: no such file or directory
This test report was produced by the test-summary action.  Made with ❤️ in Cambridge.

Copy link

codecov bot commented Feb 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (69dbdae) 55.10% compared to head (7ae8a60) 48.87%.

❗ Current head 7ae8a60 differs from pull request most recent head f65c09c. Consider uploading reports for the commit f65c09c to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2245      +/-   ##
==========================================
- Coverage   55.10%   48.87%   -6.24%     
==========================================
  Files         683      206     -477     
  Lines      114538    27316   -87222     
==========================================
- Hits        63121    13350   -49771     
+ Misses      47528    13247   -34281     
+ Partials     3889      719    -3170     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

This allows the genesis block to have the baseFee set when operating in
eth compatibility mode.
This allows the genesis block to have the gasLimit set when operating in
eth compatibility mode.
Originally it was not possible to set the baseFeeOpCodeActivationBlock
to zero in the GasPriceMinimum contract but the contract was later
updated to allow this.

This means we can set the gingerbread block to be 0 and consequently
remove the check we had in our test infrastructure that prevented
setting the gingerbread block to zero.
@piersy piersy force-pushed the piersy/fix-genesis-block-gingerbread-fields branch from 36f2a26 to fe0c2ea Compare February 1, 2024 12:01
@piersy piersy marked this pull request as ready for review February 1, 2024 15:33
e2e_test/e2e_test.go Outdated Show resolved Hide resolved
These got missed in the previous commit
Previously they were getting block 1, but somethimes the block had not
yet been mined.
Previously it was getting block 1, but somethimes the block had not
yet been mined.
Copy link
Contributor

@carterqw2 carterqw2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one!

@piersy piersy merged commit c4e31a0 into master Feb 1, 2024
26 checks passed
@piersy piersy deleted the piersy/fix-genesis-block-gingerbread-fields branch February 1, 2024 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants