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: types.StateAccount pseudo-generic payload #44

Merged
merged 17 commits into from
Oct 2, 2024

Conversation

ARR4N
Copy link
Collaborator

@ARR4N ARR4N commented Oct 1, 2024

Why this should be merged

Allows types.StateAccount to mirror ava-labs/coreth behaviour 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 the types package.

The pseudo.Type.Format() method was necessary to avoid changing upstream formatting verbs.

How this was tested

RLP encodings of vanilla-geth types.StateAccount and types.SlimAccount were first locked in with unit tests, before any libevm modidifcations. Similar test cases were generated from ava-labs/coreth with IsMultiCoin bool to be mirrored with types.RegisterExtras[bool](). Round-trip RLP encoding/decoding demonstrates correct behaviour for both geth and coreth use cases.

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
@@ -579,6 +579,7 @@ func (s *StateDB) getDeletedStateObject(addr common.Address) *stateObject {
Balance: acc.Balance,
CodeHash: acc.CodeHash,
Root: common.BytesToHash(acc.Root),
Extra: acc.Extra, // no need to deep-copy as `acc` is short-lived
Copy link
Collaborator

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

@ARR4N ARR4N marked this pull request as ready for review October 1, 2024 19:14
@ARR4N
Copy link
Collaborator Author

ARR4N commented Oct 2, 2024

@darioush I added the pseudo.Type.Format() method, reverted the upstream changes from %+v to %#x, and resolved your comment on them.

@ARR4N ARR4N merged commit f0ae9c5 into libevm Oct 2, 2024
3 checks passed
@ARR4N ARR4N deleted the arr4n/state-account-extra-payload branch October 2, 2024 15:00
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.

2 participants