diff --git a/deployment/environment/crib/env.go b/deployment/environment/crib/env.go index 3af1acaf754..281565480df 100644 --- a/deployment/environment/crib/env.go +++ b/deployment/environment/crib/env.go @@ -1,5 +1,7 @@ package crib +import "fmt" + const ( AddressBookFileName = "ccip-v2-scripts-address-book.json" NodesDetailsFileName = "ccip-v2-scripts-nodes-details.json" @@ -16,15 +18,27 @@ func NewDevspaceEnvFromStateDir(envStateDir string) CRIBEnv { } } -func (c CRIBEnv) GetConfig() DeployOutput { +func (c CRIBEnv) GetConfig(deployerKeys map[uint64]string) (DeployOutput, error) { reader := NewOutputReader(c.envStateDir) nodesDetails := reader.ReadNodesDetails() chainConfigs := reader.ReadChainConfigs() + for i, chain := range chainConfigs { + key, ok := deployerKeys[chain.ChainID] + if !ok { + return DeployOutput{}, fmt.Errorf("could not find deployer key for %s", key) + } + err := chain.SetDeployerKey(&key) + if err != nil { + return DeployOutput{}, err + } + chainConfigs[i] = chain + } + return DeployOutput{ AddressBook: reader.ReadAddressBook(), NodeIDs: nodesDetails.NodeIDs, Chains: chainConfigs, - } + }, nil } type RPC struct { diff --git a/deployment/environment/devenv/chain.go b/deployment/environment/devenv/chain.go index 5c6c4336ed7..a5c706ecd3c 100644 --- a/deployment/environment/devenv/chain.go +++ b/deployment/environment/devenv/chain.go @@ -67,7 +67,6 @@ func (c *ChainConfig) SetDeployerKey(pvtKeyStr *string) error { if err != nil { return fmt.Errorf("failed to create transactor: %w", err) } - fmt.Printf("Deployer Address: %s for chain id %d\n", deployer.From.Hex(), c.ChainID) c.DeployerKey = deployer return nil } diff --git a/integration-tests/load/ccip/ccip_test.go b/integration-tests/load/ccip/ccip_test.go index cdc98dc133a..8f5233fcfda 100644 --- a/integration-tests/load/ccip/ccip_test.go +++ b/integration-tests/load/ccip/ccip_test.go @@ -21,7 +21,11 @@ var ( "branch": "ccip_load_crib", "commit": "ccip_load_crib", } - wg sync.WaitGroup + wg sync.WaitGroup + SIM_CHAIN_PRIVATE_KEYS = map[uint64]string{ + 1337: "ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80", + 2337: "59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d", + } ) const CRIB_DIRECTORY = "/Users/austin.wang/ccip-core/repos/crib/deployments/ccip-v2/.tmp" @@ -44,7 +48,8 @@ func TestCCIPLoad_RPS(t *testing.T) { cribEnv := crib.NewDevspaceEnvFromStateDir(CRIB_DIRECTORY) - cribDeployOutput := cribEnv.GetConfig() + cribDeployOutput, err := cribEnv.GetConfig(SIM_CHAIN_PRIVATE_KEYS) + require.NoError(t, err) env, err := crib.NewDeployEnvironmentFromCribOutput(lggr, cribDeployOutput) require.NoError(t, err) require.NotNil(t, env) @@ -71,8 +76,8 @@ func TestCCIPLoad_RPS(t *testing.T) { T: t, GenName: "ccipLoad", LoadType: wasp.RPS, - CallTimeout: 20 * time.Second, - Schedule: wasp.Plain(1, 20*time.Second), + CallTimeout: 5 * time.Second, + Schedule: wasp.Plain(1, 5*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) @@ -91,6 +96,8 @@ func TestCCIPLoad_RPS(t *testing.T) { wg.Add(1) go func(chainSelector uint64, startBlock *uint64) { defer wg.Done() + lggr.Infow("Starting to query for events on ", "chainSelector", chainSelector, "startblock", startBlock) + filterOpts := &bind.FilterOpts{ Start: *startBlock, End: nil, // To the latest block @@ -102,6 +109,8 @@ func TestCCIPLoad_RPS(t *testing.T) { commitIterator, err := offRamp.FilterCommitReportAccepted(filterOpts) require.NoError(t, err) + fmt.Printf("Events on commitIterator %+v", commitIterator) + for commitIterator.Next() { event := commitIterator.Event fmt.Printf("CommitReportAccepted event: %+v\n", event) @@ -112,7 +121,8 @@ func TestCCIPLoad_RPS(t *testing.T) { timestamp := time.Unix(int64(header.Time), 0) for _, root := range event.MerkleRoots { - lokiLabels = setLokiLabels(root.SourceChainSelector, chainSelector) + lokiLabels, err = setLokiLabels(root.SourceChainSelector, chainSelector) + require.NoError(t, err) for i := root.MinSeqNr; i <= root.MaxSeqNr; i++ { // todo: push loki calls to channel? @@ -138,7 +148,8 @@ func TestCCIPLoad_RPS(t *testing.T) { timestamp := time.Unix(int64(header.Time), 0) // todo: push loki calls to channel? - lokiLabels = setLokiLabels(execIterator.Event.SourceChainSelector, chainSelector) + lokiLabels, err = setLokiLabels(execIterator.Event.SourceChainSelector, chainSelector) + require.NoError(t, err) SendMetricsToLoki(lggr, loki, lokiLabels, &LokiMetric{ EventType: executed, Timestamp: timestamp, diff --git a/integration-tests/load/ccip/destination_gun.go b/integration-tests/load/ccip/destination_gun.go index acc33b93bdc..c517cdd0ca2 100644 --- a/integration-tests/load/ccip/destination_gun.go +++ b/integration-tests/load/ccip/destination_gun.go @@ -81,23 +81,29 @@ func (m *DestinationGun) Call(_ *wasp.Generator) *wasp.Response { } fee, err := r.GetFee( - &bind.CallOpts{Context: context.Background()}, src, msg) + &bind.CallOpts{Context: context.Background()}, m.chainSelector, msg) if err != nil { + m.l.Errorw("could not get fee ", "dstChainSelector", m.chainSelector, "msg", msg, "fee", fee) return &wasp.Response{Error: err.Error(), Group: waspGroup, Failed: true} } + m.l.Debugw("setting fee for ", "srcChain", src, "dstChain", m.chainSelector, "fee", fee, "msg", msg) if msg.FeeToken == common.HexToAddress("0x0") { m.env.Chains[src].DeployerKey.Value = fee defer func() { m.env.Chains[src].DeployerKey.Value = nil }() } - _, err = r.CcipSend( + tx, err := r.CcipSend( m.env.Chains[src].DeployerKey, m.chainSelector, msg) if err != nil { + m.l.Errorw("execution reverted from ", "sourceChain", src, "destchain", m.chainSelector, "err", err, "tx", tx) return &wasp.Response{Error: err.Error(), Group: waspGroup, Failed: true} } - lokiLabels := setLokiLabels(src, m.chainSelector) + lokiLabels, err := setLokiLabels(src, m.chainSelector) + if err != nil { + m.l.Errorw("Failed setting loki labels", "error", err) + } SendMetricsToLoki(m.l, m.loki, lokiLabels, &LokiMetric{ EventType: transmitted, Timestamp: time.Now(), diff --git a/integration-tests/load/ccip/helpers.go b/integration-tests/load/ccip/helpers.go index 0df27431963..faeede61e7a 100644 --- a/integration-tests/load/ccip/helpers.go +++ b/integration-tests/load/ccip/helpers.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + chainselectors "github.com/smartcontractkit/chain-selectors" "github.com/smartcontractkit/chainlink-common/pkg/logger" "github.com/smartcontractkit/chainlink-testing-framework/wasp" "github.com/smartcontractkit/chainlink/deployment" @@ -41,13 +42,21 @@ func SendMetricsToLoki(l logger.Logger, lc *wasp.LokiClient, updatedLabels map[s } } -func setLokiLabels(src, dst uint64) map[string]string { +func setLokiLabels(src, dst uint64) (map[string]string, error) { + srcChainId, err := chainselectors.GetChainIDFromSelector(src) + if err != nil { + return nil, err + } + dstChainId, err := chainselectors.GetChainIDFromSelector(dst) + if err != nil { + return nil, err + } return map[string]string{ - "sourceEvmChainId": fmt.Sprintf("%d", src), - "destEvmChainId": fmt.Sprintf("%d", src), + "sourceEvmChainId": fmt.Sprintf("%s", srcChainId), + "destEvmChainId": fmt.Sprintf("%s", dstChainId), "destinationSelector": fmt.Sprintf("%d", dst), "testType": LokiLoadLabel, - } + }, nil } func readFile(filePath string) []byte {