Skip to content

Commit 171a770

Browse files
authored
feat: check for transporter success on devnet start (#286)
<!-- 🚨 ATTENTION! 🚨 This PR template is REQUIRED. PRs not following this format will be closed without review. Requirements: - PR title must follow commit conventions: https://www.conventionalcommits.org/en/v1.0.0/ - Label your PR with the correct type (e.g., 🐛 Bug, ✨ Enhancement, 🧪 Test, etc.) - Provide clear and specific details in each section --> **Motivation:** <!-- Explain here the context, and why you're making that change. What is the problem you're trying to solve. --> As a devkit user, I want to be certain that the transporter ran successfully before I continue so that I do not get any unexpected errors further through the process. **Modifications:** <!-- Describe the modifications you've done from a high level. What are the key technical decisions and why were they made? --> - Checks for transporter success in the devnet deploy-L2 path **Result:** <!-- *After your change, what will change. --> - Errors with appropriate error message if the transporter fails
1 parent ad656ea commit 171a770

File tree

2 files changed

+86
-78
lines changed

2 files changed

+86
-78
lines changed

pkg/commands/deploy_actions.go

Lines changed: 65 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -215,62 +215,8 @@ func StartDeployL2Action(cCtx *cli.Context) error {
215215
logger.Info("Starting L2 (%d) deployment to %s\n", l2ChainCfg.ChainID, contextName)
216216

217217
// Get operatorSets, check curveType, use contractCaller to check getOperatorSetOwner()
218-
if len(envCtx.OperatorSets) > 0 {
219-
// Collect AVS address
220-
avsAddr := envCtx.Avs.Address
221-
transportedOpSets := 0
222-
223-
// For each OperatorSets check if the transport has happened yet
224-
for _, opSet := range envCtx.OperatorSets {
225-
logger.Debug("Checking owner of AVS: %s and OperatorSet: %d", avsAddr, opSet.OperatorSetID)
226-
227-
// Collect appropriate CertVerifier based on curveType
228-
var certVerifierAddr string
229-
switch opSet.CurveType {
230-
case common.BN254Curve:
231-
certVerifierAddr = envCtx.EigenLayer.L2.BN254CertificateVerifier
232-
case common.ECDSACurve:
233-
certVerifierAddr = envCtx.EigenLayer.L2.ECDSACertificateVerifier
234-
}
235-
236-
// Pass certVerifierAddr to contractCaller
237-
if certVerifierAddr != "" {
238-
contractCaller, err := common.NewContractCaller(
239-
envCtx.Avs.AVSPrivateKey,
240-
big.NewInt(int64(l2ChainCfg.ChainID)),
241-
client,
242-
ethcommon.HexToAddress(""),
243-
ethcommon.HexToAddress(""),
244-
ethcommon.HexToAddress(""),
245-
ethcommon.HexToAddress(""),
246-
ethcommon.HexToAddress(""),
247-
ethcommon.HexToAddress(""),
248-
ethcommon.HexToAddress(certVerifierAddr),
249-
logger,
250-
)
251-
252-
// Attempt to get owner from appropriate certVerifier
253-
var owner ethcommon.Address
254-
switch opSet.CurveType {
255-
case common.BN254Curve:
256-
owner, err = contractCaller.GetBN254OperatorSetOwner(cCtx.Context, ethcommon.HexToAddress(avsAddr), uint32(opSet.OperatorSetID))
257-
case common.ECDSACurve:
258-
owner, err = contractCaller.GetECDSAOperatorSetOwner(cCtx.Context, ethcommon.HexToAddress(avsAddr), uint32(opSet.OperatorSetID))
259-
}
260-
261-
logger.Debug(" - Owner is set: %s", owner)
262-
263-
// Test to make sure the transporter has ran before deploying to L2
264-
if err == nil && owner != ethcommon.HexToAddress("") {
265-
transportedOpSets++
266-
}
267-
}
268-
}
269-
270-
// Throw error if any of the operatorSets has not been registered yet
271-
if transportedOpSets < len(envCtx.OperatorSets) {
272-
return fmt.Errorf("waiting on transporter, try again soon")
273-
}
218+
if err := CheckOperatorSetOwnerIsSet(cCtx, envCtx, l2ChainCfg, client, logger); err != nil && !errors.Is(err, context.Canceled) {
219+
return fmt.Errorf("deploy-l2-contracts failed: %w", err)
274220
}
275221

276222
// Deploy L2 contracts after transporter has been ran and operatorSetOwner has been set
@@ -568,6 +514,69 @@ func DeployL2ContractsAction(cCtx *cli.Context) error {
568514

569515
}
570516

517+
func CheckOperatorSetOwnerIsSet(cCtx *cli.Context, envCtx common.ChainContextConfig, l2ChainCfg common.ChainConfig, client *ethclient.Client, logger iface.Logger) error {
518+
// Get operatorSets, check curveType, use contractCaller to check getOperatorSetOwner()
519+
if len(envCtx.OperatorSets) > 0 {
520+
// Collect AVS address
521+
avsAddr := envCtx.Avs.Address
522+
transportedOpSets := 0
523+
524+
// For each OperatorSets check if the transport has happened yet
525+
for _, opSet := range envCtx.OperatorSets {
526+
logger.Debug("Checking owner of AVS: %s and OperatorSet: %d", avsAddr, opSet.OperatorSetID)
527+
528+
// Collect appropriate CertVerifier based on curveType
529+
var certVerifierAddr string
530+
switch opSet.CurveType {
531+
case common.BN254Curve:
532+
certVerifierAddr = envCtx.EigenLayer.L2.BN254CertificateVerifier
533+
case common.ECDSACurve:
534+
certVerifierAddr = envCtx.EigenLayer.L2.ECDSACertificateVerifier
535+
}
536+
537+
// Pass certVerifierAddr to contractCaller
538+
if certVerifierAddr != "" {
539+
contractCaller, err := common.NewContractCaller(
540+
envCtx.Avs.AVSPrivateKey,
541+
big.NewInt(int64(l2ChainCfg.ChainID)),
542+
client,
543+
ethcommon.HexToAddress(""),
544+
ethcommon.HexToAddress(""),
545+
ethcommon.HexToAddress(""),
546+
ethcommon.HexToAddress(""),
547+
ethcommon.HexToAddress(""),
548+
ethcommon.HexToAddress(""),
549+
ethcommon.HexToAddress(certVerifierAddr),
550+
logger,
551+
)
552+
553+
// Attempt to get owner from appropriate certVerifier
554+
var owner ethcommon.Address
555+
switch opSet.CurveType {
556+
case common.BN254Curve:
557+
owner, err = contractCaller.GetBN254OperatorSetOwner(cCtx.Context, ethcommon.HexToAddress(avsAddr), uint32(opSet.OperatorSetID))
558+
case common.ECDSACurve:
559+
owner, err = contractCaller.GetECDSAOperatorSetOwner(cCtx.Context, ethcommon.HexToAddress(avsAddr), uint32(opSet.OperatorSetID))
560+
}
561+
562+
logger.Debug(" - Owner is set: %s", owner)
563+
564+
// Test to make sure the transporter has ran before deploying to L2
565+
if err == nil && owner != ethcommon.HexToAddress("") {
566+
transportedOpSets++
567+
}
568+
}
569+
}
570+
571+
// Throw error if any of the operatorSets has not been registered yet
572+
if transportedOpSets < len(envCtx.OperatorSets) {
573+
return fmt.Errorf("waiting on transporter, try again soon")
574+
}
575+
}
576+
577+
return nil
578+
}
579+
571580
func UpdateAVSMetadataAction(cCtx *cli.Context, logger iface.Logger) error {
572581
// Extract vars
573582
contextName := cCtx.String("context")

pkg/commands/devnet_actions.go

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -281,14 +281,14 @@ func StartDevnetAction(cCtx *cli.Context) error {
281281
logger.Info("Funding wallets on L1...")
282282
err = devnet.FundWalletsDevnet(config, l1RpcUrl)
283283
if err != nil {
284-
return fmt.Errorf("funding L1 devnet wallets failed: %w", err)
284+
return fmt.Errorf("funding L1 devnet wallets failed - please restart devnet and try again: %w", err)
285285
}
286286

287287
// Fund the wallets defined in config on L2
288288
logger.Info("Funding wallets on L2...")
289289
err = devnet.FundWalletsDevnet(config, l2RpcUrl)
290290
if err != nil {
291-
return fmt.Errorf("failed L2 devnet wallets failed: %w", err)
291+
return fmt.Errorf("failed L2 devnet wallets failed - please restart devnet and try again: %w", err)
292292
}
293293

294294
// Fund stakers with strategy tokens
@@ -325,13 +325,13 @@ func StartDevnetAction(cCtx *cli.Context) error {
325325
logger.Info("Total startup time: %s", elapsed)
326326

327327
if err := WhitelistChainIdInCrossRegistryAction(cCtx, logger); err != nil {
328-
return fmt.Errorf("whitelisting chain id in cross registry failed: %w", err)
328+
return fmt.Errorf("whitelisting chain id in cross registry failed - please restart devnet and try again: %w", err)
329329
}
330330

331331
// Deploy the contracts after starting devnet unless skipped
332332
if !skipDeployContracts {
333-
if err := DeployL1ContractsAction(cCtx); err != nil { // Assumes DeployContractsAction remains as is or is also refactored if needed
334-
return fmt.Errorf("deploy-contracts failed: %w", err)
333+
if err := DeployL1ContractsAction(cCtx); err != nil {
334+
return fmt.Errorf("deploy-contracts failed - please restart devnet and try again: %w", err)
335335
}
336336

337337
// Sleep for 1 second to make sure new context values have been written
@@ -340,51 +340,51 @@ func StartDevnetAction(cCtx *cli.Context) error {
340340
logger.Title("Registering AVS with EigenLayer...")
341341
if !cCtx.Bool("skip-setup") {
342342
if err := UpdateAVSMetadataAction(cCtx, logger); err != nil {
343-
return fmt.Errorf("updating AVS metadata failed: %w", err)
343+
return fmt.Errorf("updating AVS metadata failed - please restart devnet and try again: %w", err)
344344
}
345345

346346
if err := SetAVSRegistrarAction(cCtx, logger); err != nil {
347-
return fmt.Errorf("setting AVS registrar failed: %w", err)
347+
return fmt.Errorf("setting AVS registrar failed - please restart devnet and try again: %w", err)
348348
}
349349

350350
if err := CreateAVSOperatorSetsAction(cCtx, logger); err != nil {
351-
return fmt.Errorf("creating AVS operator sets failed: %w", err)
351+
return fmt.Errorf("creating AVS operator sets failed - please restart devnet and try again: %w", err)
352352
}
353353

354354
if err := ConfigureOpSetCurveTypeAction(cCtx, logger); err != nil {
355-
return fmt.Errorf("failed to configure OpSet in KeyRegistrar: %w", err)
355+
return fmt.Errorf("failed to configure OpSet in KeyRegistrar - please restart devnet and try again: %w", err)
356356
}
357357

358358
if err := CreateGenerationReservationAction(cCtx, logger); err != nil {
359-
return fmt.Errorf("failed to request op set generation reservation: %w", err)
359+
return fmt.Errorf("failed to request op set generation reservation - please restart devnet and try again: %w", err)
360360
}
361361

362362
if err := RegisterOperatorsToEigenLayerFromConfigAction(cCtx, logger); err != nil {
363-
return fmt.Errorf("registering operators failed: %w", err)
363+
return fmt.Errorf("registering operators failed - please restart devnet and try again: %w", err)
364364
}
365365

366366
if err := RegisterKeyInKeyRegistrarAction(cCtx, logger); err != nil {
367-
return fmt.Errorf("registering key in key registrar failed: %w", err)
367+
return fmt.Errorf("registering key in key registrar failed - please restart devnet and try again: %w", err)
368368
}
369369

370370
if err := DepositIntoStrategiesAction(cCtx, logger); err != nil {
371-
return fmt.Errorf("depositing into strategies failed: %w", err)
371+
return fmt.Errorf("depositing into strategies failed - please restart devnet and try again: %w", err)
372372
}
373373

374374
if err := DelegateToOperatorsAction(cCtx, logger); err != nil {
375-
return fmt.Errorf("delegating to operators failed: %w", err)
375+
return fmt.Errorf("delegating to operators failed - please restart devnet and try again: %w", err)
376376
}
377377

378378
if err := SetAllocationDelayAction(cCtx, logger); err != nil {
379-
return fmt.Errorf("setting allocation delay failed: %w", err)
379+
return fmt.Errorf("setting allocation delay failed - please restart devnet and try again: %w", err)
380380
}
381381

382382
if err := ModifyAllocationsAction(cCtx, logger); err != nil {
383-
return fmt.Errorf("modifying allocations failed: %w", err)
383+
return fmt.Errorf("modifying allocations failed - please restart devnet and try again: %w", err)
384384
}
385385

386386
if err := RegisterOperatorsToAvsFromConfigAction(cCtx, logger); err != nil {
387-
return fmt.Errorf("registering operators to AVS failed: %w", err)
387+
return fmt.Errorf("registering operators to AVS failed - please restart devnet and try again: %w", err)
388388
}
389389
} else {
390390
logger.Info("Skipping AVS setup steps...")
@@ -403,7 +403,7 @@ func StartDevnetAction(cCtx *cli.Context) error {
403403
if !skipTransporter {
404404
// Post initial stake roots to L1
405405
if err := Transport(cCtx, true); err != nil && !errors.Is(err, context.Canceled) {
406-
return fmt.Errorf("transport run failed: %w", err)
406+
return fmt.Errorf("transport run failed - please restart devnet and try again: %w", err)
407407
}
408408

409409
// Shallow-copy cli.Context so that ScheduleTransport sees the new ctx
@@ -424,16 +424,15 @@ func StartDevnetAction(cCtx *cli.Context) error {
424424

425425
// Deploy L2 contracts only if L1 contracts were also deployed
426426
if !skipDeployContracts {
427-
if err := DeployL2ContractsAction(cCtx); err != nil && !errors.Is(err, context.Canceled) {
428-
logger.Error("deploy-l2-contracts failed: %v", err)
429-
return fmt.Errorf("deploy-l2-contracts failed: %w", err)
427+
if err := StartDeployL2Action(cCtx); err != nil && !errors.Is(err, context.Canceled) {
428+
return fmt.Errorf("start-l2-deploy failed - please restart devnet and try again: %w", err)
430429
}
431430
}
432431

433432
// Start offchain AVS components after starting devnet and deploying contracts unless skipped
434433
if !skipDeployContracts && !skipAvsRun {
435434
if err := AVSRun(cCtx); err != nil && !errors.Is(err, context.Canceled) {
436-
return fmt.Errorf("avs run failed: %w", err)
435+
return fmt.Errorf("avs run failed - please restart devnet and try again: %w", err)
437436
}
438437
}
439438

0 commit comments

Comments
 (0)