-
Notifications
You must be signed in to change notification settings - Fork 0
Adjust BaseFee burning mechanism #230
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
Conversation
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 <shaleva.ann@nspcc.ru>
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 <shaleva.ann@nspcc.ru>
Make the documentation follow the implementation. Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
0365b03 to
b18e501
Compare
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 <shaleva.ann@nspcc.ru>
Cache BaseFee values for TxPoolAPI and TransactionAPI. Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
b18e501 to
e8ef782
Compare
|
Ready for review, the PR comment is updated, please, take a look. |
|
@nicolegys, could you please test this branch? Especially the Oracle service with his fee history call. |
@songb2 This is our new tester. |
|
I just realized that unit-tests are failing, mostly due to the suitable mocks absence. I'll fix the UTs, but the code itself is ready for testing, @songb2. |
|
I've tested the following apis by changing baseFee and minGasTipCap in policy and also made some transactions, the reponses changes as expected:
|
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
This code was accidentally removed in e427cda. Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
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 <shaleva.ann@nspcc.ru>
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/v2@v2.25.7/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/v2@v2.25.7/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/v2@v2.25.7/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/v2@v2.25.7/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 <shaleva.ann@nspcc.ru>
|
@txhsl, @chenquanyu, please check out 6 latest commits, I haven't touched the previously reviewed changes because they are the target of an audit. Tests are fixed, but the implementation is also adjusted, I found a couple of bugs. @songb2, could you please check that the updated branch works OK with Metamask and it's possible for Metamask to generate and properly submit transaction to the network if BaseFee and minGasTipCap values are changed in Policy. Also, we need a test for t8ntool: create an Env configuration that includes NeoXBurn fork and some Otherwise ready to be merged. |
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 <shaleva.ann@nspcc.ru>
Bug introduced by e427cda. Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
322345e to
47d2712
Compare
|
@AnnaShaleva @chenquanyu @txhsl
And the issue can also refected on metamask ui, the Priority Fee should be 0.5 gwei, Max base fee should be 1.5 gwei. |
I believe this is because our network ID is not supported by their gas API. Metamask doesn't fetch these data from RPC, it sends request to https://gas.api.cx.metamask.io/networks/{networkid}/suggestedGasFees. |
I initially was sure that it was something wrong on our side, but if it depends on network ID, then there's nothing we can do about it.
About this behaviour: to calculate go-ethereum/eth/api_backend.go Lines 366 to 372 in 47d2712
So I believe that if GAS price is still 1 gwei, then And regarding go-ethereum/internal/ethapi/api.go Lines 77 to 85 in 47d2712
where suggested TipCap is a maximum from minGasTipCap and GAS price. I believe block's BaseFee is 1, and GAS price is still 1, so the described behaviour works according to the code. The question is: should we calculate suggested TipCap as a maximum from minGasTipCap and GAS price? @chenquanyu, @txhsl, what do you think?
|
|
@AnnaShaleva @chenquanyu @txhsl |
Will take a look at it, probably more modifications are needed to make t8n tool work with NeoXBurn. |
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 <shaleva.ann@nspcc.ru>
@songb2, turns out that fork should be specified via go-ethereum/tests/state_test_util.go Line 141 in ba2663c
|
It looks like |
If minGasTipCap is available in Policy, then return this value from SuggestGasTipCap. Ref. #230 (comment). Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
@chenquanyu, @txhsl, implemented, check out the last commit please. @songb2 we need to test this version with Metamask. |
Additional changes implemented.



Please note that the target branch is policy-basefee (#166).
I've reviewed all the modules that become dependent from the node state after #166. It turns out that these modules are created with the full backend and does not work with the light backend anyway, thus it's not such critical to explicitly use the node state there. The only concern is about Oracle service: it didn't have any state (or DB) dependency before these BaseFee changes and it has this dependency now. And this service has an ability to process batch of blocks, which makes it extremely resource-consuming to retrieve state for every potential block where BaseFee change might have happen.
@txhsl, @chenquanyu, @nicolegys ready for review. We'll need tests for t8n tool and, which is more important, for Oracle service.