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

fix: eth: correctly decode EthGetStorageAt output #10284

Merged
merged 3 commits into from
Feb 17, 2023

Conversation

Stebalien
Copy link
Member

Related Issues

fixes filecoin-project/ref-fvm#1621

(probably)

Proposed Changes

Correctly decode actor output in EthGetStorageAt, and test it.

Also:

  1. Actually use the passed block param.
  2. Check if the target actor is an EVM actor to avoid nonsense outputs.

We cbor-encode it. Also:

1. Actually use the passed block param.
2. Check if the target actor is an EVM actor to avoid nonsense outputs.

fixes filecoin-project/ref-fvm#1621
@Stebalien Stebalien requested a review from a team as a code owner February 15, 2023 21:58
@Stebalien Stebalien requested a review from raulk February 15, 2023 21:59
node/impl/full/eth.go Outdated Show resolved Hide resolved
Copy link
Member

@raulk raulk left a comment

Choose a reason for hiding this comment

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

A dedicated test would be nice that goes over the different cases here:

  • Actor is an evm smart contract and has the storage slot filled => return value.
  • Actor is an evm smart contract and does not have the storage slot filled => return 32-byte padded 0.
  • Actor is not an evm smart contract => ^^
  • Actor does not exist => ^^

(I volunteer to write it tomorrow if you'd like me to.)

l := len(position)
if l > 32 {
return nil, fmt.Errorf("supplied storage key is too long")
}

// pad with zero bytes if smaller than 32 bytes
position = append(make([]byte, 32-l, 32-l), position...)
position = append(make([]byte, 32-l), position...)
Copy link
Member

Choose a reason for hiding this comment

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

supernit: Could move this below to where it's used.

Copy link
Member Author

Choose a reason for hiding this comment

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

I have that there to put it next to the length check. I kept the length check at the top to fail early when passed an invalid parameter.

Copy link
Member

@raulk raulk left a comment

Choose a reason for hiding this comment

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

Other than the above, LGTM now.

@Stebalien
Copy link
Member Author

Test issue: #10407

@jennijuju jennijuju added this to the Network v18 milestone Feb 16, 2023
@Stebalien Stebalien merged commit 5854d72 into release/v1.20.0 Feb 17, 2023
@Stebalien Stebalien deleted the steb/fix-storage-lookup branch February 17, 2023 00:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants