Skip to content
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

fix(forknet): Fix fork-network tool backward compatibility #12964

Merged

Conversation

marcelo-gonzalez
Copy link
Contributor

#12938 changed the format of the data we write to the FORK_TOOL Misc column keys in the init command, but didn't keep backward compatibility. But this should have been done because we need to run fork-network again when starting a forknet so we can run the set-validators and finalize commands. So this PR reads the values the old way if there's nothing in the FORK_TOOL_FLAT_HEAD key

@marcelo-gonzalez marcelo-gonzalez requested a review from a team as a code owner February 20, 2025 16:57
@marcelo-gonzalez
Copy link
Contributor Author

marcelo-gonzalez commented Feb 20, 2025

Tested with

$ git checkout ac5aa6a366306b1e33061e3008975bd7cb97ff4f~
$ cargo build -p neard
$ python3 tests/sanity/transactions.py
$ python3 tests/mocknet/local_test_node.py local-test-setup --source-home-dir ~/.near/test4_finished --target-home-dir ~/.near/test4_finished --neard-binary-path ~/nearcore/target/debug/neard --num-nodes 1 --yes
$ git checkout master
$ cargo build -p neard
$ cp ~/nearcore/target/debug/neard ~/.near/local-mocknet/node0/neard-runner/binaries/neard0
$ python3 tests/mocknet/mirror.py --local-test new-test --epoch-length 100 --num-validators 1 --num-seats 2 --new-chain-id foonet --genesis-protocol-version 76 --stateless-setup --yes
$ cat ~/.near/local-mocknet/node0/stderr
...
thread 'main' panicked at tools/fork-network/src/cli.rs:552:77:
called `Option::unwrap()` on a `None` value
...
$ git checkout $good_commit # good commit is this PR plus https://github.com/marcelo-gonzalez/nearcore/commit/f567b7bd67a6c4aab3cc1f1e9cbf450e4aa85f9d
$ cargo build -p neard
$ cp ~/nearcore/target/debug/neard ~/.near/local-mocknet/node0/neard-runner/binaries/neard0
$ python3 tests/mocknet/mirror.py --local-test new-test --epoch-length 100 --num-validators 1 --num-seats 2 --new-chain-id foonet --genesis-protocol-version 76 --stateless-setup --yes
$ python3 tests/mocknet/mirror.py --local-test start-nodes
$ curl localhost:3041/status | jq .sync_info
<GOOD>

Copy link

codecov bot commented Feb 20, 2025

Codecov Report

Attention: Patch coverage is 0% with 49 lines in your changes missing coverage. Please review.

Project coverage is 70.23%. Comparing base (a0b4946) to head (0641f54).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
tools/fork-network/src/cli.rs 0.00% 49 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #12964      +/-   ##
==========================================
- Coverage   70.25%   70.23%   -0.02%     
==========================================
  Files         855      855              
  Lines      176300   176341      +41     
  Branches   176300   176341      +41     
==========================================
- Hits       123860   123856       -4     
- Misses      47290    47329      +39     
- Partials     5150     5156       +6     
Flag Coverage Δ
backward-compatibility 0.35% <0.00%> (-0.01%) ⬇️
db-migration 0.35% <0.00%> (-0.01%) ⬇️
genesis-check 1.41% <0.00%> (-0.01%) ⬇️
linux 69.85% <0.00%> (-0.01%) ⬇️
linux-nightly 69.86% <0.00%> (-0.05%) ⬇️
pytests 1.72% <0.00%> (-0.01%) ⬇️
sanity-checks 1.53% <0.00%> (-0.01%) ⬇️
unittests 70.07% <0.00%> (-0.02%) ⬇️
upgradability 0.35% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Longarithm
Copy link
Member

@Trisfald may I ask you for review because you reviewed the original change?

@Longarithm Longarithm requested a review from Trisfald February 21, 2025 09:17
Copy link
Contributor

@Trisfald Trisfald left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks!

I'm fine with this change just tested manually

store: Store,
epoch_manager: &dyn EpochManagerAdapter,
) -> anyhow::Result<(HashMap<ShardUId, StateRoot>, BlockInfo, EpochId, ShardLayout)> {
let epoch_id = EpochId(store.get_ser(DBCol::Misc, b"FORK_TOOL_EPOCH_ID")?.unwrap());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: These three keys (b"FORK_TOOL_EPOCH_ID", etc) now appear multiple times, we could use a constant

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@marcelo-gonzalez marcelo-gonzalez added this pull request to the merge queue Feb 21, 2025
Merged via the queue into near:master with commit 50841ef Feb 21, 2025
29 checks passed
@marcelo-gonzalez marcelo-gonzalez deleted the fork-net-backward-compat branch February 21, 2025 16:41
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.

3 participants