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

Introduce Rlp::at_with_offset method. #269

Merged
merged 2 commits into from
Nov 20, 2019
Merged

Introduce Rlp::at_with_offset method. #269

merged 2 commits into from
Nov 20, 2019

Conversation

jimpo
Copy link
Contributor

@jimpo jimpo commented Nov 20, 2019

This is needed to update parity-ethereum's Patricia Trie to version 0.16.0 of the trie-db crate.

NodeCodec in trie-db was changed in paritytech/trie#34 so that encoded nodes can be decoded into a NodePlan which specifies the slice indices of data contained within the encoded node instead of just the slices themselves. This allows for a cleaner and faster trie iteration interface.

Since parity-ethereum uses an rlp-based codec for trie nodes unlike Substrate and the reference trie, a method to get a list item with its slice offset is required. I have written a prototype implementation here (note that the grossness of having multiple rlp versions in the same crate would go away).

@ordian
Copy link
Member

ordian commented Nov 20, 2019

Could you add this description as the method docs and submit a separate PR for new version release with changelog updates (https://github.com/paritytech/parity-common/blob/master/CONTRIBUTING.md#releasing-a-new-version), thanks!

Copy link
Contributor

@dvdplm dvdplm left a comment

Choose a reason for hiding this comment

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

paritytech/trie#34 seems like a pretty major improvement, congrats; would love to see it used in eth asap.

Ok(rlp)
}

pub fn at_with_offset<'view>(&'view self, index: usize)
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the purpose of adding this as a new method rather than changing the return value of at()? Just to reduce the breakage in parity-ethereum? If yes then I think I'd prefer to do a breaking release of rlp and do the grunt work.

Copy link
Contributor Author

@jimpo jimpo Nov 20, 2019

Choose a reason for hiding this comment

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

Well, most of the time you don't need the offset, so even if designing the API from scratch I think having two separate methods probably makes sense. At the moment this is only used for rlp-encoded trie nodes.

But yeah, probably the main reason is backwards compatibility. Just doesn't seem like there's a good reason to break the current API, IMO.

Copy link
Contributor

Choose a reason for hiding this comment

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

most of the time you don't need the offset,

In your eth branch it's used 4 times and only for RlpNodeCodec so I guess you're right. at() is used much more extensively, which kind of surprised me: I'd have hoped it was used much less.

@jimpo jimpo force-pushed the jimpo/at-with-offset branch from 3fcb53a to 46b7272 Compare November 20, 2019 12:24
@jimpo jimpo merged commit 6779351 into master Nov 20, 2019
@jimpo jimpo deleted the jimpo/at-with-offset branch November 20, 2019 14:09
@jimpo jimpo mentioned this pull request Nov 20, 2019
ordian added a commit that referenced this pull request Nov 22, 2019
* master:
  Bump rlp crate version. (#270)
  Introduce Rlp::at_with_offset method. (#269)
  Make fixed-hash test structs public (#267)
  Migrate primitive types to 2018 edition (#262)
  upgrade tiny-keccak to 2.0 (#260)
ordian added a commit that referenced this pull request Nov 26, 2019
* master:
  kvdb-rocksdb: configurable memory budget per column (#256)
  Bump rlp crate version. (#270)
  Introduce Rlp::at_with_offset method. (#269)
  Make fixed-hash test structs public (#267)
  Migrate primitive types to 2018 edition (#262)
dvdplm added a commit that referenced this pull request Dec 10, 2019
* master:
  Compile triehash for no_std (#280)
  [kvdb-rocksdb] Use "pinned" gets to avoid allocations (#274)
  [kvdb-rocksdb] Release 0.2 (#273)
  [kvdb-rocksdb] switch to upstream (#257)
  travis: try to fix wasmpack chrome test on macOS (#263)
  Use 2018 edition for rustfmt (#266)
  [fixed-hash]: re-export `alloc_` (#268)
  kvdb-web: async-awaitify (#259)
  kvdb-rocksdb: configurable memory budget per column (#256)
  Bump rlp crate version. (#270)
  Introduce Rlp::at_with_offset method. (#269)
  Make fixed-hash test structs public (#267)
  Migrate primitive types to 2018 edition (#262)
  upgrade tiny-keccak to 2.0 (#260)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants