-
Notifications
You must be signed in to change notification settings - Fork 1
enhancement/precompile-lookupDelegatedAddress #3
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
enhancement/precompile-lookupDelegatedAddress #3
Conversation
01748e9 to
ba783f5
Compare
wjmelements
left a comment
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.
add the mock to src/mocks/MockFVMTest.sol
…coding, cleaned tests, and full edge-case coverage.
|
@wjmelements |
src/mocks/MockFVMTest.sol
Outdated
| if (shouldRevert[actorId]) { | ||
| revert("Mock precompile failure"); | ||
| } |
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.
why do you do this?
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.
I added so the mock precompile can deliberately fail, letting us test that the library correctly handles the !success case
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.
Do you know what is the !success case?
|
Please match the specification https://docs.filecoin.io/smart-contracts/filecoin-evm-runtime/precompiles |
…rge fmt for fixing Linter error
Yep followed the documentation itself |
No you didn't. |
| if (shouldRevert[actorId]) { | ||
| revert("Mock precompile failure"); | ||
| } |
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.
If the supplied actor ID is larger than max u64, revert.
| assembly ("memory-safe") { | ||
| let len := mload(delegatedAddress) | ||
| if len { | ||
| return(add(delegatedAddress, 32), len) |
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.
Returning the last 20 bytes (which will be the Ethereum-style address of the target actor).
| revert("Mock precompile failure"); | ||
| } | ||
|
|
||
| bytes memory delegatedAddress = delegatedAddressMocks[actorId]; |
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.
If the target actor exists and has a delegated address, succeed and return the delegated address as raw bytes.
In fact the only part of the specification that you matched was that the input was 32 bytes. |
|
Sorry, I missed it |
#2
Added the FVMAddress library with lookupDelegatedAddress() and actorIdToEthAddress() functions that convert Filecoin actor IDs into Ethereum addresses using the LookupDelegatedAddress precompile.Also addded full test coverage with mocks for local development and testing