/eip-3074-foundry

EIP-3074 (`AUTH` and `AUTHCALL` opcodes) example foundry project

Primary LanguageSolidity

eip-3074-foundry

This repository contains patched versions of foundry & the solidity compiler, integrated with patches to revm / ethers-rs, that support the EIP-3074 opcodes (AUTH & AUTHCALL).

Patches

NOTE: These are patches, don't spin up a production system with these and expect security.

Usage

Building forge

First, build the patched version of foundry (this will take a while):

git submodule update --init --recursive && \
    make build-forge-patch

This command will place the patched forge binary in bin/forge.

Building solc

Next, build the patched version of solc (this will also take a while):

make build-solc-patch

This patch supports the following semantics:

function example() public {
    // AUTHCALL by `address` member access
    address(0xbeefbabe).authcall(hex"...");

    assembly {
        // AUTH
        let authSuccess := auth(<authorized>, <args_offset_mem>, <args_length>)

        // AUTHCALL
        let authCallSuccess := authcall(
            <gas>,
            <to_addr>,
            <value>, // NOTE: This is currently sent from the Invoker contract, NOT the `authorized` account.
            <valueExt>, // Must always be `0` per the current 3074 spec, reserved for future use.
            <args_offset_mem>,
            <args_length>,
            <ret_offset_mem>,
            <ret_length>
        )
    }
}

Installing huffc

The huff version of the EIP-3074 invoker requires huffc to be installed.

make install-huff

Running Examples

To run the examples, interact with the patched forge binary as normal. There is a special override for the Prague hardfork within the foundry.toml which will enable the AUTH & AUTHCALL opcodes, and the foundry.toml specifies the patched solc binary as the compiler.