Skip to content
Draft
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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Tests for EIP-8357: EVM Verification Key Registry."""
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"factory": "0x4e59b44847b379578588920cA78FbF26c0B4956C",
"salt": "0x2b93ca1f7fa5102ac4e1a6d161cff2ae1701cf709bfa1a7a6cb213ec61125f0a",
"initcode": "0x60a58060095f395ff33460a1573373fffffffffffffffffffffffffffffffffffffffe14604a576020360360a1575f3580602c57545b801560a1575f52600160205260405f2054801560a15760205260405ff35b602036146085576040360360a1575f35801560a157805f52600160205260405f20805460a157602035801560a1578060401c60a15790555f55005b5f35801560a157805f52600160205260405f20541560a1575f55005b5f5ffd"
}
46 changes: 46 additions & 0 deletions tests/amsterdam/eip8357_verification_key_registry/spec.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
"""Reference spec and constants for EIP-8357."""

from dataclasses import dataclass

from execution_testing import Bytes


@dataclass(frozen=True)
class ReferenceSpec:
"""Reference specification."""

git_path: str
version: str


ref_spec_8357 = ReferenceSpec(
git_path="EIPS/eip-8357.md",
version="0596cdeb543f37ca4512c7b0e97d50b5ce6edae8",
)


class Spec:
"""Constants from EIP-8357."""

SYSTEM_ADDRESS = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE
FACTORY_ADDRESS = 0x4E59B44847B379578588920CA78FBF26C0B4956C
EVM_VK_REGISTRY_ADDRESS = 0x0000709B303EF147CEE6C13F3AF6C5A402DA8357
REGISTRY_DEPLOYMENT_SALT = (
0x2B93CA1F7FA5102AC4E1A6D161CFF2AE1701CF709BFA1A7A6CB213EC61125F0A
)

CURRENT_VERIFICATION_KEY_SLOT = 0
ACTIVATION_MAPPING_SLOT = 1
MAX_ACTIVATION_TIMESTAMP = 2**64 - 1

REGISTRY_RUNTIME_CODE = Bytes(
"0x3460a1573373fffffffffffffffffffffffffffffffffffffffe14604a57"
"6020360360a1575f3580602c57545b801560a1575f52600160205260405f"
"2054801560a15760205260405ff35b602036146085576040360360a1575f"
"35801560a157805f52600160205260405f20805460a157602035801560a1"
"578060401c60a15790555f55005b5f35801560a157805f52600160205260"
"405f20541560a1575f55005b5f5ffd"
)
REGISTRY_INITCODE = Bytes(
"0x60a58060095f395ff3" + REGISTRY_RUNTIME_CODE.hex()[2:]
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
"""Deployment tests for the EIP-8357 verification-key registry."""

import json
from pathlib import Path
from typing import Any

import pytest
from execution_testing import (
Account,
Address,
Alloc,
Bytes,
EIPChecklist,
Hash,
StateTestFiller,
Transaction,
compute_create2_address,
)

from .spec import Spec, ref_spec_8357

REFERENCE_SPEC_GIT_PATH = ref_spec_8357.git_path
REFERENCE_SPEC_VERSION = ref_spec_8357.version

pytestmark = pytest.mark.valid_from("Amsterdam")


def _deployment_vector() -> dict[str, Any]:
"""Load the canonical factory deployment vector."""
path = Path(__file__).with_name("registry_factory_deploy.json")
return json.loads(path.read_text())


@EIPChecklist.SystemContract.Test.Deployment.Address()
def test_registry_factory_deployment(
state_test: StateTestFiller,
pre: Alloc,
) -> None:
"""
The EIP-7997 factory deploys the registry's exact runtime at the
EIP-8357 address from the specified salt and initcode.
"""
vector = _deployment_vector()
factory = Address(vector["factory"])
salt = Hash(vector["salt"])
initcode = Bytes(vector["initcode"])
registry = compute_create2_address(factory, salt, initcode)

assert factory == Spec.FACTORY_ADDRESS
assert salt == Hash(Spec.REGISTRY_DEPLOYMENT_SALT)
assert initcode == Spec.REGISTRY_INITCODE
assert registry == Spec.EVM_VK_REGISTRY_ADDRESS

state_test(
pre=pre,
tx=Transaction(
sender=pre.fund_eoa(),
to=factory,
data=salt + initcode,
),
post={
registry: Account(
nonce=1,
balance=0,
code=Spec.REGISTRY_RUNTIME_CODE,
storage={},
),
},
)
Loading