Skip to content

Commit

Permalink
Ccip-2578 - Enable slow and fast chain (#1122)
Browse files Browse the repository at this point in the history
  • Loading branch information
AnieeG authored Jul 4, 2024
1 parent a8e009f commit 2cd83fb
Show file tree
Hide file tree
Showing 8 changed files with 328 additions and 164 deletions.
118 changes: 61 additions & 57 deletions integration-tests/ccip-tests/actions/ccip_helpers.go

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions integration-tests/ccip-tests/contracts/contract_models.go
Original file line number Diff line number Diff line change
Expand Up @@ -1497,6 +1497,7 @@ type SendReqEventData struct {
DataLength int
NoOfTokens int
Raw types.Log
Fee *big.Int
}

type OnRampWrapper struct {
Expand Down
80 changes: 15 additions & 65 deletions integration-tests/ccip-tests/load/ccip_loadgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ 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 @@ -258,78 +257,25 @@ func (c *CCIPE2ELoad) Call(_ *wasp.Generator) *wasp.Response {
}
startTime := time.Now().UTC()
if feeToken != common.HexToAddress("0x0") {
sendTx, err = sourceCCIP.Common.Router.CCIPSend(destChainSelector, msg, nil)
sendTx, err = sourceCCIP.Common.Router.CCIPSendAndProcessTx(destChainSelector, msg, nil)
} else {
// add a bit buffer to fee
sendTx, err = sourceCCIP.Common.Router.CCIPSend(destChainSelector, msg, new(big.Int).Add(big.NewInt(1e5), fee))
sendTx, err = sourceCCIP.Common.Router.CCIPSendAndProcessTx(destChainSelector, msg, new(big.Int).Add(big.NewInt(1e5), fee))
}
if err != nil {
stats.UpdateState(&lggr, 0, testreporters.TX, time.Since(startTime), testreporters.Failure)
stats.UpdateState(&lggr, 0, testreporters.TX, time.Since(startTime), testreporters.Failure, nil)
res.Error = fmt.Sprintf("ccip-send tx error %s for reqNo %d", err.Error(), msgSerialNo)
res.Data = stats.StatusByPhase
res.Failed = true
return res
}

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

if err != nil {
stats.UpdateState(&lggr, 0, testreporters.TX, time.Since(startTime), testreporters.Failure)
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,
testreporters.TransactionStats{
Fee: fee.String(),
GasUsed: rcpt.GasUsed,
TxHash: sendTx.Hash().Hex(),
NoOfTokensSent: len(msg.TokenAmounts),
MessageBytesLength: int64(len(msg.Data)),
})

stats.UpdateState(&lggr, 0, testreporters.TX, txConfirmationTime.Sub(startTime), testreporters.Success, nil)
err = c.Validate(lggr, sendTx, txConfirmationTime, []*testreporters.RequestStat{stats})
if err != nil {
res.Error = err.Error()
Expand All @@ -356,19 +302,23 @@ func (c *CCIPE2ELoad) Validate(lggr zerolog.Logger, sendTx *types.Transaction, t
if c.Lane.Source.Common.ChainClient.GetNetworkConfig().FinalityDepth == 0 &&
lstFinalizedBlock != 0 && lstFinalizedBlock > msgLogs[0].Raw.BlockNumber {
sourceLogFinalizedAt = c.LastFinalizedTimestamp.Load()
for _, stat := range stats {
for i, stat := range stats {
stat.UpdateState(&lggr, stat.SeqNum, testreporters.SourceLogFinalized,
sourceLogFinalizedAt.Sub(sourceLogTime), testreporters.Success,
testreporters.TransactionStats{
TxHash: msgLogs[0].Raw.TxHash.Hex(),
FinalizedByBlock: strconv.FormatUint(lstFinalizedBlock, 10),
FinalizedAt: sourceLogFinalizedAt.String(),
&testreporters.TransactionStats{
TxHash: msgLogs[i].Raw.TxHash.Hex(),
FinalizedByBlock: strconv.FormatUint(lstFinalizedBlock, 10),
FinalizedAt: sourceLogFinalizedAt.String(),
Fee: msgLogs[i].Fee.String(),
NoOfTokensSent: msgLogs[i].NoOfTokens,
MessageBytesLength: int64(msgLogs[i].DataLength),
MsgID: fmt.Sprintf("0x%x", msgLogs[i].MessageId[:]),
})
}
} else {
var finalizingBlock uint64
sourceLogFinalizedAt, finalizingBlock, err = c.Lane.Source.AssertSendRequestedLogFinalized(
&lggr, msgLogs[0].Raw.TxHash, sourceLogTime, stats)
&lggr, msgLogs[0].Raw.TxHash, msgLogs, sourceLogTime, stats)
if err != nil {
return err
}
Expand Down
25 changes: 2 additions & 23 deletions integration-tests/ccip-tests/load/ccip_multicall_loadgen.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package load

import (
"context"
"fmt"
"math/big"
"testing"
"time"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/prometheus/common/model"
"github.com/rs/zerolog"
Expand Down Expand Up @@ -178,33 +176,14 @@ func (m *CCIPMultiCallLoadGenerator) Call(_ *wasp.Generator) *wasp.Response {

lggr := m.logger.With().Str("Msg Tx", sendTx.Hash().String()).Logger()
txConfirmationTime := time.Now().UTC()
rcpt, err1 := bind.WaitMined(context.Background(), m.client.DeployBackend(), sendTx)
if err1 == nil {
hdr, err1 := m.client.HeaderByNumber(context.Background(), rcpt.BlockNumber)
if err1 == nil {
txConfirmationTime = hdr.Timestamp
}
}
var gasUsed uint64
if rcpt != nil {
gasUsed = rcpt.GasUsed
}
for _, rValues := range returnValuesByDest {
if len(rValues.Stats) != len(rValues.Msgs) {
res.Error = fmt.Sprintf("number of stats %d and msgs %d should be same", len(rValues.Stats), len(rValues.Msgs))
res.Failed = true
return res
}
for i, stat := range rValues.Stats {
msg := rValues.Msgs[i]
stat.UpdateState(&lggr, 0, testreporters.TX, startTime.Sub(txConfirmationTime), testreporters.Success,
testreporters.TransactionStats{
Fee: msg.Fee.String(),
GasUsed: gasUsed,
TxHash: sendTx.Hash().Hex(),
NoOfTokensSent: len(msg.Msg.TokenAmounts),
MessageBytesLength: int64(len(msg.Msg.Data)),
})
for _, stat := range rValues.Stats {
stat.UpdateState(&lggr, 0, testreporters.TX, startTime.Sub(txConfirmationTime), testreporters.Success, nil)
}
}

Expand Down
2 changes: 1 addition & 1 deletion integration-tests/ccip-tests/testconfig/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ Specifies the number of routers to be set up for each network.

### CCIP.Groups.[testgroup].MaxNoOfLanes
Specifies the maximum number of lanes to be set up between networks. If this values is not set, the test will set up lanes between all possible pairs of networks mentioned in `selected_networks` in [CCIP.Env.Networks](#ccipenvnetworksselectednetworks).
For example, if `selected_networks = ['SIMULATED_1', 'SIMULATED_2', 'SIMULATED_3']`, and `MaxNoOfLanes` is set to 3, it denotes that the test will randomly select 3 lanes between all possible pairs `SIMULATED_1`, `SIMULATED_2`, and `SIMULATED_3` for the test run.
For example, if `selected_networks = ['SIMULATED_1', 'SIMULATED_2', 'SIMULATED_3']`, and `MaxNoOfLanes` is set to 2, it denotes that the test will select the first 2 lanes between all possible pairs `SIMULATED_1`, `SIMULATED_2`, and `SIMULATED_3` for the test run.

### CCIP.Groups.[testgroup].ChaosDuration
Specifies the duration for which the chaos experiment is to be run. This is only valid if the test type is 'chaos'.
Expand Down
Loading

0 comments on commit 2cd83fb

Please sign in to comment.