-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
feat: support "safe" param for eth_getBlockByNumber for 30 blocks #12110
Conversation
… are using as 30 blocks
All checks have completed ❌ Failed Test / Test (itest-eth_legacy_transactions) (pull_request) |
Would be worth doing |
@snissn "finalised" should be very similar to the "safe" implementation no ? Best to just add it to this PR. |
there's a |
Thanks @rvagg @aarshkshah1992 !! I will move the safeEpochDelay to a const in eth_types and will use |
I've added support for 'finalized' and created a const for the safe delay with the suggested comment
|
Lack of tests is a bit of a bummer on this and there's not an easy slot for a new unit test - but if you could come up with an easy way to do it locally there then that would be great. Here's an integration test that would exercise it, which is something at least, stick this in func TestEthBlockNumberAliases(t *testing.T) {
blockTime := 2 * time.Millisecond
kit.QuietMiningLogs()
client, _, ens := kit.EnsembleMinimal(t, kit.MockProofs(), kit.ThroughRPC())
ens.InterconnectAll().BeginMining(blockTime)
ens.Start()
build.Clock.Sleep(time.Second)
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
defer cancel()
head := client.WaitTillChain(ctx, kit.HeightAtLeast(build.Finality+100))
// latest should be head-1 (parents)
latestEthBlk, err := client.EVM().EthGetBlockByNumber(ctx, "latest", true)
require.NoError(t, err)
diff := int64(latestEthBlk.Number) - int64(head.Height()-1)
require.GreaterOrEqual(t, diff, int64(0))
require.LessOrEqual(t, diff, int64(2))
// safe should be latest-30
safeEthBlk, err := client.EVM().EthGetBlockByNumber(ctx, "safe", true)
require.NoError(t, err)
diff = int64(latestEthBlk.Number-30) - int64(safeEthBlk.Number)
require.GreaterOrEqual(t, diff, int64(0))
require.LessOrEqual(t, diff, int64(2))
// finalized should be Finality blocks behind latest
finalityEthBlk, err := client.EVM().EthGetBlockByNumber(ctx, "finalized", true)
require.NoError(t, err)
diff = int64(latestEthBlk.Number) - int64(build.Finality) - int64(finalityEthBlk.Number)
require.GreaterOrEqual(t, diff, int64(0))
require.LessOrEqual(t, diff, int64(2))
} maybe that could be made more concise; the awkwardness is in wanting to allow a fast moving chain to move on between calls, so we can't guarantee we'll hit it precisely, hence the 2 epochs |
Co-authored-by: Rod Vagg <[email protected]>
…nalized as arguments
…project/lotus into mikers/safeEthGetBlockByNumber
Thanks that test looks great and it feels a lot better that we have this test coverage with this PR! 84199c2 |
…12110) * add support for eth_getBlockByNumber to accept the term safe which we are using as 30 blocks * fix lint catch of unnecessary cast * add finalized to get block by number * Update chain/types/ethtypes/eth_types.go Co-authored-by: Rod Vagg <[email protected]> * add test for eth get block by number to accept latest and safe and finalized as arguments --------- Co-authored-by: Rod Vagg <[email protected]>
…12110) * add support for eth_getBlockByNumber to accept the term safe which we are using as 30 blocks * fix lint catch of unnecessary cast * add finalized to get block by number * Update chain/types/ethtypes/eth_types.go Co-authored-by: Rod Vagg <[email protected]> * add test for eth get block by number to accept latest and safe and finalized as arguments --------- Co-authored-by: Rod Vagg <[email protected]>
…12110) * add support for eth_getBlockByNumber to accept the term safe which we are using as 30 blocks * fix lint catch of unnecessary cast * add finalized to get block by number * Update chain/types/ethtypes/eth_types.go Co-authored-by: Rod Vagg <[email protected]> * add test for eth get block by number to accept latest and safe and finalized as arguments --------- Co-authored-by: Rod Vagg <[email protected]>
Related Issues
#12083
Proposed Changes
Additional Info
Checklist
Before you mark the PR ready for review, please make sure that:
<PR type>: <area>: <change being made>
fix: mempool: Introduce a cache for valid signatures
PR type
: fix, feat, build, chore, ci, docs, perf, refactor, revert, style, testarea
, e.g. api, chain, state, mempool, multisig, networking, paych, proving, sealing, wallet, deps