Skip to content

Conversation

@AnnaShaleva
Copy link
Member

@AnnaShaleva AnnaShaleva commented Jun 14, 2024

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.

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>
@AnnaShaleva AnnaShaleva requested a review from roman-khimov June 14, 2024 20:19
@AnnaShaleva AnnaShaleva added this to the v0.1.2 milestone Jun 14, 2024
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>
@AnnaShaleva AnnaShaleva changed the title WIP: Adjust BaseFee burning mechanism Adjust BaseFee burning mechanism Jun 18, 2024
@AnnaShaleva
Copy link
Member Author

Ready for review, the PR comment is updated, please, take a look.

txhsl
txhsl previously approved these changes Jun 19, 2024
@AnnaShaleva
Copy link
Member Author

@nicolegys, could you please test this branch? Especially the Oracle service with his fee history call.

@chenquanyu
Copy link
Collaborator

@nicolegys, could you please test this branch? Especially the Oracle service with his fee history call.

@songb2 This is our new tester.

@AnnaShaleva
Copy link
Member Author

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.

@songb2
Copy link
Collaborator

songb2 commented Jun 21, 2024

I've tested the following apis by changing baseFee and minGasTipCap in policy and also made some transactions, the reponses changes as expected:

  1. eth_maxPriorityFeePerGas
  2. eth_gasPrice
  3. eth_feeHistory

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>
@AnnaShaleva
Copy link
Member Author

@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 currentBaseFee value set in the Env config. Try to execute some transaction with this Env t8ntool configuration and check whether the BaseFee limit is properly checked against the pre-configured value.

Otherwise ready to be merged.

@AnnaShaleva AnnaShaleva requested review from chenquanyu and txhsl June 26, 2024 10:13
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>
chenquanyu
chenquanyu previously approved these changes Jul 3, 2024
@songb2
Copy link
Collaborator

songb2 commented Jul 3, 2024

@AnnaShaleva @chenquanyu @txhsl
Still in testing, but I tested metamask and also some eth apis and found the following problems, please help confirm if they are issues:

  1. go to Edit gas fee page, Low, Market, and Aggressive options don't show numbers
    image
  2. By default basefee and minGasTipCap are all 1 gwei, so the eth_maxPriorityFeePerGas is also 1 gwei, and eth_gasPrice is 2 gwei.
    When I change minGasTipCap to 0.5 gwei, but eth_maxPriorityFeePerGas is still 1 gwei (I think it should change to 0.5 gwei), and eth_gasPrice is still 2 gwei (I think it should be 1.5 gwei)
condition baseFee minGasTipGap eth_maxPriorityFeePerGas eth_gasPrice
default value in policy 1 1 1 2
decrease minGasTipGap to 0.5 1 0.5 1 2

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.
image

@txhsl
Copy link
Contributor

txhsl commented Jul 4, 2024

  1. go to Edit gas fee page, Low, Market, and Aggressive options don't show numbers

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.

@AnnaShaleva
Copy link
Member Author

I believe this is because our network ID is not supported by their gas API.

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.

When I change minGasTipCap to 0.5 gwei, but eth_maxPriorityFeePerGas is still 1 gwei (I think it should change to 0.5 gwei), and eth_gasPrice is still 2 gwei (I think it should be 1.5 gwei)

About this behaviour: to calculate eth_maxPriorityFeePerGas we use maximum from minGasTipCap and GAS price:

func (b *EthAPIBackend) SuggestGasTipCap(ctx context.Context) (*big.Int, error) {
suggestTipCap, minGasTipCap, err := b.gpo.SuggestTipCap(ctx)
if err != nil {
return nil, err
}
return cmath.BigMax(suggestTipCap, minGasTipCap), nil
}

So I believe that if GAS price is still 1 gwei, then eth_maxPriorityFeePerGas returns the proper value.

And regarding eth_gasPrice: to calculate it we use suggested TipCap added to the latest block's BaseFee:

func (s *EthereumAPI) GasPrice(ctx context.Context) (*hexutil.Big, error) {
tipcap, err := s.b.SuggestGasTipCap(ctx)
if err != nil {
return nil, err
}
if head := s.b.CurrentHeader(); head.BaseFee != nil {
tipcap.Add(tipcap, head.BaseFee)
}
return (*hexutil.Big)(tipcap), err

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?

@songb2
Copy link
Collaborator

songb2 commented Jul 4, 2024

@AnnaShaleva @chenquanyu @txhsl
For the tn8tool, I try to set neoXBurnTime to cmd/evm/testdata/29/env.json, but it doesn't take effect, seems that it wasn't read by config.go. I print some logs in IsNeoXBurn, it shows that the field is nil, as as result, it return false,.
func isTimestampForked(s *uint64, head uint64) bool {
if s == nil {
return false
}
return *s <= head
}
I use the command to test ../../build/bin/evm t8n --input.alloc=./testdata/29/alloc.json --input.txs=./testdata/29/txs.json --input.env=./testdata/29/env.json --state.fork=Shanghai
image

@AnnaShaleva
Copy link
Member Author

but it doesn't take effect, seems that it wasn't read by config.go

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>
@AnnaShaleva
Copy link
Member Author

AnnaShaleva commented Jul 5, 2024

but it doesn't take effect, seems that it wasn't read by config.go

@songb2, turns out that fork should be specified via state.fork CLI flag, not via t8ntool env config. Please, check the last commit, I've extended the list of valid hardforks recognizable by t8ntool, so you have to specify --state.fork=NeoXBurn, it works like Shanghai+burn-related changes. Please, check this issue one more time and see how it works:

func GetChainConfig(forkString string) (baseConfig *params.ChainConfig, eips []int, err error) {

@chenquanyu
Copy link
Collaborator

chenquanyu commented Jul 8, 2024

The question is: should we calculate suggested TipCap as a maximum from minGasTipCap and GAS price? @chenquanyu, @txhsl, what do you think?

It looks like GAS price comes from the 60% quantile of the historical block gasTip list. If we use the maximum value of minGasTipCap and GAS price, then if we reduce minGasTipCap in Policy, suggestTipCap will always remain the same. So I suggest we just use minGasTipCap as suggestTipCap.

If minGasTipCap is available in Policy, then return this value from
SuggestGasTipCap. Ref.
#230 (comment).

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
@AnnaShaleva
Copy link
Member Author

So I suggest we just use minGasTipCap as suggestTipCap.

@chenquanyu, @txhsl, implemented, check out the last commit please.

@songb2 we need to test this version with Metamask.

@AnnaShaleva AnnaShaleva requested a review from chenquanyu July 8, 2024 12:53
@AnnaShaleva AnnaShaleva dismissed stale reviews from chenquanyu and txhsl July 8, 2024 13:13

Additional changes implemented.

@AnnaShaleva
Copy link
Member Author

I'm merging this PR into policy-basefee so that it's possible to update the base branch. However, final test with Metamask is still needed, we're not going to release without it. Thus, @songb2, please, write the test results to #166. Any further discussions are moved to the original PR.

@AnnaShaleva AnnaShaleva merged commit 1636589 into policy-basefee Jul 9, 2024
@AnnaShaleva AnnaShaleva deleted the adjust-basefee branch July 9, 2024 07:56
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.

6 participants