Skip to content

Conversation

grandizzy
Copy link
Collaborator

@grandizzy grandizzy commented Sep 17, 2025

Motivation

  • closes Incompatible with the celo network, balanceOf(), transfer(), deal() and others do not work #11622

  • moves networks specific features (precompiles for now) in networks crate, reused in forge - enables Celo transfer precompile when running forge test with --celo

  • follow-up: apply to cast as well, so network features (precompiles, custom tx types) can be applied on all foundry components

  • superseeds refactor!: remove --odyssey #11688
    Removes the --odyssey flag since Odyssey is being sunset, and we have equivalent flags that achieve the same behavior.
    If you just need EIP7701, you can use --evm-version prague.
    If you additionally need the P256 precompiles, you can use --evm-version osaka.
    Test osaka_can_run_p256_precompile updated as some additional gas spent compared with odyssey.
    Closes Sunset --odyssey flag #11681

Solution

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

very nice, just some comments/suggestions but we should proceed with this

Comment on lines 65 to 68
NetworkPrecompiles::default()
.odyssey(evm.inspector().is_odyssey())
.celo(evm.inspector().is_celo())
.inject(evm.precompiles_mut());
Copy link
Member

Choose a reason for hiding this comment

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

very nice

Comment on lines 864 to 865
precompiles_map
.extend(NetworkPrecompiles::default().odyssey(self.odyssey).celo(self.is_celo()).get());
Copy link
Member

Choose a reason for hiding this comment

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

so much better

Comment on lines 53 to 68
/// Returns precompiles for configured networks.
pub fn get(self) -> BTreeMap<String, Address> {
let mut precompiles = BTreeMap::new();
if self.odyssey {
precompiles.insert(
PrecompileId::P256Verify.name().to_string(),
u64_to_address(P256VERIFY_ADDRESS),
);
}

if self.celo {
precompiles
.insert(PRECOMPILE_ID_CELO_TRANSFER.name().to_string(), CELO_TRANSFER_ADDRESS);
}
precompiles
}
Copy link
Member

Choose a reason for hiding this comment

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

can we rename this to get_ids or something?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeah, I actually repurposed the crate foundry-evm-precompiles -> foundry-evm-networks because networks could come with more than custom precompiles, so we have now inject_precompiles and precompiles and we could add fns for custom txes or other stuff

Comment on lines 410 to 418
/// Whether to enable Odyssey features.
pub odyssey: bool,
/// Whether to enable Celo precompiles.
pub celo: bool,
Copy link
Member

Choose a reason for hiding this comment

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

does it make sense to group this to

networks: NetworkPrecompiles

or similar?

less defaults, fields

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done, looks much better

@grandizzy grandizzy changed the title [WIP] feat(forge): add precompiles crate [WIP] feat(forge): add network features crate Sep 18, 2025
mattsse
mattsse previously approved these changes Sep 18, 2025
Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

lgtm!

Some(celo_precompile::precompile())
});
}
self.networks.inject_precompiles(evm.precompiles_mut());
Copy link
Member

Choose a reason for hiding this comment

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

nicely consolidates precompile injection

/// Cumulative blob gas used by all executed transactions
pub blob_gas_used: u64,
pub enable_steps_tracing: bool,
pub odyssey: bool,
Copy link
Member

@yash-atreya yash-atreya Sep 18, 2025

Choose a reason for hiding this comment

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

@grandizzy FYI, there will be conflicts with #11688

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yep, going to include odyssey removal and superseded the other PR

Copy link
Member

@yash-atreya yash-atreya Sep 18, 2025

Choose a reason for hiding this comment

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

In that case, relaying from #11688 (comment)

Can we also remove the WalletGetCapabilities and AnvilAddCapability endpoints? Now that we have the relay open source, along with the docker container that runs Anvil and relay together for local testing?
We don't need these in anvil anymore

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

not sure, does this mean that users will have to run relay for those? @onbjerg could you pls chime in?

Copy link
Member

Choose a reason for hiding this comment

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

They can run anvil + relay using the provided docker container: https://porto.sh/relay#local-development

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

kk, so not odyssey related endpoint?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

will follow up in subsequent PR

@yash-atreya yash-atreya mentioned this pull request Sep 18, 2025
3 tasks
@grandizzy grandizzy changed the title [WIP] feat(forge): add network features crate feat(forge): introduce network custom features Sep 18, 2025
@grandizzy grandizzy changed the title feat(forge): introduce network custom features feat(forge): introduce network custom features, sunset Odyssey Sep 18, 2025
@grandizzy grandizzy marked this pull request as ready for review September 18, 2025 10:35
zerosnacks
zerosnacks previously approved these changes Sep 18, 2025
Copy link
Member

@zerosnacks zerosnacks left a comment

Choose a reason for hiding this comment

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

Nice!

Copy link
Member

@DaniPopes DaniPopes left a comment

Choose a reason for hiding this comment

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

lgtm

do we want a separate config key for this? like networks.x

should we infer this from chain id if set?

pub struct NetworkConfigs {
/// Enable Optimism network features.
#[arg(help_heading = "Networks", long, visible_alias = "optimism")]
#[serde(skip)]
Copy link
Member

Choose a reason for hiding this comment

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

why is this serde skipped?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this ends up in forge config and we don't have (yet) anything to add to forge if optimism set to true, hence decided not to include

Copy link
Member

Choose a reason for hiding this comment

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

please leave a comment

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yep, added in cf1499e

@grandizzy
Copy link
Collaborator Author

grandizzy commented Sep 18, 2025

going to open up a gh issues with follow ups to improve the impl by:

@grandizzy grandizzy merged commit 86d5c5b into foundry-rs:master Sep 18, 2025
25 checks passed
@grandizzy grandizzy deleted the precompiles branch September 18, 2025 15:34
@github-project-automation github-project-automation bot moved this to Done in Foundry Sep 18, 2025
@grandizzy grandizzy self-assigned this Sep 22, 2025
@grandizzy grandizzy added this to the v1.4.0 milestone Sep 22, 2025
@grandizzy grandizzy moved this from Done to Completed in Foundry Sep 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Completed
Development

Successfully merging this pull request may close these issues.

Sunset --odyssey flag Incompatible with the celo network, balanceOf(), transfer(), deal() and others do not work
5 participants