forked from ethereum/go-ethereum
-
Notifications
You must be signed in to change notification settings - Fork 5
feat: types.StateAccount pseudo-generic payload
#44
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ARR4N
added a commit
that referenced
this pull request
Oct 1, 2024
All commits except the last two constitute PRs #43 and #44. The last two reverted files such that only changes to the `pseudo` and `ethtest` packages remain; once this is merged into the `libevm` branch then `libevm` will be merged into the branch for #44 too. Cherry-picking commits was not possible as some touched both halves of the changes; the squash-merges will, however, make this convoluted history irrelevant. * feat: `types.StateAccount` pseudo-generic payload * feat: registration of `StateAccount` payload type * chore: mark `eth/tracers/logger` flaky * chore: copyright header + `gci` * test: lock default `types.SlimAccount` RLP encoding * feat: `vm.SlimAccount.Extra` from `StateAccount` equiv * chore: placate the linter * test: `pseudo.Type.EncodeRLP()` * test: `pseudo.Type.DecodeRLP()` * fix: `pseudo.Type.DecodeRLP()` with non-pointer type * feat: `pseudo.Type.IsZero()` and `Type.Equal(*Type)` * feat: `types.StateAccountExtra.DecodeRLP()` * chore: revert non-pseudo-package modifications * chore: delete non-pseudo-package additions
darioush
approved these changes
Oct 1, 2024
darioush
reviewed
Oct 1, 2024
darioush
reviewed
Oct 1, 2024
| Balance: acc.Balance, | ||
| CodeHash: acc.CodeHash, | ||
| Root: common.BytesToHash(acc.Root), | ||
| Extra: acc.Extra, // no need to deep-copy as `acc` is short-lived |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this code is also removed upstream in upcoming revisions, fyi
|
@darioush I added the |
darioush
approved these changes
Oct 2, 2024
ARR4N
added a commit
that referenced
this pull request
Dec 17, 2024
## Why this should be merged The `types.Header` fields of both [`coreth`](https://pkg.go.dev/github.com/ava-labs/coreth/core/types#Header) and [`subnet-evm`](https://pkg.go.dev/github.com/ava-labs/subnet-evm/core/types#Header) have been modified such that their RLP encodings (i.e. block hashes) aren't compatible with vanilla `geth` nor each other. This PR adds support for arbitrary RLP encoding coupled with type-safe extra payloads. ## How this works Equivalent to #1 (`params`) and #44 (`types.StateAccount`) registration of pseudo-generic payloads. The only major difference is the guarantee of a non-nil payload pointer, which means that the payload hooks are never called on nil pointers as this would make it difficult to decode RLP into them. ## How this was tested Round-trip RLP {en,de}coding via a registered stub hook. --------- Signed-off-by: Arran Schlosberg <[email protected]> Co-authored-by: Quentin McGaw <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why this should be merged
Allows
types.StateAccountto mirrorava-labs/corethbehaviour w.r.t. RLP encoding (i.e.IsMultiCoin) while maintaining backwards compatibility.How this works
This is very similar to
params.RegisterExtras()except that it's in thetypespackage.The
pseudo.Type.Format()method was necessary to avoid changing upstream formatting verbs.How this was tested
RLP encodings of vanilla-geth
types.StateAccountandtypes.SlimAccountwere first locked in with unit tests, before any libevm modidifcations. Similar test cases were generated fromava-labs/corethwithIsMultiCoin boolto be mirrored withtypes.RegisterExtras[bool](). Round-trip RLP encoding/decoding demonstrates correct behaviour for both geth and coreth use cases.