Skip to content

Conversation

@chenquanyu
Copy link
Collaborator

@chenquanyu chenquanyu commented Apr 16, 2024

Close #163
Add the baseFee reading from policy contract for eip1559.CalcBaseFee().

After this PR the BaseFee field in block header will be the baseFee in policy contract, so this will cause hard fork for current testnet. I have added neoxburnTime field in genesis config, neoxburnTime should be set to a future timestamp and the nodes need to be re-init if we want to upgrade the testnet.

I have tested the upgrade process in privnet seven node, the BaseFee in block header changes after the neoxburnTime timestamp and transaction need to pay at least baseFee + minGasTipCap in policy contract.

@steven1227
Copy link
Contributor

steven1227 commented Apr 16, 2024

Ready for reviewing and testing.

Base automatically changed from policy-txpool to bane-main April 16, 2024 10:06
@steven1227 steven1227 requested a review from AnnaShaleva April 22, 2024 10:35
Copy link
Member

@AnnaShaleva AnnaShaleva left a comment

Choose a reason for hiding this comment

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

I think we need to rework the code, there's a lot of places where the block state is being fetched although I'd say it shouldn't.

Copy link
Contributor

@roman-khimov roman-khimov left a comment

Choose a reason for hiding this comment

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

Looks legit otherwise.

chenquanyu and others added 7 commits May 31, 2024 11:16
If user sets BaseFee in the t8ntool environment configuration, then
the same value should be present in the Policy storage. Also, ensure
that this value is always set by the user or NeoXBurn-enabled networks.

Ref
#166 (comment),
the second option is implemented.

Signed-off-by: Anna Shaleva <[email protected]>
There's no need in two different methods since it's easy to miss the
update of the original Geth method. Make the VerifyEIP1559Header depend
on the NeoXBurn hardfork.

Signed-off-by: Anna Shaleva <[email protected]>
Make the documentation follow the implementation.

Signed-off-by: Anna Shaleva <[email protected]>
Oracle is capable of working with a full backend only anyway, thus
bringing state dependency doesn't make things worse for this service.
However, retrieving full state DB for every request is too
resource-consuming, we'll end up in a very bad situation if not caching
these values.

Signed-off-by: Anna Shaleva <[email protected]>
Cache BaseFee values for TxPoolAPI and TransactionAPI.

Signed-off-by: Anna Shaleva <[email protected]>
Signed-off-by: Anna Shaleva <[email protected]>
This code was accidentally removed in
e427cda.

Signed-off-by: Anna Shaleva <[email protected]>
It's possible that current block is nil, we have to live with it
somehow. Fix the following failing test:
```
--- FAIL: TestPendingTxFilterFullTx (1.00s)
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
	panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x1c0 pc=0xdc1715]

goroutine 52 [running]:
testing.tRunner.func1.2({0xf66340, 0x19f14a0})
	/usr/local/go/src/testing/testing.go:1631 +0x24a
testing.tRunner.func1()
	/usr/local/go/src/testing/testing.go:1634 +0x377
panic({0xf66340?, 0x19f14a0?})
	/usr/local/go/src/runtime/panic.go:770 +0x132
github.com/ethereum/go-ethereum/eth/filters.(*FilterAPI).GetFilterChanges(0xc0020020c0, {0xc000c320f0, 0x22})
	/home/anna/Documents/GitProjects/bane-labs/go-ethereum/eth/filters/api.go:468 +0x235
github.com/ethereum/go-ethereum/eth/filters.TestPendingTxFilterFullTx(0xc0006064e0)
	/home/anna/Documents/GitProjects/bane-labs/go-ethereum/eth/filters/filter_system_test.go:338 +0x826
testing.tRunner(0xc0006064e0, 0x11fc210)
	/usr/local/go/src/testing/testing.go:1689 +0xfb
created by testing.(*T).Run in goroutine 1
	/usr/local/go/src/testing/testing.go:1742 +0x390
FAIL	github.com/ethereum/go-ethereum/eth/filters	1.201s
?   	github.com/ethereum/go-ethereum/eth/gasestimator	[no test files]
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0xc061b5]

goroutine 25 [running]:
math/big.(*Int).Set(...)
	/usr/local/go/src/math/big/int.go:98
github.com/ethereum/go-ethereum/eth/gasprice.(*Oracle).suggestTipCapInternal(0xc0002a4500, {0x1084ad0, 0x16de8a0}, 0xc000324288)
	/home/anna/Documents/GitProjects/bane-labs/go-ethereum/eth/gasprice/gasprice.go:249 +0x1fd5
github.com/ethereum/go-ethereum/eth/gasprice.(*Oracle).processBlock(0xc0002a4500, {0x1084ad0, 0x16de8a0}, 0xc0001d6c40, {0x0, 0x0, 0x0?})
	/home/anna/Documents/GitProjects/bane-labs/go-ethereum/eth/gasprice/feehistory.go:85 +0x1af
github.com/ethereum/go-ethereum/eth/gasprice.(*Oracle).FeeHistory.func1()
	/home/anna/Documents/GitProjects/bane-labs/go-ethereum/eth/gasprice/feehistory.go:290 +0x605
created by github.com/ethereum/go-ethereum/eth/gasprice.(*Oracle).FeeHistory in goroutine 15
	/home/anna/Documents/GitProjects/bane-labs/go-ethereum/eth/gasprice/feehistory.go:259 +0x6c5
FAIL	github.com/ethereum/go-ethereum/eth/gasprice	0.030s

```

Signed-off-by: Anna Shaleva <[email protected]>
Get back the code removed in fb84a68.
If it's London, then BaseFee should still be calculated based on the
parent's fee. If it's NeoXBurn, then just ensure that BaseFee is set in
the config (this check is already present in the applyNeoXBurnChecks.

Fix the following test:
```
--- FAIL: TestT8n (0.39s)
    t8n_test.go:299: args: t8n --output.body "" --output.result stdout --output.alloc stdout --input.alloc ./testdata/1/alloc.json --input.txs ./testdata/1/txs.json --input.env ./testdata/1/env.json --state.fork Frontier+1346
    test_cmd.go:261: (stderr:1) ERROR(3): failed constructing chain configuration: syntax error, invalid eip number 1346
    t8n_test.go:299: args: t8n --output.body "" --output.result stdout --output.alloc stdout --input.alloc ./testdata/1/alloc.json --input.txs ./testdata/1/txs.json --input.env ./testdata/1/env.json --state.fork Byzantium
    test_cmd.go:261: (stderr:6) INFO [06-25|16:52:13.126] rejected tx                              index=1 hash=0557ba..18d673 from=0x8A8eAFb1cf62BfBeb1741769DAE1a9dd47996192 error="nonce too low: address 0x8A8eAFb1cf62BfBeb1741769DAE1a9dd47996192, tx: 0 state: 1"
    test_cmd.go:261: (stderr:6) INFO [06-25|16:52:13.126] Trie dumping started                     root=84208a..ae4e13
    test_cmd.go:261: (stderr:6) INFO [06-25|16:52:13.126] Trie dumping complete                    accounts=3 elapsed="60.108µs"
    t8n_test.go:299: args: t8n --output.body "" --output.result stdout --output.alloc stdout --input.alloc ./testdata/3/alloc.json --input.txs ./testdata/3/txs.json --input.env ./testdata/3/env.json --state.fork Berlin
    test_cmd.go:261: (stderr:9) INFO [06-25|16:52:13.152] Trie dumping started                     root=b7341d..857ea1
    test_cmd.go:261: (stderr:9) INFO [06-25|16:52:13.153] Trie dumping complete                    accounts=3 elapsed="90.49µs"
    t8n_test.go:299: args: t8n --output.body "" --output.result stdout --output.alloc stdout --input.alloc ./testdata/4/alloc.json --input.txs ./testdata/4/txs.json --input.env ./testdata/4/env.json --state.fork Berlin
    test_cmd.go:261: (stderr:12) ERROR(4): getHash(3) invoked, blockhash for that block not provided
    t8n_test.go:299: args: t8n --output.body "" --output.result stdout --output.alloc stdout --input.alloc ./testdata/5/alloc.json --input.txs ./testdata/5/txs.json --input.env ./testdata/5/env.json --state.fork Byzantium --state.reward 0x80
    test_cmd.go:261: (stderr:15) INFO [06-25|16:52:13.205] Trie dumping started                     root=a7312a..c1f393
    test_cmd.go:261: (stderr:15) INFO [06-25|16:52:13.205] Trie dumping complete                    accounts=3 elapsed="70.846µs"
    t8n_test.go:299: args: t8n --output.body stdout --output.result "" --output.alloc "" --input.alloc ./testdata/13/alloc.json --input.txs ./testdata/13/txs.json --input.env ./testdata/13/env.json --state.fork London
    test_cmd.go:261: (stderr:16) INFO [06-25|16:52:13.234] Trie dumping started                     root=e4b924..6aef61
    test_cmd.go:261: (stderr:16) INFO [06-25|16:52:13.234] Trie dumping complete                    accounts=3 elapsed="104.878µs"
    t8n_test.go:299: args: t8n --output.body "" --output.result stdout --output.alloc "" --input.alloc ./testdata/13/alloc.json --input.txs ./testdata/13/signed_txs.rlp --input.env ./testdata/13/env.json --state.fork London
    test_cmd.go:261: (stderr:18) INFO [06-25|16:52:13.256] Trie dumping started                     root=e4b924..6aef61
    test_cmd.go:261: (stderr:18) INFO [06-25|16:52:13.256] Trie dumping complete                    accounts=3 elapsed="61.682µs"
    t8n_test.go:299: args: t8n --output.body "" --output.result stdout --output.alloc "" --input.alloc ./testdata/14/alloc.json --input.txs ./testdata/14/txs.json --input.env ./testdata/14/env.json --state.fork London
    test_cmd.go:261: (stderr:19) INFO [06-25|16:52:13.277] Trie dumping started                     root=6f0588..7f4bdc
    test_cmd.go:261: (stderr:19) INFO [06-25|16:52:13.277] Trie dumping complete                    accounts=2 elapsed="65.13µs"
    t8n_test.go:299: args: t8n --output.body "" --output.result stdout --output.alloc "" --input.alloc ./testdata/14/alloc.json --input.txs ./testdata/14/txs.json --input.env ./testdata/14/env.uncles.json --state.fork London
    test_cmd.go:261: (stderr:20) INFO [06-25|16:52:13.298] Trie dumping started                     root=6f0588..7f4bdc
    test_cmd.go:261: (stderr:20) INFO [06-25|16:52:13.298] Trie dumping complete                    accounts=2 elapsed="54.479µs"
    t8n_test.go:299: args: t8n --output.body "" --output.result stdout --output.alloc "" --input.alloc ./testdata/14/alloc.json --input.txs ./testdata/14/txs.json --input.env ./testdata/14/env.uncles.json --state.fork Berlin
    test_cmd.go:261: (stderr:21) INFO [06-25|16:52:13.318] Trie dumping started                     root=6f0588..7f4bdc
    test_cmd.go:261: (stderr:21) INFO [06-25|16:52:13.318] Trie dumping complete                    accounts=2 elapsed="53.961µs"
    t8n_test.go:299: args: t8n --output.body "" --output.result stdout --output.alloc "" --input.alloc ./testdata/19/alloc.json --input.txs ./testdata/19/txs.json --input.env ./testdata/19/env.json --state.fork London
    test_cmd.go:261: (stderr:22) INFO [06-25|16:52:13.338] Trie dumping started                     root=6f0588..7f4bdc
    test_cmd.go:261: (stderr:22) INFO [06-25|16:52:13.338] Trie dumping complete                    accounts=2 elapsed="62.368µs"
    t8n_test.go:299: args: t8n --output.body "" --output.result stdout --output.alloc "" --input.alloc ./testdata/19/alloc.json --input.txs ./testdata/19/txs.json --input.env ./testdata/19/env.json --state.fork ArrowGlacier
    test_cmd.go:261: (stderr:23) INFO [06-25|16:52:13.359] Trie dumping started                     root=6f0588..7f4bdc
    test_cmd.go:261: (stderr:23) INFO [06-25|16:52:13.359] Trie dumping complete                    accounts=2 elapsed="62.569µs"
    t8n_test.go:299: args: t8n --output.body "" --output.result stdout --output.alloc "" --input.alloc ./testdata/19/alloc.json --input.txs ./testdata/19/txs.json --input.env ./testdata/19/env.json --state.fork GrayGlacier
    test_cmd.go:261: (stderr:24) INFO [06-25|16:52:13.379] Trie dumping started                     root=6f0588..7f4bdc
    test_cmd.go:261: (stderr:24) INFO [06-25|16:52:13.379] Trie dumping complete                    accounts=2 elapsed="66.893µs"
    t8n_test.go:299: args: t8n --output.body "" --output.result stdout --output.alloc "" --input.alloc ./testdata/23/alloc.json --input.txs ./testdata/23/txs.json --input.env ./testdata/23/env.json --state.fork Berlin
    test_cmd.go:261: (stderr:25) INFO [06-25|16:52:13.401] Trie dumping started                     root=653343..95154d
    test_cmd.go:261: (stderr:25) INFO [06-25|16:52:13.401] Trie dumping complete                    accounts=3 elapsed="56.934µs"
    t8n_test.go:299: args: t8n --output.body "" --output.result stdout --output.alloc stdout --input.alloc ./testdata/24/alloc.json --input.txs ./testdata/24/txs.json --input.env ./testdata/24/env.json --state.fork Merge
    test_cmd.go:261: (stderr:26) INFO [06-25|16:52:13.421] Trie dumping started                     root=9e4224..043c15
    test_cmd.go:261: (stderr:26) INFO [06-25|16:52:13.421] Trie dumping complete                    accounts=3 elapsed="65.042µs"
    t8n_test.go:299: args: t8n --output.body "" --output.result "" --output.alloc "" --input.alloc ./testdata/24/alloc.json --input.txs ./testdata/24/txs.json --input.env ./testdata/24/env-missingrandom.json --state.fork Merge
    test_cmd.go:261: (stderr:27) ERROR(3): post-merge requires currentRandom to be defined in env
    t8n_test.go:299: args: t8n --output.body "" --output.result stdout --output.alloc stdout --input.alloc ./testdata/25/alloc.json --input.txs ./testdata/25/txs.json --input.env ./testdata/25/env.json --state.fork Merge
    test_cmd.go:261: (stderr:28) panic: runtime error: invalid memory address or nil pointer dereference
    test_cmd.go:261: (stderr:28) [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x5f5dbb]
    test_cmd.go:261: (stderr:28) goroutine 1 [running]:
    test_cmd.go:261: (stderr:28) math/big.(*Int).Cmp(0xc00057da40?, 0x0?)
    test_cmd.go:261: (stderr:28) 	/usr/local/go/src/math/big/int.go:381 +0x1b
    test_cmd.go:261: (stderr:28) github.com/ethereum/go-ethereum/core.(*StateTransition).preCheck(0xc00028ebb0)
    test_cmd.go:261: (stderr:28) 	/home/anna/Documents/GitProjects/bane-labs/go-ethereum/core/state_transition.go:323 +0x6f2
    test_cmd.go:261: (stderr:28) github.com/ethereum/go-ethereum/core.(*StateTransition).TransitionDb(0xc00028ebb0)
    test_cmd.go:261: (stderr:28) 	/home/anna/Documents/GitProjects/bane-labs/go-ethereum/core/state_transition.go:396 +0x51
    test_cmd.go:261: (stderr:28) github.com/ethereum/go-ethereum/core.ApplyMessage(0x152ada8?, 0x152adb0?, 0xc000579158?)
    test_cmd.go:261: (stderr:28) 	/home/anna/Documents/GitProjects/bane-labs/go-ethereum/core/state_transition.go:184 +0x57
    test_cmd.go:261: (stderr:28) github.com/ethereum/go-ethereum/cmd/evm/internal/t8ntool.(*Prestate).Apply(0xc0003ea2d0, {{0x0, 0x0}, 0x0, 0x0, {0x0, 0x0, 0x0}}, 0xc0004ad6c0, {0x1694ef8, ...}, ...)
    test_cmd.go:261: (stderr:28) 	/home/anna/Documents/GitProjects/bane-labs/go-ethereum/cmd/evm/internal/t8ntool/execution.go:243 +0x17cf
    test_cmd.go:261: (stderr:28) github.com/ethereum/go-ethereum/cmd/evm/internal/t8ntool.Transition(0xc000267300)
    test_cmd.go:261: (stderr:28) 	/home/anna/Documents/GitProjects/bane-labs/go-ethereum/cmd/evm/internal/t8ntool/transition.go:188 +0xb65
    test_cmd.go:261: (stderr:28) github.com/ethereum/go-ethereum/internal/flags.MigrateGlobalFlags.func2.1(0xc000267300)
    test_cmd.go:261: (stderr:28) 	/home/anna/Documents/GitProjects/bane-labs/go-ethereum/internal/flags/helpers.go:100 +0x34
    test_cmd.go:261: (stderr:28) github.com/urfave/cli/v2.(*Command).Run(0x1f59480, 0xc000267300, {0xc0003ea1e0, 0xf, 0xf})
    test_cmd.go:261: (stderr:28) 	/home/anna/go/pkg/mod/github.com/urfave/cli/[email protected]/command.go:274 +0x93f
    test_cmd.go:261: (stderr:28) github.com/urfave/cli/v2.(*Command).Run(0xc00044eb00, 0xc000266040, {0xc000040100, 0x10, 0x10})
    test_cmd.go:261: (stderr:28) 	/home/anna/go/pkg/mod/github.com/urfave/cli/[email protected]/command.go:267 +0xb7d
    test_cmd.go:261: (stderr:28) github.com/urfave/cli/v2.(*App).RunContext(
    test_cmd.go:261: (stderr:28) 0xc00016c5a0, {0x169aad0, 0x2166400}, {0xc000040100, 0x10, 0x10})
    test_cmd.go:261: (stderr:28) 	/home/anna/go/pkg/mod/github.com/urfave/cli/[email protected]/app.go:332 +0x566
    test_cmd.go:261: (stderr:28) github.com/urfave/cli/v2.(*App).Run(...)
    test_cmd.go:261: (stderr:28) 	/home/anna/go/pkg/mod/github.com/urfave/cli/[email protected]/app.go:309
    test_cmd.go:261: (stderr:28) github.com/ethereum/go-ethereum/cmd/evm.TestMain.func1()
    test_cmd.go:261: (stderr:28) 	/home/anna/Documents/GitProjects/bane-labs/go-ethereum/cmd/evm/t8n_test.go:35 +0x45
    test_cmd.go:261: (stderr:28) github.com/ethereum/go-ethereum/internal/reexec.Init(...)
    test_cmd.go:261: (stderr:28) 	/home/anna/Documents/GitProjects/bane-labs/go-ethereum/internal/reexec/reexec.go:31
    test_cmd.go:261: (stderr:28) github.com/ethereum/go-ethereum/cmd/evm.TestMain(0xc00043e280)
    test_cmd.go:261: (stderr:28) 	/home/anna/Documents/GitProjects/bane-labs/go-ethereum/cmd/evm/t8n_test.go:42 +0x67
    test_cmd.go:261: (stderr:28) main.main()
    test_cmd.go:261: (stderr:28) 	_testmain.go:53 +0x195
    t8n_test.go:312: test 16, file ./testdata/25/exp.json: json parsing failed: unexpected end of JSON input
FAIL
FAIL	github.com/ethereum/go-ethereum/cmd/evm	0.413s

```

Signed-off-by: Anna Shaleva <[email protected]>
Copy link
Member

@AnnaShaleva AnnaShaleva left a comment

Choose a reason for hiding this comment

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

Once #230 is merged, we need to adjust Policy contract documentation, it's out-of-date: https://github.com/bane-labs/go-ethereum/tree/bane-main/contracts#policy

Initialize these values if London or NeoXBurn are not active yet.
Otherwise gas price related RPC handlers won't work properly with London
or NeoXBurn disabled.

Fix the following error in tests for `eth_gasPrice` handler
```
--- FAIL: TestEthClient (0.24s)
    --- FAIL: TestEthClient/StatusFunctions (0.00s)
        ethclient_test.go:503: unexpected error: method handler crashed
FAIL
FAIL	github.com/ethereum/go-ethereum/ethclient	0.258s

```

Signed-off-by: Anna Shaleva <[email protected]>
Fix
#230 (comment),
t8ntool needs state.fork to be specified to create proper config, the
default value for this CLI flag is GrayGlacier.

Signed-off-by: Anna Shaleva <[email protected]>
If minGasTipCap is available in Policy, then return this value from
SuggestGasTipCap. Ref.
#230 (comment).

Signed-off-by: Anna Shaleva <[email protected]>
Adjust BaseFee burning mechanism
@songb2
Copy link
Collaborator

songb2 commented Jul 9, 2024

@AnnaShaleva @chenquanyu @txhsl I've tested metamask and t8ntool with the latest commit on this pr #230. No more issues found.

@AnnaShaleva AnnaShaleva merged commit bba1a53 into bane-main Jul 9, 2024
@AnnaShaleva AnnaShaleva deleted the policy-basefee branch July 9, 2024 09:28
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.

Implement minGasTipCap as minimum effective gas tip governance: burning fees function.

7 participants