Skip to content

deriveDeployment runs a suite with none of its dependencies on chain, so constructors that need a dependency's code revert #247

Description

@thedavidmeister

Ask

deriveDeployment should derive a suite with its declared dependencies on chain, so a contract whose constructor needs a dependency's code can be verified.

The gap, verified on main (b19a415)

RainDeployVerifyBase.deriveDeployment (src/abstract/RainDeployVerifyBase.sol:93) does four things in order: snapshot state, clear the derived address, deploy the creation code through Zoltu, revert the snapshot. Nothing puts the suite's dependencies on chain first. That contradicts what DeploySuite.dependencies is documented to be: the addresses that MUST already have code before the suite can be deployed.

So any constructor that needs a dependency's code reverts under derivation. OZ's UpgradeableBeacon constructor reverts BeaconInvalidImplementation when the implementation has no code. deriveDeployments also feeds RainDeployVerifyChain.checkDeployedOnSupportedNetworks, so the chain group hits the same revert.

Consumer hitting it

In S01-Issuer/st0x.deploy#379, StoxWrappedTokenVaultBeacon and the three beacon-set deployers all construct beacons over dependency implementations. testSnapshotInternallyConsistent fails with DeployFailed(false, 0x0) on suite stox-wrapped-token-vault-beacon@0_1_1. The trace reverts 0x847ac564, which is BeaconInvalidImplementation(0x0d99…), the wrapped vault implementation it depends on.

A consumer can't pre-deploy its way out. Deploying every suite first leaves each set deployer's child beacons at their CREATE addresses. Re-deriving that deployer at its cleared address then creates the same beacons again and collides: about 1.02B gas burned, then DeployFailed.

#379 works around it in setUp, marked as a stopgap. It vm.etches every suite's recorded runtime code at its recorded address, so no constructor runs. Fixing this issue is what lets that stopgap be removed.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions