Skip to content

Rebuild the open-salt ICloneableFactoryV4 clone variant on main (both derivations tagged, consuming rain.factory#57 lib) #20

Description

@thedavidmeister

Ask

Implement the open-salt deterministic clone variant of ICloneableFactoryV4 in the concrete CloneFactory, on current main.

Supersedes #8 (closed): that PR was based on the abandoned 2026-07-25-rolling-candidate-model branch (diverged, never merged) and predates both the BuildScript migration and the two-tag ruling. The open-salt feature it carried is still wanted; the rest of its diff is stale. This is a rebuild on main, not a rebase of #8.

What the concrete must gain

Two entry points, per ICloneableFactoryV4 (published from rain.factory):

  • cloneDeterministicOpenSalt(implementation, data, salt)
  • predictDeterministicAddressOpenSalt(implementation, data, salt)

The open-salt address is a pure function of (implementation, data, salt) — deployer-independent — so a clone can be predicted and re-created by anyone from the same inputs.

Both derivations must be domain-tagged (two-tag ruling)

ICloneableFactoryV4 pins both salts to exact bytes:

  • namespaced: keccak256(abi.encode(ICLONEABLE_FACTORY_V4_NAMESPACED_DOMAIN, msg.sender, salt))
  • open-salt: keccak256(abi.encode(ICLONEABLE_FACTORY_V4_OPEN_SALT_DOMAIN, salt, keccak256(data)))

The concrete on main still uses the untagged namespaced form keccak256(abi.encode(msg.sender, salt)). This rebuild moves the namespaced derivation to the tagged form too, so both are symmetric and disjoint by construction. That changes the deployed bytecode and therefore the deterministic address / pins — a new deployment, intended.

Consume the derivation library, don't re-inline

The salt math lives in the reusable library from rain.factory#57 (a pure internal library published as part of rain-factory). The concrete imports and calls it rather than re-implementing _effectiveSalt / _effectiveOpenSalt inline — one source of truth for the pinned bytes.

Fit to current main

  • Build on the BuildScript/abstracts model (Build.sol is BuildScript, CloneFactoryDeploySuites); regenerate the candidate snapshot in the new format (src/generated/candidate/CloneFactory.sol), not the old *.pointers.sol.
  • Regenerate pins / codehash / .gas-snapshot; the inherited snapshot + chain verify suites cover the new candidate.
  • No historical/evolution narration in NatSpec/comments (current behavior only).

Tests

Open-salt determinism, predict-matches-clone, deployer-independence (same (data, salt) → same address regardless of msg.sender), the tagged namespaced derivation, and disjointness of the two derivations. Adversarial mutation pass on the new logic.

Blocked on

rain.factory republishing with ICloneableFactoryV4 (#51, merged) and the derivation library (#57). The concrete's rain-factory dependency must be bumped to that version before this can compile against the library.

Metadata

Metadata

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