Repository navigation
feat(daemon): import enriched snapshots #7734
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
Open
Open
Changes from all commits
Commits
Show all changes
67 commits
Select commit
Hold shift + click to select a range
3d7c7c9
feat(daemon): improt enriched snapshots
EclesioMeloJunior 7af312d
chore: remove backfill from rpc-checks
EclesioMeloJunior f4452c3
Merge branch 'main' into forest-enrich-archive
EclesioMeloJunior eb1a0de
Merge branch 'main' into forest-enrich-archive
EclesioMeloJunior 3f4494e
chore: changes to metadata url format
EclesioMeloJunior 417dce5
Merge branch 'main' of github.com:ChainSafe/forest into forest-enrich…
EclesioMeloJunior 78eaa9c
Merge branch 'forest-enrich-archive' of github.com:ChainSafe/forest i…
EclesioMeloJunior 6c1be3a
Merge branch 'main' into forest-enrich-archive
EclesioMeloJunior 0948434
Update CHANGELOG.md
EclesioMeloJunior 25a2657
Merge branch 'main' into forest-enrich-archive
EclesioMeloJunior 3720635
Merge branch 'main' of github.com:ChainSafe/forest into forest-enrich…
EclesioMeloJunior 6c1c8ea
chore: batch writes to db to improve speed
EclesioMeloJunior 9b6b5e6
Merge branch 'forest-enrich-archive' of github.com:ChainSafe/forest i…
EclesioMeloJunior 2cf0536
Merge branch 'main' into forest-enrich-archive
EclesioMeloJunior c64f488
Merge branch 'main' into forest-enrich-archive
EclesioMeloJunior 9713afe
chore: address comments
EclesioMeloJunior b65be4d
Merge branch 'main' into forest-enrich-archive
EclesioMeloJunior 995fa7d
chore: share import_tipset_lookup_snapshot & backfill_receipts_events
EclesioMeloJunior 108abc5
Merge branch 'forest-enrich-archive' of github.com:ChainSafe/forest i…
EclesioMeloJunior 8f85fbf
chore: resolve redirect urls
EclesioMeloJunior d8766e4
chore: solve problems
EclesioMeloJunior d52b43d
Merge branch 'main' into forest-enrich-archive
EclesioMeloJunior 9bab5cc
chore: fix backfill problems
EclesioMeloJunior ddceb1b
Merge branch 'main' of github.com:ChainSafe/forest into forest-enrich…
EclesioMeloJunior 75ab9c8
Merge branch 'forest-enrich-archive' of github.com:ChainSafe/forest i…
EclesioMeloJunior b0756bd
Merge branch 'main' into forest-enrich-archive
EclesioMeloJunior 5ca5642
chore: include few logs
EclesioMeloJunior 1576430
Merge branch 'forest-enrich-archive' of github.com:ChainSafe/forest i…
EclesioMeloJunior 6ae1502
use a simple regex on download_extended_snapshot
EclesioMeloJunior 78d87aa
chore: introduce SnapshotImportPath
EclesioMeloJunior e6b59d1
chore: use `ensure!`
EclesioMeloJunior c77e9f6
chore: remove counter
EclesioMeloJunior 40d6cce
chore: remove out-of-scope changes
EclesioMeloJunior 64f8a79
Merge branch 'main' into forest-enrich-archive
EclesioMeloJunior 4cbdcf3
backfill only after receipts_events and tipset lookup import
EclesioMeloJunior f122381
chore: avoid warn log by starting backfill at the heads parent
EclesioMeloJunior 935fd25
chore: update documentation
EclesioMeloJunior 5f6401d
implement `CarBlock::validate` the same check as `forest-tool db impo…
EclesioMeloJunior 6a57c04
chore: remove unneded `resolve.rb` as we auto backfill on node startup
EclesioMeloJunior 6bf80a1
`maybe_import_extended_snapshots` no longer takes a db parameter
EclesioMeloJunior ab6b83e
Merge branch 'forest-enrich-archive' of github.com:ChainSafe/forest i…
EclesioMeloJunior 2c57904
chore: address doc lint
EclesioMeloJunior a093b5b
Merge branch 'main' into forest-enrich-archive
EclesioMeloJunior aeb5cc4
Merge branch 'main' into forest-enrich-archive
EclesioMeloJunior 4a46a58
Merge branch 'main' into forest-enrich-archive
EclesioMeloJunior 0353b94
chore: show download progress
EclesioMeloJunior 7962684
chore: remove double loop while importing tipset_lookup
EclesioMeloJunior a510b22
Merge branch 'forest-enrich-archive' of github.com:ChainSafe/forest i…
EclesioMeloJunior 56ada40
chore: addressing comments
EclesioMeloJunior 6f13b85
Merge branch 'main' into forest-enrich-archive
EclesioMeloJunior a9bdaff
chore: show tipset import entries progress
EclesioMeloJunior 5fe6b05
Merge branch 'forest-enrich-archive' of github.com:ChainSafe/forest i…
EclesioMeloJunior e4ec43b
Merge branch 'main' into forest-enrich-archive
EclesioMeloJunior 535e214
Merge branch 'main' into forest-enrich-archive
EclesioMeloJunior 22146db
chore: fallback to url when HEAD request cannot redirect successfully
EclesioMeloJunior ca6a40b
chore: url join + query so it dont drop any url info
EclesioMeloJunior 3201c35
Merge branch 'forest-enrich-archive' of github.com:ChainSafe/forest i…
EclesioMeloJunior ad737e6
backfill cover only the number of state roots advertised at snapshot …
EclesioMeloJunior dc08f70
chore: validate before writing
EclesioMeloJunior f5acd03
Merge branch 'main' of github.com:ChainSafe/forest into forest-enrich…
EclesioMeloJunior 440506f
place a max cap on backfill & resolve fail if no extended snapshots a…
EclesioMeloJunior 1aca6c2
chore: use `BlockstoreWithWriteBuffer`
EclesioMeloJunior 6f776ec
chore: include tests
EclesioMeloJunior 34f77da
Merge branch 'main' of github.com:ChainSafe/forest into forest-enrich…
EclesioMeloJunior 4665573
chore: fix lint
EclesioMeloJunior d513bf8
Merge branch 'main' of github.com:ChainSafe/forest into forest-enrich…
EclesioMeloJunior 2975247
chore: addressing most of the comments
EclesioMeloJunior File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,11 @@ | ||
| #!/usr/bin/env bash | ||
| # Runs in the `init` service: imports the snapshot ./resolve.rb picked and | ||
| # back-fills the chain index, all before the daemon starts. | ||
| # Runs in the `init` service: imports the snapshot ./resolve.rb picked, along | ||
| # with its extended snapshots (receipts and events, tipset lookup), before the | ||
| # daemon starts. | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| url=$(< /data/snapshot-url) | ||
| epoch=$(< /data/snapshot-epoch) | ||
| read -r chain start _ < /data/check-target | ||
| read -r chain _ < /data/check-target | ||
|
EclesioMeloJunior marked this conversation as resolved.
Resolved
|
||
|
|
||
| forest --chain="${chain}" --encrypt-keystore=false --import-snapshot="${url}" --halt-after-import | ||
|
|
||
| # inclusive on both ends | ||
| forest-tool index backfill --chain="${chain}" --from="${epoch}" --to="${start}" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,31 +1,35 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| # Confirms the node indexed the epochs the checks query. | ||
| # Confirms the node indexed the epochs the checks query: the tipset is served and the receipts | ||
| # of its messages are in the store, read back through the standard chain API. | ||
|
|
||
| require 'json' | ||
| require 'net/http' | ||
|
|
||
| url = URI("http://#{ENV.fetch('FOREST_RPC_URL')}") | ||
|
|
||
| ARGV.each do |argument| | ||
| epoch = Integer(argument) | ||
| def rpc(url, method, params) | ||
| request = Net::HTTP::Post.new(url, 'Content-Type' => 'application/json') | ||
| request.body = { | ||
| jsonrpc: '2.0', | ||
| id: 1, | ||
| method: 'eth_getBlockByNumber', | ||
| params: ["0x#{epoch.to_s(16)}", false] | ||
| }.to_json | ||
| request.body = { jsonrpc: '2.0', id: 1, method: method, params: params }.to_json | ||
| JSON.parse(Net::HTTP.start(url.hostname, url.port) { |http| http.request(request) }.body) | ||
| end | ||
|
|
||
| response = Net::HTTP.start(url.hostname, url.port) { |http| http.request(request) } | ||
| body = JSON.parse(response.body) | ||
| ARGV.each do |argument| | ||
| epoch = Integer(argument) | ||
| block = rpc(url, 'eth_getBlockByNumber', ["0x#{epoch.to_s(16)}", false]) | ||
| # Error code 12 denotes a null round across implementations. | ||
| # https://github.com/ChainSafe/forest/blob/8c980e679b6606c534c6eb5bd8aa03ff8cc6f5c0/src/rpc/methods/eth/errors.rs#L22 | ||
| null_round = body.dig('error', 'code') == 12 | ||
|
|
||
| unless body.dig('result', 'number') || null_round | ||
| abort "epoch #{epoch} is not indexed: #{response.code} #{response.body}" | ||
| if block.dig('error', 'code') == 12 | ||
| puts "epoch #{epoch} was a null round" | ||
| next | ||
| end | ||
| abort "epoch #{epoch} is not indexed: #{block}" unless block.dig('result', 'number') | ||
|
|
||
| puts "epoch #{epoch} #{null_round ? 'was a null round' : 'is indexed'}" | ||
| # The receipts of an epoch's messages are stored under its child tipset, the first non-null | ||
| # tipset above it. Reading them back is the same check any client would make. | ||
| child = rpc(url, 'Filecoin.ChainGetTipSetAfterHeight', [epoch + 1, []]) | ||
| abort "epoch #{epoch} has no tipset above it: #{child['error']}" if child['error'] | ||
| receipts = rpc(url, 'Filecoin.ChainGetParentReceipts', [child.dig('result', 'Cids', 0)]) | ||
| abort "epoch #{epoch} has no receipts: #{receipts['error']}" if receipts['error'] | ||
| puts "epoch #{epoch} is indexed" | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.