-
Notifications
You must be signed in to change notification settings - Fork 1
Enhance/precompile resolveaddress #4
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
base: main
Are you sure you want to change the base?
Enhance/precompile resolveaddress #4
Conversation
|
|
||
| import {RESOLVE_ADDRESS} from "./FVMPrecompiles.sol"; | ||
|
|
||
| library FVMAddress { |
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.
Because this overlaps with #3, I think it makes sense for library FVMAddress to be one pull request.
| pragma solidity ^0.8.30; | ||
|
|
||
| contract FVMResolveAddress { | ||
| mapping(bytes32 => uint64) public addressMocks; |
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.
mockActorIds
| import {FVMGetBeaconRandomness} from "./FVMGetBeaconRandomness.sol"; | ||
| import {FVMResolveAddress} from "./FVMResolveAddress.sol"; | ||
|
|
||
| /// @notice Mocks the FVM precompiles for forge test |
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 want to keep this. Why do you remove it?
| mapping(bytes32 => uint64) public addressMocks; | ||
| mapping(bytes32 => bool) public addressExists; | ||
|
|
||
| function mockResolveAddress(bytes memory filAddress, uint64 actorId) external { |
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.
also provide a helper for mocking address that converts the address to f4
| library FVMAddress { | ||
| function resolveAddress(bytes memory filAddress) internal view returns (bool success, uint64 actorId) { | ||
| bytes memory result; | ||
| (success, result) = address(RESOLVE_ADDRESS).staticcall(filAddress); |
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.
RESOLVE_ADDRESS is already an address and doesn't need to be cast to address
| function toActorId(bytes memory filAddress) internal view returns (uint64 actorId) { | ||
| (bool success, uint64 id) = resolveAddress(filAddress); | ||
| require(success, "FVMAddress: Invalid address format"); | ||
| require(id != 0, "FVMAddress: Actor not found"); |
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.
0 is a valid ID. It is the id of the system actor.
| import {RESOLVE_ADDRESS} from "./FVMPrecompiles.sol"; | ||
|
|
||
| library FVMAddress { | ||
| function resolveAddress(bytes memory filAddress) internal view returns (bool success, uint64 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.
I think we should be returning exists rather than success. success is uninteresting because it only fails if the address is invalid. should revert in that case.
#1
@wjmelements
I’ve added full ResolveAddress precompile support with a spec-aligned FVMAddress library, a simple mock for testing, and full coverage for success, not-found, and invalid-address scenarios. Everything’s tested and formatted cleanly.