Skip to content

Commit

Permalink
configure input to skip request in load if other requests are trigger…
Browse files Browse the repository at this point in the history
…ed within certain timeframe
  • Loading branch information
AnieeG committed Apr 4, 2024
1 parent 7a9ce88 commit 878ab58
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 54 deletions.
24 changes: 24 additions & 0 deletions integration-tests/ccip-tests/actions/ccip_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -1357,6 +1357,30 @@ func (sourceCCIP *SourceCCIPModule) AssertSendRequestedLogFinalized(
return finalizedAt, finalizedBlockNum.Uint64(), nil
}

func (sourceCCIP *SourceCCIPModule) IsRequestTriggeredWithinTimeframe(timeframe *config2.Duration) *time.Time {
if timeframe == nil {
return nil
}
var foundAt *time.Time
lastSeenTimestamp := time.Now().UTC().Add(-timeframe.Duration())
sourceCCIP.CCIPSendRequestedWatcher.Range(func(key, value any) bool {
if sendRequestedEvents, exists := value.([]*evm_2_evm_onramp.EVM2EVMOnRampCCIPSendRequested); exists {
for _, sendRequestedEvent := range sendRequestedEvents {
raw := sendRequestedEvent.Raw
hdr, err := sourceCCIP.Common.ChainClient.HeaderByNumber(context.Background(), big.NewInt(int64(raw.BlockNumber)))
if err == nil {
if hdr.Timestamp.After(lastSeenTimestamp) {
foundAt = pointer.ToTime(hdr.Timestamp)
return false
}
}
}
}
return true
})
return foundAt
}

func (sourceCCIP *SourceCCIPModule) AssertEventCCIPSendRequested(
lggr zerolog.Logger,
txHash string,
Expand Down
41 changes: 29 additions & 12 deletions integration-tests/ccip-tests/load/ccip_loadgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/rs/zerolog"
chain_selectors "github.com/smartcontractkit/chain-selectors"
"github.com/smartcontractkit/chainlink-common/pkg/config"
"github.com/smartcontractkit/wasp"
"github.com/stretchr/testify/require"
"go.uber.org/atomic"
Expand All @@ -38,19 +39,27 @@ type CCIPLaneOptimized struct {
}

type CCIPE2ELoad struct {
t *testing.T
Lane *CCIPLaneOptimized
NoOfReq int64 // approx no of Request fired
CurrentMsgSerialNo *atomic.Int64 // current msg serial number in the load sequence
CallTimeOut time.Duration // max time to wait for various on-chain events
msg router.ClientEVM2AnyMessage
MaxDataBytes uint32
SendMaxDataIntermittentlyInMsgCount int64
LastFinalizedTxBlock atomic.Uint64
LastFinalizedTimestamp atomic.Time
t *testing.T
Lane *CCIPLaneOptimized
NoOfReq int64 // approx no of Request fired
CurrentMsgSerialNo *atomic.Int64 // current msg serial number in the load sequence
CallTimeOut time.Duration // max time to wait for various on-chain events
msg router.ClientEVM2AnyMessage
MaxDataBytes uint32
SendMaxDataIntermittentlyInMsgCount int64
SkipRequestIfAnotherRequestTriggeredWithin *config.Duration
LastFinalizedTxBlock atomic.Uint64
LastFinalizedTimestamp atomic.Time
}

func NewCCIPLoad(t *testing.T, lane *actions.CCIPLane, timeout time.Duration, noOfReq int64, sendMaxDataIntermittentlyInEveryMsgCount int64) *CCIPE2ELoad {
func NewCCIPLoad(
t *testing.T,
lane *actions.CCIPLane,
timeout time.Duration,
noOfReq int64,
sendMaxDataIntermittentlyInEveryMsgCount int64,
SkipRequestIfAnotherRequestTriggeredWithin *config.Duration,
) *CCIPE2ELoad {
// to avoid holding extra data
loadLane := &CCIPLaneOptimized{
Logger: lane.Logger,
Expand All @@ -68,6 +77,7 @@ func NewCCIPLoad(t *testing.T, lane *actions.CCIPLane, timeout time.Duration, no
CallTimeOut: timeout,
NoOfReq: noOfReq,
SendMaxDataIntermittentlyInMsgCount: sendMaxDataIntermittentlyInEveryMsgCount,
SkipRequestIfAnotherRequestTriggeredWithin: SkipRequestIfAnotherRequestTriggeredWithin,
}
}

Expand Down Expand Up @@ -175,7 +185,14 @@ func (c *CCIPE2ELoad) CCIPMsg() (router.ClientEVM2AnyMessage, *testreporters.Req
func (c *CCIPE2ELoad) Call(_ *wasp.Generator) *wasp.Response {
res := &wasp.Response{}
sourceCCIP := c.Lane.Source

recentRequestFoundAt := sourceCCIP.IsRequestTriggeredWithinTimeframe(c.SkipRequestIfAnotherRequestTriggeredWithin)
if recentRequestFoundAt != nil {
c.Lane.Logger.
Info().
Str("Found At=", recentRequestFoundAt.String()).
Msgf("Skipping ...Another Request found within given timeframe %s", c.SkipRequestIfAnotherRequestTriggeredWithin.String())
return res
}
msg, stats := c.CCIPMsg()
msgSerialNo := stats.ReqNo
lggr := c.Lane.Logger.With().Int64("msg Number", stats.ReqNo).Logger()
Expand Down
6 changes: 5 additions & 1 deletion integration-tests/ccip-tests/load/ccip_multicall_loadgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,11 @@ func NewMultiCallLoadGenerator(testCfg *testsetups.CCIPTestConfig, lanes []*acti
for _, lane := range lanes {
// for multicall load generator, we don't want to send max data intermittently, it might
// cause oversized data for multicall
ccipLoad := NewCCIPLoad(testCfg.Test, lane, testCfg.TestGroupInput.PhaseTimeout.Duration(), 100000, 0)
ccipLoad := NewCCIPLoad(
testCfg.Test, lane, testCfg.TestGroupInput.PhaseTimeout.Duration(),
100000, 0,
testCfg.TestGroupInput.SkipRequestIfAnotherRequestTriggeredWithin,
)
ccipLoad.BeforeAllCall(testCfg.TestGroupInput.MsgType, big.NewInt(*testCfg.TestGroupInput.DestGasLimit))
m.E2ELoads[fmt.Sprintf("%s-%s", lane.SourceNetworkName, lane.DestNetworkName)] = ccipLoad
}
Expand Down
6 changes: 5 additions & 1 deletion integration-tests/ccip-tests/load/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,11 @@ func (l *LoadArgs) TriggerLoadByLane() {
Str("Destination Network", lane.DestNetworkName).
Msg("Starting load for lane")
sendMaxData := pointer.GetInt64(l.TestCfg.TestGroupInput.SendMaxDataInEveryMsgCount)
ccipLoad := NewCCIPLoad(l.TestCfg.Test, lane, l.TestCfg.TestGroupInput.PhaseTimeout.Duration(), 100000, sendMaxData)
ccipLoad := NewCCIPLoad(
l.TestCfg.Test, lane, l.TestCfg.TestGroupInput.PhaseTimeout.Duration(),
100000, sendMaxData,
l.TestCfg.TestGroupInput.SkipRequestIfAnotherRequestTriggeredWithin,
)
ccipLoad.BeforeAllCall(l.TestCfg.TestGroupInput.MsgType, big.NewInt(*l.TestCfg.TestGroupInput.DestGasLimit))
lokiConfig := l.TestCfg.EnvInput.Logging.Loki
labels := make(map[string]string)
Expand Down
79 changes: 40 additions & 39 deletions integration-tests/ccip-tests/testconfig/ccip.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,45 +18,46 @@ import (
)

type CCIPTestConfig struct {
KeepEnvAlive *bool `toml:",omitempty"`
BiDirectionalLane *bool `toml:",omitempty"`
CommitAndExecuteOnSameDON *bool `toml:",omitempty"`
NoOfCommitNodes int `toml:",omitempty"`
MsgType string `toml:",omitempty"`
DestGasLimit *int64 `toml:",omitempty"`
MulticallInOneTx *bool `toml:",omitempty"`
NoOfSendsInMulticall int `toml:",omitempty"`
PhaseTimeout *config.Duration `toml:",omitempty"`
TestDuration *config.Duration `toml:",omitempty"`
LocalCluster *bool `toml:",omitempty"`
ExistingDeployment *bool `toml:",omitempty"`
TestRunName string `toml:",omitempty"`
ReuseContracts *bool `toml:",omitempty"`
NodeFunding float64 `toml:",omitempty"`
RequestPerUnitTime []int64 `toml:",omitempty"`
TimeUnit *config.Duration `toml:",omitempty"`
StepDuration []*config.Duration `toml:",omitempty"`
WaitBetweenChaosDuringLoad *config.Duration `toml:",omitempty"`
NetworkPairs []string `toml:",omitempty"`
NoOfNetworks int `toml:",omitempty"`
NoOfRoutersPerPair int `toml:",omitempty"`
Blockscout bool `toml:",omitempty"`
NoOfTokensPerChain int `toml:",omitempty"`
NoOfTokensInMsg int `toml:",omitempty"`
AmountPerToken int64 `toml:",omitempty"`
MaxNoOfLanes int `toml:",omitempty"`
ChaosDuration *config.Duration `toml:",omitempty"`
NoOfUSDCMockTokens *int `toml:",omitempty"`
TimeoutForPriceUpdate *config.Duration `toml:",omitempty"`
WithPipeline *bool `toml:",omitempty"`
FailOnFirstErrorInLoad *bool `toml:",omitempty"`
DynamicPriceUpdateInterval *config.Duration `toml:",omitempty"`
SendMaxDataInEveryMsgCount *int64 `toml:",omitempty"`
CommitOCRParams *contracts.OffChainAggregatorV2Config `toml:",omitempty"`
ExecOCRParams *contracts.OffChainAggregatorV2Config `toml:",omitempty"`
CommitInflightExpiry *config.Duration `toml:",omitempty"`
ExecInflightExpiry *config.Duration `toml:",omitempty"`
OptimizeSpace *bool `toml:",omitempty"`
KeepEnvAlive *bool `toml:",omitempty"`
BiDirectionalLane *bool `toml:",omitempty"`
CommitAndExecuteOnSameDON *bool `toml:",omitempty"`
NoOfCommitNodes int `toml:",omitempty"`
MsgType string `toml:",omitempty"`
DestGasLimit *int64 `toml:",omitempty"`
MulticallInOneTx *bool `toml:",omitempty"`
NoOfSendsInMulticall int `toml:",omitempty"`
PhaseTimeout *config.Duration `toml:",omitempty"`
TestDuration *config.Duration `toml:",omitempty"`
LocalCluster *bool `toml:",omitempty"`
ExistingDeployment *bool `toml:",omitempty"`
TestRunName string `toml:",omitempty"`
ReuseContracts *bool `toml:",omitempty"`
NodeFunding float64 `toml:",omitempty"`
RequestPerUnitTime []int64 `toml:",omitempty"`
TimeUnit *config.Duration `toml:",omitempty"`
StepDuration []*config.Duration `toml:",omitempty"`
WaitBetweenChaosDuringLoad *config.Duration `toml:",omitempty"`
NetworkPairs []string `toml:",omitempty"`
NoOfNetworks int `toml:",omitempty"`
NoOfRoutersPerPair int `toml:",omitempty"`
Blockscout bool `toml:",omitempty"`
NoOfTokensPerChain int `toml:",omitempty"`
NoOfTokensInMsg int `toml:",omitempty"`
AmountPerToken int64 `toml:",omitempty"`
MaxNoOfLanes int `toml:",omitempty"`
ChaosDuration *config.Duration `toml:",omitempty"`
NoOfUSDCMockTokens *int `toml:",omitempty"`
TimeoutForPriceUpdate *config.Duration `toml:",omitempty"`
WithPipeline *bool `toml:",omitempty"`
FailOnFirstErrorInLoad *bool `toml:",omitempty"`
DynamicPriceUpdateInterval *config.Duration `toml:",omitempty"`
SendMaxDataInEveryMsgCount *int64 `toml:",omitempty"`
CommitOCRParams *contracts.OffChainAggregatorV2Config `toml:",omitempty"`
ExecOCRParams *contracts.OffChainAggregatorV2Config `toml:",omitempty"`
CommitInflightExpiry *config.Duration `toml:",omitempty"`
ExecInflightExpiry *config.Duration `toml:",omitempty"`
OptimizeSpace *bool `toml:",omitempty"`
SkipRequestIfAnotherRequestTriggeredWithin *config.Duration `toml:",omitempty"`
}

func (c *CCIPTestConfig) SetTestRunName(name string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -691,12 +691,13 @@ PhaseTimeout = '20m'
TestDuration = '5h'
ExistingDeployment = true
RequestPerUnitTime = [1]
TimeUnit = '2h'
TimeUnit = '1h'
NoOfTokensPerChain = 1
NoOfTokensInMsg = 1
AmountPerToken = 1
TestRunName = 'mainnet-2.7-ccip1.2'
FailOnFirstErrorInLoad = true
SkipRequestIfAnotherRequestTriggeredWithin = '40m'

[CCIP.Groups.smoke]
MsgType = 'WithoutToken'
Expand Down

0 comments on commit 878ab58

Please sign in to comment.