Skip to content

Commit

Permalink
Check for Config promotion event before checking getcandidate digest (#…
Browse files Browse the repository at this point in the history
…14778)

* trying to fix flake

* simplify

* fix blocking call

* more simplify

---------

Co-authored-by: Connor Stein <[email protected]>
  • Loading branch information
AnieeG and connorwstein authored Oct 16, 2024
1 parent e1c7c5b commit 275bcf0
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 29 deletions.
21 changes: 17 additions & 4 deletions integration-tests/deployment/ccip/deploy_home_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ func setupExecDON(

execCandidateDigest, err := ccipHome.GetCandidateDigest(nil, donID, execConfig.PluginType)
if err != nil {
return fmt.Errorf("get commit candidate digest: %w", err)
return fmt.Errorf("get exec candidate digest 1st time: %w", err)
}

if execCandidateDigest == [32]byte{} {
Expand Down Expand Up @@ -605,11 +605,24 @@ func setupExecDON(
if err != nil {
return fmt.Errorf("update don w/ exec config: %w", err)
}

if _, err := deployment.ConfirmIfNoError(home, tx, err); err != nil {
bn, err := deployment.ConfirmIfNoError(home, tx, err)
if err != nil {
return fmt.Errorf("confirm update don w/ exec config: %w", err)
}

if bn == 0 {
return fmt.Errorf("UpdateDON tx not confirmed")
}
// check if candidate digest is promoted
pEvent, err := ccipHome.FilterConfigPromoted(&bind.FilterOpts{
Context: context.Background(),
Start: bn,
}, [][32]byte{execCandidateDigest})
if err != nil {
return fmt.Errorf("filter exec config promoted: %w", err)
}
if !pEvent.Next() {
return fmt.Errorf("exec config not promoted")
}
// check that candidate digest is empty.
execCandidateDigest, err = ccipHome.GetCandidateDigest(nil, donID, execConfig.PluginType)
if err != nil {
Expand Down
47 changes: 22 additions & 25 deletions integration-tests/deployment/devenv/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/sethvargo/go-retry"
chainselectors "github.com/smartcontractkit/chain-selectors"

"github.com/smartcontractkit/chainlink-common/pkg/logger"
Expand Down Expand Up @@ -60,30 +59,28 @@ func NewChains(logger logger.Logger, configs []ChainConfig) (map[uint64]deployme
if tx == nil {
return 0, fmt.Errorf("tx was nil, nothing to confirm")
}
err := retry.Do(context.Background(),
retry.WithMaxDuration(3*time.Minute, retry.NewFibonacci(1*time.Second)),
func(ctx context.Context) error {
chainId, err := ec.ChainID(ctx)
if err != nil {
return fmt.Errorf("failed to get chain id: %w", err)
}
receipt, err := bind.WaitMined(ctx, ec, tx)
if err != nil {
return retry.RetryableError(fmt.Errorf("failed to get receipt for chain %d: %w", chainId, err))
}
if receipt != nil {
blockNumber = receipt.BlockNumber.Uint64()
}
if receipt.Status == 0 {
errReason, err := deployment.GetErrorReasonFromTx(ec, chainCfg.DeployerKey.From, *tx, receipt)
if err == nil && errReason != "" {
return fmt.Errorf("tx %s reverted,error reason: %s", tx.Hash().Hex(), errReason)
}
return fmt.Errorf("tx %s reverted, could not decode error reason", tx.Hash().Hex())
}
return nil
})
return blockNumber, err
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Minute)
defer cancel()
chainId, err := ec.ChainID(ctx)
if err != nil {
return blockNumber, fmt.Errorf("failed to get chain id: %w", err)
}
receipt, err := bind.WaitMined(ctx, ec, tx)
if err != nil {
return blockNumber, fmt.Errorf("failed to get confirmed receipt for chain %d: %w", chainId, err)
}
if receipt == nil {
return blockNumber, fmt.Errorf("receipt was nil for tx %s", tx.Hash().Hex())
}
blockNumber = receipt.BlockNumber.Uint64()
if receipt.Status == 0 {
errReason, err := deployment.GetErrorReasonFromTx(ec, chainCfg.DeployerKey.From, *tx, receipt)
if err == nil && errReason != "" {
return blockNumber, fmt.Errorf("tx %s reverted,error reason: %s", tx.Hash().Hex(), errReason)
}
return blockNumber, fmt.Errorf("tx %s reverted, could not decode error reason", tx.Hash().Hex())
}
return blockNumber, nil
},
}
}
Expand Down

0 comments on commit 275bcf0

Please sign in to comment.