Skip to content

✨ LibTransient registry #1377

@Vectorized

Description

@Vectorized

Problem:

Passing constructor args affect the initcode.

So if two contracts (e.g. Delegation and EntryPoint) wants to store the implementation of each other in immutable bytecode, this can't be done.

Solution:

  1. Make a registry that allows for:
// Always returns true on success. Replaces the existing value if one exists.
// If a value already exist, only it's creator can replace it.
function set(bytes32 key, bytes memory value) public returns (bool) 

// Reverts if there's no `key`.
function get(bytes32 key) public view returns (bytes memory)

// Reverts if there's no `key`.
// Only the creator of a value can clear it.
function clear(bytes32 key) public returns (bool)

This registry doesn't need to support compat.

As to why it only supports bytes, we believe it's generally cheaper to force devs to abi.encode and send it in a single call.

  1. Add these to LibTransient.
function registrySet(bytes32 key, bytes memory value) internal 
function registryGet(bytes32 key) internal view returns (bytes memory)
function registryClear(bytes32 key) internal 
  1. Now that the contracts do not have constructor args anymore (can retrieve from the registry), it's initcode will be constant and this means its create2 address can be precomputed agnostic of any constructor args.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions