Skip to content

Enshrine new convention for Network Upgrade Transactions which deploy new contracts #781

@geoknee

Description

@geoknee

Currently, for transactions such as these (example https://specs.optimism.io/protocol/isthmus/derivation.html#l1block-deployment) we choose the from address to be a unique account which has nonce=0. The choice of from affects the deployment address of the contract. Using a fresh account means we can safely set nonce:0 in the upgrade transaction.

That unique account tends to be chosen in the 0x421... namespace. Choosing it correctly involves checking the entire spec history to ensure we aren't reusing an address. This is error prone, particularly when forks get reordered.

A better pattern is

take the first 20 bytes of the source hash as sender address. That way you have a guaranteed unique deployer address, and thus nonce 0, and thus a unique and deterministic deployed contract address. Without making it coupled to bytecode, so the proxy upgrade tx input stays stable on dev changes

h/t to @protolambda for this idea.

The source hash is defined here https://specs.optimism.io/protocol/deposits.html#source-hash-computation

Note: the idea of using a CREATE2 type deployment was considered, but discarded in favour of the above approach (in particular it would couple the deployment address and tx input to the contract bytecode, which is undesirable).

Metadata

Metadata

Assignees

No one assigned

    Labels

    H-jovianHardfork: change is planned for Jovian upgrade

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions