Skip to content

Commit

Permalink
test changes
Browse files Browse the repository at this point in the history
  • Loading branch information
0xAustinWang committed Jan 13, 2025
1 parent d57b108 commit 1ea5e2f
Show file tree
Hide file tree
Showing 9 changed files with 169 additions and 144 deletions.
95 changes: 0 additions & 95 deletions ccip/config/evm/fallback.toml

This file was deleted.

6 changes: 4 additions & 2 deletions deployment/ccip/changeset/cs_ccip_home.go
Original file line number Diff line number Diff line change
Expand Up @@ -1024,8 +1024,10 @@ func (c UpdateChainConfigConfig) Validate(e deployment.Environment) error {
if !exists {
return fmt.Errorf("home chain %d does not exist", c.HomeChainSelector)
}
if err := commoncs.ValidateOwnership(e.GetContext(), c.MCMS != nil, e.Chains[c.HomeChainSelector].DeployerKey.From, homeChainState.Timelock.Address(), homeChainState.CCIPHome); err != nil {
return err
if c.MCMS != nil {
if err := commoncs.ValidateOwnership(e.GetContext(), c.MCMS != nil, e.Chains[c.HomeChainSelector].DeployerKey.From, homeChainState.Timelock.Address(), homeChainState.CCIPHome); err != nil {
return err
}
}
for _, remove := range c.RemoteChainRemoves {
if err := deployment.IsValidChainSelector(remove); err != nil {
Expand Down
45 changes: 23 additions & 22 deletions deployment/environment/crib/ccip_deployer.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,19 +152,18 @@ func DeployCCIPAndAddLanes(ctx context.Context, lggr logger.Logger, envConfig de
return DeployCCIPOutput{}, fmt.Errorf("failed to load onchain state: %w", err)
}
// Add all lanes
for from := range e.Chains {
for to := range e.Chains {
if from != to {
stateChain1 := state.Chains[from]
for src := range e.Chains {
for dst := range e.Chains {
if src != dst {
stateChain1 := state.Chains[src]
newEnv, err := commonchangeset.ApplyChangesets(nil, *e, nil, []commonchangeset.ChangesetApplication{
{
Changeset: commonchangeset.WrapChangeSet(changeset.UpdateOnRampsDests),
Config: changeset.UpdateOnRampDestsConfig{
UpdatesByChain: map[uint64]map[uint64]changeset.OnRampDestinationUpdate{
from: {
to: {
src: {
dst: {
IsEnabled: true,
TestRouter: false,
AllowListEnabled: false,
},
},
Expand All @@ -175,13 +174,13 @@ func DeployCCIPAndAddLanes(ctx context.Context, lggr logger.Logger, envConfig de
Changeset: commonchangeset.WrapChangeSet(changeset.UpdateFeeQuoterPricesCS),
Config: changeset.UpdateFeeQuoterPricesConfig{
PricesByChain: map[uint64]changeset.FeeQuoterPriceUpdatePerSource{
from: {
src: {
TokenPrices: map[common.Address]*big.Int{
stateChain1.LinkToken.Address(): changeset.DefaultLinkPrice,
stateChain1.Weth9.Address(): changeset.DefaultWethPrice,
},
GasPrices: map[uint64]*big.Int{
to: changeset.DefaultGasPrice,
dst: changeset.DefaultGasPrice,
},
},
},
Expand All @@ -191,8 +190,8 @@ func DeployCCIPAndAddLanes(ctx context.Context, lggr logger.Logger, envConfig de
Changeset: commonchangeset.WrapChangeSet(changeset.UpdateFeeQuoterDests),
Config: changeset.UpdateFeeQuoterDestsConfig{
UpdatesByChain: map[uint64]map[uint64]fee_quoter.FeeQuoterDestChainConfig{
from: {
to: changeset.DefaultFeeQuoterDestChainConfig(),
src: {
dst: changeset.DefaultFeeQuoterDestChainConfig(),
},
},
},
Expand All @@ -201,10 +200,9 @@ func DeployCCIPAndAddLanes(ctx context.Context, lggr logger.Logger, envConfig de
Changeset: commonchangeset.WrapChangeSet(changeset.UpdateOffRampSources),
Config: changeset.UpdateOffRampSourcesConfig{
UpdatesByChain: map[uint64]map[uint64]changeset.OffRampSourceUpdate{
to: {
from: {
IsEnabled: true,
TestRouter: false,
dst: {
src: {
IsEnabled: true,
},
},
},
Expand All @@ -213,18 +211,21 @@ func DeployCCIPAndAddLanes(ctx context.Context, lggr logger.Logger, envConfig de
{
Changeset: commonchangeset.WrapChangeSet(changeset.UpdateRouterRamps),
Config: changeset.UpdateRouterRampsConfig{
TestRouter: false,
UpdatesByChain: map[uint64]changeset.RouterUpdates{
// onRamp update on source chain
from: {
src: {
OffRampUpdates: map[uint64]bool{
dst: true,
},
OnRampUpdates: map[uint64]bool{
to: true,
dst: true,
},
},
// off
from: {
dst: {
OffRampUpdates: map[uint64]bool{
to: true,
src: true,
},
OnRampUpdates: map[uint64]bool{
src: true,
},
},
},
Expand Down
11 changes: 8 additions & 3 deletions deployment/environment/devenv/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,18 @@ const (
EVMChainType = "EVM"
)

type CribRPCs struct {
Internal string
External string
}

// ChainConfig holds the configuration for a with a deployer key which can be used to send transactions to the chain.
type ChainConfig struct {
ChainID uint64 // chain id as per EIP-155, mainly applicable for EVM chains
ChainName string // name of the chain populated from chainselector repo
ChainType string // should denote the chain family. Acceptable values are EVM, COSMOS, SOLANA, STARKNET, APTOS etc
WSRPCs []string // websocket rpcs to connect to the chain
HTTPRPCs []string // http rpcs to connect to the chain
WSRPCs []CribRPCs // websocket rpcs to connect to the chain
HTTPRPCs []CribRPCs // http rpcs to connect to the chain
DeployerKey *bind.TransactOpts // key to deploy and configure contracts on the chain
Users []*bind.TransactOpts // map of addresses to their transact opts to interact with the chain as users
}
Expand Down Expand Up @@ -97,7 +102,7 @@ func NewChains(logger logger.Logger, configs []ChainConfig) (map[uint64]deployme
// TODO : better client handling
var ec *ethclient.Client
for _, rpc := range chainCfg.WSRPCs {
ec, err = ethclient.Dial(rpc)
ec, err = ethclient.Dial(rpc.External)
if err != nil {
logger.Warnf("failed to dial ws rpc %s", rpc)
continue
Expand Down
47 changes: 40 additions & 7 deletions integration-tests/load/ccip/ccip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,17 @@ func TestCCIPLoad_RPS(t *testing.T) {
config, err := tc.GetConfig([]string{"Load"}, tc.CCIP)
require.NoError(t, err)
lggr.Infof("loaded ccip test config: %+v", config.CCIP.Load)
userOverrides := config.CCIP.Load

timeout, err := time.ParseDuration(*userOverrides.TestTimeout)
if err != nil {
require.NoError(t, err)
}
t.Cleanup(func() {
time.AfterFunc(timeout, func() {
t.Fatalf("Test passed timeout after %v", timeout)
})
})

cribEnv := crib.NewDevspaceEnvFromStateDir(CRIB_DIRECTORY)

Expand All @@ -61,7 +72,7 @@ func TestCCIPLoad_RPS(t *testing.T) {
require.NoError(t, err)

// Parse all events from the simulated chains, send to Loki
loki, err := wasp.NewLokiClient(wasp.NewLokiConfig(config.CCIP.Load.LokiEndpoint, nil, nil, nil))
loki, err := wasp.NewLokiClient(wasp.NewLokiConfig(userOverrides.LokiEndpoint, nil, nil, nil))
require.NoError(t, err)
defer loki.StopNow()

Expand All @@ -75,8 +86,16 @@ func TestCCIPLoad_RPS(t *testing.T) {
block := latesthdr.Number.Uint64()
startBlocks[selector] = &block

gunMap[selector] = NewDestinationGun(env.Logger, selector, *env, state.Chains[selector].Receiver.Address(), loki)

// Only create a destination gun if we have decided to send traffic to this chain
for _, cs := range *userOverrides.EnabledDestionationChains {
if cs == selector {
gunMap[selector], err = NewDestinationGun(env.Logger, selector, *env, state.Chains[selector].Receiver.Address(), userOverrides, loki)
if err != nil {
lggr.Errorw("Failed to initialize DestinationGun for", "chainSelector", chain, "error", err)
t.Fatal(err)
}
}
}
}

for _, gun := range gunMap {
Expand All @@ -85,7 +104,7 @@ func TestCCIPLoad_RPS(t *testing.T) {
GenName: "ccipLoad",
LoadType: wasp.RPS,
CallTimeout: 5 * time.Second,
Schedule: wasp.Plain(1, 5*time.Second),
Schedule: wasp.Plain(1, time.Duration(*userOverrides.SecondsPerRequestPerDestination)*time.Second),
// will need to be divided by number of chains
// this schedule is per generator
// in this example, it would be 1 request per 10seconds per generator (dest chain)
Expand All @@ -97,20 +116,34 @@ func TestCCIPLoad_RPS(t *testing.T) {
}))
}

_, err = p.Run(true)
// find get fee revert
csPair := ChainSelectorPair{
src: 12922642891491394802,
dst: 3379446385462418246,
}
res, err := state.Chains[csPair.src].Router.IsChainSupported(nil, csPair.dst)
lggr.Infow("IsChainSupported", "res", res, "err", err)

destChainConfig, err := state.Chains[csPair.src].FeeQuoter.GetDestChainConfig(nil, csPair.dst)
lggr.Infow("GetDestChainConfig", "destChainConfig", destChainConfig, "err", err)

// find the getFee revert
_, err = p.Run(true)
//csPair := ChainSelectorPair{
// src: 12922642891491394802,
// dst: 3379446385462418246,
//}
src, dst := env.Chains[csPair.src], env.Chains[csPair.dst]
startblk := uint64(11654)

seqNum := gunMap[csPair.dst].seqNums[csPair].End.Load()
_, err = ccipchangeset.ConfirmCommitWithExpectedSeqNumRange(t, src, dst, state.Chains[3379446385462418246].OffRamp, &startblk, cciptypes.SeqNumRange{
cciptypes.SeqNum(seqNum),
cciptypes.SeqNum(seqNum),
cciptypes.SeqNum(seqNum - 1),
cciptypes.SeqNum(seqNum - 1),
}, false)

// todo: create channels that watch for these events beforehand using WatchExecutionStateChanged and WatchCommitReportAccepted
// rather than waiting for the generator to finish
lokiLabels := map[string]string{}
for chainSelector, startBlock := range startBlocks {
wg.Add(1)
Expand Down
Loading

0 comments on commit 1ea5e2f

Please sign in to comment.