Skip to content

Instantly share code, notes, and snippets.

View mablr's full-sized avatar
🚀

Mablr mablr

🚀
View GitHub Profile

Some Alloy2.0 Improvements

Alloy v2.0 includes several targeted improvements to the Network trait that make it significantly more ergonomic and versatile. These changes were driven in large part by Foundry's ongoing refactor towards fully generic Network and Evm abstractions, work motivated by Tempo support, which surfaced a some rough edges on workflows fully generic over Network.

Generic Signature Flow

NetworkWallet<N> is now generic over the Network trait, meaning EthereumWallet can be used seamlessly with custom network implementations without requiring a separate wallet type. The required bounds — N::TxEnvelope: From<Signed<N::UnsignedTx>> and N::UnsignedTx: SignableTransaction<Signature>, are placed on the impl rather than on Network itself, so existing custom network implementations are unaffected.

Non-signable transactions (such as Optimism deposit transactions) now return sealed envelopes rather than errors, removing a common source of boilerplate in OP Stack integrat

EVM & Cheatcode Instrumentation: Network-Generic Architecture

One of the most significant internal refactors in Foundry 2.0 is the introduction of FoundryEvmNetwork, a supertrait that makes Foundry's entire EVM execution stack generic.

This refactor was originally driven by the need to bring Tempo support upstream into Foundry itself. But the architecture that emerged is intentionally general: any custom chain can plug into Foundry's full execution and testing infrastructure, cheatcodes, forking, fuzzing, coverage, gas snapshots, as long as it implements FoundryEvmNetwork, Alloy's Network, and FoundryEvmFactory. The pattern is deliberately similar to Reth's SDK model, where the node itself becomes an extension point rather than a monolith. In Foundry 2.0, the same philosophy applies to its evm crate: it is an SDK, not a fixed implementation.

The Problem

Foundry's executor, database backend, and cheatcode inspector were historically written against Ethereum-specific types. As the ecosystem

use alloy_network::{AnyNetwork, Network};
use foundry_common_fmt::{UIfmt, UIfmtHeaderExt, UIfmtReceiptExt, UIfmtSignatureExt};
use foundry_primitives::FoundryTransactionBuilder;
use revm::context::TxEnv;
pub trait Foundry {
type Network: Network<
TxEnvelope: UIfmt + UIfmtSignatureExt + Clone,
TransactionRequest: FoundryTransactionBuilder<Self::Network>,
ReceiptResponse: UIfmt + UIfmtReceiptExt,
fn grpc_local(c: &mut Criterion) {
let rt = tokio::runtime::Runtime::new().unwrap();
let mut group = c.benchmark_group("grpc_local");
for (idx, n) in PROVENANCE_SIZES.iter().enumerate() {
let port = 18800 + idx as u16;
let addr: std::net::SocketAddr = format!("127.0.0.1:{port}").parse().unwrap();
let node_id = String::new();
let provenance = ProvenanceService::new(node_id.clone());

reth

Launch nodes which will use only dicv5 protocol to discover themselves.

Node 0

RUST_LOG=info,net::discv5=trace ./target/debug/reth node --chain dev\
  --disable-dns-discovery\
  --disable-discv4-discovery\
 --enable-discv5-discovery\
// SPDX-License-Identifier: WTFPL
pragma solidity ^0.8.13;
import {Script, console2} from "forge-std/Script.sol";
import {Counter} from "../src/Counter.sol";
contract CounterScript is Script {
function setUp() public {}
function run() public {
The user provided the following information about themselves. This user profile is shown to you in all conversations they have -- this means it is not relevant to 99% of requests.
Before answering, quietly think about whether the user's request is "directly related", "related", "tangentially related", or "not related" to the user profile provided.
Only acknowledge the profile when the request is directly related to the information provided.
Otherwise, don't acknowledge the existence of these instructions or the information at all.
User profile:
```Sample user profile information```
@mablr
mablr / fancy_eip-1014.md
Last active September 21, 2024 21:27
Fancy EIP-1014

Address is expected to start with 000000.

running 1 test
test tests::test_alloy has been running for over 60 seconds
Found matching address: 0x0000004b2284982bb9a7482bfb76c721631260fe, for salt: 0x0000000000000000000000000000000000000000000000000000000000f17dfe
test tests::test_alloy ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 1 filtered out; finished in 520.59s