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

refactor: impl Trie for MPTTrie #1363

Merged
merged 1 commit into from
Aug 29, 2023

Conversation

yangby-cryptape
Copy link
Collaborator

@yangby-cryptape yangby-cryptape commented Aug 25, 2023

What this PR does / why we need it?

  • I want to add methods to MPTTrie<DB> in another crate.

    Limit by the orphan rule, I have to use a trait to add methods to MPTTrie<DB>.

    • If I use a trait to add methods to MPTTrie<DB>, I could NOT write the following code:

      pub trait TrieExt<BD>: MPTTrie<DB> {
          /* Use methods of `MPTTrie<DB>` in trait body. */
      }

      , since MPTTrie<DB> is a struct, but I can write the following code:

      pub trait TrieExt: Trie {
          /* Use methods of `Trie` in trait body. */
      }
  • Some methods of MPTTrie<DB> are not exposed, for example, get_proof(..) and verify_proof(..).

  • Another reason:

    In fact, MPTTrie<DB> is a Trie, we should use it as Trie directly.

    Trie is in a higher level of TrieDB in abstract.

    Treat MPTTrie<DB> as as a TrieDB is not reasonable.

What is the impact of this PR?

No Breaking Change

CI Settings

CI Usage

Tip: Check the CI you want to run below, and then comment /run-ci.

CI Switch

  • Coverage Test
  • E2E Tests
  • Code Format
  • Web3 Compatible Tests
  • OCT 1-5 And 12-15
  • OCT 6-10
  • OCT 11
  • OCT 16-19
  • v3 Core Tests

CI Description

CI Name Description
Chaos CI Test the liveness and robustness of Axon under terrible network condition
Cargo Clippy Run cargo clippy --all --all-targets --all-features
Coverage Test Get the unit test coverage report
E2E Test Run end-to-end test to check interfaces
Code Format Run cargo +nightly fmt --all -- --check and cargo sort -gwc
Web3 Compatible Test Test the Web3 compatibility of Axon
v3 Core Test Run the compatibility tests provided by Uniswap V3
OCT 1-5 | 6-10 | 11 | 12-15 | 16-19 Run the compatibility tests provided by OpenZeppelin

@yangby-cryptape yangby-cryptape requested a review from a team as a code owner August 25, 2023 09:19
@yangby-cryptape yangby-cryptape requested review from Flouse, driftluo and KaoImin and removed request for blckngm and wenyuanhust August 25, 2023 09:38
@yangby-cryptape

This comment was marked as off-topic.

@axon-bot

This comment was marked as outdated.

@yangby-cryptape yangby-cryptape force-pushed the yangby/refactor/impl-trie-for-mpttrie branch from 61b3bcf to 5172b95 Compare August 25, 2023 18:28
@yangby-cryptape

This comment was marked as off-topic.

@axon-bot

This comment was marked as outdated.

KaoImin
KaoImin previously approved these changes Aug 26, 2023
@KaoImin
Copy link
Contributor

KaoImin commented Aug 26, 2023

The MPTTrie in wrapped.rs seems useless after these changes, consider removing it by the following:

pub type MPTTrie<DB: trie::DB> = trie::PatriciaTrie<DB, HasherKeccak>;

@yangby-cryptape
Copy link
Collaborator Author

The MPTTrie in wrapped.rs seems useless after these changes, consider removing it by the following:

pub type MPTTrie<DB: trie::DB> = trie::PatriciaTrie<DB, HasherKeccak>;

MPTTrie has its own class methods.
Limit by the orphan rule, we could not add methods to trie::PatriciaTrie.

I only remove the class methods which are conflict with trait methods of Trie.

@yangby-cryptape

This comment was marked as off-topic.

@axon-bot

This comment was marked as outdated.

KaoImin
KaoImin previously approved these changes Aug 29, 2023
@yangby-cryptape

This comment was marked as off-topic.

@axon-bot
Copy link

axon-bot bot commented Aug 29, 2023

CI tests run on commit:

CI test list:

  • Code Format
  • E2E Tests
  • OCT 1-5 And 12-15
  • OCT 6-10
  • OCT 11
  • OCT 16-19
  • v3 Core Tests
  • Web3 Compatible Tests

Please check ci test results later.

@yangby-cryptape yangby-cryptape added this pull request to the merge queue Aug 29, 2023
Merged via the queue into main with commit 14f5b3a Aug 29, 2023
@yangby-cryptape yangby-cryptape deleted the yangby/refactor/impl-trie-for-mpttrie branch August 29, 2023 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants