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

feat(migration): Migrate contract store (contract's slots) from monservice to modular-service representation #10252

Merged
merged 2 commits into from Dec 5, 2023

Conversation

david-bakin-sl
Copy link
Member

Description:

New class ContractStateMigrator will migrate from a mono service's contract store representation to a modular service's contract store (given by a WritableKVStore).

Can optionally perform a validation on the resulting migrated state, ensuring that it is consistent in some ways

  • has same number of entries as original state
  • all linked lists of slots are still linked

Shown correct by enhancing the contract store dumper to (optionally) migrate the contract store before dumping it. Diff on the two dumps (without migration and with migration) shows only the summary line changes: and that only to include a migration flag (to distinguish them).

Has code that commits the migration-in-progress modular store every 10000 items added (to force flush-to-disk). Tricky thing there is there doesn't appear currently to be any access path from a WritableKVState to get to the point where you can copy() the underlying VirtualMap/MerkleMap. But the caller must have access to the underlying structure. And so the caller passes in an operator that does the commit + copy and returns the new store to work with.

An example command line for the dumper:

./services-cli.sh signed-state -f states/2023-10-29T03:18:19Z/151988064/SignedState.swh dump contract-stores -k -s \
     --migration --validate-migration \
     -o 2023-10-29T03:18:19Z-151988064.contract-stores.new.txt

Related issue(s):

Fixes #10210

Checklist

  • Documented (Code comments, README, etc.)
  • Tested (via dumper, against mainnet states)

Copy link

github-actions bot commented Dec 4, 2023

Node: Unit Test Results

    2 289 files  ±0      2 289 suites  ±0   40m 3s ⏱️ - 1m 26s
118 408 tests ±0  118 374 ✔️ ±0  34 💤 ±0  0 ±0 
126 830 runs  ±0  126 796 ✔️ ±0  34 💤 ±0  0 ±0 

Results for commit b4092b6. ± Comparison against base commit 864ea88.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Dec 4, 2023

Node: HAPI Test (Token) Results

190 tests  ±0   188 ✔️ ±0   20m 53s ⏱️ +43s
  13 suites ±0       2 💤 ±0 
  13 files   ±0       0 ±0 

Results for commit b4092b6. ± Comparison against base commit 864ea88.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Dec 4, 2023

Node: HAPI Test (Crypto) Results

211 tests  ±0   201 ✔️ ±0   20m 27s ⏱️ +9s
  22 suites ±0     10 💤 ±0 
  22 files   ±0       0 ±0 

Results for commit b4092b6. ± Comparison against base commit 864ea88.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Dec 4, 2023

Node: E2E Test Results

    1 files      1 suites   23m 52s ⏱️
311 tests 311 ✔️ 0 💤 0
333 runs  333 ✔️ 0 💤 0

Results for commit b4092b6.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Dec 4, 2023

Node: HAPI Test (Misc) Results

419 tests  ±0   313 ✔️ ±0   25m 8s ⏱️ - 2m 11s
  73 suites ±0   106 💤 ±0 
  73 files   ±0       0 ±0 

Results for commit b4092b6. ± Comparison against base commit 864ea88.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Dec 4, 2023

Node: HAPI Test (Time Consuming) Results

21 tests     9 ✔️  26m 28s ⏱️
  2 suites  12 💤
  2 files      0

Results for commit b4092b6.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Dec 4, 2023

Node: Integration Test Results

279 tests  ±0   279 ✔️ ±0   28m 32s ⏱️ +41s
    5 suites ±0       0 💤 ±0 
    5 files   ±0       0 ±0 

Results for commit b4092b6. ± Comparison against base commit 864ea88.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Dec 4, 2023

Node: HAPI Test (Smart Contract) Results

405 tests  ±0   325 ✔️ ±0   45m 49s ⏱️ + 2m 52s
  56 suites ±0     80 💤 ±0 
  56 files   ±0       0 ±0 

Results for commit b4092b6. ± Comparison against base commit 864ea88.

♻️ This comment has been updated with latest results.

…service to modular-service representation

New class `ContractStateMigrator` will migrate from a mono service's contract store representation to a modular
service's contract store (given by a `WritableKVStore`).

Can optionally perform a validation on the resulting migrated state, ensuring that it is consistent in some ways
* has same number of entries as original state
* all linked lists of slots are still linked

Shown correct by enhancing the contract store dumper to (optionally) migrate the contract store before dumping it.
Diff on the two dumps (without migration and with migration) shows only the summary line changes: and that only to
include a migration flag (to distinguish them).

Has code that commits the migration-in-progress modular store every 10000 items added (to force flush-to-disk).  Tricky
thing there is there doesn't appear currently to be any access path from a `WritableKVState` to get to the point where
you can `copy()` the underlying `VirtualMap`/`MerkleMap`.  But the _caller_ must have access to the underlying
structure.  And so the caller passes in an operator that does the commit + copy and returns the new store to work with.

An example command line for the dumper:

```
./services-cli.sh signed-state -f states/2023-10-29T03:18:19Z/151988064/SignedState.swh dump contract-stores -k -s \
     --migration --validate-migration \
     -o 2023-10-29T03:18:19Z-151988064.contract-stores.new.txt
```

Fixes #10210

Signed-off-by: David S Bakin <117694041+david-bakin-sl@users.noreply.github.com>
Copy link

codecov bot commented Dec 4, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

❗ No coverage uploaded for pull request base (develop@864ea88). Click here to learn what that means.

❗ Current head b2cb512 differs from pull request most recent head b4092b6. Consider uploading reports for the commit b4092b6 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             develop   #10252   +/-   ##
==========================================
  Coverage           ?   63.53%           
  Complexity         ?    30933           
==========================================
  Files              ?     3331           
  Lines              ?   134235           
  Branches           ?    13951           
==========================================
  Hits               ?    85286           
  Misses             ?    45592           
  Partials           ?     3357           

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

... mainly to kick the Github DCO service to get its act together

Signed-off-by: David S Bakin <117694041+david-bakin-sl@users.noreply.github.com>
jeromy-cannon
jeromy-cannon previously approved these changes Dec 4, 2023
Copy link
Member

@mhess-swl mhess-swl left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks a bunch @david-bakin-sl!

@david-bakin-sl david-bakin-sl merged commit 1a2a719 into develop Dec 5, 2023
24 of 25 checks passed
@david-bakin-sl david-bakin-sl deleted the 10210-contract-store-migration branch December 5, 2023 00:38
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.

Need to migrate the contract store from mono-service's representation to modular-service's representation.
3 participants