Skip to content
This repository was archived by the owner on Nov 17, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion bindings/go/evmc/evmc.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,14 +205,17 @@ type Result struct {
}

func (vm *VM) Execute(ctx HostContext, rev Revision,
kind CallKind, static bool, depth int, gas int64,
kind CallKind, static bool, delegated bool, depth int, gas int64,
recipient Address, sender Address, input []byte, value Hash,
code []byte) (res Result, err error) {

flags := C.uint32_t(0)
if static {
flags |= C.EVMC_STATIC
}
if delegated {
flags |= C.EVMC_DELEGATED
}

ctxId := addHostContext(ctx)
// FIXME: Clarify passing by pointer vs passing by value.
Expand Down
2 changes: 1 addition & 1 deletion bindings/go/evmc/evmc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func TestExecuteEmptyCode(t *testing.T) {

addr := Address{}
h := Hash{}
result, err := vm.Execute(nil, Byzantium, Call, false, 1, 999, addr, addr, nil, h, nil)
result, err := vm.Execute(nil, Byzantium, Call, false, false, 1, 999, addr, addr, nil, h, nil)

if !bytes.Equal(result.Output, []byte("")) {
t.Errorf("execution unexpected output: %x", result.Output)
Expand Down
4 changes: 2 additions & 2 deletions bindings/go/evmc/host_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func TestGetBlockNumberFromTxContext(t *testing.T) {
host := &testHostContext{}
addr := Address{}
h := Hash{}
result, err := vm.Execute(host, Byzantium, Call, false, 1, 100, addr, addr, nil, h, code)
result, err := vm.Execute(host, Byzantium, Call, false, false, 1, 100, addr, addr, nil, h, code)
output := result.Output
gasLeft := result.GasLeft

Expand Down Expand Up @@ -121,7 +121,7 @@ func TestCall(t *testing.T) {
host := &testHostContext{}
addr := Address{}
h := Hash{}
result, err := vm.Execute(host, Byzantium, Call, false, 1, 100, addr, addr, nil, h, code)
result, err := vm.Execute(host, Byzantium, Call, false, false, 1, 100, addr, addr, nil, h, code)
output := result.Output
gasLeft := result.GasLeft

Expand Down
2 changes: 2 additions & 0 deletions examples/example_host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ class ExampleHost : public evmc::Host
{
accounts[addr].transient_storage[key] = value;
}

evmc::address get_delegate_address(const evmc::address&) const noexcept override { return {}; }
};


Expand Down
25 changes: 23 additions & 2 deletions include/evmc/evmc.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ enum evmc_call_kind
/** The flags for ::evmc_message. */
enum evmc_flags
{
EVMC_STATIC = 1 /**< Static call mode. */
EVMC_STATIC = 1, /**< Static call mode. */
EVMC_DELEGATED = 2 /**< Delegated call mode (EIP-7702). Valid since Prague. */
};

/**
Expand All @@ -101,7 +102,7 @@ struct evmc_message

/**
* Additional flags modifying the call execution behavior.
* In the current version the only valid values are ::EVMC_STATIC or 0.
*
*/
uint32_t flags;

Expand Down Expand Up @@ -833,6 +834,23 @@ typedef enum evmc_access_status (*evmc_access_storage_fn)(struct evmc_host_conte
typedef struct evmc_result (*evmc_call_fn)(struct evmc_host_context* context,
const struct evmc_message* msg);

/**
* Get delegate address function.
*
* This callback function is used by a VM to get target address of EIP-7702 delegation designation,
* in case it is set for given account.
* If account's code does not contain delegation designation, this function returns address
* 0x0000000000000000000000000000000000000000.
*
* @param context The pointer to the Host execution context.
* @param address The address of the account.
* @return The address of delegation designation target account
* or 0 if delegation is not set.
*/
typedef evmc_address (*evmc_get_delegate_address_fn)(struct evmc_host_context* context,
const evmc_address* address);


/**
* The Host interface.
*
Expand Down Expand Up @@ -890,6 +908,9 @@ struct evmc_host_interface

/** Set transient storage callback function. */
evmc_set_transient_storage_fn set_transient_storage;

/** Get delegate address function. */
evmc_get_delegate_address_fn get_delegate_address;
};


Expand Down
14 changes: 14 additions & 0 deletions include/evmc/evmc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,9 @@ class HostInterface
virtual void set_transient_storage(const address& addr,
const bytes32& key,
const bytes32& value) noexcept = 0;

/// @copydoc evmc_host_interface::get_delegate_address
virtual address get_delegate_address(const address& addr) const noexcept = 0;
};


Expand Down Expand Up @@ -609,6 +612,11 @@ class HostContext : public HostInterface
{
host->set_transient_storage(context, &address, &key, &value);
}

address get_delegate_address(const address& address) const noexcept final
{
return host->get_delegate_address(context, &address);
}
};


Expand Down Expand Up @@ -877,6 +885,11 @@ inline void set_transient_storage(evmc_host_context* h,
{
Host::from_context(h)->set_transient_storage(*addr, *key, *value);
}

inline evmc_address get_delegate_address(evmc_host_context* h, const evmc_address* addr) noexcept
{
return Host::from_context(h)->get_delegate_address(*addr);
}
} // namespace internal

inline const evmc_host_interface& Host::get_interface() noexcept
Expand All @@ -898,6 +911,7 @@ inline const evmc_host_interface& Host::get_interface() noexcept
::evmc::internal::access_storage,
::evmc::internal::get_transient_storage,
::evmc::internal::set_transient_storage,
::evmc::internal::get_delegate_address,
};
return interface;
}
Expand Down
7 changes: 7 additions & 0 deletions include/evmc/mocked_host.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -507,5 +507,12 @@ class MockedHost : public Host
record_account_access(addr);
accounts[addr].transient_storage[key] = value;
}

/// Get account's delegate address.
address get_delegate_address(const address& addr) const noexcept override
{
record_account_access(addr);
return {};
}
};
} // namespace evmc
5 changes: 5 additions & 0 deletions test/unittests/cpp_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ class NullHost : public evmc::Host
const evmc::bytes32& /*key*/,
const evmc::bytes32& /*value*/) noexcept override
{}

evmc::address get_delegate_address(const evmc::address& addr) const noexcept override
{
return {};
}
};

TEST(cpp, address)
Expand Down