-
Notifications
You must be signed in to change notification settings - Fork 157
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
Refactor validation: introduce the Consensus trait #1656
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1656 +/- ##
==========================================
- Coverage 28.68% 28.57% -0.12%
==========================================
Files 189 192 +3
Lines 20863 20934 +71
==========================================
- Hits 5985 5982 -3
- Misses 14878 14952 +74
Continue to review full report at Codecov.
|
Looks good. Mind adding license headers to the two new files? It can be done by running |
Thanks @lemmih I added the license and resolved the clippy issues, also signed the CLA. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really nice PR, a lot of documentation, thanks! Control question, did you check if it syncs on mainnet and calibnet?
No. I see in the readme how to start it with calibnet, but not where I should get a How do you run these tests? |
Right now those snapshots are generated with Lotus, there is a PR in progress to get out of this dependency. For now you can download a recent one here To run calibnet on NV16 this PR needs to be merged first. Mainnet should be fine though. Basically for mainnet:
And observe it if syncs for some time. Definitely, a piece of documentation (and automated testing) we should work on! |
I found a link https://fil-chain-snapshots-fallback.s3.amazonaws.com/mainnet/minimal_finality_stateroots_latest.car to the mainnet snapshot but it's over 70Gb. I'm not going to download that, but tried the sync without it and it seems to work all right: ❯ target/release/forest --target-peer-count 50 --encrypt-keystore false ─╯
2022-07-14T19:24:36.043Z WARN forest::cli > No configurations found, using defaults.
2022-07-14T19:24:36.044Z INFO forest::daemon > Starting Forest daemon, version v0.2.2/unstable/65e3dcff
2022-07-14T19:24:36.044Z INFO forest_libp2p::service > Recovered libp2p keypair from "/home/aakoshh/.local/share/forest/libp2p/keypair"
2022-07-14T19:24:36.044Z WARN forest::daemon > Warning: Keystore encryption disabled!
2022-07-14T19:24:36.044Z WARN key_management::keystore > Keystore does not exist, initializing new keystore at: "/home/aakoshh/.local/share/forest/keystore.json"
2022-07-14T19:24:36.044Z INFO utils > Permissions set to 0600 on File { fd: 6, path: "/home/aakoshh/.local/share/forest/keystore.json", read: false, write: true }
2022-07-14T19:24:36.044Z INFO forest::daemon > Admin token: ...
2022-07-14T19:24:36.044Z INFO metrics > Prometheus server started at 127.0.0.1:6116
2022-07-14T19:24:36.090Z WARN chain::store::chain_store > No previous chain state found
2022-07-14T19:24:36.110Z INFO genesis > Initialized genesis: BlockHeader: Cid(bafy2bzacecnamqgqmifpluoeldx7zzglxcljo6oja4vrmtj7432rphldpdmm2)
2022-07-14T19:24:36.111Z INFO forest::daemon > Using network :: cannot get name
2022-07-14T19:24:36.563Z INFO forest::daemon > JSON-RPC endpoint started at 127.0.0.1:1234
2022-07-14T19:24:36.563Z INFO rpc > Ready for RPC connections
2022-07-14T19:24:37.974Z INFO chain_sync::chain_muxer > Local node is behind the network, starting BOOTSTRAP from LOCAL_HEAD = 0 -> NETWORK_HEAD = 1984009
Downloading headers 3614 / 1984009 [>-------------------------------------------------------------------------------------------------------------------------------------------------------] 0.18 % 147.05/s 224m ^C 2022-07-14T19:25:02.716Z WARN forest::cli > Got interrupt, shutting down...
2022-07-14T19:25:02.717Z INFO utils > Permissions set to 0600 on File { fd: 24, path: "/home/aakoshh/.local/share/forest/keystore.json", read: false, write: true }
2022-07-14T19:25:02.746Z INFO forest::daemon > Forest finish shutdown.
I guess it's now downloading all the headers in reverse, which means I should see some blocks being imported in ~4 hours ⏳ |
@LesnyRumcajs the sync with the mainnet ran into some issue with 90 minutes left on the clock, it found no peers to request headers from. So I created a separate branch from this where I merged the PR you mentioned and tried syncing with calibnet instead, using the snapshot you linked to. That seems to have worked: ./target/release/forest --chain calibnet --import-snapshot ../calibnet-2022-07-01.car --target-peer-count 50 --encrypt-keystore false ─╯
2022-07-14T22:04:08.309Z WARN forest::cli > No configurations found, using defaults.
2022-07-14T22:04:08.309Z INFO forest::daemon > Starting Forest daemon, version v0.2.2/unstable/e6206af3
2022-07-14T22:04:08.309Z INFO forest_libp2p::service > Recovered libp2p keypair from "/home/aakoshh/.local/share/forest/libp2p/keypair"
2022-07-14T22:04:08.309Z WARN forest::daemon > Warning: Keystore encryption disabled!
2022-07-14T22:04:08.310Z INFO forest::daemon > Admin token: eyJ0eXAiOiJKV1QiLCJhbGciOi...
2022-07-14T22:04:08.310Z INFO metrics > Prometheus server started at 127.0.0.1:6116
2022-07-14T22:04:08.376Z INFO genesis > Initialized genesis: BlockHeader: Cid(bafy2bzacecz3trtejxtzix4f4eebs7dekm6snfsmvffiqz2rfx7iwgsgtieq4)
2022-07-14T22:04:08.376Z INFO forest::daemon > Using network :: cannot get name
2022-07-14T22:04:08.376Z INFO genesis > Importing chain from snapshot
2022-07-14T22:04:08.376Z INFO genesis > Reading file...
Scanning blockchain 1082530 / 1087290 [=====================================================================================================================================================] 99.56 % 8530.18/s 1s
2022-07-14T22:06:45.956Z INFO genesis > Accepting [Cid(bafy2bzacea7c2aqujxac37aeizzg5hr2eudwumppgcek5qvxmrkp3gjv7jlm6), Cid(bafy2bzacebl2enajghfcgzvgxf66syddba4adfsexz74jca3ygxbdb2jae7bg), Cid(bafy2bzacedjwvigkrlyzvn6qvxzygw7u2qqxqywc7i7wnwqkcxfk7rf75lovw), Cid(bafy2bzacecrx6cmjyobmuaexgascuqh3ad4kxh3ff2bdxjecmusvwvs22w65w), Cid(bafy2bzacebrv2rkkqvqxuoeou2a55xwhjqsyyujic54sfsfzxuqjo2tirfk4a), Cid(bafy2bzacedd76nyajhq2bphw3aztdmtlwtrrawcvvkrcebdq6lreabqig3wyy)] as new head.
2022-07-14T22:06:46.433Z INFO forest::daemon > JSON-RPC endpoint started at 127.0.0.1:1234
2022-07-14T22:06:46.433Z INFO rpc > Ready for RPC connections
2022-07-14T22:06:48.521Z INFO chain_sync::chain_muxer > Local node is behind the network, starting BOOTSTRAP from LOCAL_HEAD = 1087290 -> NETWORK_HEAD = 1125853
Downloading headers 38563 / 38563 [=============================================================================================================================================================] 100.00 % 97.03/s
2022-07-14T22:13:27.051Z INFO chain_sync::tipset_syncer > Validating tipset: EPOCH = 1087290
2022-07-14T22:13:30.707Z INFO chain_sync::tipset_syncer > Validating tipset: EPOCH = 1087291
2022-07-14T22:13:30.764Z INFO chain_sync::tipset_syncer > Validating tipset: EPOCH = 1087292
2022-07-14T22:13:31.161Z INFO chain_sync::tipset_syncer > Validating tipset: EPOCH = 1087293
... |
@aakoshh You can't really sync without the snapshots as Forest doesn't have any migrations at the moment - only pure NV16. Even with those in place, it would take several weeks to sync. But it's a good point for exiting early instead of raising hopes and expectations! Glad it works, thanks for checking it out! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, nice refactor!
Summary of changes
Changes introduced in this pull request:
chain_sync::consensus::Consensus
trait which currently has a singlevalidate_block
method for consensus specific rules. It also has an associated error type.blockchain/fil_consensus
crate withFilecoinConsensus
implementing theConsensus
trait. Moved the errors and validations specific to PoSt, tickets, beacons, DRAND, etc. into this crate.FilecoinConsensus
also captures the generic beacon type and theProofValidator
.tipset_syncer
andChainMuxer
get a genericconsensus: C where C: Consensus
argument so they can delegate the custom validations to it.ProofValidator
was moved intoFilecoinConsensus
I was able to remove it from all but one method in the RPC andStateManager
where a block is assembled.Other information and links
This is laying some groundworks towards implementing Hierarchical Consensus
In the future we want to expand this interface to be able to generate blocks on a schedule, adhering to some hitherto unknown consensus protocol.