Skip to content

Conversation

@Sam-wiz
Copy link

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

#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.


import {RESOLVE_ADDRESS} from "./FVMPrecompiles.sol";

library FVMAddress {
Copy link
Collaborator

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

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

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

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

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

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

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.

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