Skip to content

Commit

Permalink
few more fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
AnieeG committed Jul 8, 2024
1 parent 69b7f58 commit 7ec7387
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 10 deletions.
6 changes: 6 additions & 0 deletions integration-tests/ccip-tests/actions/ccip_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ type CCIPCommon struct {
tokenPriceUpdateWatcher map[common.Address]*big.Int // key - token; value - timestamp of update
gasUpdateWatcherMu *sync.Mutex
gasUpdateWatcher map[uint64]*big.Int // key - destchain id; value - timestamp of update
priceUpdateFound chan struct{}
}

// FreeUpUnusedSpace sets nil to various elements of ccipModule which are only used
Expand Down Expand Up @@ -513,6 +514,7 @@ func (ccipModule *CCIPCommon) WaitForPriceUpdates(
Uint64("dest chain", destChainId).
Str("source chain", ccipModule.ChainClient.GetNetworkName()).
Msg("Price updated")
ccipModule.priceUpdateFound <- struct{}{}
return nil
}
case <-localCtx.Done():
Expand Down Expand Up @@ -574,6 +576,7 @@ func (ccipModule *CCIPCommon) WatchForPriceUpdates(ctx context.Context, lggr *ze
ccipModule.gasUpdateWatcherMu = nil
ccipModule.tokenPriceUpdateWatcher = nil
ccipModule.tokenPriceUpdateWatcherMu = nil
ccipModule.priceUpdateFound = nil
}()
for {
select {
Expand All @@ -593,6 +596,8 @@ func (ccipModule *CCIPCommon) WatchForPriceUpdates(ctx context.Context, lggr *ze
Msg("UsdPerTokenUpdated event received")
case <-ctx.Done():
return
case <-ccipModule.priceUpdateFound:
return
}
}
}()
Expand Down Expand Up @@ -1270,6 +1275,7 @@ func DefaultCCIPModule(
NoOfTokensNeedingDynamicPrice: pointer.GetInt(testGroupConf.TokenConfig.NoOfTokensWithDynamicPrice),
poolFunds: testhelpers.Link(5),
gasUpdateWatcherMu: &sync.Mutex{},
priceUpdateFound: make(chan struct{}),
gasUpdateWatcher: make(map[uint64]*big.Int),
tokenPriceUpdateWatcherMu: &sync.Mutex{},
tokenPriceUpdateWatcher: make(map[common.Address]*big.Int),
Expand Down
58 changes: 51 additions & 7 deletions integration-tests/ccip-tests/load/ccip_loadgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"time"

"github.com/AlekSi/pointer"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/rs/zerolog"
Expand Down Expand Up @@ -248,19 +249,16 @@ func (c *CCIPE2ELoad) Call(_ *wasp.Generator) *wasp.Response {
// if the token address is 0x0 it will use Native as fee token and the fee amount should be mentioned in bind.TransactOpts's value
fee, err := sourceCCIP.Common.Router.GetFee(destChainSelector, msg)
if err != nil {
res.Error = fmt.Sprintf("reqNo %d err %s - while getting fee from router - msg Data %x FeeToken %s TokenAmounts %+v ExtraArgs %x Receiver %x",
msgSerialNo, err.Error(),
msg.Data, msg.FeeToken, msg.TokenAmounts, msg.ExtraArgs, msg.Receiver)

res.Error = fmt.Sprintf("reqNo %d err %s - while getting fee from router", msgSerialNo, err.Error())
res.Failed = true
return res
}
startTime := time.Now().UTC()
if feeToken != common.HexToAddress("0x0") {
sendTx, err = sourceCCIP.Common.Router.CCIPSendAndProcessTx(destChainSelector, msg, nil)
sendTx, err = sourceCCIP.Common.Router.CCIPSend(destChainSelector, msg, nil)
} else {
// add a bit buffer to fee
sendTx, err = sourceCCIP.Common.Router.CCIPSendAndProcessTx(destChainSelector, msg, new(big.Int).Add(big.NewInt(1e5), fee))
sendTx, err = sourceCCIP.Common.Router.CCIPSend(destChainSelector, msg, new(big.Int).Add(big.NewInt(1e5), fee))
}
if err != nil {
stats.UpdateState(&lggr, 0, testreporters.TX, time.Since(startTime), testreporters.Failure, nil)
Expand All @@ -270,11 +268,57 @@ func (c *CCIPE2ELoad) Call(_ *wasp.Generator) *wasp.Response {
return res
}

err = sourceCCIP.Common.ChainClient.MarkTxAsSentOnL2(sendTx)

if err != nil {
stats.UpdateState(&lggr, 0, testreporters.TX, time.Since(startTime), testreporters.Failure, nil)
res.Error = fmt.Sprintf("reqNo %d failed to mark tx as sent on L2 %s", msgSerialNo, err.Error())
res.Data = stats.StatusByPhase
res.Failed = true
return res
}

txConfirmationTime := time.Now().UTC()
// wait for the tx to be mined, timeout is set to 10 minutes
lggr.Info().Str("tx", sendTx.Hash().Hex()).Msg("waiting for tx to be mined")
ctx, cancel := context.WithTimeout(context.Background(), sourceCCIP.Common.ChainClient.GetNetworkConfig().Timeout.Duration)
defer cancel()
rcpt, err := bind.WaitMined(ctx, sourceCCIP.Common.ChainClient.DeployBackend(), sendTx)
if err != nil {
res.Error = fmt.Sprintf("ccip-send request tx not mined, err=%s", err.Error())
res.Failed = true
res.Data = stats.StatusByPhase
return res
}
if rcpt == nil {
res.Error = "ccip-send request tx not mined, receipt is nil"
res.Failed = true
res.Data = stats.StatusByPhase
return res
}
hdr, err := c.Lane.Source.Common.ChainClient.HeaderByNumber(context.Background(), rcpt.BlockNumber)
if err == nil && hdr != nil {
txConfirmationTime = hdr.Timestamp
}
lggr = lggr.With().Str("Msg Tx", sendTx.Hash().String()).Logger()

if rcpt.Status != types.ReceiptStatusSuccessful {
stats.UpdateState(&lggr, 0, testreporters.TX, txConfirmationTime.Sub(startTime), testreporters.Failure,
&testreporters.TransactionStats{
Fee: fee.String(),
GasUsed: rcpt.GasUsed,
TxHash: sendTx.Hash().Hex(),
NoOfTokensSent: len(msg.TokenAmounts),
MessageBytesLength: int64(len(msg.Data)),
})
errReason, v, err := c.Lane.Source.Common.ChainClient.RevertReasonFromTx(rcpt.TxHash, router.RouterABI)
if err != nil {
errReason = "could not decode"
}
res.Error = fmt.Sprintf("ccip-send request receipt is not successful, errReason=%s, args =%v", errReason, v)
res.Failed = true
res.Data = stats.StatusByPhase
return res
}
stats.UpdateState(&lggr, 0, testreporters.TX, txConfirmationTime.Sub(startTime), testreporters.Success, nil)
err = c.Validate(lggr, sendTx, txConfirmationTime, []*testreporters.RequestStat{stats})
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion integration-tests/ccip-tests/load/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ import (

"github.com/AlekSi/pointer"
"github.com/rs/zerolog"
"github.com/smartcontractkit/chainlink-common/pkg/config"
"github.com/smartcontractkit/wasp"
"github.com/stretchr/testify/require"
"go.uber.org/atomic"
"golang.org/x/sync/errgroup"

"github.com/smartcontractkit/chainlink-common/pkg/config"

"github.com/smartcontractkit/chainlink-testing-framework/k8s/chaos"
"github.com/smartcontractkit/chainlink-testing-framework/utils/testcontext"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,12 @@ evm_finality_depth = 200

[CCIP.Env.Network.AnvilConfigs.PRIVATE-CHAIN-1]
block_time = 1
block_gaslimit = 100000000

#
[CCIP.Env.Network.AnvilConfigs.PRIVATE-CHAIN-2]
block_time = 1
block_gaslimit = 100000000

[CCIP.Env.NewCLCluster]
NoOfNodes = 17
Expand Down Expand Up @@ -149,7 +152,7 @@ BatchGasLimit = 11000000
TimeoutForPriceUpdate = '15m'
NoOfTokensPerChain = 60
NoOfTokensWithDynamicPrice = 15
DynamicPriceUpdateInterval ='15s'
DynamicPriceUpdateInterval ='5m'
CCIPOwnerTokens = true

[CCIP.Groups.load.LoadProfile]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,20 @@ evm_finality_depth = 1

[CCIP.Env.Network.AnvilConfigs.PRIVATE-CHAIN-1]
block_time = 1
block_gaslimit = 100000000

#
[CCIP.Env.Network.AnvilConfigs.SLOW-CHAIN-1]
block_time = 12
block_gaslimit = 100000000

[CCIP.Env.Network.AnvilConfigs.SLOW-CHAIN-2]
block_time = 12
block_gaslimit = 100000000

[CCIP.Env.Network.AnvilConfigs.SLOW-CHAIN-3]
block_time = 12
block_gaslimit = 100000000

[CCIP.Env.NewCLCluster]
NoOfNodes = 17
Expand Down Expand Up @@ -187,7 +192,7 @@ BatchGasLimit = 11000000
TimeoutForPriceUpdate = '15m'
NoOfTokensPerChain = 60
NoOfTokensWithDynamicPrice = 15
DynamicPriceUpdateInterval ='15s'
DynamicPriceUpdateInterval ='5m'
CCIPOwnerTokens = true

[CCIP.Groups.load.LoadProfile]
Expand Down
2 changes: 2 additions & 0 deletions integration-tests/ccip-tests/testsetups/test_env.go
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,8 @@ func DeployEnvironments(
"forkComputeUnitsPerSecond": anvilConfig.ComputePerSecond,
"forkNoRateLimit": anvilConfig.RateLimitDisabled,
"blocksToKeepInMemory": anvilConfig.BlocksToKeepInMem,
"blockGasLimit": anvilConfig.BlockGaslimit,
"baseFee": anvilConfig.BaseFee,
},
"resources": testInputs.GethResourceProfile,
},
Expand Down

0 comments on commit 7ec7387

Please sign in to comment.