diff --git a/ethergo/deployer/registry.go b/ethergo/deployer/registry.go index dd17eaa0e5..007b80cbe2 100644 --- a/ethergo/deployer/registry.go +++ b/ethergo/deployer/registry.go @@ -2,12 +2,15 @@ package deployer import ( "context" + "sync" + "testing" + "time" + "github.com/neverlee/keymutex" "github.com/stretchr/testify/require" + "github.com/synapsecns/sanguine/core/retry" "github.com/synapsecns/sanguine/ethergo/backends" "github.com/synapsecns/sanguine/ethergo/contracts" - "sync" - "testing" ) // ContractDeployer is a contract deployer for a single contract type. @@ -151,15 +154,24 @@ func (c *contractRegistryImpl) Deploy(ctx context.Context, contractType contract deploymentHandle := c.deployers[contractType.ID()] c.structMux.RUnlock() - deployedContract, err := deploymentHandle.Deploy(ctx) + var deployedContract contracts.DeployedContract + err := retry.WithBackoff(ctx, func(ctx context.Context) (err error) { + deployedContract, err = deploymentHandle.Deploy(ctx) + if err != nil { + return + } + c.backend.WaitForConfirmation(ctx, deployedContract.DeployTx()) + err = c.backend.VerifyContract(contractType, deployedContract) + if err != nil { + return + } + logger.Debugf("added contract %s of types %s in tx %s on chain id %s", deployedContract.Address(), contractType.Name(), deployedContract.DeployTx().Hash().String(), deployedContract.ChainID().String()) + return + }, retry.WithMax(120*time.Second)) require.Nil(c.tb, err) - - c.backend.WaitForConfirmation(ctx, deployedContract.DeployTx()) - err = c.backend.VerifyContract(contractType, deployedContract) if err != nil { logger.Warnf("got error %s while verifying contract, skipping", err) } - logger.Debugf("added contract %s of types %s in tx %s on chain id %s", deployedContract.Address(), contractType.Name(), deployedContract.DeployTx().Hash().String(), deployedContract.ChainID().String()) return deployedContract }