Skip to content

Commit 1dd00ca

Browse files
yashvardhan-kukrejasigma
authored andcommitted
feat(op-deployer): interop dep set generation
Signed-off-by: Yashvardhan Kukreja <[email protected]>
1 parent 22fa5e9 commit 1dd00ca

File tree

4 files changed

+58
-8
lines changed

4 files changed

+58
-8
lines changed

devnet-sdk/proofs/prestate/client.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,30 +63,34 @@ func WithInteropDepSet(content io.Reader) PrestateBuilderOption {
6363
}
6464
}
6565

66-
type dependency struct {
66+
type Dependency struct {
6767
ChainIndex uint32 `json:"chainIndex"`
6868
ActivationTime uint64 `json:"activationTime"`
6969
HistoryMinTime uint64 `json:"historyMinTime"`
7070
}
7171

72-
type dependencySet struct {
73-
Dependencies map[string]dependency `json:"dependencies"`
72+
type DependencySet struct {
73+
Dependencies map[string]Dependency `json:"dependencies"`
7474
}
7575

76-
func generateInteropDepSet(chains []string) ([]byte, error) {
77-
deps := dependencySet{
78-
Dependencies: make(map[string]dependency),
76+
func RenderInteropDepSet(chains []string) DependencySet {
77+
deps := DependencySet{
78+
Dependencies: make(map[string]Dependency),
7979
}
8080

8181
for i, chain := range chains {
82-
deps.Dependencies[chain] = dependency{
82+
deps.Dependencies[chain] = Dependency{
8383
ChainIndex: uint32(i),
8484
ActivationTime: 0,
8585
HistoryMinTime: 0,
8686
}
8787
}
8888

89-
json, err := json.Marshal(deps)
89+
return deps
90+
}
91+
92+
func generateInteropDepSet(chains []string) ([]byte, error) {
93+
json, err := json.Marshal(RenderInteropDepSet(chains))
9094
if err != nil {
9195
return nil, err
9296
}

op-deployer/pkg/deployer/apply.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,16 @@ func ApplyPipeline(
361361
})
362362
}
363363

364+
// Generate the interop dependency set if interop is enabled
365+
if intent.UseInterop {
366+
pline = append(pline, pipelineStage{
367+
"generate-interop-depset",
368+
func() error {
369+
return pipeline.GenerateInteropDepset(ctx, pEnv, intent, st)
370+
},
371+
})
372+
}
373+
364374
// Generate the prestate for all chains
365375
pline = append(pline, pipelineStage{
366376
"deploy-pre-state",
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package pipeline
2+
3+
import (
4+
"context"
5+
"fmt"
6+
7+
"github.com/ethereum-optimism/optimism/devnet-sdk/proofs/prestate"
8+
"github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/state"
9+
)
10+
11+
func GenerateInteropDepset(ctx context.Context, pEnv *Env, globalIntent *state.Intent, st *state.State) error {
12+
lgr := pEnv.Logger.New("stage", "generate-interop-depset")
13+
14+
if !globalIntent.UseInterop {
15+
lgr.Warn("interop not enabled - skipping interop depset generation")
16+
return nil
17+
}
18+
19+
var chains []string
20+
for _, chain := range globalIntent.Chains {
21+
chains = append(chains, chain.ID.Big().String())
22+
}
23+
24+
lgr.Info("rendering the interop dependency set...")
25+
depSet := prestate.RenderInteropDepSet(chains)
26+
st.InteropDepSet = &depSet
27+
28+
if err := pEnv.StateWriter.WriteState(st); err != nil {
29+
return fmt.Errorf("failed to write state: %w", err)
30+
}
31+
32+
return nil
33+
}

op-deployer/pkg/deployer/state/state.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ type State struct {
3333
// PrestateManifest contains the prestate generated by the op-program-svc
3434
PrestateManifest *prestate.PrestateManifest `json:"prestateManifest"`
3535

36+
// InteropDepSet contains the interop dependency set render by the prestate SDK if interop is enabled
37+
InteropDepSet *prestate.DependencySet `json:"interopDepSet,omitempty"`
38+
3639
// SuperchainDeployment contains the addresses of the Superchain
3740
// deployment. It only contains the proxies because the implementations
3841
// can be looked up on chain.

0 commit comments

Comments
 (0)