Skip to content

Conversation

@Sam-wiz
Copy link

@Sam-wiz Sam-wiz commented Nov 30, 2025

#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

@Sam-wiz Sam-wiz changed the title enhancement/precompile-resolveaddress enhancement/precompile-lookupDelegatedAddress Nov 30, 2025
@Sam-wiz Sam-wiz force-pushed the enhancement/precompile-resolveaddress branch from 01748e9 to ba783f5 Compare November 30, 2025 01:20
Copy link
Collaborator

@wjmelements wjmelements left a 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.
@Sam-wiz
Copy link
Author

Sam-wiz commented Nov 30, 2025

@wjmelements
I have pushed all the changes you mentioned

@Sam-wiz Sam-wiz requested a review from wjmelements November 30, 2025 02:11
@wjmelements wjmelements added the enhancement New feature or request label Nov 30, 2025
Comment on lines 41 to 43
if (shouldRevert[actorId]) {
revert("Mock precompile failure");
}
Copy link
Collaborator

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?

Copy link
Author

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

Copy link
Collaborator

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?

@wjmelements
Copy link
Collaborator

@Sam-wiz Sam-wiz requested a review from wjmelements November 30, 2025 08:06
@Sam-wiz
Copy link
Author

Sam-wiz commented Nov 30, 2025

Please match the specification https://docs.filecoin.io/smart-contracts/filecoin-evm-runtime/precompiles

Yep followed the documentation itself

@wjmelements
Copy link
Collaborator

Please match the specification https://docs.filecoin.io/smart-contracts/filecoin-evm-runtime/precompiles

Yep followed the documentation itself

No you didn't.

Comment on lines +34 to +36
if (shouldRevert[actorId]) {
revert("Mock precompile failure");
}
Copy link
Collaborator

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)
Copy link
Collaborator

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];
Copy link
Collaborator

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.

@wjmelements
Copy link
Collaborator

Please match the specification https://docs.filecoin.io/smart-contracts/filecoin-evm-runtime/precompiles

Yep followed the documentation itself

No you didn't.

In fact the only part of the specification that you matched was that the input was 32 bytes.

@Sam-wiz
Copy link
Author

Sam-wiz commented Dec 14, 2025

Sorry, I missed it
Will push the PR for both issues exactly as the documentation
Thanks for citing it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants