Skip to content

Commit a0eb9da

Browse files
authored
op-deployer: remove legacy DeployAltDA script (#15722)
* op-deployer: remove legacy DeployAltDA script * DeployAltDA2: allow input.resolverRefundPercentage to be 0 * DeployAltDA2: remove test revert for resolverRefundPercentage=0 * rename DeployAltDA2 to DeployAltDA
1 parent ddfda5c commit a0eb9da

File tree

11 files changed

+177
-778
lines changed

11 files changed

+177
-778
lines changed
Lines changed: 4 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package opcm
22

33
import (
4-
"fmt"
54
"math/big"
65

76
"github.com/ethereum-optimism/optimism/op-chain-ops/script"
@@ -23,41 +22,9 @@ type DeployAltDAOutput struct {
2322
DataAvailabilityChallengeImpl common.Address
2423
}
2524

26-
type DeployAltDAScript struct {
27-
Run func(input, output common.Address) error
28-
}
29-
30-
func DeployAltDA(
31-
host *script.Host,
32-
input DeployAltDAInput,
33-
) (DeployAltDAOutput, error) {
34-
var output DeployAltDAOutput
35-
inputAddr := host.NewScriptAddress()
36-
outputAddr := host.NewScriptAddress()
37-
38-
cleanupInput, err := script.WithPrecompileAtAddress[*DeployAltDAInput](host, inputAddr, &input)
39-
if err != nil {
40-
return output, fmt.Errorf("failed to insert DeployAltDAInput precompile: %w", err)
41-
}
42-
defer cleanupInput()
43-
44-
cleanupOutput, err := script.WithPrecompileAtAddress[*DeployAltDAOutput](host, outputAddr, &output,
45-
script.WithFieldSetter[*DeployAltDAOutput])
46-
if err != nil {
47-
return output, fmt.Errorf("failed to insert DeployAltDAOutput precompile: %w", err)
48-
}
49-
defer cleanupOutput()
50-
51-
implContract := "DeployAltDA"
52-
deployScript, cleanupDeploy, err := script.WithScript[DeployAltDAScript](host, "DeployAltDA.s.sol", implContract)
53-
if err != nil {
54-
return output, fmt.Errorf("failed to load %s script: %w", implContract, err)
55-
}
56-
defer cleanupDeploy()
57-
58-
if err := deployScript.Run(inputAddr, outputAddr); err != nil {
59-
return output, fmt.Errorf("failed to run %s script: %w", implContract, err)
60-
}
25+
type DeployAltDAScript script.DeployScriptWithOutput[DeployAltDAInput, DeployAltDAOutput]
6126

62-
return output, nil
27+
// NewDeployAltDAScript loads and validates the DeployAltDA script contract
28+
func NewDeployAltDAScript(host *script.Host) (DeployAltDAScript, error) {
29+
return script.NewDeployScriptWithOutputFromFile[DeployAltDAInput, DeployAltDAOutput](host, "DeployAltDA.s.sol", "DeployAltDA")
6330
}

op-deployer/pkg/deployer/opcm/alt_da2.go

Lines changed: 0 additions & 30 deletions
This file was deleted.

op-deployer/pkg/deployer/opcm/alt_da2_test.go

Lines changed: 0 additions & 64 deletions
This file was deleted.

op-deployer/pkg/deployer/opcm/alt_da_test.go

Lines changed: 26 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,41 +4,34 @@ import (
44
"math/big"
55
"testing"
66

7-
"github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/broadcaster"
8-
"github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/testutil"
9-
"github.com/ethereum-optimism/optimism/op-deployer/pkg/env"
10-
"github.com/ethereum-optimism/optimism/op-service/testlog"
117
"github.com/ethereum/go-ethereum/common"
12-
"github.com/ethereum/go-ethereum/log"
138
"github.com/stretchr/testify/require"
149
)
1510

16-
func TestDeployAltDA(t *testing.T) {
17-
t.Parallel()
18-
19-
_, artifacts := testutil.LocalArtifacts(t)
20-
21-
host, err := env.DefaultScriptHost(
22-
broadcaster.NoopBroadcaster(),
23-
testlog.Logger(t, log.LevelInfo),
24-
common.Address{'D'},
25-
artifacts,
26-
)
27-
require.NoError(t, err)
28-
29-
input := DeployAltDAInput{
30-
Salt: common.HexToHash("0x1234"),
31-
ProxyAdmin: common.Address{'P'},
32-
ChallengeContractOwner: common.Address{'O'},
33-
ChallengeWindow: big.NewInt(100),
34-
ResolveWindow: big.NewInt(200),
35-
BondSize: big.NewInt(300),
36-
ResolverRefundPercentage: big.NewInt(50), // must be < 100
37-
}
38-
39-
output, err := DeployAltDA(host, input)
40-
require.NoError(t, err)
41-
42-
require.NotEmpty(t, output.DataAvailabilityChallengeProxy)
43-
require.NotEmpty(t, output.DataAvailabilityChallengeImpl)
11+
func TestNewDeployAltDAScript(t *testing.T) {
12+
t.Run("should not fail with current version of DeployAltDA contract", func(t *testing.T) {
13+
// First we grab a test host
14+
host1 := createTestHost(t)
15+
16+
// Then we load the script
17+
//
18+
// This would raise an error if the Go types didn't match the ABI
19+
deploySuperchain, err := NewDeployAltDAScript(host1)
20+
require.NoError(t, err)
21+
22+
// Then we deploy
23+
output, err := deploySuperchain.Run(DeployAltDAInput{
24+
Salt: common.BigToHash(big.NewInt(1)),
25+
ProxyAdmin: common.BigToAddress(big.NewInt(2)),
26+
ChallengeContractOwner: common.BigToAddress(big.NewInt(3)),
27+
ChallengeWindow: big.NewInt(4),
28+
ResolveWindow: big.NewInt(5),
29+
BondSize: big.NewInt(6),
30+
ResolverRefundPercentage: big.NewInt(7),
31+
})
32+
33+
// And do some simple asserts
34+
require.NoError(t, err)
35+
require.NotNil(t, output)
36+
})
4437
}

op-deployer/pkg/deployer/opcm/scripts.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
// Scripts contains all the deployment scripts for ease of passing them around
1010
type Scripts struct {
1111
DeployAlphabetVM DeployAlphabetVMScript
12-
DeployAltDA DeployAltDA2Script
12+
DeployAltDA DeployAltDAScript
1313
DeployAsterisc DeployAsteriscScript
1414
DeployDisputeGame DeployDisputeGameScript
1515
DeployImplementations DeployImplementations2Script

op-deployer/pkg/deployer/pipeline/alt_da.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,13 @@ func DeployAltDA(env *Env, intent *state.Intent, st *state.State, chainID common
2828
return nil
2929
}
3030

31-
var dao opcm.DeployAltDAOutput
3231
lgr.Info("deploying alt-da contracts")
33-
dao, err = opcm.DeployAltDA(env.L1ScriptHost, opcm.DeployAltDAInput{
32+
deployAltDAScript, err := opcm.NewDeployAltDAScript(env.L1ScriptHost)
33+
if err != nil {
34+
return fmt.Errorf("failed to load DeployAltDA script: %w", err)
35+
}
36+
37+
output, err := deployAltDAScript.Run(opcm.DeployAltDAInput{
3438
Salt: st.Create2Salt,
3539
ProxyAdmin: chainState.OpChainContracts.OpChainProxyAdminImpl,
3640
ChallengeContractOwner: chainIntent.Roles.L1ProxyAdminOwner,
@@ -43,8 +47,8 @@ func DeployAltDA(env *Env, intent *state.Intent, st *state.State, chainID common
4347
return fmt.Errorf("failed to deploy alt-da contracts: %w", err)
4448
}
4549

46-
chainState.OpChainContracts.AltDAChallengeProxy = dao.DataAvailabilityChallengeProxy
47-
chainState.OpChainContracts.AltDAChallengeImpl = dao.DataAvailabilityChallengeImpl
50+
chainState.OpChainContracts.AltDAChallengeProxy = output.DataAvailabilityChallengeProxy
51+
chainState.OpChainContracts.AltDAChallengeImpl = output.DataAvailabilityChallengeImpl
4852
return nil
4953
}
5054

packages/contracts-bedrock/scripts/deploy/Deploy.s.sol

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { ChainAssertions } from "scripts/deploy/ChainAssertions.sol";
1717
import { DeployUtils } from "scripts/libraries/DeployUtils.sol";
1818
import { DeploySuperchain2 } from "scripts/deploy/DeploySuperchain2.s.sol";
1919
import { DeployImplementations2 } from "scripts/deploy/DeployImplementations2.s.sol";
20-
import { DeployAltDA2 } from "scripts/deploy/DeployAltDA2.s.sol";
20+
import { DeployAltDA } from "scripts/deploy/DeployAltDA.s.sol";
2121
import { StandardConstants } from "scripts/deploy/StandardConstants.sol";
2222

2323
// Libraries
@@ -181,8 +181,8 @@ contract Deploy is Deployer {
181181
if (typeHash == keccakHash) {
182182
console.log("Deploying OP AltDA");
183183

184-
DeployAltDA2 da2 = new DeployAltDA2();
185-
DeployAltDA2.Input memory dii = DeployAltDA2.Input({
184+
DeployAltDA da = new DeployAltDA();
185+
DeployAltDA.Input memory dii = DeployAltDA.Input({
186186
salt: _implSalt(),
187187
proxyAdmin: IProxyAdmin(artifacts.mustGetAddress("ProxyAdmin")),
188188
challengeContractOwner: cfg.finalSystemOwner(),
@@ -192,7 +192,7 @@ contract Deploy is Deployer {
192192
resolverRefundPercentage: cfg.daResolverRefundPercentage()
193193
});
194194

195-
DeployAltDA2.Output memory dio = da2.run(dii);
195+
DeployAltDA.Output memory dio = da.run(dii);
196196

197197
artifacts.save("DataAvailabilityChallengeProxy", address(dio.dataAvailabilityChallengeProxy));
198198
artifacts.save("DataAvailabilityChallengeImpl", address(dio.dataAvailabilityChallengeImpl));

0 commit comments

Comments
 (0)