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(trie): Add trie v1 support #3276

Closed
wants to merge 2 commits into from
Closed

feat(trie): Add trie v1 support #3276

wants to merge 2 commits into from

Conversation

dimartiro
Copy link
Contributor

@dimartiro dimartiro commented May 24, 2023

Changes

More info in this discussion paritytech/substrate#11607 (comment)

This PR is based on:

#2665

  • Decode header using variant struct of bits + bit mask
  • Add empty variant header
  • Remove now unneeded encodeRoot (taken care by new variant) - no compatibility change at all
  • (Side change) more readable decode test cases
  • Do not allow header 00000000 when decoding, if v0 is used (blocked by versioning PR)
  • Make sure encoding and decoding new lines are test covered

#2641

  • Add node headers
  • Reject decoding new headers when using v0 state trie
  • Proof verification to use compact encoding escape header
  • Implement leaf with hashed subvalue
  • Implement branch with hashed subvalue
  • Support child tries upgrade
  • Support proof generation/verification

#2774

  • Version relevant trie calls (Put, Hash)
  • Convert wasmer Core_version Version to typed trie.Version
  • Adapt tests/test helpers to read the state version from the genesis runtime code

#2664

  • Implement runtime functions
    • ext_trie_blake2_256_root_version_2
    • ext_trie_blake2_256_ordered_root_version_2
    • ext_trie_blake2_256_verify_proof_version_2
    • ext_default_child_storage_root_version_2
    • ext_storage_root_version_2
  • Change version from 4 bytes pointed by pointer to uint8 read from uint32 4 bytes.
  • Panic instead of logger.Error

General

  • Add missing tests
  • Fix unit tests
  • Fix integration tests

Nice to have

#2912

Tests

go test ./lib/trie/... ./internal/trie/...

Issues

Closes #2418

Primary Reviewer

@timwu20

@dimartiro dimartiro changed the title feat(trie): Add trie v1 new nodes support feat(trie): Add trie v1 support May 24, 2023
@codecov
Copy link

codecov bot commented May 24, 2023

Codecov Report

Merging #3276 (20af8f5) into development (e5b12f4) will increase coverage by 0.35%.
The diff coverage is 97.77%.

Additional details and impacted files
@@               Coverage Diff               @@
##           development    #3276      +/-   ##
===============================================
+ Coverage        50.79%   51.15%   +0.35%     
===============================================
  Files              223      224       +1     
  Lines            27906    27925      +19     
===============================================
+ Hits             14175    14285     +110     
+ Misses           12372    12276      -96     
- Partials          1359     1364       +5     

@dimartiro dimartiro closed this Jun 1, 2023
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.

Implement storage trie version 1
1 participant