Skip to content

Commit

Permalink
throw reverts at deployer level in addition to solidity level
Browse files Browse the repository at this point in the history
  • Loading branch information
trajan0x committed Sep 3, 2023
1 parent 3f354d8 commit f2d2280
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 21 deletions.
4 changes: 2 additions & 2 deletions agents/testutil/deployers.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ func (d InboxDeployer) Deploy(ctx context.Context) (contracts.DeployedContract,
originAddress := originContract.Address()
destinationAddress := destinationContract.Address()*/
return d.DeploySimpleContract(ctx, func(transactOps *bind.TransactOpts, backend bind.ContractBackend) (address common.Address, tx *types.Transaction, data interface{}, err error) {
if d.Backend().GetChainID() == SynChainID {
return common.Address{}, nil, nil, fmt.Errorf("could not deploy %s on synchain", d.ContractType().ContractName())
if d.Backend().GetChainID() != SynChainID {
return common.Address{}, nil, nil, fmt.Errorf("could not deploy %s on non-synchain", d.ContractType().ContractName())
}

// deploy the inbox contract
Expand Down
26 changes: 7 additions & 19 deletions ethergo/deployer/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@ 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.
Expand Down Expand Up @@ -154,24 +151,15 @@ func (c *contractRegistryImpl) Deploy(ctx context.Context, contractType contract
deploymentHandle := c.deployers[contractType.ID()]
c.structMux.RUnlock()

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))
deployedContract, err := deploymentHandle.Deploy(ctx)
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
}
Expand Down

0 comments on commit f2d2280

Please sign in to comment.