diff --git a/.golangci.yml b/.golangci.yml index bb5384922ab..5e6a3decd0a 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -229,6 +229,13 @@ linters: - gosec path: test text: "^G404:" + # AddressBook on ChangesetOutput/Environment is deprecated in favor of + # DataStore, but the migration is still pending. Suppress centrally instead + # of scattering inline //nolint:staticcheck directives across every changeset + # return site. Mirrors deployment/.golangci.yml. + - linters: + - staticcheck + text: "SA1019: (.*).AddressBook is deprecated" paths: - "core/scripts/cre/environment/examples/workflows" issues: diff --git a/core/scripts/cre/environment/configs/workflow-gateway-failover-don.toml b/core/scripts/cre/environment/configs/workflow-gateway-failover-don.toml index 8b9f9c5b2d2..3b12b52eea2 100644 --- a/core/scripts/cre/environment/configs/workflow-gateway-failover-don.toml +++ b/core/scripts/cre/environment/configs/workflow-gateway-failover-don.toml @@ -30,8 +30,8 @@ [[nodesets]] nodes = 4 - name = "shard0" - don_families = ["test-don-family"] + name = "workflow-1-zone-a" + don_families = ["zone-a", "zone-a_shard-0"] don_types = ["workflow", "shard"] shard_index = 0 override_mode = "each" @@ -83,8 +83,8 @@ [[nodesets]] nodes = 4 - name = "shard1" - don_families = ["test-don-family"] + name = "workflow-1-zone-a-shard-1" + don_families = ["zone-a", "zone-a_shard-1"] don_types = ["workflow", "shard"] shard_index = 1 override_mode = "all" @@ -109,7 +109,7 @@ [[nodesets]] nodes = 1 name = "bootstrap-gateway" - don_families = ["test-don-family"] + don_families = ["zone-a"] don_types = ["bootstrap", "gateway"] override_mode = "each" http_port_range_start = 11300 diff --git a/core/scripts/cre/environment/configs/workflow-gateway-sharded-5-dons.toml b/core/scripts/cre/environment/configs/workflow-gateway-sharded-5-dons.toml index ac4effd8997..3833a8586bc 100644 --- a/core/scripts/cre/environment/configs/workflow-gateway-sharded-5-dons.toml +++ b/core/scripts/cre/environment/configs/workflow-gateway-sharded-5-dons.toml @@ -40,8 +40,8 @@ [[nodesets]] nodes = 4 - name = "shard0" - don_families = ["test-don-family"] + name = "workflow-1-zone-a" + don_families = ["zone-a", "zone-a_shard-0"] don_types = ["workflow", "shard"] override_mode = "each" http_port_range_start = 10000 @@ -96,8 +96,8 @@ [[nodesets]] nodes = 4 - name = "shard1" - don_families = ["test-don-family"] + name = "workflow-1-zone-a-shard-1" + don_families = ["zone-a", "zone-a_shard-1"] don_types = ["workflow", "shard"] shard_index = 1 override_mode = "all" @@ -125,8 +125,8 @@ [[nodesets]] nodes = 4 - name = "shard2" - don_families = ["test-don-family"] + name = "workflow-1-zone-a-shard-2" + don_families = ["zone-a", "zone-a_shard-2"] don_types = ["workflow", "shard"] shard_index = 2 override_mode = "all" @@ -154,8 +154,8 @@ [[nodesets]] nodes = 4 - name = "shard3" - don_families = ["test-don-family"] + name = "workflow-1-zone-a-shard-3" + don_families = ["zone-a", "zone-a_shard-3"] don_types = ["workflow", "shard"] shard_index = 3 override_mode = "all" @@ -183,8 +183,8 @@ [[nodesets]] nodes = 4 - name = "shard4" - don_families = ["test-don-family"] + name = "workflow-1-zone-a-shard-4" + don_families = ["zone-a", "zone-a_shard-4"] don_types = ["workflow", "shard"] shard_index = 4 override_mode = "all" @@ -212,8 +212,8 @@ [[nodesets]] nodes = 4 - name = "shard5" - don_families = ["test-don-family"] + name = "workflow-1-zone-a-shard-5" + don_families = ["zone-a", "zone-a_shard-5"] don_types = ["workflow", "shard"] shard_index = 5 override_mode = "all" @@ -242,7 +242,7 @@ [[nodesets]] nodes = 1 name = "bootstrap-gateway" - don_families = ["test-don-family"] + don_families = ["zone-a"] don_types = ["bootstrap", "gateway"] override_mode = "each" http_port_range_start = 10300 diff --git a/core/scripts/cre/environment/configs/workflow-gateway-sharded-don.toml b/core/scripts/cre/environment/configs/workflow-gateway-sharded-don.toml index d73891c8e31..827b0261f9c 100644 --- a/core/scripts/cre/environment/configs/workflow-gateway-sharded-don.toml +++ b/core/scripts/cre/environment/configs/workflow-gateway-sharded-don.toml @@ -37,8 +37,8 @@ [[nodesets]] nodes = 4 - name = "shard0" - don_families = ["test-don-family"] + name = "workflow-1-zone-a" + don_families = ["zone-a", "zone-a_shard-0"] don_types = ["workflow", "shard"] shard_index = 0 override_mode = "each" @@ -97,8 +97,8 @@ [[nodesets]] nodes = 4 - name = "shard1" - don_families = ["test-don-family"] + name = "workflow-1-zone-a-shard-1" + don_families = ["zone-a", "zone-a_shard-1"] don_types = ["workflow", "shard"] shard_index = 1 override_mode = "all" @@ -127,7 +127,7 @@ [[nodesets]] nodes = 1 name = "bootstrap-gateway" - don_families = ["test-don-family"] + don_families = ["zone-a"] don_types = ["bootstrap", "gateway"] override_mode = "each" http_port_range_start = 10300 diff --git a/core/scripts/cre/environment/configs/workflow-gateway-sharded-manual.toml b/core/scripts/cre/environment/configs/workflow-gateway-sharded-manual.toml index df551033b90..5b6bb1392d0 100644 --- a/core/scripts/cre/environment/configs/workflow-gateway-sharded-manual.toml +++ b/core/scripts/cre/environment/configs/workflow-gateway-sharded-manual.toml @@ -30,8 +30,8 @@ [[nodesets]] nodes = 4 - name = "shard0" - don_families = ["test-don-family"] + name = "workflow-1-zone-a" + don_families = ["zone-a", "zone-a_shard-0"] don_types = ["workflow", "shard"] shard_index = 0 override_mode = "each" @@ -83,8 +83,8 @@ [[nodesets]] nodes = 4 - name = "shard1" - don_families = ["test-don-family"] + name = "workflow-1-zone-a-shard-1" + don_families = ["zone-a", "zone-a_shard-1"] don_types = ["workflow", "shard"] shard_index = 1 override_mode = "all" @@ -109,7 +109,7 @@ [[nodesets]] nodes = 1 name = "bootstrap-gateway" - don_families = ["test-don-family"] + don_families = ["zone-a"] don_types = ["bootstrap", "gateway"] override_mode = "each" http_port_range_start = 10300 diff --git a/core/scripts/cre/environment/configs/workflow-gateway-sharded-ringocr-overrides.toml b/core/scripts/cre/environment/configs/workflow-gateway-sharded-ringocr-overrides.toml index d43f1e765cf..d47dd7999be 100644 --- a/core/scripts/cre/environment/configs/workflow-gateway-sharded-ringocr-overrides.toml +++ b/core/scripts/cre/environment/configs/workflow-gateway-sharded-ringocr-overrides.toml @@ -30,8 +30,8 @@ [[nodesets]] nodes = 4 - name = "shard0" - don_families = ["test-don-family"] + name = "workflow-1-zone-a" + don_families = ["zone-a", "zone-a_shard-0"] don_types = ["workflow", "shard"] shard_index = 0 override_mode = "each" @@ -83,8 +83,8 @@ [[nodesets]] nodes = 4 - name = "shard1" - don_families = ["test-don-family"] + name = "workflow-1-zone-a-shard-1" + don_families = ["zone-a", "zone-a_shard-1"] don_types = ["workflow", "shard"] shard_index = 1 override_mode = "all" @@ -109,7 +109,7 @@ [[nodesets]] nodes = 1 name = "bootstrap-gateway" - don_families = ["test-don-family"] + don_families = ["zone-a"] don_types = ["bootstrap", "gateway"] override_mode = "each" http_port_range_start = 10300 diff --git a/core/scripts/cre/environment/configs/workflow-sharded-capabilities-don.toml b/core/scripts/cre/environment/configs/workflow-sharded-capabilities-don.toml index 5f7a340d742..4881e6b8c12 100644 --- a/core/scripts/cre/environment/configs/workflow-sharded-capabilities-don.toml +++ b/core/scripts/cre/environment/configs/workflow-sharded-capabilities-don.toml @@ -1,24 +1,24 @@ # Sharded capability routing via DON families. # # The same capability (evm-1337) is hosted on multiple capability DON shards. Each workflow -# shard is routed to exactly one capability shard by sharing a per-shard DON family, while a -# common family ("zone-a") keeps every workflow shard connected to the gateway and to shared -# (non-sharded) capability DONs. +# shard is routed to exactly one capability shard by sharing a per-shard DON family. +# Shared (non-sharded) capability DONs belong to all shard families. # # The workflow shards deliberately host no EVM capability of their own: if they did, the # launcher would serve evm-1337 locally and family routing would never be exercised. # # Family layout (see don_families): -# workflow-shard-0 : don_families=["zone-a", "zone-a_shard-0"] -# workflow-shard-1 : don_families=["zone-a", "zone-a_shard-1"] -# cap-shard-0 : don_families=["zone-a_shard-0"] -# cap-shard-1 : don_families=["zone-a_shard-1"] -# shared-cap : don_families=["zone-a"] (hosts vault; reachable by all shards) -# bootstrap-gateway: don_families=["zone-a"] +# workflow-1-zone-a : don_families=["zone-a", "zone-a_shard-0"] +# workflow-1-zone-a-shard-1 : don_families=["zone-a", "zone-a_shard-1"] +# chain-capabilities-zone-a-shard-0 : don_families=["zone-a_shard-0"] +# chain-capabilities-zone-a-shard-1 : don_families=["zone-a_shard-1"] +# chain-capabilities-zone-a : don_families=["zone-a_shard-0", "zone-a_shard-1"] (hosts vault; reachable by all shards) +# bootstrap-gateway : don_families=["zone-a"] (don2don is not needed here but test framework uses it to associate gateways with workflow DONs) # -# The launcher's family-overlap filter therefore routes workflow-shard-0 -> cap-shard-0 and -# workflow-shard-1 -> cap-shard-1 for evm-1337, while both shards reach shared-cap via "zone-a". -# Gateway pairing uses the primary (first) don_families entry ("zone-a") only. +# The launcher's family-overlap filter therefore routes workflow-1-zone-a -> chain-capabilities-zone-a-shard-0 +# and workflow-1-zone-a-shard-1 -> chain-capabilities-zone-a-shard-1 for evm-1337, while both shards reach +# chain-capabilities-zone-a. +# Gateway and bootstrap don't need don2don communication - they are both reached via public URLs. [chip_router] image = "local-cre-chip-router:v1.0.1" @@ -52,7 +52,7 @@ # --- Workflow shard 0 ------------------------------------------------------- [[nodesets]] nodes = 4 - name = "workflow-shard-0" + name = "workflow-1-zone-a" don_families = ["zone-a", "zone-a_shard-0"] don_types = ["workflow", "shard"] shard_index = 0 @@ -107,7 +107,7 @@ # --- Workflow shard 1 ------------------------------------------------------- [[nodesets]] nodes = 4 - name = "workflow-shard-1" + name = "workflow-1-zone-a-shard-1" don_families = ["zone-a", "zone-a_shard-1"] don_types = ["workflow", "shard"] shard_index = 1 @@ -134,7 +134,7 @@ # --- Capability shard 0 (hosts the sharded capability) ---------------------- [[nodesets]] nodes = 4 - name = "cap-shard-0" + name = "chain-capabilities-zone-a-shard-0" don_families = ["zone-a_shard-0"] don_types = ["capabilities"] exposes_remote_capabilities = true @@ -160,7 +160,7 @@ # --- Capability shard 1 (hosts the same sharded capability) ----------------- [[nodesets]] nodes = 4 - name = "cap-shard-1" + name = "chain-capabilities-zone-a-shard-1" don_families = ["zone-a_shard-1"] don_types = ["capabilities"] exposes_remote_capabilities = true @@ -186,8 +186,8 @@ # --- Shared (non-sharded) capability DON, reachable by every workflow shard -- [[nodesets]] nodes = 4 - name = "shared-cap" - don_families = ["zone-a"] + name = "chain-capabilities-zone-a" + don_families = ["zone-a_shard-0", "zone-a_shard-1"] don_types = ["capabilities"] exposes_remote_capabilities = true override_mode = "all" diff --git a/core/services/cre/cre.go b/core/services/cre/cre.go index bae52a64320..1e9b2046986 100644 --- a/core/services/cre/cre.go +++ b/core/services/cre/cre.go @@ -270,7 +270,7 @@ func (s *Services) newSubservices( return srvs, nil } - registrySyncerServices, donNotifier, err := s.newRegistrySyncer( + registrySyncerServices, donNotifier, shardIndexMapper, err := s.newRegistrySyncer( lggr, cfg, relayerChainInterops, @@ -321,6 +321,7 @@ func (s *Services) newSubservices( s.GatewayConnectorWrapper, meterIdentity, dispatcherWrapper.dispatcher, + shardIndexMapper, ) if err != nil { return nil, err @@ -406,6 +407,7 @@ func newRegistrySyncerV2( ds sqlutil.DataSource, ocrConfigService capregconfig.OCRConfigService, wfLauncher registrysyncerV2.Listener, + shardIndexMapper registrysyncerV2.Listener, ) ([]commonsrv.Service, error) { registrySyncer, err := registrysyncerV2.New( lggr, @@ -418,7 +420,7 @@ func newRegistrySyncerV2( return nil, fmt.Errorf("could not configure syncer: %w", err) } - return wireRegistrySyncerV2(registrySyncer, ocrConfigService, ocrConfigService, wfLauncher), nil + return wireRegistrySyncerV2(registrySyncer, ocrConfigService, ocrConfigService, wfLauncher, shardIndexMapper), nil } func wireRegistrySyncerV2( @@ -426,10 +428,11 @@ func wireRegistrySyncerV2( ocrConfigService commonsrv.Service, ocrConfigListener registrysyncerV2.Listener, wfLauncher registrysyncerV2.Listener, + shardIndexMapper registrysyncerV2.Listener, ) []commonsrv.Service { // The OCR config service must be started and receive each registry snapshot // before capabilities using its dynamic config trackers are launched. - registrySyncer.AddListener(ocrConfigListener, wfLauncher) + registrySyncer.AddListener(ocrConfigListener, wfLauncher, shardIndexMapper) return []commonsrv.Service{ocrConfigService, registrySyncer} } @@ -441,7 +444,7 @@ func (s *Services) newRegistrySyncer( ds sqlutil.DataSource, opts Opts, dispatcherWrapper *dispatcherWrapper, -) ([]commonsrv.Service, capabilities.DonNotifyWaitSubscriber, error) { +) ([]commonsrv.Service, capabilities.DonNotifyWaitSubscriber, *shardownership.ShardIndexMapper, error) { var srvcs []commonsrv.Service capCfg := cfg.Capabilities() @@ -450,7 +453,7 @@ func (s *Services) newRegistrySyncer( registryAddress := capCfg.ExternalRegistry().Address() relayer, err := relayerChainInterops.Get(rid) if err != nil { - return nil, nil, fmt.Errorf("could not fetch relayer %s configured for capabilities registry: %w", rid, err) + return nil, nil, nil, fmt.Errorf("could not fetch relayer %s configured for capabilities registry: %w", rid, err) } var streamConfig config.StreamConfig @@ -462,16 +465,20 @@ func (s *Services) newRegistrySyncer( ocrConfigService, ocrErr := newOCRConfigService(lggr, rid, registryAddress, dispatcherWrapper) if ocrErr != nil { - return nil, nil, ocrErr + return nil, nil, nil, ocrErr } s.OCRConfigService = ocrConfigService + // Tracks workflow DONs from registry updates so shard indices used for + // failover ownership decisions can be remapped to their current DON IDs. + shardIndexMapper := shardownership.NewShardIndexMapper(lggr) + externalRegistryVersion, err := semver.NewVersion(capCfg.ExternalRegistry().ContractVersion()) if err != nil { - return nil, nil, err + return nil, nil, nil, err } if externalRegistryVersion.Major() != 2 { - return nil, nil, fmt.Errorf("unsupported external registry version: %s", externalRegistryVersion.String()) + return nil, nil, nil, fmt.Errorf("unsupported external registry version: %s", externalRegistryVersion.String()) } var ( @@ -497,7 +504,7 @@ func (s *Services) newRegistrySyncer( shardIndex, ) if err != nil { - return nil, nil, fmt.Errorf("could not create workflow launcher: %w", err) + return nil, nil, nil, fmt.Errorf("could not create workflow launcher: %w", err) } srvcs = append(srvcs, wfLauncher) @@ -546,12 +553,13 @@ func (s *Services) newRegistrySyncer( ds, ocrConfigService, wfLauncher, + shardIndexMapper, ) if err != nil { - return nil, nil, err + return nil, nil, nil, err } srvcs = append(srvcs, srvs...) - return srvcs, donNotifier, nil + return srvcs, donNotifier, shardIndexMapper, nil } func newOCRConfigService( @@ -861,6 +869,7 @@ func newWorkflowRegistrySyncerV2( gatewayConnectorWrapper *gatewayconnector.ServiceWrapper, meterIdentity resourcemanager.ResourceIdentity, dispatcher remotetypes.Dispatcher, + shardIndexMapper *shardownership.ShardIndexMapper, ) (syncerV2.WorkflowRegistrySyncer, []commonsrv.Service, error) { capCfg := cfg.Capabilities() wfReg := capCfg.WorkflowRegistry() @@ -940,11 +949,11 @@ func newWorkflowRegistrySyncerV2( var shardResolver shardownership.ShardResolver switch assignmentMode { case toml.ShardAssignmentModeManualOnly: - shardResolver = shardownership.NewManualShardResolver(opts.ShardAssignmentSettings, orgResolver, lggr) + shardResolver = shardownership.NewManualShardResolver(opts.ShardAssignmentSettings, orgResolver, shardIndexMapper, lggr) lggr.Infow("Using manual-only shard assignment mode") case toml.ShardAssignmentModeRingOCROverrides: ringOCR := shardownership.NewRingOCRShardResolver(shardOrchestratorClient, lggr) - shardResolver = shardownership.NewOverrideShardResolver(opts.ShardAssignmentSettings, orgResolver, ringOCR, lggr) + shardResolver = shardownership.NewOverrideShardResolver(opts.ShardAssignmentSettings, orgResolver, shardIndexMapper, ringOCR, lggr) lggr.Infow("Using ringocr-with-overrides shard assignment mode") default: shardResolver = shardownership.NewRingOCRShardResolver(shardOrchestratorClient, lggr) @@ -963,6 +972,7 @@ func newWorkflowRegistrySyncerV2( syncerV2.WithShardExecutionGuard(shardOrchestratorClient, shardingEnabled), syncerV2.WithShardRoutingSteady(shardRoutingSteady), syncerV2.WithShardResolver(shardResolver), + syncerV2.WithShardIndex(uint32(cfg.Sharding().ShardIndex())), } if shardingEnabled && dispatcher != nil { handlerOpts = append(handlerOpts, @@ -1140,6 +1150,7 @@ func newWorkflowRegistrySyncer( gatewayConnectorWrapper *gatewayconnector.ServiceWrapper, meterIdentity resourcemanager.ResourceIdentity, dispatcher remotetypes.Dispatcher, + shardIndexMapper *shardownership.ShardIndexMapper, ) (syncerV2.WorkflowRegistrySyncer, metering.BillingClient, []commonsrv.Service, error) { capCfg := cfg.Capabilities() @@ -1175,6 +1186,7 @@ func newWorkflowRegistrySyncer( gatewayConnectorWrapper, meterIdentity, dispatcher, + shardIndexMapper, ) return syncer, billingClient, srvcs, err } diff --git a/core/services/cre/cre_test.go b/core/services/cre/cre_test.go index 150d1e3d00e..3a73897b39e 100644 --- a/core/services/cre/cre_test.go +++ b/core/services/cre/cre_test.go @@ -118,10 +118,11 @@ func TestWireRegistrySyncerV2(t *testing.T) { ocrConfigService := registrysyncerV2Mocks.NewRegistrySyncer(t) ocrConfigListener := ®istryListenerStub{name: "OCR config service"} wfLauncher := ®istryListenerStub{name: "workflow launcher"} + shardIndexMapper := ®istryListenerStub{name: "shard index mapper"} - registrySyncer.EXPECT().AddListener(ocrConfigListener, wfLauncher) + registrySyncer.EXPECT().AddListener(ocrConfigListener, wfLauncher, shardIndexMapper) - services := wireRegistrySyncerV2(registrySyncer, ocrConfigService, ocrConfigListener, wfLauncher) + services := wireRegistrySyncerV2(registrySyncer, ocrConfigService, ocrConfigListener, wfLauncher, shardIndexMapper) require.Len(t, services, 2) require.Same(t, ocrConfigService, services[0]) require.Same(t, registrySyncer, services[1]) diff --git a/core/services/workflows/shardownership/check.go b/core/services/workflows/shardownership/check.go index 0b7d717fac5..ad74a41078a 100644 --- a/core/services/workflows/shardownership/check.go +++ b/core/services/workflows/shardownership/check.go @@ -20,11 +20,11 @@ func CheckCommittedOwner(ctx context.Context, client shardorchestrator.ClientInt if err != nil { return DenyOrchestratorError, nil, err } - shard, ok := resp.Mappings[workflowID] + donID, ok := resp.Mappings[workflowID] if !ok { return DenyNotOwner, resp, nil } - if shard != myDonID { + if donID != myDonID { return DenyNotOwner, resp, nil } return Allow, resp, nil diff --git a/core/services/workflows/shardownership/resolver.go b/core/services/workflows/shardownership/resolver.go index 1ac94ed9b83..36e5afea274 100644 --- a/core/services/workflows/shardownership/resolver.go +++ b/core/services/workflows/shardownership/resolver.go @@ -6,6 +6,7 @@ import ( "fmt" "maps" "strings" + "time" "github.com/smartcontractkit/chainlink-common/pkg/logger" "github.com/smartcontractkit/chainlink-common/pkg/loop" @@ -70,13 +71,14 @@ func (r *ringOCRShardResolver) GetRoutingResponse(ctx context.Context, workflowI } type manualShardResolver struct { - settings *loop.AtomicSettings - orgResolver OrgResolver - lggr logger.Logger + settings *loop.AtomicSettings + orgResolver OrgResolver + shardIndexMapper *ShardIndexMapper + lggr logger.Logger } -func NewManualShardResolver(settings *loop.AtomicSettings, orgResolver OrgResolver, lggr logger.Logger) ShardResolver { - return &manualShardResolver{settings: settings, orgResolver: orgResolver, lggr: logger.Named(lggr, "ManualShardResolver")} +func NewManualShardResolver(settings *loop.AtomicSettings, orgResolver OrgResolver, shardIndexMapper *ShardIndexMapper, lggr logger.Logger) ShardResolver { + return &manualShardResolver{settings: settings, orgResolver: orgResolver, shardIndexMapper: shardIndexMapper, lggr: logger.Named(lggr, "ManualShardResolver")} } func (m *manualShardResolver) ResolveShard(ctx context.Context, _ string, ownerHex string) (uint32, bool, error) { @@ -84,7 +86,11 @@ func (m *manualShardResolver) ResolveShard(ctx context.Context, _ string, ownerH if err != nil || cfg == nil { return 0, false, err } - return resolveManual(ctx, cfg, ownerHex, m.orgResolver) + shardIndex, found, err := resolveManual(ctx, cfg, ownerHex, m.orgResolver) + if err != nil || !found { + return 0, found, err + } + return m.toDonID(ctx, shardIndex), true, nil } func (m *manualShardResolver) ResolveAllShards(ctx context.Context, _ string, ownerHex string) ([]uint32, bool, error) { @@ -92,7 +98,11 @@ func (m *manualShardResolver) ResolveAllShards(ctx context.Context, _ string, ow if err != nil || cfg == nil { return nil, false, err } - return resolveAllManual(ctx, cfg, ownerHex, m.orgResolver) + shardIndices, found, err := resolveAllManual(ctx, cfg, ownerHex, m.orgResolver) + if err != nil || !found { + return nil, found, err + } + return m.toDonIDs(ctx, shardIndices), true, nil } func (m *manualShardResolver) ResolveShards(ctx context.Context, workflowIDs []string, ownerHexes []string) (map[string]uint32, error) { @@ -108,17 +118,48 @@ func (m *manualShardResolver) ResolveShards(ctx context.Context, workflowIDs []s if i >= len(ownerHexes) { break } - donID, found, err := resolveManual(ctx, cfg, ownerHexes[i], m.orgResolver) + shardIndex, found, err := resolveManual(ctx, cfg, ownerHexes[i], m.orgResolver) if err != nil { return nil, err } if found { - result[wfID] = donID + result[wfID] = m.toDonID(ctx, shardIndex) } } return result, nil } +// toDonID translates a configured shard index into the DON ID currently +// assigned that index. Falls back to returning shardIndex unchanged when no +// donIndex is wired, or the index is out of range for the current registry +// snapshot. +func (m *manualShardResolver) toDonID(ctx context.Context, shardIndex uint32) uint32 { + if m.shardIndexMapper == nil { + return shardIndex + } + // Prevent a boot-time race where a workflow is launched before + // the registry syncer has delivered its first snapshot. + // NOTE: consider waiting indefinitely or put a global lock earlier + waitCtx, cancel := context.WithTimeout(ctx, 30*time.Second) + defer cancel() + if err := m.shardIndexMapper.WaitReady(waitCtx); err != nil { + m.lggr.Warnw("shard DON index not ready, resolving with a possibly incomplete registry view", "shardIndex", shardIndex, "err", err) + } + don := m.shardIndexMapper.DonByShardIndex(ctx, shardIndex) + if don == nil { + return shardIndex + } + return don.ID +} + +func (m *manualShardResolver) toDonIDs(ctx context.Context, shardIndices []uint32) []uint32 { + donIDs := make([]uint32, len(shardIndices)) + for i, idx := range shardIndices { + donIDs[i] = m.toDonID(ctx, idx) + } + return donIDs +} + func loadShardAssignmentConfig(settings *loop.AtomicSettings) (*cresettings.ShardAssignmentConfig, error) { if settings == nil { return nil, nil @@ -199,9 +240,9 @@ type overrideShardResolver struct { lggr logger.Logger } -func NewOverrideShardResolver(settings *loop.AtomicSettings, orgResolver OrgResolver, ringOCR ShardResolver, lggr logger.Logger) ShardResolver { +func NewOverrideShardResolver(settings *loop.AtomicSettings, orgResolver OrgResolver, shardIndexMapper *ShardIndexMapper, ringOCR ShardResolver, lggr logger.Logger) ShardResolver { return &overrideShardResolver{ - manual: &manualShardResolver{settings: settings, orgResolver: orgResolver, lggr: logger.Named(lggr, "ManualShardResolver")}, + manual: &manualShardResolver{settings: settings, orgResolver: orgResolver, shardIndexMapper: shardIndexMapper, lggr: logger.Named(lggr, "ManualShardResolver")}, orgResolver: orgResolver, ringOCR: ringOCR, lggr: logger.Named(lggr, "OverrideShardResolver"), @@ -214,12 +255,12 @@ func (o *overrideShardResolver) ResolveShard(ctx context.Context, workflowID str return 0, false, err } if cfg != nil { - donID, found, err := resolveManual(ctx, cfg, ownerHex, o.orgResolver) + shardIndex, found, err := resolveManual(ctx, cfg, ownerHex, o.orgResolver) if err != nil { return 0, false, err } if found { - return donID, true, nil + return o.manual.toDonID(ctx, shardIndex), true, nil } } return o.ringOCR.ResolveShard(ctx, workflowID, ownerHex) @@ -231,12 +272,12 @@ func (o *overrideShardResolver) ResolveAllShards(ctx context.Context, workflowID return nil, false, cfgErr } if cfg != nil { - shards, found, resolveErr := resolveAllManual(ctx, cfg, ownerHex, o.orgResolver) + shardIndices, found, resolveErr := resolveAllManual(ctx, cfg, ownerHex, o.orgResolver) if resolveErr != nil { return nil, false, resolveErr } if found { - return shards, true, nil + return o.manual.toDonIDs(ctx, shardIndices), true, nil } } shardID, found, err := o.ringOCR.ResolveShard(ctx, workflowID, ownerHex) @@ -262,12 +303,12 @@ func (o *overrideShardResolver) ResolveShards(ctx context.Context, workflowIDs [ if i >= len(ownerHexes) { break } - donID, found, err := resolveManual(ctx, cfg, ownerHexes[i], o.orgResolver) + shardIndex, found, err := resolveManual(ctx, cfg, ownerHexes[i], o.orgResolver) if err != nil { return nil, err } if found { - result[wfID] = donID + result[wfID] = o.manual.toDonID(ctx, shardIndex) } else { ringWorkflowIDs = append(ringWorkflowIDs, wfID) } diff --git a/core/services/workflows/shardownership/resolver_test.go b/core/services/workflows/shardownership/resolver_test.go index c0ba5124cb1..883124f5131 100644 --- a/core/services/workflows/shardownership/resolver_test.go +++ b/core/services/workflows/shardownership/resolver_test.go @@ -4,10 +4,13 @@ import ( "context" "fmt" "testing" + "time" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + ragetypes "github.com/smartcontractkit/libocr/ragep2p/types" + "github.com/smartcontractkit/chainlink-common/pkg/logger" "github.com/smartcontractkit/chainlink-common/pkg/loop" "github.com/smartcontractkit/chainlink-common/pkg/types/core" @@ -31,7 +34,7 @@ static_default_assignment = [0] "0x70997970c51812dc3a010c7d01b50e0d17dc79c8" = [0, 2] `) - r := NewManualShardResolver(settings, nil, nopLogger) + r := NewManualShardResolver(settings, nil, nil, nopLogger) donID, found, err := r.ResolveShard(context.Background(), "wf-1", "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266") require.NoError(t, err) @@ -51,7 +54,7 @@ func TestManualShardResolver_StaticDefaultFallback(t *testing.T) { static_default_assignment = [0] `) - r := NewManualShardResolver(settings, nil, nopLogger) + r := NewManualShardResolver(settings, nil, nil, nopLogger) donID, found, err := r.ResolveShard(context.Background(), "wf-1", "0x0000000000000000000000000000000000000001") require.NoError(t, err) @@ -66,7 +69,7 @@ func TestManualShardResolver_HashedOwnerDelegatesToRingOCR(t *testing.T) { hashed_owner_assignment = ["0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266"] `) - r := NewManualShardResolver(settings, nil, nopLogger) + r := NewManualShardResolver(settings, nil, nil, nopLogger) donID, found, err := r.ResolveShard(context.Background(), "wf-1", "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266") require.NoError(t, err) @@ -82,7 +85,7 @@ hashed_default_assignment = true static_default_assignment = [0] `) - r := NewManualShardResolver(settings, nil, nopLogger) + r := NewManualShardResolver(settings, nil, nil, nopLogger) _, found, err := r.ResolveShard(context.Background(), "wf-1", "0x0000000000000000000000000000000000000001") require.NoError(t, err) @@ -92,7 +95,7 @@ static_default_assignment = [0] func TestManualShardResolver_NilConfig(t *testing.T) { t.Parallel() settings := &loop.AtomicSettings{} - r := NewManualShardResolver(settings, nil, nopLogger) + r := NewManualShardResolver(settings, nil, nil, nopLogger) donID, found, err := r.ResolveShard(context.Background(), "wf-1", "0x0000000000000000000000000000000000000001") require.NoError(t, err) @@ -110,7 +113,7 @@ static_default_assignment = [0] "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266" = [1] `) - r := NewManualShardResolver(settings, nil, nopLogger) + r := NewManualShardResolver(settings, nil, nil, nopLogger) wfIDs := []string{"wf-1", "wf-2"} owners := []string{"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266", "0x0000000000000000000000000000000000000001"} @@ -120,6 +123,66 @@ static_default_assignment = [0] assert.Equal(t, uint32(0), result["wf-2"]) } +// TestManualShardResolver_TranslatesShardIndexToDonID proves manualShardResolver +// returns a real DON ID (not the raw configured shard index), by translating +// through a ShardIndexMapper — the value ResolveShard callers compare against +// MyDONID must be in the same units ringOCRShardResolver already returns. +func TestManualShardResolver_TranslatesShardIndexToDonID(t *testing.T) { + t.Parallel() + settings := &loop.AtomicSettings{} + storeShardAssignment(t, settings, ` +static_default_assignment = [1] +`) + + me := makePeerID(1) + donIndex := NewShardIndexMapper(nopLogger) + require.NoError(t, donIndex.OnNewRegistry(t.Context(), newTestRegistry(t, me, + testDON{id: 10, name: "workflow-1-zone-a", families: []string{"zone-a_shard-0", "zone-a"}, acceptsWorkflows: true, members: []ragetypes.PeerID{me}}, + testDON{id: 20, name: "workflow-1-zone-a-shard-1", families: []string{"zone-a_shard-1", "zone-a"}, acceptsWorkflows: true}, + ))) + + r := NewManualShardResolver(settings, nil, donIndex, nopLogger) + + donID, found, err := r.ResolveShard(context.Background(), "wf-1", "0x0000000000000000000000000000000000000001") + require.NoError(t, err) + assert.True(t, found) + assert.Equal(t, uint32(20), donID, "shard index 1 must resolve to the second DON by ID, not pass through as-is") +} + +// TestManualShardResolver_WaitsForDonIndexReady proves ResolveShard blocks +// (briefly) for the DON index's first registry snapshot instead of racing +// ahead and resolving the configured shard index as if it were already a +// DON ID. Without this wait, every node would spuriously deny ownership +// during the boot window before the registry syncer's first update lands. +func TestManualShardResolver_WaitsForDonIndexReady(t *testing.T) { + t.Parallel() + settings := &loop.AtomicSettings{} + storeShardAssignment(t, settings, ` +static_default_assignment = [1] +`) + + me := makePeerID(1) + donIndex := NewShardIndexMapper(nopLogger) + r := NewManualShardResolver(settings, nil, donIndex, nopLogger) + + go func() { + time.Sleep(50 * time.Millisecond) + _ = donIndex.OnNewRegistry(context.Background(), newTestRegistry(t, me, + testDON{id: 10, name: "workflow-1-zone-a", families: []string{"zone-a_shard-0", "zone-a"}, acceptsWorkflows: true, members: []ragetypes.PeerID{me}}, + testDON{id: 20, name: "workflow-1-zone-a-shard-1", families: []string{"zone-a_shard-1", "zone-a"}, acceptsWorkflows: true}, + )) + }() + + start := time.Now() + donID, found, err := r.ResolveShard(context.Background(), "wf-1", "0x0000000000000000000000000000000000000001") + elapsed := time.Since(start) + + require.NoError(t, err) + assert.True(t, found) + assert.Equal(t, uint32(20), donID) + assert.Less(t, elapsed, 5*time.Second, "must unblock as soon as the registry syncs, not wait out the full bound") +} + func TestOverrideShardResolver_ManualWins(t *testing.T) { t.Parallel() settings := &loop.AtomicSettings{} @@ -131,7 +194,7 @@ static_default_assignment = [0] `) mockRing := &mockRingOCRResolver{mappings: map[string]uint32{"wf-1": 0}} - r := NewOverrideShardResolver(settings, nil, &shardResolverAdapter{inner: mockRing}, nopLogger) + r := NewOverrideShardResolver(settings, nil, nil, &shardResolverAdapter{inner: mockRing}, nopLogger) donID, found, err := r.ResolveShard(context.Background(), "wf-1", "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266") require.NoError(t, err) @@ -147,7 +210,7 @@ hashed_default_assignment = true `) mockRing := &mockRingOCRResolver{mappings: map[string]uint32{"wf-1": 1}} - r := NewOverrideShardResolver(settings, nil, &shardResolverAdapter{inner: mockRing}, nopLogger) + r := NewOverrideShardResolver(settings, nil, nil, &shardResolverAdapter{inner: mockRing}, nopLogger) donID, found, err := r.ResolveShard(context.Background(), "wf-1", "0x0000000000000000000000000000000000000001") require.NoError(t, err) @@ -167,7 +230,7 @@ hashed_default_assignment = true `) mockRing := &mockRingOCRResolver{mappings: map[string]uint32{"wf-2": 0}} - r := NewOverrideShardResolver(settings, nil, &shardResolverAdapter{inner: mockRing}, nopLogger) + r := NewOverrideShardResolver(settings, nil, nil, &shardResolverAdapter{inner: mockRing}, nopLogger) wfIDs := []string{"wf-1", "wf-2"} owners := []string{"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266", "0x0000000000000000000000000000000000000001"} @@ -192,7 +255,7 @@ static_default_assignment = [0] "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266": "org_abc123", "0x70997970c51812dc3a010c7d01b50e0d17dc79c8": "org_def456", }} - r := NewManualShardResolver(settings, orgR, nopLogger) + r := NewManualShardResolver(settings, orgR, nil, nopLogger) donID, found, err := r.ResolveShard(context.Background(), "wf-1", "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266") require.NoError(t, err) @@ -221,7 +284,7 @@ static_default_assignment = [0] orgR := &mockOrgResolver{mappings: map[string]string{ "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266": "org_abc123", }} - r := NewManualShardResolver(settings, orgR, nopLogger) + r := NewManualShardResolver(settings, orgR, nil, nopLogger) donID, found, err := r.ResolveShard(context.Background(), "wf-1", "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266") require.NoError(t, err) @@ -242,7 +305,7 @@ static_default_assignment = [0] orgR := &mockOrgResolver{mappings: map[string]string{ "0x0000000000000000000000000000000000000001": "org_unknown", }} - r := NewManualShardResolver(settings, orgR, nopLogger) + r := NewManualShardResolver(settings, orgR, nil, nopLogger) donID, found, err := r.ResolveShard(context.Background(), "wf-1", "0x0000000000000000000000000000000000000001") require.NoError(t, err) @@ -260,7 +323,7 @@ static_default_assignment = [0] org_abc123 = [2] `) - r := NewManualShardResolver(settings, nil, nopLogger) + r := NewManualShardResolver(settings, nil, nil, nopLogger) donID, found, err := r.ResolveShard(context.Background(), "wf-1", "0x0000000000000000000000000000000000000001") require.NoError(t, err) @@ -284,7 +347,7 @@ hashed_default_assignment = true "0x0000000000000000000000000000000000000001": "org_def456", }} mockRing := &mockRingOCRResolver{mappings: map[string]uint32{"wf-2": 0}} - r := NewOverrideShardResolver(settings, orgR, &shardResolverAdapter{inner: mockRing}, nopLogger) + r := NewOverrideShardResolver(settings, orgR, nil, &shardResolverAdapter{inner: mockRing}, nopLogger) donID, found, err := r.ResolveShard(context.Background(), "wf-1", "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266") require.NoError(t, err) diff --git a/core/services/workflows/shardownership/shard_index_mapper.go b/core/services/workflows/shardownership/shard_index_mapper.go new file mode 100644 index 00000000000..ea66dfb8d49 --- /dev/null +++ b/core/services/workflows/shardownership/shard_index_mapper.go @@ -0,0 +1,175 @@ +package shardownership + +import ( + "context" + "errors" + "fmt" + "slices" + "strings" + "sync" + + commoncap "github.com/smartcontractkit/chainlink-common/pkg/capabilities" + "github.com/smartcontractkit/chainlink-common/pkg/capabilities/registry" + "github.com/smartcontractkit/chainlink-common/pkg/logger" +) + +// shardNameMarker is the marker a workflow DON's name is suffixed with to +// encode its shard index (e.g. "workflow-1-zone-a-shard-1" -> shard 1). A +// name with no such suffix (e.g. "workflow-1-zone-a") is shard index 0. +const shardNameMarker = "shard-" + +// ShardIndexMapper tracks the workflow DONs currently known to the Capabilities +// Registry and detects their shard indices (0, 1, 2, ...). +// It's a global singleton object used by ManualShardResolver and, in consequence, +// every per-workflow instance of ShardFailoverManager. +// It implements registrysyncer/v2.Listener and refreshes on every registry +// update. +type ShardIndexMapper struct { + lggr logger.Logger + + mu sync.RWMutex + byIndex []commoncap.DON + + readyOnce sync.Once + ready chan struct{} +} + +func NewShardIndexMapper(lggr logger.Logger) *ShardIndexMapper { + return &ShardIndexMapper{lggr: logger.Named(lggr, "ShardIndexMapper"), ready: make(chan struct{})} +} + +// OnNewRegistry implements registrysyncer/v2.Listener. It determines this +// node's shard-group name prefix (its own DON name with any "shard-X" suffix +// stripped), then indexes every other workflow DON that shares at least one +// family with its own workflow DON and shares that name prefix, by the shard +// index encoded in its name. +func (s *ShardIndexMapper) OnNewRegistry(ctx context.Context, reg *registry.RegistryMetadata) error { + localNode, err := reg.LocalNode(ctx) + if err != nil { + return fmt.Errorf("failed to resolve local node: %w", err) + } + if localNode.WorkflowDON.ID == 0 { + return errors.New("local node does not belong to a workflow DON") + } + + namePrefix := shardGroupNamePrefix(localNode.WorkflowDON.Name) + + byIndex, err := shardDONsByIndex(reg, localNode.WorkflowDON, namePrefix) + if err != nil { + return err + } + + s.mu.Lock() + s.byIndex = byIndex + s.mu.Unlock() + s.readyOnce.Do(func() { close(s.ready) }) + + s.lggr.Debugw("refreshed shard DON index", "namePrefix", namePrefix, "workflowDONs", len(byIndex)) + return nil +} + +// sharesFamily reports whether a and b have at least one family in common. +func sharesFamily(a, b []string) bool { + for _, family := range a { + if slices.Contains(b, family) { + return true + } + } + return false +} + +// shardDONsByIndex finds every workflow DON in the registry that shares at +// least one family with localDON (the local node's own shard group) and +// shares namePrefix (the local node's own DON name with any shard suffix +// stripped), and returns them indexed by the shard index encoded in their +// name (see shardIndexFromName). +func shardDONsByIndex(reg *registry.RegistryMetadata, localDON commoncap.DON, namePrefix string) ([]commoncap.DON, error) { + byIndex := make(map[uint32]commoncap.DON) + maxIndex := uint32(0) + for _, don := range reg.IDsToDONs { + if !don.AcceptsWorkflows || !sharesFamily(don.Families, localDON.Families) || shardGroupNamePrefix(don.Name) != namePrefix { + continue + } + idx, err := shardIndexFromName(don.Name) + if err != nil { + return nil, fmt.Errorf("DON %q: %w", don.Name, err) + } + if existing, ok := byIndex[idx]; ok { + return nil, fmt.Errorf("name prefix %q has two DONs at shard index %d: %q and %q", namePrefix, idx, existing.Name, don.Name) + } + byIndex[idx] = don.DON + if idx > maxIndex { + maxIndex = idx + } + } + if len(byIndex) == 0 { + return nil, fmt.Errorf("no workflow DONs found sharing a family with local DON %q and name prefix %q", localDON.Name, namePrefix) + } + + result := make([]commoncap.DON, maxIndex+1) + for idx, don := range byIndex { + result[idx] = don + } + return result, nil +} + +// shardIndexFromName parses the single-digit shard index encoded in a +// workflow DON's name (e.g. "workflow-1-zone-a-shard-1" -> 1). A name with no +// "shard-" suffix is shard index 0. +func shardIndexFromName(name string) (uint32, error) { + idx := strings.LastIndex(name, shardNameMarker) + if idx == -1 { + return 0, nil + } + suffix := name[idx+len(shardNameMarker):] + if len(suffix) != 1 || suffix[0] < '0' || suffix[0] > '9' { + return 0, fmt.Errorf("expected DON name %q to end with %q followed by a single digit, got suffix %q", name, shardNameMarker, suffix) + } + return uint32(suffix[0] - '0'), nil +} + +// shardGroupNamePrefix strips the "_shard-X" or "-shard-X" suffix (and its +// separating underscore or hyphen) from a workflow DON's name, leaving the +// base name shared by every DON in its shard group (e.g. +// "workflow-1-zone-a-shard-1" -> "workflow-1-zone-a"). A name with no such +// suffix is returned unchanged. +func shardGroupNamePrefix(name string) string { + idx := strings.LastIndex(name, shardNameMarker) + if idx == -1 { + return name + } + prefix := name[:idx] + if strings.HasSuffix(prefix, "_") || strings.HasSuffix(prefix, "-") { + prefix = prefix[:len(prefix)-1] + } + return prefix +} + +// WaitReady blocks until the first registry snapshot has been processed (so +// DonByShardIndex reflects at least one real registry view rather than the +// empty startup state), or until ctx is done, whichever comes first. +func (s *ShardIndexMapper) WaitReady(ctx context.Context) error { + select { + case <-s.ready: + return nil + case <-ctx.Done(): + return ctx.Err() + } +} + +// DonByShardIndex returns the DON assigned to shardIndex (0-based, ascending +// DON ID order among the current workflow DONs), or nil if shardIndex is out +// of range for the last registry snapshot seen, or unassigned (a gap in the +// shard indices seen). +func (s *ShardIndexMapper) DonByShardIndex(_ context.Context, shardIndex uint32) *commoncap.DON { + s.mu.RLock() + defer s.mu.RUnlock() + if int(shardIndex) >= len(s.byIndex) { + return nil + } + don := s.byIndex[shardIndex] + if don.ID == 0 { + return nil + } + return &don +} diff --git a/core/services/workflows/shardownership/shard_index_mapper_test.go b/core/services/workflows/shardownership/shard_index_mapper_test.go new file mode 100644 index 00000000000..4d22259268e --- /dev/null +++ b/core/services/workflows/shardownership/shard_index_mapper_test.go @@ -0,0 +1,314 @@ +package shardownership + +import ( + "context" + "testing" + "time" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + ragetypes "github.com/smartcontractkit/libocr/ragep2p/types" + + "github.com/smartcontractkit/chainlink-common/pkg/capabilities/registry" + "github.com/smartcontractkit/chainlink-common/pkg/logger" +) + +func makePeerID(b byte) ragetypes.PeerID { + var id ragetypes.PeerID + id[0] = b + return id +} + +// testDON describes a DON to seed into a test registry. members[0] (if set) +// is treated as "my" peer when localPeerID matches it. +type testDON struct { + id uint32 + name string + families []string + acceptsWorkflows bool + members []ragetypes.PeerID +} + +// newTestRegistry builds a minimally valid *registry.RegistryMetadata (so +// LocalNode/NodeByPeerID don't hit ensureNotEmpty or nil-Logger panics), +// with localPeerID as the local node's peer ID. +func newTestRegistry(t *testing.T, localPeerID ragetypes.PeerID, dons ...testDON) *registry.RegistryMetadata { + t.Helper() + + idsToDONs := make(map[registry.DonID]registry.DON, len(dons)) + for _, d := range dons { + idsToDONs[registry.DonID(d.id)] = registry.DON{ + ID: d.id, + Name: d.name, + Families: d.families, + AcceptsWorkflows: d.acceptsWorkflows, + Members: d.members, + } + } + + reg := registry.NewRegistryMetadata( + logger.Test(t), + func() (ragetypes.PeerID, error) { return localPeerID, nil }, + idsToDONs, + map[ragetypes.PeerID]registry.NodeInfo{localPeerID: {}}, + map[string]registry.Capability{"cron-trigger@1.0.0": {}}, + ) + return ® +} + +func TestShardIndexMapper_DonByShardIndex(t *testing.T) { + t.Parallel() + + me := makePeerID(1) + reg := newTestRegistry(t, me, + testDON{id: 10, name: "workflow-1-zone-a", families: []string{"zone-a_shard-0", "zone-a"}, acceptsWorkflows: true, members: []ragetypes.PeerID{me}}, + testDON{id: 30, name: "workflow-1-zone-a-shard-2", families: []string{"zone-a_shard-2", "zone-a"}, acceptsWorkflows: true}, + testDON{id: 20, name: "workflow-1-zone-a-shard-1", families: []string{"zone-a_shard-1", "zone-a"}, acceptsWorkflows: true}, + // Different family entirely: must be excluded even though it accepts workflows. + testDON{id: 40, name: "workflow-2-zone-b", families: []string{"zone-b_shard-0", "zone-b"}, acceptsWorkflows: true}, + // Capability-only DON in the same family: must be excluded. + testDON{id: 99, name: "chain-capabilities-zone-a", families: []string{"zone-a"}, acceptsWorkflows: false}, + ) + + idx := NewShardIndexMapper(logger.Test(t)) + require.NoError(t, idx.OnNewRegistry(t.Context(), reg)) + + assert.Equal(t, uint32(10), idx.DonByShardIndex(t.Context(), 0).ID) + assert.Equal(t, uint32(20), idx.DonByShardIndex(t.Context(), 1).ID) + assert.Equal(t, uint32(30), idx.DonByShardIndex(t.Context(), 2).ID) + assert.Nil(t, idx.DonByShardIndex(t.Context(), 3)) +} + +func TestShardIndexMapper_ExcludesSameFamilyDifferentNamePrefix(t *testing.T) { + t.Parallel() + + me := makePeerID(1) + reg := newTestRegistry(t, me, + testDON{id: 10, name: "workflow-1-zone-a", families: []string{"zone-a_shard-0", "zone-a"}, acceptsWorkflows: true, members: []ragetypes.PeerID{me}}, + testDON{id: 20, name: "workflow-1-zone-a-shard-1", families: []string{"zone-a_shard-1", "zone-a"}, acceptsWorkflows: true}, + // Same family as me, but a different name prefix: a distinct shard group that happens to share the family. Must be excluded. + testDON{id: 40, name: "workflow-2-zone-a-shard-1", families: []string{"zone-a_shard-1", "zone-a"}, acceptsWorkflows: true}, + ) + + idx := NewShardIndexMapper(logger.Test(t)) + require.NoError(t, idx.OnNewRegistry(t.Context(), reg)) + + assert.Equal(t, uint32(10), idx.DonByShardIndex(t.Context(), 0).ID) + assert.Equal(t, uint32(20), idx.DonByShardIndex(t.Context(), 1).ID) + assert.Nil(t, idx.DonByShardIndex(t.Context(), 2)) +} + +func TestShardIndexMapper_MatchesOnPartiallyOverlappingFamilies(t *testing.T) { + t.Parallel() + + me := makePeerID(1) + reg := newTestRegistry(t, me, + // Local DON and its shard peer share only "zone-a"; each also has its own + // shard-specific family that the other doesn't have. A single shared + // family is enough to match. + testDON{id: 10, name: "workflow-1-zone-a", families: []string{"zone-a_shard-0", "zone-a", "extra-family"}, acceptsWorkflows: true, members: []ragetypes.PeerID{me}}, + testDON{id: 20, name: "workflow-1-zone-a-shard-1", families: []string{"zone-a_shard-1", "zone-a"}, acceptsWorkflows: true}, + ) + + idx := NewShardIndexMapper(logger.Test(t)) + require.NoError(t, idx.OnNewRegistry(t.Context(), reg)) + + assert.Equal(t, uint32(10), idx.DonByShardIndex(t.Context(), 0).ID) + assert.Equal(t, uint32(20), idx.DonByShardIndex(t.Context(), 1).ID) +} + +func TestShardIndexMapper_ExcludesSameNamePrefixNoSharedFamily(t *testing.T) { + t.Parallel() + + me := makePeerID(1) + reg := newTestRegistry(t, me, + testDON{id: 10, name: "workflow-1-zone-a", families: []string{"zone-a_shard-0", "zone-a"}, acceptsWorkflows: true, members: []ragetypes.PeerID{me}}, + // Same name prefix, but no family in common with the local DON: must be excluded. + testDON{id: 20, name: "workflow-1-zone-a-shard-1", families: []string{"zone-b"}, acceptsWorkflows: true}, + ) + + idx := NewShardIndexMapper(logger.Test(t)) + require.NoError(t, idx.OnNewRegistry(t.Context(), reg)) + + assert.Equal(t, uint32(10), idx.DonByShardIndex(t.Context(), 0).ID) + assert.Nil(t, idx.DonByShardIndex(t.Context(), 1)) +} + +func TestShardIndexMapper_NoShardSuffixMeansIndexZero(t *testing.T) { + t.Parallel() + + me := makePeerID(1) + reg := newTestRegistry(t, me, + testDON{id: 10, name: "workflow-1-zone-a", families: []string{"zone-a_shard-0", "zone-a"}, acceptsWorkflows: true, members: []ragetypes.PeerID{me}}, + ) + + idx := NewShardIndexMapper(logger.Test(t)) + require.NoError(t, idx.OnNewRegistry(t.Context(), reg)) + require.NotNil(t, idx.DonByShardIndex(t.Context(), 0)) + assert.Equal(t, uint32(10), idx.DonByShardIndex(t.Context(), 0).ID) +} + +func TestShardIndexMapper_RefreshesOnNewRegistry(t *testing.T) { + t.Parallel() + + me := makePeerID(1) + idx := NewShardIndexMapper(logger.Test(t)) + + require.NoError(t, idx.OnNewRegistry(t.Context(), newTestRegistry(t, me, + testDON{id: 5, name: "workflow-1-zone-a", families: []string{"zone-a_shard-0", "zone-a"}, acceptsWorkflows: true, members: []ragetypes.PeerID{me}}, + ))) + require.NotNil(t, idx.DonByShardIndex(t.Context(), 0)) + assert.Nil(t, idx.DonByShardIndex(t.Context(), 1)) + + // A later registry snapshot with a different shard layout replaces the stale entry. + require.NoError(t, idx.OnNewRegistry(t.Context(), newTestRegistry(t, me, + testDON{id: 7, name: "workflow-1-zone-a", families: []string{"zone-a_shard-0", "zone-a"}, acceptsWorkflows: true, members: []ragetypes.PeerID{me}}, + testDON{id: 8, name: "workflow-1-zone-a-shard-1", families: []string{"zone-a_shard-1", "zone-a"}, acceptsWorkflows: true}, + ))) + assert.Equal(t, uint32(7), idx.DonByShardIndex(t.Context(), 0).ID) + assert.Equal(t, uint32(8), idx.DonByShardIndex(t.Context(), 1).ID) +} + +func TestShardIndexMapper_ErrorsWhenLocalDonHasNoFamilies(t *testing.T) { + t.Parallel() + + me := makePeerID(1) + reg := newTestRegistry(t, me, + testDON{id: 10, name: "workflow-1-zone-a", families: nil, acceptsWorkflows: true, members: []ragetypes.PeerID{me}}, + ) + + idx := NewShardIndexMapper(logger.Test(t)) + err := idx.OnNewRegistry(t.Context(), reg) + require.Error(t, err) + assert.Contains(t, err.Error(), "no workflow DONs found") +} + +func TestShardIndexMapper_ErrorsWhenLocalNodeNotInAnyWorkflowDon(t *testing.T) { + t.Parallel() + + me := makePeerID(1) + other := makePeerID(2) + reg := newTestRegistry(t, me, + testDON{id: 10, name: "workflow-1-zone-a", families: []string{"zone-a_shard-0", "zone-a"}, acceptsWorkflows: true, members: []ragetypes.PeerID{other}}, + ) + + idx := NewShardIndexMapper(logger.Test(t)) + err := idx.OnNewRegistry(t.Context(), reg) + require.Error(t, err) + assert.Contains(t, err.Error(), "does not belong to a workflow DON") +} + +func TestShardIndexMapper_ErrorsOnMultiDigitShardSuffix(t *testing.T) { + t.Parallel() + + me := makePeerID(1) + reg := newTestRegistry(t, me, + testDON{id: 10, name: "workflow-1-zone-a", families: []string{"zone-a_shard-0", "zone-a"}, acceptsWorkflows: true, members: []ragetypes.PeerID{me}}, + testDON{id: 11, name: "workflow-1-zone-a-shard-12", families: []string{"zone-a"}, acceptsWorkflows: true}, + ) + + idx := NewShardIndexMapper(logger.Test(t)) + err := idx.OnNewRegistry(t.Context(), reg) + require.Error(t, err) + assert.Contains(t, err.Error(), "single digit") +} + +func TestShardIndexMapper_ErrorsOnDuplicateShardIndex(t *testing.T) { + t.Parallel() + + me := makePeerID(1) + reg := newTestRegistry(t, me, + testDON{id: 10, name: "workflow-1-zone-a", families: []string{"zone-a_shard-0", "zone-a"}, acceptsWorkflows: true, members: []ragetypes.PeerID{me}}, + testDON{id: 11, name: "workflow-1-zone-a", families: []string{"zone-a_shard-0", "zone-a"}, acceptsWorkflows: true}, + ) + + idx := NewShardIndexMapper(logger.Test(t)) + err := idx.OnNewRegistry(t.Context(), reg) + require.Error(t, err) + assert.Contains(t, err.Error(), "two DONs at shard index") +} + +func TestShardIndexMapper_WaitReady(t *testing.T) { + t.Parallel() + + me := makePeerID(1) + idx := NewShardIndexMapper(logger.Test(t)) + + // No registry snapshot yet: WaitReady must block until ctx is done. + ctx, cancel := context.WithTimeout(t.Context(), 20*time.Millisecond) + defer cancel() + require.ErrorIs(t, idx.WaitReady(ctx), context.DeadlineExceeded) + + // Once a snapshot arrives, WaitReady returns immediately, including for + // callers that started waiting before the snapshot was processed. + done := make(chan error, 1) + go func() { + done <- idx.WaitReady(t.Context()) + }() + + require.NoError(t, idx.OnNewRegistry(t.Context(), newTestRegistry(t, me, + testDON{id: 1, name: "workflow-1-zone-a", families: []string{"zone-a_shard-0", "zone-a"}, acceptsWorkflows: true, members: []ragetypes.PeerID{me}}, + ))) + + select { + case err := <-done: + require.NoError(t, err) + case <-time.After(2 * time.Second): + t.Fatal("WaitReady did not unblock after OnNewRegistry") + } + + require.NoError(t, idx.WaitReady(t.Context())) +} + +func TestShardIndexFromName(t *testing.T) { + t.Parallel() + + tests := []struct { + name string + donName string + wantIndex uint32 + wantErr bool + }{ + {name: "no suffix", donName: "workflow-1-zone-a", wantIndex: 0}, + {name: "shard 1", donName: "workflow-1-zone-a-shard-1", wantIndex: 1}, + {name: "shard 9", donName: "workflow-1-zone-a-shard-9", wantIndex: 9}, + {name: "multi-digit rejected", donName: "workflow-1-zone-a-shard-12", wantErr: true}, + {name: "non-digit rejected", donName: "workflow-1-zone-a-shard-x", wantErr: true}, + {name: "trailing hyphen rejected", donName: "workflow-1-zone-a-shard-", wantErr: true}, + } + for _, tc := range tests { + t.Run(tc.name, func(t *testing.T) { + t.Parallel() + got, err := shardIndexFromName(tc.donName) + if tc.wantErr { + require.Error(t, err) + return + } + require.NoError(t, err) + assert.Equal(t, tc.wantIndex, got) + }) + } +} + +func TestShardGroupNamePrefix(t *testing.T) { + t.Parallel() + + tests := []struct { + name string + donName string + wantPrefix string + }{ + {name: "no suffix", donName: "workflow-1-zone-a", wantPrefix: "workflow-1-zone-a"}, + {name: "hyphen shard 1", donName: "workflow-1-zone-a-shard-1", wantPrefix: "workflow-1-zone-a"}, + {name: "hyphen shard 9", donName: "workflow-1-zone-a-shard-9", wantPrefix: "workflow-1-zone-a"}, + {name: "underscore shard 1", donName: "workflow-1-zone-a_shard-1", wantPrefix: "workflow-1-zone-a"}, + {name: "malformed suffix still stripped", donName: "workflow-1-zone-a-shard-12", wantPrefix: "workflow-1-zone-a"}, + } + for _, tc := range tests { + t.Run(tc.name, func(t *testing.T) { + t.Parallel() + assert.Equal(t, tc.wantPrefix, shardGroupNamePrefix(tc.donName)) + }) + } +} diff --git a/core/services/workflows/syncer/v2/handler.go b/core/services/workflows/syncer/v2/handler.go index bdae912f3a0..8fffb25c9f8 100644 --- a/core/services/workflows/syncer/v2/handler.go +++ b/core/services/workflows/syncer/v2/handler.go @@ -125,6 +125,7 @@ type eventHandler struct { shardOrchestratorClient shardorchestrator.ClientInterface shardingEnabled bool myDonID uint32 + myShardIndex uint32 shardRoutingSteady *shardownership.SteadySignal shardResolver shardownership.ShardResolver dispatcher remotetypes.Dispatcher @@ -199,6 +200,12 @@ func WithShardResolver(resolver shardownership.ShardResolver) func(*eventHandler } } +func WithShardIndex(shardIndex uint32) func(*eventHandler) { + return func(e *eventHandler) { + e.myShardIndex = shardIndex + } +} + func WithDispatcher(dispatcher remotetypes.Dispatcher) func(*eventHandler) { return func(e *eventHandler) { e.dispatcher = dispatcher @@ -912,7 +919,8 @@ func (h *eventHandler) engineFactoryFn(ctx context.Context, workflowID, owner st } manager = NewShardFailoverManager(ShardFailoverManagerConfig{ ShardingEnabled: h.shardingEnabled, - MyShardID: h.myDonID, + MyDONID: h.myDonID, + MyShardIndex: h.myShardIndex, WorkflowID: workflowID, WorkflowOwner: owner, ShardResolver: h.shardResolver, diff --git a/core/services/workflows/syncer/v2/shard_failover_manager.go b/core/services/workflows/syncer/v2/shard_failover_manager.go index 5fa7129ccc0..265792de952 100644 --- a/core/services/workflows/syncer/v2/shard_failover_manager.go +++ b/core/services/workflows/syncer/v2/shard_failover_manager.go @@ -59,7 +59,8 @@ type cachedEvent struct { type ShardFailoverManagerConfig struct { ShardingEnabled bool - MyShardID uint32 + MyDONID uint32 + MyShardIndex uint32 WorkflowID string WorkflowOwner string @@ -67,9 +68,13 @@ type ShardFailoverManagerConfig struct { ShardOrchestratorClient shardorchestrator.ClientInterface ShardRoutingSteady *shardownership.SteadySignal - FailoverGate limits.GateLimiter - Communicator *sharding.ShardFailoverCommunicator - ShardDonLookup func(ctx context.Context, shardID uint32) *commoncap.DON + FailoverGate limits.GateLimiter + Communicator *sharding.ShardFailoverCommunicator + // ShardDonLookup resolves a DON ID to the current DON, e.g. via + // capRegistry.DONByID. ResolveAllShards always returns real DON IDs + // (shardownership.manualShardResolver translates any configured shard + // index to a DON ID internally), so no shard-index remapping happens here. + ShardDonLookup func(ctx context.Context, donID uint32) *commoncap.DON DonSubscriber capabilities.DonSubscriber Logger logger.Logger @@ -170,10 +175,12 @@ func (m *ShardFailoverManager) forwardExecutionStatus(workflowID string, executi if !m.isPrimaryShard(context.Background(), m.cfg.WorkflowID, m.cfg.WorkflowOwner) { return } + // Position 1 in ResolveAllShards' result is the secondary DON ID for this + // workflow; ShardDonLookup resolves it to the current DON. secondaryDon := m.resolveDon(context.Background(), m.cfg.WorkflowID, m.cfg.WorkflowOwner, 1) if secondaryDon == nil { m.cfg.Logger.Warnw("failover: primary cannot resolve secondary DON, skipping status update", - "workflowID", workflowID, "myShardID", m.cfg.MyShardID) + "workflowID", workflowID, "myShardIndex", m.cfg.MyShardIndex) return } execStatus := mapExecutionStatus(status, errClass) @@ -183,7 +190,7 @@ func (m *ShardFailoverManager) forwardExecutionStatus(workflowID string, executi TriggerEventId: triggerEventID, TriggerIndex: uint32(triggerIndex), //nolint:gosec // G115: triggerIndex is small Status: execStatus, - PrimaryDonId: m.cfg.MyShardID, + PrimaryDonId: m.cfg.MyDONID, }, *secondaryDon) } @@ -229,16 +236,16 @@ func (m *ShardFailoverManager) checkShardOwnership(ctx context.Context) shardown switch { case m.cfg.ShardResolver != nil: - shardID, found, err := m.cfg.ShardResolver.ResolveShard(ctx, m.cfg.WorkflowID, m.cfg.WorkflowOwner) + donID, found, err := m.cfg.ShardResolver.ResolveShard(ctx, m.cfg.WorkflowID, m.cfg.WorkflowOwner) if err != nil { return shardownership.DenyOrchestratorError } - if !found || shardID != m.cfg.MyShardID { + if !found || donID != m.cfg.MyDONID { return shardownership.DenyNotOwner } return shardownership.Allow case m.cfg.ShardOrchestratorClient != nil: - verdict, _, _ := shardownership.CheckCommittedOwner(ctx, m.cfg.ShardOrchestratorClient, m.cfg.WorkflowID, m.cfg.MyShardID) + verdict, _, _ := shardownership.CheckCommittedOwner(ctx, m.cfg.ShardOrchestratorClient, m.cfg.WorkflowID, m.cfg.MyDONID) return verdict default: return shardownership.Allow @@ -252,7 +259,7 @@ func (m *ShardFailoverManager) cacheEvent(event v2.RoutedTriggerEvent) { m.mu.Unlock() m.cfg.Logger.Infow("secondary shard: cached trigger event for failover", "eventID", eventID, - "myShardID", m.cfg.MyShardID, + "myShardIndex", m.cfg.MyShardIndex, "workflowID", m.cfg.WorkflowID, "triggerIndex", event.TriggerIndex) } @@ -327,7 +334,7 @@ func (m *ShardFailoverManager) wireFailover(ctx context.Context) error { m.cfg.Communicator.RegisterHandler(m.cfg.WorkflowID, primaryDonVal, m.HandleExecutionStatusUpdate) m.cfg.Logger.Infow("shard failover: wired communicator", - "myShardID", m.cfg.MyShardID, + "myShardIndex", m.cfg.MyShardIndex, "workflowID", m.cfg.WorkflowID, "primaryDonID", primaryDonIDOrZero(primaryDon)) @@ -346,19 +353,19 @@ func primaryDonIDOrZero(d *commoncap.DON) uint32 { func (m *ShardFailoverManager) isPrimaryShard(ctx context.Context, workflowID, owner string) bool { if m.cfg.ShardResolver == nil { - return m.cfg.MyShardID == 0 + return m.cfg.MyShardIndex == 0 } allResolver, ok := m.cfg.ShardResolver.(shardownership.AllShardsResolver) if !ok { - return m.cfg.MyShardID == 0 + return m.cfg.MyShardIndex == 0 } ctx, cancel := context.WithTimeout(ctx, 5*time.Second) defer cancel() shards, found, err := allResolver.ResolveAllShards(ctx, workflowID, owner) if err != nil || !found || len(shards) == 0 { - return m.cfg.MyShardID == 0 + return m.cfg.MyShardIndex == 0 } - return shards[0] == m.cfg.MyShardID + return shards[0] == m.cfg.MyDONID } func (m *ShardFailoverManager) resolveDon(ctx context.Context, workflowID, owner string, shardIndex int) *commoncap.DON { diff --git a/core/services/workflows/syncer/v2/shard_failover_manager_test.go b/core/services/workflows/syncer/v2/shard_failover_manager_test.go index 017fdc0d960..fb73d29a82d 100644 --- a/core/services/workflows/syncer/v2/shard_failover_manager_test.go +++ b/core/services/workflows/syncer/v2/shard_failover_manager_test.go @@ -207,7 +207,7 @@ func TestShardFailoverManager_MultipleWorkflowsSharedDispatcher(t *testing.T) { makeManager := func(workflowID string) *ShardFailoverManager { return NewShardFailoverManager(ShardFailoverManagerConfig{ ShardingEnabled: true, - MyShardID: 2, + MyShardIndex: 2, WorkflowID: workflowID, WorkflowOwner: "0xowner", ShardResolver: resolver, diff --git a/core/services/workflows/syncer/v2/workflow_registry_test.go b/core/services/workflows/syncer/v2/workflow_registry_test.go index 3e71f8f5f04..97b3c995b7c 100644 --- a/core/services/workflows/syncer/v2/workflow_registry_test.go +++ b/core/services/workflows/syncer/v2/workflow_registry_test.go @@ -2041,7 +2041,7 @@ func TestWorkflowRegistry_ShardResolverWiring(t *testing.T) { Settings: manualConfigTOML, Hash: "test", })) - manual := shardownership.NewManualShardResolver(settings, nil, logger.TestLogger(t)) + manual := shardownership.NewManualShardResolver(settings, nil, nil, logger.TestLogger(t)) wr := newReg(t, WithShardEnabled(true), WithShardOrchestratorClient(nil), @@ -2067,7 +2067,7 @@ func TestWorkflowRegistry_ShardResolverWiring(t *testing.T) { wf1.Hex(): 0, wf2.Hex(): 1, }} - override := shardownership.NewOverrideShardResolver(settings, nil, + override := shardownership.NewOverrideShardResolver(settings, nil, nil, shardownership.NewRingOCRShardResolver(ringClient, logger.TestLogger(t)), logger.TestLogger(t)) wr := newReg(t, @@ -2095,7 +2095,7 @@ func TestWorkflowRegistry_ShardResolverWiring(t *testing.T) { ringClient := &mockShardMappingClient{mappings: map[string]uint32{ wf1.Hex(): 0, }} - override := shardownership.NewOverrideShardResolver(settings, nil, + override := shardownership.NewOverrideShardResolver(settings, nil, nil, shardownership.NewRingOCRShardResolver(ringClient, logger.TestLogger(t)), logger.TestLogger(t)) wr := newReg(t, diff --git a/deployment/.golangci.yml b/deployment/.golangci.yml index 4f9e1cd449f..eeacc0304a4 100644 --- a/deployment/.golangci.yml +++ b/deployment/.golangci.yml @@ -174,6 +174,9 @@ linters: - linters: - staticcheck text: "SA1019: (.*).ExistingAddresses is deprecated: AddressBook is deprecated" + - linters: + - staticcheck + text: "SA1019: (.*).AddressBook is deprecated" - linters: - revive text: "^var-naming: don't use an underscore in package name" diff --git a/deployment/ccip/changeset/ccip-attestation/cs_deploy_evm_signer_registry.go b/deployment/ccip/changeset/ccip-attestation/cs_deploy_evm_signer_registry.go index 301793bbb17..03f87e2ec37 100644 --- a/deployment/ccip/changeset/ccip-attestation/cs_deploy_evm_signer_registry.go +++ b/deployment/ccip/changeset/ccip-attestation/cs_deploy_evm_signer_registry.go @@ -103,5 +103,8 @@ func signerRegistryDeploymentLogic(e cldf.Environment, config SignerRegistryChan e.Logger.Infof("Successfully deployed signer registry %s on %s", signerRegistry.Address.String(), chain.String()) } - return cldf.ChangesetOutput{AddressBook: addressBook, DataStore: ds}, nil + return cldf.ChangesetOutput{ + AddressBook: addressBook, + DataStore: ds, + }, nil } diff --git a/deployment/ccip/changeset/crossfamily/v1_6/cs_add_evm_solana_lane.go b/deployment/ccip/changeset/crossfamily/v1_6/cs_add_evm_solana_lane.go index af1742e0baf..a627d0d331f 100644 --- a/deployment/ccip/changeset/crossfamily/v1_6/cs_add_evm_solana_lane.go +++ b/deployment/ccip/changeset/crossfamily/v1_6/cs_add_evm_solana_lane.go @@ -38,7 +38,7 @@ var ( if input.MCMSConfig == nil || len(allProposals) == 0 { return input.Proposals, nil } - proposal, err := proposeutils.AggregateProposals( //nolint:staticcheck //SA1019 ignoring deprecated + proposal, err := proposeutils.AggregateProposals( //nolint:staticcheck // SA1019: AggregateProposalsV2 migration is tracked separately deps.Env, deps.EVMMCMSState, deps.SolanaMCMSState, @@ -180,7 +180,7 @@ var ( } return OpsOutput{ Proposals: output.MCMSTimelockProposals, - AddressBook: output.AddressBook, //nolint:staticcheck //SA1019 ignoring deprecated + AddressBook: output.AddressBook, DataStore: output.DataStore, }, nil }, @@ -205,7 +205,7 @@ var ( } return OpsOutput{ Proposals: output.MCMSTimelockProposals, - AddressBook: output.AddressBook, //nolint:staticcheck //SA1019 ignoring deprecated + AddressBook: output.AddressBook, DataStore: output.DataStore, }, nil }, @@ -230,7 +230,7 @@ var ( } return OpsOutput{ Proposals: output.MCMSTimelockProposals, - AddressBook: output.AddressBook, //nolint:staticcheck //SA1019 ignoring deprecated + AddressBook: output.AddressBook, DataStore: output.DataStore, }, nil }, diff --git a/deployment/ccip/changeset/cs_orchestrate_changesets.go b/deployment/ccip/changeset/cs_orchestrate_changesets.go index 5d210da47f4..fa3a58c8fcd 100644 --- a/deployment/ccip/changeset/cs_orchestrate_changesets.go +++ b/deployment/ccip/changeset/cs_orchestrate_changesets.go @@ -228,7 +228,7 @@ func MergeChangesetOutput(e cldf.Environment, dest *cldf.ChangesetOutput, src cl dest.Reports = append(dest.Reports, src.Reports...) } - src.AddressBook = nil //nolint:staticcheck // AddressBook is deprecated, but Phase 1 still uses it + src.AddressBook = nil src.DataStore = nil if err := cldf.MergeChangesetOutput(e, dest, src); err != nil { return fmt.Errorf("failed to merge changeset output: %w", err) @@ -301,7 +301,7 @@ func mergeAddressBookEntries(dst cldf.AddressBook, entries map[uint64]map[string func planChangesetMerge(env cldf.Environment, dest, src cldf.ChangesetOutput) (*changesetMergePlan, error) { plan := &changesetMergePlan{} - if err := plan.planAddressBook(env, dest.AddressBook, src.AddressBook); err != nil { //nolint:staticcheck // AddressBook is deprecated, but Phase 1 still uses it + if err := plan.planAddressBook(env, dest.AddressBook, src.AddressBook); err != nil { return nil, err } @@ -640,7 +640,7 @@ func (p *changesetMergePlan) applyAddressBookAndDataStore(env cldf.Environment, } if p.addressBook != nil { - dest.AddressBook = p.addressBook //nolint:staticcheck // AddressBook is deprecated, but Phase 1 still uses it + dest.AddressBook = p.addressBook } if p.dataStore != nil { dest.DataStore = p.dataStore diff --git a/deployment/ccip/changeset/cs_prerequisites.go b/deployment/ccip/changeset/cs_prerequisites.go index 182368a0fe9..315a58ea53d 100644 --- a/deployment/ccip/changeset/cs_prerequisites.go +++ b/deployment/ccip/changeset/cs_prerequisites.go @@ -329,7 +329,8 @@ func deployPrerequisiteContracts(e cldf.Environment, ab cldf.AddressBook, ds dat lggr.Warnw( "RMNProxy is not owned by the deployer and RMNProxy is not pointing to the correct RMN contract, "+ "run SetRMNRemoteOnRMNProxyChangeset to update RMN with a proposal", - "chain", chain.String(), "owner", rmnOwner, "currentRMN", currentRMNAddr, "expectedRMN", rmnAddr) + "chain", chain.String(), "owner", rmnOwner, "currentRMN", currentRMNAddr, "expectedRMN", rmnAddr, + ) } else { tx, err := rmnProxy.SetARM(chain.DeployerKey, rmnAddr) if err != nil { @@ -355,7 +356,8 @@ func deployPrerequisiteContracts(e cldf.Environment, ab cldf.AddressBook, ds dat ) tokenAdminRegistryAddr, tx2, tokenAdminRegistry, err2 = token_admin_registry.DeployTokenAdminRegistry( chain.DeployerKey, - chain.Client) + chain.Client, + ) return cldf.ContractDeploy[*token_admin_registry.TokenAdminRegistry]{ Address: tokenAdminRegistryAddr, Contract: tokenAdminRegistry, Tx: tx2, Tv: cldf.NewTypeAndVersion(shared.TokenAdminRegistry, deployment.Version1_5_0), Err: err2, @@ -389,7 +391,8 @@ func deployPrerequisiteContracts(e cldf.Environment, ab cldf.AddressBook, ds dat regModAddr, tx2, regMod, err2 = registry_module_owner_custom.DeployRegistryModuleOwnerCustom( chain.DeployerKey, chain.Client, - tokenAdminReg.Address()) + tokenAdminReg.Address(), + ) return cldf.ContractDeploy[*registry_module_owner_custom.RegistryModuleOwnerCustom]{ Address: regModAddr, Contract: regMod, Tx: tx2, Tv: cldf.NewTypeAndVersion(shared.RegistryModule, deployment.Version1_6_0), Err: err2, diff --git a/deployment/ccip/changeset/internal/deploy_home_chain.go b/deployment/ccip/changeset/internal/deploy_home_chain.go index 80d6f306716..7e044c7fa02 100644 --- a/deployment/ccip/changeset/internal/deploy_home_chain.go +++ b/deployment/ccip/changeset/internal/deploy_home_chain.go @@ -22,8 +22,8 @@ import ( "github.com/smartcontractkit/chainlink-ccip/chains/evm/gobindings/generated/v1_6_0/ccip_home" "github.com/smartcontractkit/chainlink-ccip/chains/evm/gobindings/generated/v1_6_0/offramp" - "github.com/smartcontractkit/chainlink-ccip/pkg/types/ccipocr3" "github.com/smartcontractkit/chainlink-ccip/pluginconfig" + "github.com/smartcontractkit/chainlink-common/pkg/types/ccipocr3" "github.com/smartcontractkit/chainlink-common/pkg/utils/bytes" focr "github.com/smartcontractkit/chainlink-deployments-framework/offchain/ocr" capabilities_registry "github.com/smartcontractkit/chainlink-evm/gethwrappers/keystone/generated/capabilities_registry_1_1_0" @@ -38,9 +38,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/types" ) -var ( - CCIPHomeABI *abi.ABI -) +var CCIPHomeABI *abi.ABI func init() { var err error @@ -638,7 +636,7 @@ func BuildOCR3ConfigForCCIPHome( return nil, fmt.Errorf("failed to parse TON address '%s'", transmitter) } // TODO: this reimplements addrCodec's ToRawAddr helper - parsed = binary.BigEndian.AppendUint32(nil, uint32(pk.Workchain())) //nolint:gosec // G115 + parsed = binary.BigEndian.AppendUint32(nil, uint32(pk.Workchain())) //nolint:gosec // G115: TON workchain -1 intentionally wraps to 0xFFFFFFFF in raw address serialization parsed = append(parsed, pk.Data()...) case chain_selectors.FamilyAptos: parsed, err = hex.DecodeString(strings.TrimPrefix(string(transmitter), "0x")) diff --git a/deployment/ccip/changeset/merge_test.go b/deployment/ccip/changeset/merge_test.go index e2c7eaaf7f1..5cda95fe30e 100644 --- a/deployment/ccip/changeset/merge_test.go +++ b/deployment/ccip/changeset/merge_test.go @@ -322,24 +322,24 @@ func TestMergeChangesetOutputLeavesNothingHalfMerged(t *testing.T) { // The destination already holds one Router; the source deploys a different one under the // same key, which is the conflict that will reject the merge. dest := cldf.ChangesetOutput{ - AddressBook: cldf.NewMemoryAddressBook(), //nolint:staticcheck // Phase 1 merge still stages the address book + AddressBook: cldf.NewMemoryAddressBook(), DataStore: datastore.NewMemoryDataStore(), } - require.NoError(t, dest.AddressBook.Save(chainSelector, addrA, tv)) //nolint:staticcheck // Phase 1 merge still stages the address book + require.NoError(t, dest.AddressBook.Save(chainSelector, addrA, tv)) require.NoError(t, dest.DataStore.Addresses().Add(ref(addrA))) src := cldf.ChangesetOutput{ - AddressBook: cldf.NewMemoryAddressBook(), //nolint:staticcheck // Phase 1 merge still stages the address book + AddressBook: cldf.NewMemoryAddressBook(), DataStore: datastore.NewMemoryDataStore(), } - require.NoError(t, src.AddressBook.Save(chainSelector, addrB, tv)) //nolint:staticcheck // Phase 1 merge still stages the address book + require.NoError(t, src.AddressBook.Save(chainSelector, addrB, tv)) require.NoError(t, src.DataStore.Addresses().Add(ref(addrB))) require.Error(t, MergeChangesetOutput(e, &dest, src)) // The address book merge would have succeeded on its own, and used to run first. It must // not have been applied. - destAddrs, err := dest.AddressBook.Addresses() //nolint:staticcheck // Phase 1 merge still stages the address book + destAddrs, err := dest.AddressBook.Addresses() require.NoError(t, err) require.Len(t, destAddrs[chainSelector], 1, "destination address book must be unchanged") require.Contains(t, destAddrs[chainSelector], addrA) @@ -366,8 +366,8 @@ func TestMergeChangesetOutputPublishesFirstMergeToEnv(t *testing.T) { addr := "0x5B5BBb15ECE0a4Ed8cDab22F902e83F66aBe848f" tv := cldf.NewTypeAndVersion("Router", *semver.MustParse("1.6.0")) - src := cldf.ChangesetOutput{AddressBook: cldf.NewMemoryAddressBook()} //nolint:staticcheck // Phase 1 merge still stages the address book - require.NoError(t, src.AddressBook.Save(chainSelector, addr, tv)) //nolint:staticcheck // Phase 1 merge still stages the address book + src := cldf.ChangesetOutput{AddressBook: cldf.NewMemoryAddressBook()} + require.NoError(t, src.AddressBook.Save(chainSelector, addr, tv)) var dest cldf.ChangesetOutput require.NoError(t, MergeChangesetOutput(e, &dest, src)) @@ -378,7 +378,7 @@ func TestMergeChangesetOutputPublishesFirstMergeToEnv(t *testing.T) { // The destination is a copy, not the source's own book: merging again must not corrupt the // first sub-changeset's output. - require.NotSame(t, src.AddressBook, dest.AddressBook) //nolint:staticcheck // Phase 1 merge still stages the address book + require.NotSame(t, src.AddressBook, dest.AddressBook) } func TestMergeChangesetOutputToleratesKnownAddresses(t *testing.T) { @@ -392,8 +392,8 @@ func TestMergeChangesetOutputToleratesKnownAddresses(t *testing.T) { e := mergeTestEnvironment(t) require.NoError(t, e.ExistingAddresses.Save(chainSelector, addr, tv)) - src := cldf.ChangesetOutput{AddressBook: cldf.NewMemoryAddressBook()} //nolint:staticcheck // Phase 1 merge still stages the address book - require.NoError(t, src.AddressBook.Save(chainSelector, addr, tv)) //nolint:staticcheck // Phase 1 merge still stages the address book + src := cldf.ChangesetOutput{AddressBook: cldf.NewMemoryAddressBook()} + require.NoError(t, src.AddressBook.Save(chainSelector, addr, tv)) var dest cldf.ChangesetOutput require.NoError(t, MergeChangesetOutput(e, &dest, src)) @@ -404,8 +404,8 @@ func TestMergeChangesetOutputToleratesKnownAddresses(t *testing.T) { e := mergeTestEnvironment(t) require.NoError(t, e.ExistingAddresses.Save(chainSelector, addr, tv)) - src := cldf.ChangesetOutput{AddressBook: cldf.NewMemoryAddressBook()} //nolint:staticcheck // Phase 1 merge still stages the address book - require.NoError(t, src.AddressBook.Save(chainSelector, addr, //nolint:staticcheck // Phase 1 merge still stages the address book + src := cldf.ChangesetOutput{AddressBook: cldf.NewMemoryAddressBook()} + require.NoError(t, src.AddressBook.Save(chainSelector, addr, cldf.NewTypeAndVersion("FeeQuoter", *semver.MustParse("1.6.0")))) var dest cldf.ChangesetOutput diff --git a/deployment/ccip/changeset/save_existing.go b/deployment/ccip/changeset/save_existing.go index c154417e4e6..0a384eb57cb 100644 --- a/deployment/ccip/changeset/save_existing.go +++ b/deployment/ccip/changeset/save_existing.go @@ -15,9 +15,7 @@ import ( "github.com/smartcontractkit/chainlink/deployment/ccip/shared" ) -var ( - _ cldf.ChangeSet[ExistingContractsConfig] = SaveExistingContractsChangeset -) +var _ cldf.ChangeSet[ExistingContractsConfig] = SaveExistingContractsChangeset type Contract struct { Address string diff --git a/deployment/ccip/changeset/save_existing_test.go b/deployment/ccip/changeset/save_existing_test.go index 438b9132096..ca5b39ac867 100644 --- a/deployment/ccip/changeset/save_existing_test.go +++ b/deployment/ccip/changeset/save_existing_test.go @@ -30,7 +30,8 @@ func TestSaveExisting(t *testing.T) { map[uint64]cldf_chain.BlockChain{ chainsel.TEST_90000001.Selector: cldf_evm.Chain{}, chainsel.TEST_90000002.Selector: cldf_evm.Chain{}, - }), + }, + ), } ExistingContracts := ExistingContractsConfig{ ExistingContracts: []Contract{ @@ -55,7 +56,7 @@ func TestSaveExisting(t *testing.T) { output, err := SaveExistingContractsChangeset(dummyEnv, ExistingContracts) require.NoError(t, err) - require.NoError(t, dummyEnv.ExistingAddresses.Merge(output.AddressBook)) //nolint:staticcheck // AddressBook is deprecated but still returned by this changeset. + require.NoError(t, dummyEnv.ExistingAddresses.Merge(output.AddressBook)) addresses, err := dummyEnv.ExistingAddresses.Addresses() require.NoError(t, err) require.Len(t, addresses, 2) @@ -73,7 +74,8 @@ func TestSaveExistingAddressWithLabels(t *testing.T) { map[uint64]cldf_chain.BlockChain{ chainsel.TEST_90000001.Selector: cldf_evm.Chain{}, chainsel.TEST_90000002.Selector: cldf_evm.Chain{}, - }), + }, + ), } dummyType1 := cldf.TypeAndVersion{ Type: "dummyType", @@ -93,7 +95,7 @@ func TestSaveExistingAddressWithLabels(t *testing.T) { output, err := SaveExistingContractsChangeset(dummyEnv, ExistingContracts) require.NoError(t, err) - require.NoError(t, dummyEnv.ExistingAddresses.Merge(output.AddressBook)) //nolint:staticcheck // AddressBook is deprecated but still returned by this changeset. + require.NoError(t, dummyEnv.ExistingAddresses.Merge(output.AddressBook)) addresses, err := dummyEnv.ExistingAddresses.Addresses() require.NoError(t, err) require.Len(t, addresses, 1) @@ -112,7 +114,8 @@ func TestSaveExistingMCMSAddressWithLabels(t *testing.T) { map[uint64]cldf_chain.BlockChain{ chainsel.TEST_90000001.Selector: cldf_evm.Chain{}, chainsel.TEST_90000002.Selector: cldf_evm.Chain{}, - }), + }, + ), } mcmsContractTV := cldf.TypeAndVersion{ Type: types.ManyChainMultisig, @@ -133,7 +136,7 @@ func TestSaveExistingMCMSAddressWithLabels(t *testing.T) { output, err := SaveExistingContractsChangeset(dummyEnv, ExistingContracts) require.NoError(t, err) - require.NoError(t, dummyEnv.ExistingAddresses.Merge(output.AddressBook)) //nolint:staticcheck // AddressBook is deprecated but still returned by this changeset. + require.NoError(t, dummyEnv.ExistingAddresses.Merge(output.AddressBook)) addresses, err := dummyEnv.ExistingAddresses.Addresses() require.NoError(t, err) require.Len(t, addresses, 1) @@ -159,7 +162,8 @@ func TestSaveExistingContractsDualWrite(t *testing.T) { BlockChains: cldf_chain.NewBlockChains( map[uint64]cldf_chain.BlockChain{ chainsel.TEST_90000001.Selector: cldf_evm.Chain{}, - }), + }, + ), } addr1 := common.BigToAddress(big.NewInt(1)).String() addr2 := common.BigToAddress(big.NewInt(2)).String() @@ -191,7 +195,7 @@ func TestSaveExistingContractsDualWrite(t *testing.T) { output, err := SaveExistingContractsChangeset(dummyEnv, cfg) require.NoError(t, err) - addresses, err := output.AddressBook.Addresses() //nolint:staticcheck // AddressBook is deprecated but still returned by this changeset. + addresses, err := output.AddressBook.Addresses() require.NoError(t, err) require.Len(t, addresses[chainsel.TEST_90000001.Selector], 2) diff --git a/deployment/ccip/changeset/solana_v0_1_0/cs_add_remote_chain.go b/deployment/ccip/changeset/solana_v0_1_0/cs_add_remote_chain.go index b518cb636b5..521cfde60df 100644 --- a/deployment/ccip/changeset/solana_v0_1_0/cs_add_remote_chain.go +++ b/deployment/ccip/changeset/solana_v0_1_0/cs_add_remote_chain.go @@ -122,7 +122,8 @@ func AddRemoteChainToRouter(e cldf.Environment, cfg AddRemoteChainToRouterConfig // create proposals for ixns if len(txns) > 0 { proposal, err := BuildProposalsForTxns( - e, cfg.ChainSelector, "proposal to add remote chains to Solana", cfg.MCMS.MinDelay, txns) + e, cfg.ChainSelector, "proposal to add remote chains to Solana", cfg.MCMS.MinDelay, txns, + ) if err != nil { return cldf.ChangesetOutput{}, fmt.Errorf("failed to build proposal: %w", err) } @@ -134,7 +135,10 @@ func AddRemoteChainToRouter(e cldf.Environment, cfg AddRemoteChainToRouterConfig }, nil } - return cldf.ChangesetOutput{AddressBook: ab, DataStore: ds}, nil + return cldf.ChangesetOutput{ + AddressBook: ab, + DataStore: ds, + }, nil } func doAddRemoteChainToRouter( @@ -164,7 +168,8 @@ func doAddRemoteChainToRouter( runSafely( func() { solRouter.SetProgramID(ccipRouterID) - }) + }, + ) authority := GetAuthorityForIxn( &e, chain, @@ -339,13 +344,17 @@ func AddRemoteChainToFeeQuoter(e cldf.Environment, cfg AddRemoteChainToFeeQuoter if err != nil { // skipped: doAddRemoteChainToFeeQuoter does not save any lane/multi-instance refs, // so the datastore needs no additional qualifier pass. - return cldf.ChangesetOutput{AddressBook: ab, DataStore: ds}, err //nolint:staticcheck // Phase 1 still returns the address book + return cldf.ChangesetOutput{ + AddressBook: ab, + DataStore: ds, + }, err } // create proposals for ixns if len(txns) > 0 { proposal, err := BuildProposalsForTxns( - e, cfg.ChainSelector, "proposal to add remote chains to Solana", cfg.MCMS.MinDelay, txns) + e, cfg.ChainSelector, "proposal to add remote chains to Solana", cfg.MCMS.MinDelay, txns, + ) if err != nil { return cldf.ChangesetOutput{}, fmt.Errorf("failed to build proposal: %w", err) } @@ -360,7 +369,10 @@ func AddRemoteChainToFeeQuoter(e cldf.Environment, cfg AddRemoteChainToFeeQuoter // skipped: doAddRemoteChainToFeeQuoter does not save any lane/multi-instance refs, // so the datastore needs no additional qualifier pass. - return cldf.ChangesetOutput{AddressBook: ab, DataStore: ds}, nil + return cldf.ChangesetOutput{ + AddressBook: ab, + DataStore: ds, + }, nil } func doAddRemoteChainToFeeQuoter( @@ -382,13 +394,15 @@ func doAddRemoteChainToFeeQuoter( chainState, shared.FeeQuoter, solana.PublicKey{}, - "") + "", + ) lookUpTableEntries := make([]solana.PublicKey, 0) // fee quoter setup runSafely( func() { solFeeQuoter.SetProgramID(feeQuoterID) - }) + }, + ) authority := GetAuthorityForIxn( &e, chain, @@ -521,7 +535,6 @@ func AddRemoteChainToOffRamp(e cldf.Environment, cfg AddRemoteChainToOffRampConf txns, err := doAddRemoteChainToOffRamp(e, s, cfg, ab, ds) if err != nil { return cldf.ChangesetOutput{ - //nolint:staticcheck // SA1019: AddressBook is deprecated, migration to DataStore pending AddressBook: ab, DataStore: ds, }, err @@ -530,7 +543,8 @@ func AddRemoteChainToOffRamp(e cldf.Environment, cfg AddRemoteChainToOffRampConf // create proposals for ixns if len(txns) > 0 { proposal, err := BuildProposalsForTxns( - e, cfg.ChainSelector, "proposal to add remote chains to Solana", cfg.MCMS.MinDelay, txns) + e, cfg.ChainSelector, "proposal to add remote chains to Solana", cfg.MCMS.MinDelay, txns, + ) if err != nil { return cldf.ChangesetOutput{}, fmt.Errorf("failed to build proposal: %w", err) } @@ -541,7 +555,10 @@ func AddRemoteChainToOffRamp(e cldf.Environment, cfg AddRemoteChainToOffRampConf }, nil } - return cldf.ChangesetOutput{AddressBook: ab, DataStore: ds}, nil + return cldf.ChangesetOutput{ + AddressBook: ab, + DataStore: ds, + }, nil } func doAddRemoteChainToOffRamp( @@ -563,12 +580,14 @@ func doAddRemoteChainToOffRamp( chainState, shared.OffRamp, solana.PublicKey{}, - "") + "", + ) lookUpTableEntries := make([]solana.PublicKey, 0) runSafely( func() { solOffRamp.SetProgramID(offRampID) - }) + }, + ) authority := GetAuthorityForIxn( &e, chain, @@ -675,7 +694,8 @@ func extendLookupTable(e cldf.Environment, chain cldf_solana.Chain, offRampID so addresses, err := solCommonUtil.GetAddressLookupTable( e.GetContext(), chain.Client, - addressLookupTable) + addressLookupTable, + ) if err != nil { return fmt.Errorf("failed to get address lookup table: %w", err) } diff --git a/deployment/ccip/changeset/solana_v0_1_0/cs_build_solana.go b/deployment/ccip/changeset/solana_v0_1_0/cs_build_solana.go index 91184b80bac..8e5f97c21c9 100644 --- a/deployment/ccip/changeset/solana_v0_1_0/cs_build_solana.go +++ b/deployment/ccip/changeset/solana_v0_1_0/cs_build_solana.go @@ -3,6 +3,7 @@ package solana import ( "bufio" "bytes" + "context" "errors" "fmt" "os" @@ -68,7 +69,7 @@ type BuildSolanaConfig struct { // Run a command in a specific directory func runCommand(command string, args []string, workDir string) (string, error) { - cmd := exec.Command(command, args...) + cmd := exec.CommandContext(context.Background(), command, args...) cmd.Dir = workDir var stdout, stderr bytes.Buffer cmd.Stdout = &stdout @@ -149,7 +150,7 @@ func replaceKeysForUpgrade(e cldf.Environment, keys map[cldf.ContractType]string // Replace declare_id!("..."); with the new key updatedContent := regexp.MustCompile(`declare_id!\(".*?"\);`).ReplaceAllString(string(content), fmt.Sprintf(`declare_id!("%s");`, key)) - err = os.WriteFile(fullPath, []byte(updatedContent), 0600) //nolint:gosec // G703 + err = os.WriteFile(fullPath, []byte(updatedContent), 0o600) //nolint:gosec // G703: false positive, path is within the freshly cloned repo dir if err != nil { return fmt.Errorf("failed to write updated keys to file %s: %w", fullPath, err) } @@ -192,7 +193,7 @@ func syncRouterAndCommon() error { updatedContent := declareRegex.ReplaceAllString(string(commonContent), declareID) - return os.WriteFile(commonFile, []byte(updatedContent), 0600) //nolint:gosec // G703 + return os.WriteFile(commonFile, []byte(updatedContent), 0o600) //nolint:gosec // G703: false positive, path is within the freshly cloned repo dir } func generateVanityKeys(e cldf.Environment, keys map[cldf.ContractType]string) error { @@ -250,7 +251,7 @@ func generateVanityKeys(e cldf.Environment, keys map[cldf.ContractType]string) e return nil } -func copyFile(srcFile string, destDir string) error { +func copyFile(srcFile, destDir string) error { output, err := runCommand("cp", []string{srcFile, destDir}, ".") if err != nil { return fmt.Errorf("failed to copy file: %s %w", output, err) diff --git a/deployment/ccip/changeset/solana_v0_1_0/cs_deploy_chain.go b/deployment/ccip/changeset/solana_v0_1_0/cs_deploy_chain.go index f551128c055..5a947155a8f 100644 --- a/deployment/ccip/changeset/solana_v0_1_0/cs_deploy_chain.go +++ b/deployment/ccip/changeset/solana_v0_1_0/cs_deploy_chain.go @@ -154,7 +154,7 @@ func (c DeployChainContractsConfig) Validate(e cldf.Environment, existingState s // initialisation of the mcms contracts then happens via testhelpers.TransferOwnershipSolana if chainState.Router.IsZero() { if c.MCMSWithTimelockConfig == nil { - return fmt.Errorf("Router is not deployed. This looks like an initial deploy.MCMS config must be set for chain %d", c.ChainSelector) + return fmt.Errorf("router is not deployed. This looks like an initial deploy.MCMS config must be set for chain %d", c.ChainSelector) } } return nil @@ -289,13 +289,13 @@ func deployChainContractsSolana( // FEE QUOTER DEPLOY var feeQuoterAddress solana.PublicKey - //nolint:gocritic // this is a false positive, we need to check if the address is zero - if chainState.FeeQuoter.IsZero() { + switch { + case chainState.FeeQuoter.IsZero(): feeQuoterAddress, err = DeployAndMaybeSaveToAddressBook(e, chain, ab, ds, shared.FeeQuoter, deployment.Version1_0_0, false, "") if err != nil { return batches, fmt.Errorf("failed to deploy program: %w", err) } - } else if config.UpgradeConfig.NewFeeQuoterVersion != nil { + case config.UpgradeConfig.NewFeeQuoterVersion != nil: // fee quoter updated in place feeQuoterAddress = chainState.FeeQuoter newTxns, err := generateUpgradeTxns(e, chain, ab, ds, config, config.UpgradeConfig.NewFeeQuoterVersion, chainState.FeeQuoter, shared.FeeQuoter) @@ -309,7 +309,7 @@ func deployChainContractsSolana( Transactions: newTxns, }) } - } else { + default: e.Logger.Infow("Using existing fee quoter", "addr", chainState.FeeQuoter.String()) feeQuoterAddress = chainState.FeeQuoter } @@ -319,14 +319,14 @@ func deployChainContractsSolana( // ROUTER DEPLOY var ccipRouterProgram solana.PublicKey - //nolint:gocritic // this is a false positive, we need to check if the address is zero - if chainState.Router.IsZero() { + switch { + case chainState.Router.IsZero(): // deploy router ccipRouterProgram, err = DeployAndMaybeSaveToAddressBook(e, chain, ab, ds, shared.Router, deployment.Version1_0_0, false, "") if err != nil { return batches, fmt.Errorf("failed to deploy program: %w", err) } - } else if config.UpgradeConfig.NewRouterVersion != nil { + case config.UpgradeConfig.NewRouterVersion != nil: // router updated in place ccipRouterProgram = chainState.Router newTxns, err := generateUpgradeTxns(e, chain, ab, ds, config, config.UpgradeConfig.NewRouterVersion, chainState.Router, shared.Router) @@ -340,7 +340,7 @@ func deployChainContractsSolana( Transactions: newTxns, }) } - } else { + default: e.Logger.Infow("Using existing router", "addr", chainState.Router.String()) ccipRouterProgram = chainState.Router } @@ -350,14 +350,14 @@ func deployChainContractsSolana( // OFFRAMP DEPLOY var offRampAddress solana.PublicKey - //nolint:gocritic // this is a false positive, we need to check if the address is zero - if chainState.OffRamp.IsZero() { + switch { + case chainState.OffRamp.IsZero(): // deploy offramp offRampAddress, err = DeployAndMaybeSaveToAddressBook(e, chain, ab, ds, shared.OffRamp, deployment.Version1_0_0, false, "") if err != nil { return batches, fmt.Errorf("failed to deploy program: %w", err) } - } else if config.UpgradeConfig.NewOffRampVersion != nil { + case config.UpgradeConfig.NewOffRampVersion != nil: tv := cldf.NewTypeAndVersion(shared.OffRamp, *config.UpgradeConfig.NewOffRampVersion) existingAddresses, err := e.ExistingAddresses.AddressesForChain(chain.Selector) if err != nil { @@ -411,7 +411,7 @@ func deployChainContractsSolana( }) } } - } else { + default: e.Logger.Infow("Using existing offramp", "addr", chainState.OffRamp.String()) offRampAddress = chainState.OffRamp } @@ -421,12 +421,13 @@ func deployChainContractsSolana( // RMN REMOTE DEPLOY var rmnRemoteAddress solana.PublicKey - if chainState.RMNRemote.IsZero() { + switch { + case chainState.RMNRemote.IsZero(): rmnRemoteAddress, err = DeployAndMaybeSaveToAddressBook(e, chain, ab, ds, shared.RMNRemote, deployment.Version1_0_0, false, "") if err != nil { return batches, fmt.Errorf("failed to deploy program: %w", err) } - } else if config.UpgradeConfig.NewRMNRemoteVersion != nil { + case config.UpgradeConfig.NewRMNRemoteVersion != nil: rmnRemoteAddress = chainState.RMNRemote newTxns, err := generateUpgradeTxns(e, chain, ab, ds, config, config.UpgradeConfig.NewRMNRemoteVersion, chainState.RMNRemote, shared.RMNRemote) if err != nil { @@ -439,7 +440,7 @@ func deployChainContractsSolana( Transactions: newTxns, }) } - } else { + default: e.Logger.Infow("Using existing rmn remote", "addr", chainState.RMNRemote.String()) rmnRemoteAddress = chainState.RMNRemote } @@ -490,7 +491,8 @@ func deployChainContractsSolana( solana.Token2022ProgramID, solana.TokenProgramID, solana.SPLAssociatedTokenAccountProgramID, - }) + }, + ) if err2 != nil { return batches, fmt.Errorf("failed to create address lookup table: %w", err) } @@ -519,13 +521,13 @@ func deployChainContractsSolana( if config.BurnMintTokenPoolMetadata != "" { metadata = config.BurnMintTokenPoolMetadata } - //nolint:gocritic // this is a false positive, we need to check if the address is zero - if chainState.BurnMintTokenPools[metadata].IsZero() { + switch { + case chainState.BurnMintTokenPools[metadata].IsZero(): burnMintTokenPool, err = DeployAndMaybeSaveToAddressBook(e, chain, ab, ds, shared.BurnMintTokenPool, deployment.Version1_0_0, false, metadata) if err != nil { return batches, fmt.Errorf("failed to deploy program: %w", err) } - } else if config.UpgradeConfig.NewBurnMintTokenPoolVersion != nil { + case config.UpgradeConfig.NewBurnMintTokenPoolVersion != nil: burnMintTokenPool = chainState.BurnMintTokenPools[metadata] newTxns, err := generateUpgradeTxns(e, chain, ab, ds, config, config.UpgradeConfig.NewBurnMintTokenPoolVersion, chainState.BurnMintTokenPools[metadata], shared.BurnMintTokenPool) if err != nil { @@ -538,7 +540,7 @@ func deployChainContractsSolana( Transactions: newTxns, }) } - } else { + default: e.Logger.Infow("Using existing burn mint token pool", "addr", chainState.BurnMintTokenPools[metadata].String()) burnMintTokenPool = chainState.BurnMintTokenPools[metadata] } @@ -548,13 +550,13 @@ func deployChainContractsSolana( if config.LockReleaseTokenPoolMetadata != "" { metadata = config.LockReleaseTokenPoolMetadata } - //nolint:gocritic // this is a false positive, we need to check if the address is zero - if chainState.LockReleaseTokenPools[metadata].IsZero() { + switch { + case chainState.LockReleaseTokenPools[metadata].IsZero(): lockReleaseTokenPool, err = DeployAndMaybeSaveToAddressBook(e, chain, ab, ds, shared.LockReleaseTokenPool, deployment.Version1_0_0, false, metadata) if err != nil { return batches, fmt.Errorf("failed to deploy program: %w", err) } - } else if config.UpgradeConfig.NewLockReleaseTokenPoolVersion != nil { + case config.UpgradeConfig.NewLockReleaseTokenPoolVersion != nil: lockReleaseTokenPool = chainState.LockReleaseTokenPools[metadata] newTxns, err := generateUpgradeTxns(e, chain, ab, ds, config, config.UpgradeConfig.NewLockReleaseTokenPoolVersion, chainState.LockReleaseTokenPools[metadata], shared.LockReleaseTokenPool) if err != nil { @@ -567,7 +569,7 @@ func deployChainContractsSolana( Transactions: newTxns, }) } - } else { + default: e.Logger.Infow("Using existing lock release token pool", "addr", chainState.LockReleaseTokenPools[metadata].String()) lockReleaseTokenPool = chainState.LockReleaseTokenPools[metadata] } @@ -1033,13 +1035,12 @@ func generateExtendIxn( return nil, nil } extraBytes := newProgramSize - programDataSize - if extraBytes > math.MaxUint32 { - return nil, fmt.Errorf("extra bytes %d exceeds maximum value %d", extraBytes, math.MaxUint32) + if extraBytes > math.MaxUint32-1024 { + return nil, fmt.Errorf("extra bytes %d exceeds maximum value %d", extraBytes, math.MaxUint32-1024) } // https://github.com/solana-labs/solana/blob/7700cb3128c1f19820de67b81aa45d18f73d2ac0/sdk/program/src/loader_upgradeable_instruction.rs#L146 - data := binary.LittleEndian.AppendUint32([]byte{}, 6) // 4-byte Extend instruction identifier - //nolint:gosec // G115 we check for overflow above - data = binary.LittleEndian.AppendUint32(data, uint32(extraBytes+1024)) // add some padding + data := binary.LittleEndian.AppendUint32([]byte{}, 6) // 4-byte Extend instruction identifier + data = binary.LittleEndian.AppendUint32(data, uint32(extraBytes+1024)) //nolint:gosec // G115: guard above covers the 1024 bytes of padding keys := solana.AccountMetaSlice{ solana.NewAccountMeta(programDataAccount, true, false), // Program data account (writable) diff --git a/deployment/ccip/changeset/solana_v0_1_0/cs_e2e.go b/deployment/ccip/changeset/solana_v0_1_0/cs_e2e.go index ddabbc89bc0..8adbff8ec46 100644 --- a/deployment/ccip/changeset/solana_v0_1_0/cs_e2e.go +++ b/deployment/ccip/changeset/solana_v0_1_0/cs_e2e.go @@ -35,11 +35,11 @@ type E2ETokenPoolConfig struct { func E2ETokenPool(e cldf.Environment, cfg E2ETokenPoolConfig) (cldf.ChangesetOutput, error) { finalOutput := cldf.ChangesetOutput{} - finalOutput.AddressBook = cldf.NewMemoryAddressBook() //nolint:staticcheck // Addressbook is deprecated, but we still use it for the time being + finalOutput.AddressBook = cldf.NewMemoryAddressBook() addressBookToRemove := cldf.NewMemoryAddressBook() defer func(e cldf.Environment) { e.Logger.Info("SolanaE2ETokenPool changeset completed") - e.Logger.Info("Final output: ", finalOutput.AddressBook) //nolint:staticcheck // Addressbook is deprecated, but we still use it for the time being + e.Logger.Info("Final output: ", finalOutput.AddressBook) }(e) // if mcms config is not provided, use the mcms config from one of the other configs if cfg.MCMS == nil { @@ -101,7 +101,7 @@ func ProcessConfig[T any]( return fmt.Errorf("failed to merge changeset output: %w", err) } - if ab := output.AddressBook; ab != nil { //nolint:staticcheck // Addressbook is deprecated, but we still use it for the time being + if ab := output.AddressBook; ab != nil { if err := tempRemoveBook.Merge(ab); err != nil { return fmt.Errorf("failed to merge into temp: %w", err) } diff --git a/deployment/ccip/changeset/solana_v0_1_0/cs_ops.go b/deployment/ccip/changeset/solana_v0_1_0/cs_ops.go index 0cca5fda06a..d43e508a28e 100644 --- a/deployment/ccip/changeset/solana_v0_1_0/cs_ops.go +++ b/deployment/ccip/changeset/solana_v0_1_0/cs_ops.go @@ -98,19 +98,19 @@ func DeployReceiverForTest(e cldf.Environment, cfg DeployForTestConfig) (cldf.Ch var receiverAddress solana.PublicKey if !cfg.IsUpgrade { - //nolint:gocritic // this is a false positive, we need to check if the address is zero - if chainState.Receiver.IsZero() { + switch { + case chainState.Receiver.IsZero(): receiverAddress, err = DeployAndMaybeSaveToAddressBook(e, chain, ab, ds, shared.Receiver, deployment.Version1_0_0, false, "") if err != nil { return cldf.ChangesetOutput{}, fmt.Errorf("failed to deploy program: %w", err) } - } else if cfg.ReceiverVersion != nil { + case cfg.ReceiverVersion != nil: // this block is for re-deploying with a new version receiverAddress, err = DeployAndMaybeSaveToAddressBook(e, chain, ab, ds, shared.Receiver, *cfg.ReceiverVersion, false, "") if err != nil { return cldf.ChangesetOutput{}, fmt.Errorf("failed to deploy program: %w", err) } - } else { + default: e.Logger.Infow("Using existing receiver", "addr", chainState.Receiver.String()) receiverAddress = chainState.Receiver } diff --git a/deployment/ccip/changeset/solana_v0_1_0/cs_set_ocr3.go b/deployment/ccip/changeset/solana_v0_1_0/cs_set_ocr3.go index fcf4e876755..9eb49329ad2 100644 --- a/deployment/ccip/changeset/solana_v0_1_0/cs_set_ocr3.go +++ b/deployment/ccip/changeset/solana_v0_1_0/cs_set_ocr3.go @@ -10,9 +10,10 @@ import ( cldf_solana "github.com/smartcontractkit/chainlink-deployments-framework/chain/solana" - cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment" proposeutils "github.com/smartcontractkit/cld-changesets/legacy/mcms/proposeutils" + cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment" + "github.com/smartcontractkit/mcms" "github.com/smartcontractkit/mcms/sdk" mcmsSolana "github.com/smartcontractkit/mcms/sdk/solana" diff --git a/deployment/ccip/changeset/solana_v0_1_0/cs_token_pool.go b/deployment/ccip/changeset/solana_v0_1_0/cs_token_pool.go index acc4d855ee4..388df093bcf 100644 --- a/deployment/ccip/changeset/solana_v0_1_0/cs_token_pool.go +++ b/deployment/ccip/changeset/solana_v0_1_0/cs_token_pool.go @@ -58,7 +58,7 @@ func appendTxs(instructions []solana.Instruction, tokenPool solana.PublicKey, po } // get diff of pool addresses -func poolDiff(existingPoolAddresses []solBaseTokenPool.RemoteAddress, newPoolAddresses []solBaseTokenPool.RemoteAddress) []solBaseTokenPool.RemoteAddress { +func poolDiff(existingPoolAddresses, newPoolAddresses []solBaseTokenPool.RemoteAddress) []solBaseTokenPool.RemoteAddress { var result []solBaseTokenPool.RemoteAddress // for every new address, check if it exists in the existing pool addresses for _, newAddr := range newPoolAddresses { @@ -78,8 +78,8 @@ func poolDiff(existingPoolAddresses []solBaseTokenPool.RemoteAddress, newPoolAdd // get pool pdas func getPoolPDAs( - solTokenPubKey solana.PublicKey, poolAddress solana.PublicKey, remoteChainSelector uint64, -) (poolConfigPDA solana.PublicKey, remoteChainConfigPDA solana.PublicKey) { + solTokenPubKey, poolAddress solana.PublicKey, remoteChainSelector uint64, +) (poolConfigPDA, remoteChainConfigPDA solana.PublicKey) { poolConfigPDA, _ = solTokenUtil.TokenPoolConfigAddress(solTokenPubKey, poolAddress) remoteChainConfigPDA, _, _ = solTokenUtil.TokenPoolChainConfigPDA(remoteChainSelector, solTokenPubKey, poolAddress) return poolConfigPDA, remoteChainConfigPDA @@ -280,7 +280,7 @@ func AddTokenPoolAndLookupTable(e cldf.Environment, cfg AddTokenPoolAndLookupTab if err != nil { return cldf.ChangesetOutput{}, fmt.Errorf("failed to add token pool lookup table: %w", err) } - err = addressBook.Merge(csOutput.AddressBook) //nolint:staticcheck // Addressbook is deprecated, but we still use it for the time being + err = addressBook.Merge(csOutput.AddressBook) if err != nil { return cldf.ChangesetOutput{}, fmt.Errorf("failed to merge address book: %w", err) } @@ -527,7 +527,8 @@ func SetupTokenPoolForRemoteChain(e cldf.Environment, cfg SetupTokenPoolForRemot if len(txns) > 0 { proposal, err := BuildProposalsForTxns( - e, cfg.SolChainSelector, "proposal to edit token pools in Solana", cfg.MCMS.MinDelay, txns) + e, cfg.SolChainSelector, "proposal to edit token pools in Solana", cfg.MCMS.MinDelay, txns, + ) if err != nil { return cldf.ChangesetOutput{}, fmt.Errorf("failed to build proposal: %w", err) } @@ -540,7 +541,7 @@ func SetupTokenPoolForRemoteChain(e cldf.Environment, cfg SetupTokenPoolForRemot } // checks if the evmChainSelector is supported for the given token and pool type -func isSupportedChain(chain cldf_solana.Chain, solTokenPubKey solana.PublicKey, solPoolAddress solana.PublicKey, evmChainSelector uint64) (bool, solTestTokenPool.ChainConfig, error) { +func isSupportedChain(chain cldf_solana.Chain, solTokenPubKey, solPoolAddress solana.PublicKey, evmChainSelector uint64) (bool, solTestTokenPool.ChainConfig, error) { var remoteChainConfigAccount solTestTokenPool.ChainConfig // check if this remote chain is already configured for this token remoteChainConfigPDA, _, err := solTokenUtil.TokenPoolChainConfigPDA(evmChainSelector, solTokenPubKey, solPoolAddress) diff --git a/deployment/ccip/changeset/solana_v0_1_0/utils.go b/deployment/ccip/changeset/solana_v0_1_0/utils.go index 2b615f43d66..1c1cc2fc267 100644 --- a/deployment/ccip/changeset/solana_v0_1_0/utils.go +++ b/deployment/ccip/changeset/solana_v0_1_0/utils.go @@ -16,9 +16,10 @@ import ( cldf_solana "github.com/smartcontractkit/chainlink-deployments-framework/chain/solana" cldfproposalutils "github.com/smartcontractkit/chainlink-deployments-framework/engine/cld/mcms/proposalutils" - cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment" proposeutils "github.com/smartcontractkit/cld-changesets/legacy/mcms/proposeutils" + cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment" + "github.com/smartcontractkit/chainlink/deployment/ccip/shared" "github.com/smartcontractkit/chainlink/deployment/ccip/shared/stateview" solanastateview "github.com/smartcontractkit/chainlink/deployment/ccip/shared/stateview/solana" diff --git a/deployment/ccip/changeset/solana_v0_1_1/cs_add_remote_chain.go b/deployment/ccip/changeset/solana_v0_1_1/cs_add_remote_chain.go index 7fe29897853..97bb0280c59 100644 --- a/deployment/ccip/changeset/solana_v0_1_1/cs_add_remote_chain.go +++ b/deployment/ccip/changeset/solana_v0_1_1/cs_add_remote_chain.go @@ -113,7 +113,6 @@ func AddRemoteChainToRouter(e cldf.Environment, cfg AddRemoteChainToRouterConfig txns, err := doAddRemoteChainToRouter(e, s, cfg, ab, ds) if err != nil { return cldf.ChangesetOutput{ - //nolint:staticcheck // SA1019: AddressBook is deprecated, migration to DataStore pending AddressBook: ab, DataStore: ds, }, err @@ -122,7 +121,8 @@ func AddRemoteChainToRouter(e cldf.Environment, cfg AddRemoteChainToRouterConfig // create proposals for ixns if len(txns) > 0 { proposal, err := BuildProposalsForTxnsWithConfig( - e, cfg.ChainSelector, "proposal to add remote chains to Solana", cfg.MCMS, txns) + e, cfg.ChainSelector, "proposal to add remote chains to Solana", cfg.MCMS, txns, + ) if err != nil { return cldf.ChangesetOutput{}, fmt.Errorf("failed to build proposal: %w", err) } @@ -133,7 +133,10 @@ func AddRemoteChainToRouter(e cldf.Environment, cfg AddRemoteChainToRouterConfig }, nil } - return cldf.ChangesetOutput{AddressBook: ab, DataStore: ds}, nil + return cldf.ChangesetOutput{ + AddressBook: ab, + DataStore: ds, + }, nil } func doAddRemoteChainToRouter( @@ -354,13 +357,17 @@ func AddRemoteChainToFeeQuoter(e cldf.Environment, cfg AddRemoteChainToFeeQuoter if err != nil { // skipped: doAddRemoteChainToFeeQuoter does not save any lane/multi-instance refs, // so the datastore needs no additional qualifier pass. - return cldf.ChangesetOutput{AddressBook: ab, DataStore: ds}, err //nolint:staticcheck // Phase 1 still returns the address book + return cldf.ChangesetOutput{ + AddressBook: ab, + DataStore: ds, + }, err } // create proposals for ixns if len(txns) > 0 { proposal, err := BuildProposalsForTxnsWithConfig( - e, cfg.ChainSelector, "proposal to add remote chains to Solana", cfg.MCMS, txns) + e, cfg.ChainSelector, "proposal to add remote chains to Solana", cfg.MCMS, txns, + ) if err != nil { return cldf.ChangesetOutput{}, fmt.Errorf("failed to build proposal: %w", err) } @@ -375,7 +382,10 @@ func AddRemoteChainToFeeQuoter(e cldf.Environment, cfg AddRemoteChainToFeeQuoter // skipped: doAddRemoteChainToFeeQuoter does not save any lane/multi-instance refs, // so the datastore needs no additional qualifier pass. - return cldf.ChangesetOutput{AddressBook: ab, DataStore: ds}, nil + return cldf.ChangesetOutput{ + AddressBook: ab, + DataStore: ds, + }, nil } func doAddRemoteChainToFeeQuoter( @@ -397,7 +407,8 @@ func doAddRemoteChainToFeeQuoter( chainState, shared.FeeQuoter, solana.PublicKey{}, - "") + "", + ) lookUpTableEntries := make([]solana.PublicKey, 0) authority := GetAuthorityForIxn( &e, @@ -544,7 +555,6 @@ func AddRemoteChainToOffRamp(e cldf.Environment, cfg AddRemoteChainToOffRampConf txns, err := doAddRemoteChainToOffRamp(e, s, cfg, ab, ds) if err != nil { return cldf.ChangesetOutput{ - //nolint:staticcheck // SA1019: AddressBook is deprecated, migration to DataStore pending AddressBook: ab, DataStore: ds, }, err @@ -553,7 +563,8 @@ func AddRemoteChainToOffRamp(e cldf.Environment, cfg AddRemoteChainToOffRampConf // create proposals for ixns if len(txns) > 0 { proposal, err := BuildProposalsForTxnsWithConfig( - e, cfg.ChainSelector, "proposal to add remote chains to Solana", cfg.MCMS, txns) + e, cfg.ChainSelector, "proposal to add remote chains to Solana", cfg.MCMS, txns, + ) if err != nil { return cldf.ChangesetOutput{}, fmt.Errorf("failed to build proposal: %w", err) } @@ -564,7 +575,10 @@ func AddRemoteChainToOffRamp(e cldf.Environment, cfg AddRemoteChainToOffRampConf }, nil } - return cldf.ChangesetOutput{AddressBook: ab, DataStore: ds}, nil + return cldf.ChangesetOutput{ + AddressBook: ab, + DataStore: ds, + }, nil } func doAddRemoteChainToOffRamp( @@ -586,7 +600,8 @@ func doAddRemoteChainToOffRamp( chainState, shared.OffRamp, solana.PublicKey{}, - "") + "", + ) lookUpTableEntries := make([]solana.PublicKey, 0) authority := GetAuthorityForIxn( &e, @@ -708,7 +723,8 @@ func extendLookupTable(e cldf.Environment, chain cldf_solana.Chain, offRampID so addresses, err := solCommonUtil.GetAddressLookupTable( e.GetContext(), chain.Client, - addressLookupTable) + addressLookupTable, + ) if err != nil { return fmt.Errorf("failed to get address lookup table: %w", err) } diff --git a/deployment/ccip/changeset/solana_v0_1_1/cs_build_solana.go b/deployment/ccip/changeset/solana_v0_1_1/cs_build_solana.go index 2fe277f2e96..c111924a581 100644 --- a/deployment/ccip/changeset/solana_v0_1_1/cs_build_solana.go +++ b/deployment/ccip/changeset/solana_v0_1_1/cs_build_solana.go @@ -3,6 +3,7 @@ package solana import ( "bufio" "bytes" + "context" "errors" "fmt" "os" @@ -69,7 +70,7 @@ type BuildSolanaConfig struct { // Run a command in a specific directory func RunCommand(command string, args []string, workDir string) (string, error) { - cmd := exec.Command(command, args...) + cmd := exec.CommandContext(context.Background(), command, args...) cmd.Dir = workDir var stdout, stderr bytes.Buffer cmd.Stdout = &stdout @@ -150,7 +151,7 @@ func replaceKeysForUpgrade(e cldf.Environment, keys map[cldf.ContractType]string // Replace declare_id!("..."); with the new key updatedContent := regexp.MustCompile(`declare_id!\(".*?"\);`).ReplaceAllString(string(content), fmt.Sprintf(`declare_id!("%s");`, key)) - err = os.WriteFile(fullPath, []byte(updatedContent), 0600) //nolint:gosec // G703 + err = os.WriteFile(fullPath, []byte(updatedContent), 0o600) //nolint:gosec // G703: false positive, path is within the freshly cloned repo dir if err != nil { return fmt.Errorf("failed to write updated keys to file %s: %w", fullPath, err) } @@ -193,7 +194,7 @@ func syncRouterAndCommon() error { updatedContent := declareRegex.ReplaceAllString(string(commonContent), declareID) - return os.WriteFile(commonFile, []byte(updatedContent), 0600) //nolint:gosec // G703 + return os.WriteFile(commonFile, []byte(updatedContent), 0o600) //nolint:gosec // G703: false positive, path is within the freshly cloned repo dir } func generateVanityKeys(e cldf.Environment, keys map[cldf.ContractType]string) error { @@ -251,7 +252,7 @@ func generateVanityKeys(e cldf.Environment, keys map[cldf.ContractType]string) e return nil } -func copyFile(srcFile string, destDir string) error { +func copyFile(srcFile, destDir string) error { output, err := RunCommand("cp", []string{srcFile, destDir}, ".") if err != nil { return fmt.Errorf("failed to copy file: %s %w", output, err) diff --git a/deployment/ccip/changeset/solana_v0_1_1/cs_deploy_chain.go b/deployment/ccip/changeset/solana_v0_1_1/cs_deploy_chain.go index 740ada75fc7..7f15662dc52 100644 --- a/deployment/ccip/changeset/solana_v0_1_1/cs_deploy_chain.go +++ b/deployment/ccip/changeset/solana_v0_1_1/cs_deploy_chain.go @@ -368,7 +368,8 @@ func deployChainContractsSolana( // FEE QUOTER DEPLOY feeQuoterAddress, fqJustDeployed, batches, err := resolveProgram( - e, chain, ab, ds, config, batches, shared.FeeQuoter, chainState.FeeQuoter, config.UpgradeConfig.NewFeeQuoterVersion) + e, chain, ab, ds, config, batches, shared.FeeQuoter, chainState.FeeQuoter, config.UpgradeConfig.NewFeeQuoterVersion, + ) if err != nil { return batches, err } @@ -378,7 +379,8 @@ func deployChainContractsSolana( // ROUTER DEPLOY ccipRouterProgram, routerJustDeployed, batches, err := resolveProgram( - e, chain, ab, ds, config, batches, shared.Router, chainState.Router, config.UpgradeConfig.NewRouterVersion) + e, chain, ab, ds, config, batches, shared.Router, chainState.Router, config.UpgradeConfig.NewRouterVersion, + ) if err != nil { return batches, err } @@ -392,15 +394,15 @@ func deployChainContractsSolana( // track that in offRampJustDeployed so the initialize pass below knows whether it needs setup. var offRampAddress solana.PublicKey offRampJustDeployed := false - //nolint:gocritic // this is a false positive, we need to check if the address is zero - if chainState.OffRamp.IsZero() { + switch { + case chainState.OffRamp.IsZero(): // deploy offramp offRampAddress, err = DeployAndMaybeSaveToAddressBook(e, chain, ab, ds, shared.OffRamp, deployment.Version1_0_0, false, "") if err != nil { return batches, fmt.Errorf("failed to deploy program: %w", err) } offRampJustDeployed = true - } else if config.UpgradeConfig.NewOffRampVersion != nil { + case config.UpgradeConfig.NewOffRampVersion != nil: tv := cldf.NewTypeAndVersion(shared.OffRamp, *config.UpgradeConfig.NewOffRampVersion) existingAddresses, err := e.ExistingAddresses.AddressesForChain(chain.Selector) if err != nil { @@ -446,7 +448,7 @@ func deployChainContractsSolana( } batches = appendBatchOperation(batches, chain.Selector, newTxns) } - } else { + default: e.Logger.Infow("Using existing offramp", "addr", chainState.OffRamp.String()) offRampAddress = chainState.OffRamp } @@ -456,7 +458,8 @@ func deployChainContractsSolana( // RMN REMOTE DEPLOY rmnRemoteAddress, rmnJustDeployed, batches, err := resolveProgram( - e, chain, ab, ds, config, batches, shared.RMNRemote, chainState.RMNRemote, config.UpgradeConfig.NewRMNRemoteVersion) + e, chain, ab, ds, config, batches, shared.RMNRemote, chainState.RMNRemote, config.UpgradeConfig.NewRMNRemoteVersion, + ) if err != nil { return batches, err } @@ -517,7 +520,8 @@ func deployChainContractsSolana( solana.Token2022ProgramID, solana.TokenProgramID, solana.SPLAssociatedTokenAccountProgramID, - }) + }, + ) if err != nil { return batches, fmt.Errorf("failed to create address lookup table: %w", err) } @@ -547,8 +551,8 @@ func deployChainContractsSolana( config.BurnMintTokenPoolMetadata = []string{shared.CLLMetadata} } for _, metadata := range config.BurnMintTokenPoolMetadata { - //nolint:gocritic // this is a false positive, we need to check if the address is zero - if chainState.BurnMintTokenPools[metadata].IsZero() { + switch { + case chainState.BurnMintTokenPools[metadata].IsZero(): e.Logger.Infow("Deploying new burn mint token pool", "metadata", metadata) burnMintTokenPool, err := DeployAndMaybeSaveToAddressBook(e, chain, ab, ds, shared.BurnMintTokenPool, deployment.Version1_0_0, false, metadata) if err != nil { @@ -557,7 +561,7 @@ func deployChainContractsSolana( burnMintTokenPools = append(burnMintTokenPools, burnMintTokenPool) // Solana pool programs are keyed by pool-set metadata (not token), so that is their // datastore qualifier. - } else if config.UpgradeConfig.NewBurnMintTokenPoolVersion != nil { + case config.UpgradeConfig.NewBurnMintTokenPoolVersion != nil: e.Logger.Infow("Upgrading existing burn mint token pool", "addr", chainState.BurnMintTokenPools[metadata].String()) burnMintTokenPool := chainState.BurnMintTokenPools[metadata] if metadata != shared.CLLMetadata { @@ -583,7 +587,7 @@ func deployChainContractsSolana( } batches = appendBatchOperation(batches, chain.Selector, newTxns) burnMintTokenPools = append(burnMintTokenPools, burnMintTokenPool) - } else { + default: e.Logger.Infow("Using existing burn mint token pool", "addr", chainState.BurnMintTokenPools[metadata].String()) burnMintTokenPools = append(burnMintTokenPools, chainState.BurnMintTokenPools[metadata]) } @@ -594,8 +598,8 @@ func deployChainContractsSolana( config.LockReleaseTokenPoolMetadata = []string{shared.CLLMetadata} } for _, metadata := range config.LockReleaseTokenPoolMetadata { - //nolint:gocritic // this is a false positive, we need to check if the address is zero - if chainState.LockReleaseTokenPools[metadata].IsZero() { + switch { + case chainState.LockReleaseTokenPools[metadata].IsZero(): e.Logger.Infow("Deploying new lock release token pool", "metadata", metadata) lockReleaseTokenPool, err := DeployAndMaybeSaveToAddressBook(e, chain, ab, ds, shared.LockReleaseTokenPool, deployment.Version1_0_0, false, metadata) if err != nil { @@ -604,7 +608,7 @@ func deployChainContractsSolana( lockReleaseTokenPools = append(lockReleaseTokenPools, lockReleaseTokenPool) // Solana pool programs are keyed by pool-set metadata (not token), so that is their // datastore qualifier. - } else if config.UpgradeConfig.NewLockReleaseTokenPoolVersion != nil { + case config.UpgradeConfig.NewLockReleaseTokenPoolVersion != nil: e.Logger.Infow("Upgrading existing lock release token pool", "addr", chainState.LockReleaseTokenPools[metadata].String()) lockReleaseTokenPool := chainState.LockReleaseTokenPools[metadata] if metadata != shared.CLLMetadata { @@ -630,7 +634,7 @@ func deployChainContractsSolana( } lockReleaseTokenPools = append(lockReleaseTokenPools, lockReleaseTokenPool) batches = appendBatchOperation(batches, chain.Selector, newTxns) - } else { + default: e.Logger.Infow("Using existing lock release token pool", "addr", chainState.LockReleaseTokenPools[metadata].String()) lockReleaseTokenPools = append(lockReleaseTokenPools, chainState.LockReleaseTokenPools[metadata]) } @@ -1157,13 +1161,12 @@ func generateExtendIxn( return nil, nil } extraBytes := newProgramSize - programDataSize - if extraBytes > math.MaxUint32 { - return nil, fmt.Errorf("extra bytes %d exceeds maximum value %d", extraBytes, math.MaxUint32) + if extraBytes > math.MaxUint32-1024 { + return nil, fmt.Errorf("extra bytes %d exceeds maximum value %d", extraBytes, math.MaxUint32-1024) } // https://github.com/solana-labs/solana/blob/7700cb3128c1f19820de67b81aa45d18f73d2ac0/sdk/program/src/loader_upgradeable_instruction.rs#L146 - data := binary.LittleEndian.AppendUint32([]byte{}, 6) // 4-byte Extend instruction identifier - //nolint:gosec // G115 we check for overflow above - data = binary.LittleEndian.AppendUint32(data, uint32(extraBytes+1024)) // add some padding + data := binary.LittleEndian.AppendUint32([]byte{}, 6) // 4-byte Extend instruction identifier + data = binary.LittleEndian.AppendUint32(data, uint32(extraBytes+1024)) //nolint:gosec // G115: guard above covers the 1024 bytes of padding keys := solana.AccountMetaSlice{ solana.NewAccountMeta(programDataAccount, true, false), // Program data account (writable) @@ -1325,7 +1328,8 @@ func CloseBuffersChangeset(e cldf.Environment, cfg CloseBuffersConfig) (cldf.Cha } if len(txns) > 0 { proposal, err := BuildProposalsForTxnsWithConfig( - e, cfg.ChainSelector, "proposal to close existing programs", cfg.MCMS, txns) + e, cfg.ChainSelector, "proposal to close existing programs", cfg.MCMS, txns, + ) if err != nil { return cldf.ChangesetOutput{}, fmt.Errorf("failed to build proposal: %w", err) } diff --git a/deployment/ccip/changeset/solana_v0_1_1/cs_deploy_chain_test.go b/deployment/ccip/changeset/solana_v0_1_1/cs_deploy_chain_test.go index 3ec0735213e..1bf47fb7d11 100644 --- a/deployment/ccip/changeset/solana_v0_1_1/cs_deploy_chain_test.go +++ b/deployment/ccip/changeset/solana_v0_1_1/cs_deploy_chain_test.go @@ -577,6 +577,7 @@ func TestIDL(t *testing.T) { }, ), }) + require.NoError(t, err) // Close IDL e, _, err = commonchangeset.ApplyChangesets(t, e, []commonchangeset.ConfiguredChangeSet{ diff --git a/deployment/ccip/changeset/solana_v0_1_1/cs_e2e.go b/deployment/ccip/changeset/solana_v0_1_1/cs_e2e.go index 41e444c99bd..56198918ca1 100644 --- a/deployment/ccip/changeset/solana_v0_1_1/cs_e2e.go +++ b/deployment/ccip/changeset/solana_v0_1_1/cs_e2e.go @@ -40,11 +40,11 @@ type E2ETokenPoolConfig struct { func E2ETokenPool(e cldf.Environment, cfg E2ETokenPoolConfig) (cldf.ChangesetOutput, error) { finalOutput := cldf.ChangesetOutput{} - finalOutput.AddressBook = cldf.NewMemoryAddressBook() //nolint:staticcheck // Addressbook is deprecated, but we still use it for the time being + finalOutput.AddressBook = cldf.NewMemoryAddressBook() addressBookToRemove := cldf.NewMemoryAddressBook() defer func(e cldf.Environment) { e.Logger.Info("SolanaE2ETokenPool changeset completed") - e.Logger.Info("Final output: ", finalOutput.AddressBook) //nolint:staticcheck // Addressbook is deprecated, but we still use it for the time being + e.Logger.Info("Final output: ", finalOutput.AddressBook) }(e) // if mcms config is not provided, use the mcms config from one of the other configs if cfg.MCMS == nil { @@ -110,7 +110,7 @@ func ProcessConfig[T any]( return fmt.Errorf("failed to merge changeset output: %w", err) } - if ab := output.AddressBook; ab != nil { //nolint:staticcheck // Addressbook is deprecated, but we still use it for the time being + if ab := output.AddressBook; ab != nil { if err := tempRemoveBook.Merge(ab); err != nil { return fmt.Errorf("failed to merge into temp: %w", err) } diff --git a/deployment/ccip/changeset/solana_v0_1_1/cs_idl.go b/deployment/ccip/changeset/solana_v0_1_1/cs_idl.go index 764420710aa..0fe6a02c765 100644 --- a/deployment/ccip/changeset/solana_v0_1_1/cs_idl.go +++ b/deployment/ccip/changeset/solana_v0_1_1/cs_idl.go @@ -5,7 +5,6 @@ import ( "encoding/json" "errors" "fmt" - "math" "os" "path/filepath" "strings" @@ -287,7 +286,7 @@ func RepoSetup(e cldf.Environment, chain cldfsolana.Chain, gitCommitSha string) } // update IDL with program ID -func updateIDL(e cldf.Environment, idlFile string, programID string) error { +func updateIDL(e cldf.Environment, idlFile, programID string) error { e.Logger.Debug("Reading IDL") idlBytes, err := os.ReadFile(idlFile) if err != nil { @@ -310,14 +309,14 @@ func updateIDL(e cldf.Environment, idlFile string, programID string) error { } e.Logger.Debug("Writing updated IDL") // Write updated IDL back to file - if err := os.WriteFile(idlFile, updatedIDLBytes, 0600); err != nil { + if err := os.WriteFile(idlFile, updatedIDLBytes, 0o600); err != nil { return fmt.Errorf("failed to write updated IDL: %w", err) } return nil } // get IDL file and update with program ID -func getIDL(e cldf.Environment, programsPath, programID string, programName string) (string, error) { +func getIDL(e cldf.Environment, programsPath, programID, programName string) (string, error) { idlFile := filepath.Join(programsPath, programName+".json") if _, err := os.Stat(idlFile); err != nil { return "", fmt.Errorf("idl file not found: %w", err) @@ -417,13 +416,13 @@ const DefaultIDLMaxSize = 10000 // This is using the max value of creating an ID // Number ids of the operations: copied from https://github.com/solana-foundation/anchor/blob/v0.29.0/lang/src/idl.rs#L36 const ( - IdlInstructionCreate int = iota // One time initializer for creating the program's idl account. - IdlInstructionCreateBuffer // Creates a new IDL account buffer. Can be called several times. - IdlInstructionWrite // Appends the given data to the end of the idl account buffer. - IdlInstructionSetBuffer // Sets a new data buffer for the IdlAccount. - IdlInstructionSetAuthority // Sets a new authority on the IdlAccount. - IdlInstructionClose // Closes the IDL pda Account - IdlInstructionResize // Increases account size for accounts that need over 10kb. + IdlInstructionCreate byte = iota // One time initializer for creating the program's idl account. + IdlInstructionCreateBuffer // Creates a new IDL account buffer. Can be called several times. + IdlInstructionWrite // Appends the given data to the end of the idl account buffer. + IdlInstructionSetBuffer // Sets a new data buffer for the IdlAccount. + IdlInstructionSetAuthority // Sets a new authority on the IdlAccount. + IdlInstructionClose // Closes the IDL pda Account + IdlInstructionResize // Increases account size for accounts that need over 10kb. ) // changeset to set idl authority for a program to timelock @@ -594,13 +593,10 @@ func getAffectedPrograms(e cldf.Environment, c IDLConfig, chainState solanastate } // Build instruction to interact with Anchor IDL using the list of ids above for each message -func buildIdlInstruction(programID solana.PublicKey, accountsForIx solana.AccountMetaSlice, idlInstruction int, params []byte) (solana.GenericInstruction, error) { +func buildIdlInstruction(programID solana.PublicKey, accountsForIx solana.AccountMetaSlice, idlInstruction byte, params []byte) (solana.GenericInstruction, error) { data := binary.LittleEndian.AppendUint64([]byte{}, IdlIxTag) // 8-byte Extend instruction identifier - if idlInstruction > math.MaxUint8 { - return solana.GenericInstruction{}, fmt.Errorf("invalid idl instruction: does not fit in byte: %d", idlInstruction) - } - data = append(data, byte(idlInstruction)) //nolint:gosec //G115 // Append the numeric ID of the operation - data = append(data, params...) // Append any additional parameters + data = append(data, idlInstruction) // Append the numeric ID of the operation + data = append(data, params...) // Append any additional parameters instruction := solana.NewInstruction( programID, @@ -622,7 +618,7 @@ func calculateAuthority(e cldf.Environment, c IDLConfig) (solana.PublicKey, erro return authority, err } -func getTxIfMCMSExecuteIfNot(e cldf.Environment, programID string, programName string, c IDLConfig, instruction solana.GenericInstruction) (*mcmsTypes.Transaction, error) { +func getTxIfMCMSExecuteIfNot(e cldf.Environment, programID, programName string, c IDLConfig, instruction solana.GenericInstruction) (*mcmsTypes.Transaction, error) { if c.MCMS != nil { upgradeTx, err := BuildMCMSTxn(&instruction, programID, cldf.ContractType(programName)) if err != nil { @@ -697,7 +693,7 @@ func getAccountsForCreateIdlInstruction( return accounts, solana.GenericInstruction{}, nil } -func getAccountsForSetBufferIdlInstruction(e cldf.Environment, programID solana.PublicKey, buffer solana.PublicKey, authority solana.PublicKey) (solana.AccountMetaSlice, solana.GenericInstruction, error) { +func getAccountsForSetBufferIdlInstruction(e cldf.Environment, programID, buffer, authority solana.PublicKey) (solana.AccountMetaSlice, solana.GenericInstruction, error) { idlAddress, err := getIDLAddress(e, programID) if err != nil { return nil, solana.GenericInstruction{}, fmt.Errorf("error getting idl address for %s: %w", programID.String(), err) @@ -806,7 +802,7 @@ func closeIdlInstruction(e cldf.Environment, programID solana.PublicKey, program return getTxIfMCMSExecuteIfNot(e, programID.String(), programName, c, instruction) } -func getAccountsForCloseIdlInstruction(e cldf.Environment, programID solana.PublicKey, authority solana.PublicKey, spillAddress solana.PublicKey) (solana.AccountMetaSlice, error) { +func getAccountsForCloseIdlInstruction(e cldf.Environment, programID, authority, spillAddress solana.PublicKey) (solana.AccountMetaSlice, error) { idlAddress, err := getIDLAddress(e, programID) accounts := solana.AccountMetaSlice{ solana.Meta(idlAddress).WRITE(), @@ -833,7 +829,7 @@ func setAuthorityIDLIx(e cldf.Environment, programID solana.PublicKey, programNa return getTxIfMCMSExecuteIfNot(e, programID.String(), programName, c, instruction) } -func getAccountsForSetAuthorityIdlInstruction(e cldf.Environment, programID solana.PublicKey, authority solana.PublicKey) (solana.AccountMetaSlice, error) { +func getAccountsForSetAuthorityIdlInstruction(e cldf.Environment, programID, authority solana.PublicKey) (solana.AccountMetaSlice, error) { idlAddress, err := getIDLAddress(e, programID) if err != nil { return nil, fmt.Errorf("error getting idl address for %s: %w", programID.String(), err) diff --git a/deployment/ccip/changeset/solana_v0_1_1/cs_ops.go b/deployment/ccip/changeset/solana_v0_1_1/cs_ops.go index 742570b407c..d9fb673388f 100644 --- a/deployment/ccip/changeset/solana_v0_1_1/cs_ops.go +++ b/deployment/ccip/changeset/solana_v0_1_1/cs_ops.go @@ -133,7 +133,8 @@ func UpdateOffRampRefAddresses( chainState, shared.OffRamp, solana.PublicKey{}, - "") + "", + ) authority := GetAuthorityForIxn( &e, chain, @@ -164,7 +165,8 @@ func UpdateOffRampRefAddresses( return cldf.ChangesetOutput{}, fmt.Errorf("failed to create transaction: %w", err) } proposal, err := BuildProposalsForTxnsWithConfig( - e, config.ChainSelector, "proposal to UpdateOffRampRefAddresses in Solana", config.MCMS, []mcmsTypes.Transaction{*tx}) + e, config.ChainSelector, "proposal to UpdateOffRampRefAddresses in Solana", config.MCMS, []mcmsTypes.Transaction{*tx}, + ) if err != nil { return cldf.ChangesetOutput{}, fmt.Errorf("failed to build proposal: %w", err) } @@ -253,7 +255,8 @@ func SetUpgradeAuthorityChangeset( tx, err := BuildMCMSTxn( ixn, solana.BPFLoaderUpgradeableProgramID.String(), - cldf.ContractType(solana.BPFLoaderUpgradeableProgramID.String())) + cldf.ContractType(solana.BPFLoaderUpgradeableProgramID.String()), + ) if err != nil { return cldf.ChangesetOutput{}, fmt.Errorf("failed to create transaction: %w", err) } @@ -262,7 +265,8 @@ func SetUpgradeAuthorityChangeset( } if len(mcmsTxns) > 0 { proposal, err := BuildProposalsForTxnsWithConfig( - e, config.ChainSelector, "proposal to SetUpgradeAuthority in Solana", config.MCMS, mcmsTxns) + e, config.ChainSelector, "proposal to SetUpgradeAuthority in Solana", config.MCMS, mcmsTxns, + ) if err != nil { return cldf.ChangesetOutput{}, fmt.Errorf("failed to build proposal: %w", err) } @@ -274,7 +278,7 @@ func SetUpgradeAuthorityChangeset( } // SetUpgradeAuthority creates a transaction to set the upgrade authority for a program -func SetUpgradeAuthority(e *cldf.Environment, programID solana.PublicKey, currentUpgradeAuthority solana.PublicKey, newUpgradeAuthority solana.PublicKey, isBuffer bool) solana.Instruction { +func SetUpgradeAuthority(e *cldf.Environment, programID, currentUpgradeAuthority, newUpgradeAuthority solana.PublicKey, isBuffer bool) solana.Instruction { e.Logger.Infow("Setting upgrade authority", "programID", programID.String(), "currentUpgradeAuthority", currentUpgradeAuthority.String(), "newUpgradeAuthority", newUpgradeAuthority.String()) // Buffers use the program account as the program data account programDataSlice := solana.NewAccountMeta(programID, true, false) @@ -356,7 +360,8 @@ func SetFeeAggregator(e cldf.Environment, cfg SetFeeAggregatorConfig) (cldf.Chan chainState, shared.Router, solana.PublicKey{}, - "") + "", + ) runSafely(func() { solRouter.SetProgramID(chainState.Router) @@ -385,7 +390,8 @@ func SetFeeAggregator(e cldf.Environment, cfg SetFeeAggregatorConfig) (cldf.Chan return cldf.ChangesetOutput{}, fmt.Errorf("failed to create transaction: %w", err) } proposal, err := BuildProposalsForTxnsWithConfig( - e, cfg.ChainSelector, "proposal to SetFeeAggregator in Solana", cfg.MCMS, []mcmsTypes.Transaction{*tx}) + e, cfg.ChainSelector, "proposal to SetFeeAggregator in Solana", cfg.MCMS, []mcmsTypes.Transaction{*tx}, + ) if err != nil { return cldf.ChangesetOutput{}, fmt.Errorf("failed to build proposal: %w", err) } @@ -445,19 +451,19 @@ func DeployReceiverForTest(e cldf.Environment, cfg DeployForTestConfig) (cldf.Ch var receiverAddress solana.PublicKey if !cfg.IsUpgrade { - //nolint:gocritic // this is a false positive, we need to check if the address is zero - if chainState.Receiver.IsZero() { + switch { + case chainState.Receiver.IsZero(): receiverAddress, err = DeployAndMaybeSaveToAddressBook(e, chain, ab, ds, shared.Receiver, deployment.Version1_0_0, false, "") if err != nil { return cldf.ChangesetOutput{}, fmt.Errorf("failed to deploy program: %w", err) } - } else if cfg.ReceiverVersion != nil { + case cfg.ReceiverVersion != nil: // this block is for re-deploying with a new version receiverAddress, err = DeployAndMaybeSaveToAddressBook(e, chain, ab, ds, shared.Receiver, *cfg.ReceiverVersion, false, "") if err != nil { return cldf.ChangesetOutput{}, fmt.Errorf("failed to deploy program: %w", err) } - } else { + default: e.Logger.Infow("Using existing receiver", "addr", chainState.Receiver.String()) receiverAddress = chainState.Receiver } @@ -593,21 +599,24 @@ func SetDefaultCodeVersion(e cldf.Environment, cfg SetDefaultCodeVersionConfig) chainState, shared.Router, solana.PublicKey{}, - "") + "", + ) offRampUsingMCMS := solanastateview.IsSolanaProgramOwnedByTimelock( &e, chain, chainState, shared.OffRamp, solana.PublicKey{}, - "") + "", + ) feeQuoterUsingMCMS := solanastateview.IsSolanaProgramOwnedByTimelock( &e, chain, chainState, shared.FeeQuoter, solana.PublicKey{}, - "") + "", + ) txns := make([]mcmsTypes.Transaction, 0) ixns := make([]solana.Instruction, 0) authority := GetAuthorityForIxn( @@ -616,7 +625,8 @@ func SetDefaultCodeVersion(e cldf.Environment, cfg SetDefaultCodeVersionConfig) chainState, shared.Router, solana.PublicKey{}, - "") + "", + ) runSafely(func() { solRouter.SetProgramID(chainState.Router) }) @@ -646,7 +656,8 @@ func SetDefaultCodeVersion(e cldf.Environment, cfg SetDefaultCodeVersionConfig) chainState, shared.OffRamp, solana.PublicKey{}, - "") + "", + ) runSafely(func() { solOffRamp.SetProgramID(chainState.OffRamp) }) @@ -675,7 +686,8 @@ func SetDefaultCodeVersion(e cldf.Environment, cfg SetDefaultCodeVersionConfig) chainState, shared.FeeQuoter, solana.PublicKey{}, - "") + "", + ) runSafely(func() { solFeeQuoter.SetProgramID(chainState.FeeQuoter) }) @@ -706,7 +718,8 @@ func SetDefaultCodeVersion(e cldf.Environment, cfg SetDefaultCodeVersionConfig) if len(txns) > 0 { proposal, err := BuildProposalsForTxnsWithConfig( - e, cfg.ChainSelector, "proposal to SetDefaultCodeVersion in Solana", cfg.MCMS, txns) + e, cfg.ChainSelector, "proposal to SetDefaultCodeVersion in Solana", cfg.MCMS, txns, + ) if err != nil { return cldf.ChangesetOutput{}, fmt.Errorf("failed to build proposal: %w", err) } @@ -756,14 +769,16 @@ func UpdateSvmChainSelector(e cldf.Environment, cfg UpdateSvmChainSelectorConfig chainState, shared.Router, solana.PublicKey{}, - "") + "", + ) offRampUsingMCMS := solanastateview.IsSolanaProgramOwnedByTimelock( &e, chain, chainState, shared.OffRamp, solana.PublicKey{}, - "") + "", + ) txns := make([]mcmsTypes.Transaction, 0) ixns := make([]solana.Instruction, 0) authority := GetAuthorityForIxn( @@ -772,7 +787,8 @@ func UpdateSvmChainSelector(e cldf.Environment, cfg UpdateSvmChainSelectorConfig chainState, shared.Router, solana.PublicKey{}, - "") + "", + ) runSafely(func() { solRouter.SetProgramID(chainState.Router) }) @@ -802,7 +818,8 @@ func UpdateSvmChainSelector(e cldf.Environment, cfg UpdateSvmChainSelectorConfig chainState, shared.OffRamp, solana.PublicKey{}, - "") + "", + ) runSafely(func() { solOffRamp.SetProgramID(chainState.OffRamp) }) @@ -833,7 +850,8 @@ func UpdateSvmChainSelector(e cldf.Environment, cfg UpdateSvmChainSelectorConfig if len(txns) > 0 { proposal, err := BuildProposalsForTxnsWithConfig( - e, cfg.OldChainSelector, "proposal to UpdateSvmChainSelector in Solana", cfg.MCMS, txns) + e, cfg.OldChainSelector, "proposal to UpdateSvmChainSelector in Solana", cfg.MCMS, txns, + ) if err != nil { return cldf.ChangesetOutput{}, fmt.Errorf("failed to build proposal: %w", err) } @@ -877,7 +895,8 @@ func UpdateEnableManualExecutionAfter(e cldf.Environment, cfg UpdateEnableManual chainState, shared.OffRamp, solana.PublicKey{}, - "") + "", + ) txns := make([]mcmsTypes.Transaction, 0) ixns := make([]solana.Instruction, 0) authority := GetAuthorityForIxn( @@ -886,7 +905,8 @@ func UpdateEnableManualExecutionAfter(e cldf.Environment, cfg UpdateEnableManual chainState, shared.OffRamp, solana.PublicKey{}, - "") + "", + ) runSafely(func() { solOffRamp.SetProgramID(chainState.OffRamp) }) @@ -917,7 +937,8 @@ func UpdateEnableManualExecutionAfter(e cldf.Environment, cfg UpdateEnableManual if len(txns) > 0 { proposal, err := BuildProposalsForTxnsWithConfig( - e, cfg.ChainSelector, "proposal to UpdateEnableManualExecutionAfter in Solana", cfg.MCMS, txns) + e, cfg.ChainSelector, "proposal to UpdateEnableManualExecutionAfter in Solana", cfg.MCMS, txns, + ) if err != nil { return cldf.ChangesetOutput{}, fmt.Errorf("failed to build proposal: %w", err) } @@ -979,7 +1000,8 @@ func ConfigureCCIPVersion(e cldf.Environment, cfg ConfigureCCIPVersionConfig) (c chainState, shared.Router, solana.PublicKey{}, - "") + "", + ) txns := make([]mcmsTypes.Transaction, 0) ixns := make([]solana.Instruction, 0) authority := GetAuthorityForIxn( @@ -988,7 +1010,8 @@ func ConfigureCCIPVersion(e cldf.Environment, cfg ConfigureCCIPVersionConfig) (c chainState, shared.Router, solana.PublicKey{}, - "") + "", + ) runSafely(func() { solRouter.SetProgramID(chainState.Router) }) @@ -1036,7 +1059,8 @@ func ConfigureCCIPVersion(e cldf.Environment, cfg ConfigureCCIPVersionConfig) (c if len(txns) > 0 { proposal, err := BuildProposalsForTxnsWithConfig( - e, cfg.ChainSelector, "proposal to ConfigureCCIPVersion in Solana", cfg.MCMS, txns) + e, cfg.ChainSelector, "proposal to ConfigureCCIPVersion in Solana", cfg.MCMS, txns, + ) if err != nil { return cldf.ChangesetOutput{}, fmt.Errorf("failed to build proposal: %w", err) } @@ -1079,7 +1103,8 @@ func RemoveOffRamp(e cldf.Environment, cfg RemoveOffRampConfig) (cldf.ChangesetO chainState, shared.Router, solana.PublicKey{}, - "") + "", + ) txns := make([]mcmsTypes.Transaction, 0) ixns := make([]solana.Instruction, 0) authority := GetAuthorityForIxn( @@ -1088,7 +1113,8 @@ func RemoveOffRamp(e cldf.Environment, cfg RemoveOffRampConfig) (cldf.ChangesetO chainState, shared.Router, solana.PublicKey{}, - "") + "", + ) runSafely(func() { solRouter.SetProgramID(chainState.Router) }) @@ -1122,7 +1148,8 @@ func RemoveOffRamp(e cldf.Environment, cfg RemoveOffRampConfig) (cldf.ChangesetO if len(txns) > 0 { proposal, err := BuildProposalsForTxnsWithConfig( - e, cfg.ChainSelector, "proposal to RemoveOffRamp in Solana", cfg.MCMS, txns) + e, cfg.ChainSelector, "proposal to RemoveOffRamp in Solana", cfg.MCMS, txns, + ) if err != nil { return cldf.ChangesetOutput{}, fmt.Errorf("failed to build proposal: %w", err) } diff --git a/deployment/ccip/changeset/solana_v0_1_1/cs_solana_token.go b/deployment/ccip/changeset/solana_v0_1_1/cs_solana_token.go index 99f78d84ca1..76933fb330d 100644 --- a/deployment/ccip/changeset/solana_v0_1_1/cs_solana_token.go +++ b/deployment/ccip/changeset/solana_v0_1_1/cs_solana_token.go @@ -388,7 +388,8 @@ func SetTokenAuthority(e cldf.Environment, cfg SetTokenAuthorityConfig) (cldf.Ch if len(mcmsTxs) > 0 { proposal, err := BuildProposalsForTxnsWithConfig( - e, cfg.ChainSelector, "proposal to SetTokenAuthority in Solana", cfg.MCMS, mcmsTxs) + e, cfg.ChainSelector, "proposal to SetTokenAuthority in Solana", cfg.MCMS, mcmsTxs, + ) if err != nil { return cldf.ChangesetOutput{}, fmt.Errorf("failed to build proposal: %w", err) } @@ -514,7 +515,8 @@ func UploadTokenMetadata(e cldf.Environment, cfg UploadTokenMetadataConfig) (cld } e.Logger.Infow("Updating token metadata authority", "metadataPDA", metadataPDA, "authority", mintMetadata.UpdateAuthority, "data", newData) instruction, err := modifyTokenMetadataIx( - metadataPDA, mintMetadata.UpdateAuthority, &newUpdateAuthority, &newData) + metadataPDA, mintMetadata.UpdateAuthority, &newUpdateAuthority, &newData, + ) if err != nil { return cldf.ChangesetOutput{}, fmt.Errorf("error generating modify metadata ix: %w", err) } @@ -548,7 +550,8 @@ func modifyTokenMetadataIx( ix := tokenMetadata.NewUpdateMetadataAccountV2Instruction( args, metadataPDA, - authority).Build() + authority, + ).Build() data, err := ix.Data() if err != nil { return solana.GenericInstruction{}, fmt.Errorf("error building update metadata account data: %w", err) diff --git a/deployment/ccip/changeset/solana_v0_1_1/cs_token_pool.go b/deployment/ccip/changeset/solana_v0_1_1/cs_token_pool.go index 0057d85fc5a..21130b0016c 100644 --- a/deployment/ccip/changeset/solana_v0_1_1/cs_token_pool.go +++ b/deployment/ccip/changeset/solana_v0_1_1/cs_token_pool.go @@ -87,7 +87,7 @@ func appendTxs(instructions []solana.Instruction, tokenPool solana.PublicKey, po } // get diff of pool addresses -func poolDiff(existingPoolAddresses []solBaseTokenPool.RemoteAddress, newPoolAddresses []solBaseTokenPool.RemoteAddress) []solBaseTokenPool.RemoteAddress { +func poolDiff(existingPoolAddresses, newPoolAddresses []solBaseTokenPool.RemoteAddress) []solBaseTokenPool.RemoteAddress { var result []solBaseTokenPool.RemoteAddress // for every new address, check if it exists in the existing pool addresses for _, newAddr := range newPoolAddresses { @@ -107,8 +107,8 @@ func poolDiff(existingPoolAddresses []solBaseTokenPool.RemoteAddress, newPoolAdd // get pool pdas func getPoolPDAs( - solTokenPubKey solana.PublicKey, poolAddress solana.PublicKey, remoteChainSelector uint64, -) (poolConfigPDA solana.PublicKey, remoteChainConfigPDA solana.PublicKey) { + solTokenPubKey, poolAddress solana.PublicKey, remoteChainSelector uint64, +) (poolConfigPDA, remoteChainConfigPDA solana.PublicKey) { poolConfigPDA, _ = solTokenUtil.TokenPoolConfigAddress(solTokenPubKey, poolAddress) remoteChainConfigPDA, _, _ = solTokenUtil.TokenPoolChainConfigPDA(remoteChainSelector, solTokenPubKey, poolAddress) return poolConfigPDA, remoteChainConfigPDA @@ -432,7 +432,7 @@ func AddTokenPoolAndLookupTable(e cldf.Environment, cfg AddTokenPoolAndLookupTab if err != nil { return cldf.ChangesetOutput{}, fmt.Errorf("failed to add token pool lookup table: %w", err) } - err = addressBook.Merge(csOutput.AddressBook) //nolint:staticcheck // SA1019: AddressBook is deprecated, migration to DataStore pending + err = addressBook.Merge(csOutput.AddressBook) if err != nil { return cldf.ChangesetOutput{}, fmt.Errorf("failed to merge address book: %w", err) } @@ -446,7 +446,8 @@ func AddTokenPoolAndLookupTable(e cldf.Environment, cfg AddTokenPoolAndLookupTab if len(txns) > 0 { proposal, err := BuildProposalsForTxnsWithConfig( - e, cfg.ChainSelector, "proposal to initialize token pools", cfg.MCMS, txns) + e, cfg.ChainSelector, "proposal to initialize token pools", cfg.MCMS, txns, + ) if err != nil { return cldf.ChangesetOutput{}, fmt.Errorf("failed to build proposal: %w", err) } @@ -722,7 +723,8 @@ func InitGlobalConfigTokenPoolProgram(e cldf.Environment, cfg TokenPoolConfigWit if len(txns) > 0 { proposal, err := BuildProposalsForTxnsWithConfig( - e, cfg.ChainSelector, "proposal to init global config in Solana Token Pool", cfg.MCMS, txns) + e, cfg.ChainSelector, "proposal to init global config in Solana Token Pool", cfg.MCMS, txns, + ) if err != nil { return cldf.ChangesetOutput{}, fmt.Errorf("failed to build proposal: %w", err) } @@ -837,7 +839,8 @@ func modifySelfServedConfig(e cldf.Environment, cfg TokenPoolConfigWithMCM, enab if len(txns) > 0 { proposal, err := BuildProposalsForTxnsWithConfig( - e, cfg.ChainSelector, "proposal to init global config in Solana Token Pool", cfg.MCMS, txns) + e, cfg.ChainSelector, "proposal to init global config in Solana Token Pool", cfg.MCMS, txns, + ) if err != nil { return cldf.ChangesetOutput{}, fmt.Errorf("failed to build proposal: %w", err) } @@ -1114,7 +1117,8 @@ func TransferMintAuthorityToSignerPDA(e cldf.Environment, cfg TransferMintAuthor return cldf.ChangesetOutput{}, fmt.Errorf("failed to generate mcms txn: %w", err) } proposal, err := BuildProposalsForTxnsWithConfig( - e, cfg.ChainSelector, "proposal to transfer mint authority to signer PDA", cfg.MCMS, txns) + e, cfg.ChainSelector, "proposal to transfer mint authority to signer PDA", cfg.MCMS, txns, + ) if err != nil { return cldf.ChangesetOutput{}, fmt.Errorf("failed to build proposal: %w", err) } @@ -1186,7 +1190,8 @@ func ModifyMintAuthority(e cldf.Environment, cfg NewMintTokenPoolConfig) (cldf.C timelockSigner, newMintAuthority, tokenPool, - programData.Address) + programData.Address, + ) // Old mint authority is required only if the current mint authority is a multisig if (cfg.OldMintAuthority != solana.PublicKey{}) { builder.AccountMetaSlice = append(builder.AccountMetaSlice, solana.Meta(cfg.OldMintAuthority)) @@ -1208,7 +1213,8 @@ func ModifyMintAuthority(e cldf.Environment, cfg NewMintTokenPoolConfig) (cldf.C chain.DeployerKey.PublicKey(), newMintAuthority, tokenPool, - programData.Address) + programData.Address, + ) // Old mint authority is required only if the current mint authority is a multisig if (cfg.OldMintAuthority != solana.PublicKey{}) { builder.AccountMetaSlice = append(builder.AccountMetaSlice, solana.Meta(cfg.OldMintAuthority)) @@ -1224,7 +1230,8 @@ func ModifyMintAuthority(e cldf.Environment, cfg NewMintTokenPoolConfig) (cldf.C if len(txns) > 0 { proposal, err := BuildProposalsForTxnsWithConfig( - e, cfg.ChainSelector, "proposal to init global config in Solana Token Pool", cfg.MCMS, txns) + e, cfg.ChainSelector, "proposal to init global config in Solana Token Pool", cfg.MCMS, txns, + ) if err != nil { return cldf.ChangesetOutput{}, fmt.Errorf("failed to build proposal: %w", err) } @@ -1331,7 +1338,8 @@ func SetupTokenPoolForRemoteChain(e cldf.Environment, cfg SetupTokenPoolForRemot if len(txns) > 0 { proposal, err := BuildProposalsForTxnsWithConfig( - e, cfg.SolChainSelector, "proposal to edit token pools in Solana", cfg.MCMS, txns) + e, cfg.SolChainSelector, "proposal to edit token pools in Solana", cfg.MCMS, txns, + ) if err != nil { return cldf.ChangesetOutput{}, fmt.Errorf("failed to build proposal: %w", err) } @@ -1344,7 +1352,7 @@ func SetupTokenPoolForRemoteChain(e cldf.Environment, cfg SetupTokenPoolForRemot } // checks if the evmChainSelector is supported for the given token and pool type -func isSupportedChain(chain cldf_solana.Chain, solTokenPubKey solana.PublicKey, solPoolAddress solana.PublicKey, poolType cldf.ContractType, evmChainSelector uint64) (bool, solBaseTokenPool.BaseChain, error) { +func isSupportedChain(chain cldf_solana.Chain, solTokenPubKey, solPoolAddress solana.PublicKey, poolType cldf.ContractType, evmChainSelector uint64) (bool, solBaseTokenPool.BaseChain, error) { // check if this remote chain is already configured for this token remoteChainConfigPDA, _, err := solTokenUtil.TokenPoolChainConfigPDA(evmChainSelector, solTokenPubKey, solPoolAddress) if err != nil { @@ -2208,7 +2216,6 @@ func ConfigureTokenPoolAllowList(e cldf.Environment, cfg ConfigureTokenPoolAllow ) switch cfg.PoolType { case shared.BurnMintTokenPool: - poolConfigPDA, _ := solTokenUtil.TokenPoolConfigAddress(tokenPubKey, tokenPool) runSafely(func() { solBurnMintTokenPool.SetProgramID(tokenPool) }) @@ -2224,7 +2231,6 @@ func ConfigureTokenPoolAllowList(e cldf.Environment, cfg ConfigureTokenPoolAllow return cldf.ChangesetOutput{}, fmt.Errorf("failed to generate instructions: %w", err) } case shared.LockReleaseTokenPool: - poolConfigPDA, _ := solTokenUtil.TokenPoolConfigAddress(tokenPubKey, tokenPool) runSafely(func() { solLockReleaseTokenPool.SetProgramID(tokenPool) }) @@ -2263,7 +2269,8 @@ func ConfigureTokenPoolAllowList(e cldf.Environment, cfg ConfigureTokenPoolAllow return cldf.ChangesetOutput{}, fmt.Errorf("failed to create transaction: %w", err) } proposal, err := BuildProposalsForTxnsWithConfig( - e, cfg.SolChainSelector, "proposal to ConfigureTokenPoolAllowList in Solana", cfg.MCMS, []mcmsTypes.Transaction{*tx}) + e, cfg.SolChainSelector, "proposal to ConfigureTokenPoolAllowList in Solana", cfg.MCMS, []mcmsTypes.Transaction{*tx}, + ) if err != nil { return cldf.ChangesetOutput{}, fmt.Errorf("failed to build proposal: %w", err) } @@ -2339,7 +2346,6 @@ func RemoveFromTokenPoolAllowList(e cldf.Environment, cfg RemoveFromAllowListCon ) switch cfg.PoolType { case shared.BurnMintTokenPool: - poolConfigPDA, _ := solTokenUtil.TokenPoolConfigAddress(tokenPubKey, tokenPool) runSafely(func() { solBurnMintTokenPool.SetProgramID(tokenPool) }) @@ -2354,7 +2360,6 @@ func RemoveFromTokenPoolAllowList(e cldf.Environment, cfg RemoveFromAllowListCon return cldf.ChangesetOutput{}, fmt.Errorf("failed to generate instructions: %w", err) } case shared.LockReleaseTokenPool: - poolConfigPDA, _ := solTokenUtil.TokenPoolConfigAddress(tokenPubKey, tokenPool) runSafely(func() { solLockReleaseTokenPool.SetProgramID(tokenPool) }) @@ -2391,7 +2396,8 @@ func RemoveFromTokenPoolAllowList(e cldf.Environment, cfg RemoveFromAllowListCon return cldf.ChangesetOutput{}, fmt.Errorf("failed to create transaction: %w", err) } proposal, err := BuildProposalsForTxnsWithConfig( - e, cfg.SolChainSelector, "proposal to RemoveFromTokenPoolAllowList in Solana", cfg.MCMS, []mcmsTypes.Transaction{*tx}) + e, cfg.SolChainSelector, "proposal to RemoveFromTokenPoolAllowList in Solana", cfg.MCMS, []mcmsTypes.Transaction{*tx}, + ) if err != nil { return cldf.ChangesetOutput{}, fmt.Errorf("failed to build proposal: %w", err) } @@ -2513,7 +2519,8 @@ func LockReleaseLiquidityOps(e cldf.Environment, cfg LockReleaseLiquidityOpsConf e.GetContext(), chain.Client, cfg.LiquidityCfg.RemoteTokenAccount, - cldf_solana.SolDefaultCommitment) + cldf_solana.SolDefaultCommitment, + ) if err != nil { return cldf.ChangesetOutput{}, fmt.Errorf("failed to get token balance: %w", err) } @@ -2588,7 +2595,8 @@ func LockReleaseLiquidityOps(e cldf.Environment, cfg LockReleaseLiquidityOpsConf return cldf.ChangesetOutput{}, fmt.Errorf("failed to generate mcms txn: %w", err) } proposal, err := BuildProposalsForTxnsWithConfig( - e, cfg.SolChainSelector, "proposal to RemoveFromTokenPoolAllowList in Solana", cfg.MCMS, txns) + e, cfg.SolChainSelector, "proposal to RemoveFromTokenPoolAllowList in Solana", cfg.MCMS, txns, + ) if err != nil { return cldf.ChangesetOutput{}, fmt.Errorf("failed to build proposal: %w", err) } @@ -2813,7 +2821,8 @@ func TokenPoolOps(e cldf.Environment, cfg TokenPoolOpsCfg) (cldf.ChangesetOutput return cldf.ChangesetOutput{}, fmt.Errorf("failed to create transaction: %w", err) } proposal, err := BuildProposalsForTxnsWithConfig( - e, cfg.SolChainSelector, "proposal to ConfigureTokenPoolAllowList in Solana", cfg.MCMS, []mcmsTypes.Transaction{*tx}) + e, cfg.SolChainSelector, "proposal to ConfigureTokenPoolAllowList in Solana", cfg.MCMS, []mcmsTypes.Transaction{*tx}, + ) if err != nil { return cldf.ChangesetOutput{}, fmt.Errorf("failed to build proposal: %w", err) } @@ -2859,14 +2868,16 @@ func InitializeStateVersion(e cldf.Environment, cfg TokenPoolConfigWithMCM) (cld }) initializeStateVersionIx, err = solBurnMintTokenPool.NewInitializeStateVersionInstruction( tokenPubKey, - poolConfig).ValidateAndBuild() + poolConfig, + ).ValidateAndBuild() case shared.LockReleaseTokenPool: runSafely(func() { solLockReleaseTokenPool.SetProgramID(tokenPool) }) initializeStateVersionIx, err = solLockReleaseTokenPool.NewInitializeStateVersionInstruction( tokenPubKey, - poolConfig).ValidateAndBuild() + poolConfig, + ).ValidateAndBuild() default: return cldf.ChangesetOutput{}, fmt.Errorf("invalid token pool type: %w", err) } @@ -2899,7 +2910,8 @@ func InitializeStateVersion(e cldf.Environment, cfg TokenPoolConfigWithMCM) (cld if len(txns) > 0 { proposal, err := BuildProposalsForTxnsWithConfig( - e, cfg.ChainSelector, "proposal to init global config in Solana Token Pool", cfg.MCMS, txns) + e, cfg.ChainSelector, "proposal to init global config in Solana Token Pool", cfg.MCMS, txns, + ) if err != nil { return cldf.ChangesetOutput{}, fmt.Errorf("failed to build proposal: %w", err) } @@ -3036,7 +3048,8 @@ func SyncDomain(e cldf.Environment, cfg SyncDomainConfig) (cldf.ChangesetOutput, if len(txns) > 0 { proposal, err := BuildProposalsForTxnsWithConfig( - e, cfg.ChainSelector, "proposal to edit USDC token pool CCTP config in Solana", cfg.MCMS, txns) + e, cfg.ChainSelector, "proposal to edit USDC token pool CCTP config in Solana", cfg.MCMS, txns, + ) if err != nil { return cldf.ChangesetOutput{}, fmt.Errorf("failed to build proposal: %w", err) } @@ -3340,7 +3353,8 @@ func SetRateLimitAdmin(e cldf.Environment, cfg SetRateLimitAdminConfig) (cldf.Ch if len(mcmsTxs) > 0 { proposal, err := BuildProposalsForTxnsWithConfig( - e, cfg.SolChainSelector, "proposal to SetRateLimitAdmin in Solana", cfg.MCMS, mcmsTxs) + e, cfg.SolChainSelector, "proposal to SetRateLimitAdmin in Solana", cfg.MCMS, mcmsTxs, + ) if err != nil { return cldf.ChangesetOutput{}, fmt.Errorf("failed to build proposal: %w", err) } diff --git a/deployment/ccip/changeset/solana_v0_1_1/cs_verify_contracts.go b/deployment/ccip/changeset/solana_v0_1_1/cs_verify_contracts.go index d954c2bae09..904c29b56ad 100644 --- a/deployment/ccip/changeset/solana_v0_1_1/cs_verify_contracts.go +++ b/deployment/ccip/changeset/solana_v0_1_1/cs_verify_contracts.go @@ -4,6 +4,7 @@ import ( "encoding/json" "errors" "fmt" + "slices" "strings" "github.com/gagliardetto/solana-go" @@ -200,9 +201,9 @@ func getIxnFromEncodedTx(e cldf.Environment, output string, timelockSignerPDA so // if solana-verify cli changes the output format, this will break lines := strings.Split(output, "\n") var base58EncodedTx string - for i := len(lines) - 1; i >= 0; i-- { - if strings.TrimSpace(lines[i]) != "" { - base58EncodedTx = strings.TrimSpace(lines[i]) + for _, line := range slices.Backward(lines) { + if strings.TrimSpace(line) != "" { + base58EncodedTx = strings.TrimSpace(line) break } } diff --git a/deployment/ccip/changeset/solana_v0_1_1/save_existing_test.go b/deployment/ccip/changeset/solana_v0_1_1/save_existing_test.go index 515708487df..9ad72e6c654 100644 --- a/deployment/ccip/changeset/solana_v0_1_1/save_existing_test.go +++ b/deployment/ccip/changeset/solana_v0_1_1/save_existing_test.go @@ -51,7 +51,7 @@ func TestSaveExistingCCIP(t *testing.T) { output, err := commonchangeset.SaveExistingContractsChangeset(*e, cfg) require.NoError(t, err) - err = e.ExistingAddresses.Merge(output.AddressBook) //nolint:staticcheck // AddressBook is deprecated but still in use for this changeset + err = e.ExistingAddresses.Merge(output.AddressBook) require.NoError(t, err) ds := datastore.NewMemoryDataStore() require.NoError(t, ds.Merge(e.DataStore)) @@ -90,7 +90,7 @@ func TestSaveExisting(t *testing.T) { output, err := commonchangeset.SaveExistingContractsChangeset(*e, ExistingContracts) require.NoError(t, err) - require.NoError(t, e.ExistingAddresses.Merge(output.AddressBook)) //nolint:staticcheck // AddressBook is deprecated but still in use for this changeset + require.NoError(t, e.ExistingAddresses.Merge(output.AddressBook)) addresses, err := e.ExistingAddresses.Addresses() require.NoError(t, err) require.Len(t, addresses, 1) diff --git a/deployment/ccip/changeset/solana_v0_1_1/self_serve.go b/deployment/ccip/changeset/solana_v0_1_1/self_serve.go index 0d60afe499e..d174478db9b 100644 --- a/deployment/ccip/changeset/solana_v0_1_1/self_serve.go +++ b/deployment/ccip/changeset/solana_v0_1_1/self_serve.go @@ -141,20 +141,23 @@ func OnboardTokenPoolsForSelfServe(e cldf.Environment, cfg OnboardTokenPoolsForS inputs = append(inputs, MCMSTxParams{ Ix: proposeTokenAdminRegistryAdminIx, ProgramID: routerState.routerProgramID.String(), - ContractType: shared.Router}) + ContractType: shared.Router, + }) } if initializeTokenPoolIx != nil { inputs = append(inputs, MCMSTxParams{ Ix: initializeTokenPoolIx, ProgramID: currentTokenPoolSolanaState.tokenPoolProgramID.String(), - ContractType: registerTokenConfig.PoolType}) + ContractType: registerTokenConfig.PoolType, + }) } inputs = append(inputs, MCMSTxParams{ Ix: transferTokenPoolOwnershipIx, ProgramID: currentTokenPoolSolanaState.tokenPoolProgramID.String(), - ContractType: registerTokenConfig.PoolType}) + ContractType: registerTokenConfig.PoolType, + }) moreTx, err := BuildManyMCMSTxsFrom(inputs) if err != nil { return cldf.ChangesetOutput{}, err @@ -179,7 +182,7 @@ func OnboardTokenPoolsForSelfServe(e cldf.Environment, cfg OnboardTokenPoolsForS if err != nil { return cldf.ChangesetOutput{}, err } - out.AddressBook = newAddresses //nolint:staticcheck // AddressBook remains required for backward compatibility during the migration. + out.AddressBook = newAddresses out.DataStore = ds return out, nil } @@ -219,30 +222,30 @@ func generateProposeTokenAdminRegistryAdministratorIx(e cldf.Environment, regist return nil, fmt.Errorf("failed to extract data payload from ccip admin propose admin instruction: %w", err) } return solana.NewInstruction(routerState.routerProgramID, tempIx.Accounts(), ixData), nil - } else { - if !tokenAdminRegistryAccount.Administrator.IsZero() { - e.Logger.Infow("Skipping Override Pending Administrator as there is already an administrator") - return nil, nil - } - e.Logger.Infow("Running NewCcipAdminOverridePendingAdministratorInstruction") - // Use this if the proposed token admin registry admin set was incorrect - overridePendingAdministratorIx, err := solRouter.NewCcipAdminOverridePendingAdministratorInstruction( - registerTokenConfig.ProposedOwner, // customer's admin of the tokenAdminRegistry PDA in the Router - routerState.routerConfigPDA, - tokenAdminRegistryPDA, - tokenMint, - routerState.ccipAdmin, - solana.SystemProgramID, - ).ValidateAndBuild() - if err != nil { - return nil, fmt.Errorf("failed to generate instruction to override pending administrator: %w", err) - } - ixData, err := overridePendingAdministratorIx.Data() - if err != nil { - return nil, fmt.Errorf("failed to extract data payload from ccip admin override pending admin instruction: %w", err) - } - return solana.NewInstruction(routerState.routerProgramID, overridePendingAdministratorIx.Accounts(), ixData), nil } + + if !tokenAdminRegistryAccount.Administrator.IsZero() { + e.Logger.Infow("Skipping Override Pending Administrator as there is already an administrator") + return nil, nil + } + e.Logger.Infow("Running NewCcipAdminOverridePendingAdministratorInstruction") + // Use this if the proposed token admin registry admin set was incorrect + overridePendingAdministratorIx, err := solRouter.NewCcipAdminOverridePendingAdministratorInstruction( + registerTokenConfig.ProposedOwner, // customer's admin of the tokenAdminRegistry PDA in the Router + routerState.routerConfigPDA, + tokenAdminRegistryPDA, + tokenMint, + routerState.ccipAdmin, + solana.SystemProgramID, + ).ValidateAndBuild() + if err != nil { + return nil, fmt.Errorf("failed to generate instruction to override pending administrator: %w", err) + } + ixData, err := overridePendingAdministratorIx.Data() + if err != nil { + return nil, fmt.Errorf("failed to extract data payload from ccip admin override pending admin instruction: %w", err) + } + return solana.NewInstruction(routerState.routerProgramID, overridePendingAdministratorIx.Accounts(), ixData), nil } func generateInitializeCLLTokenPoolIx(e cldf.Environment, config OnboardTokenPoolConfig, state tokenPoolSolanaState, solChainState globalState) (solana.Instruction, error) { @@ -352,13 +355,13 @@ func loadRouterSolanaState(e cldf.Environment, cfg OnboardTokenPoolsForSelfServe "", ) return globalState{ - chain: chain, - chainState: chainState, - }, routerSolanaState{ - routerProgramID: routerProgramAddress, - routerConfigPDA: routerConfigPDA, - ccipAdmin: ccipAdmin, - }, nil + chain: chain, + chainState: chainState, + }, routerSolanaState{ + routerProgramID: routerProgramAddress, + routerConfigPDA: routerConfigPDA, + ccipAdmin: ccipAdmin, + }, nil } type tokenPoolSolanaState struct { diff --git a/deployment/ccip/changeset/solana_v0_1_1/utils.go b/deployment/ccip/changeset/solana_v0_1_1/utils.go index faa731db752..0515575f8eb 100644 --- a/deployment/ccip/changeset/solana_v0_1_1/utils.go +++ b/deployment/ccip/changeset/solana_v0_1_1/utils.go @@ -17,9 +17,10 @@ import ( cldf_solana "github.com/smartcontractkit/chainlink-deployments-framework/chain/solana" cldfproposalutils "github.com/smartcontractkit/chainlink-deployments-framework/engine/cld/mcms/proposalutils" - cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment" proposeutils "github.com/smartcontractkit/cld-changesets/legacy/mcms/proposeutils" + cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment" + "github.com/smartcontractkit/chainlink/deployment/ccip/shared" "github.com/smartcontractkit/chainlink/deployment/ccip/shared/stateview" solanastateview "github.com/smartcontractkit/chainlink/deployment/ccip/shared/stateview/solana" diff --git a/deployment/ccip/changeset/testhelpers/cciptesthelpertypes/types.go b/deployment/ccip/changeset/testhelpers/cciptesthelpertypes/types.go index f9a6155549c..d26028c4043 100644 --- a/deployment/ccip/changeset/testhelpers/cciptesthelpertypes/types.go +++ b/deployment/ccip/changeset/testhelpers/cciptesthelpertypes/types.go @@ -9,7 +9,7 @@ import ( "golang.org/x/exp/constraints" "golang.org/x/exp/maps" - cciptypes "github.com/smartcontractkit/chainlink-ccip/pkg/types/ccipocr3" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccipocr3" ) // NewRandomTopology creates a new random topology with the given arguments. diff --git a/deployment/ccip/changeset/testhelpers/cciptesthelpertypes/types_test.go b/deployment/ccip/changeset/testhelpers/cciptesthelpertypes/types_test.go index b50b750ffbf..5f452edfc5a 100644 --- a/deployment/ccip/changeset/testhelpers/cciptesthelpertypes/types_test.go +++ b/deployment/ccip/changeset/testhelpers/cciptesthelpertypes/types_test.go @@ -9,7 +9,7 @@ import ( "github.com/stretchr/testify/require" - cciptypes "github.com/smartcontractkit/chainlink-ccip/pkg/types/ccipocr3" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccipocr3" "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/testhelpers/cciptesthelpertypes/mocks" ) diff --git a/deployment/ccip/changeset/testhelpers/messagingtest/helpers.go b/deployment/ccip/changeset/testhelpers/messagingtest/helpers.go index ce60f041aaa..769b82e7b83 100644 --- a/deployment/ccip/changeset/testhelpers/messagingtest/helpers.go +++ b/deployment/ccip/changeset/testhelpers/messagingtest/helpers.go @@ -8,6 +8,7 @@ import ( "github.com/stretchr/testify/require" chain_selectors "github.com/smartcontractkit/chain-selectors" + "github.com/smartcontractkit/chainlink-ccip/chains/evm/gobindings/generated/v1_2_0/router" "github.com/smartcontractkit/chainlink-common/pkg/types/ccipocr3" cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment" @@ -187,7 +188,7 @@ func Run(t *testing.T, tc TestCase) (out TestCaseOutput) { sender := tc.Env.BlockChains.EVMChains()[tc.SourceChain].DeployerKey currBalance, err := tc.Env.BlockChains.EVMChains()[tc.SourceChain].Client.BalanceAt(tc.T.Context(), sender.From, nil) require.NoError(tc.T, err) - //nolint:testifylint // incorrect lint, GreaterOrEqual can't be used with *big.Int. + //nolint:testifylint // invalid suggestion: require.GreaterOrEqual does not support *big.Int require.True(tc.T, currBalance.Cmp(totalValue) >= 0, "sender balance should be greater than or equal to total value") tx, err := tc.OnchainState.MustGetEVMChainState(tc.SourceChain).Multicall3.Aggregate3Value( @@ -343,7 +344,7 @@ func Run(t *testing.T, tc TestCase) (out TestCaseOutput) { case ValidationTypeNone: tc.T.Logf("skipping validation of sent message") } - return + return out } // SleepReplayAndSettle sleeps, replays logs, then sleeps again. EVM replay uses ReplayAsync and diff --git a/deployment/ccip/changeset/testhelpers/test_adapter_aptos.go b/deployment/ccip/changeset/testhelpers/test_adapter_aptos.go index b2ab8f0e67e..617c3671411 100644 --- a/deployment/ccip/changeset/testhelpers/test_adapter_aptos.go +++ b/deployment/ccip/changeset/testhelpers/test_adapter_aptos.go @@ -109,7 +109,8 @@ func AptosEventEmitter[T any]( ) (<-chan struct { Event T Version uint64 -}, <-chan error) { +}, <-chan error, +) { ch := make(chan struct { Event T Version uint64 @@ -299,7 +300,7 @@ func confirmExecWithExpectedSeqNrsAptos( t.Logf("(Aptos) received ExecutionStateChanged (state %s) on chain %d (offramp %s) with expected sequence number %d (tx %d)", executionStateToString(event.Event.State), dest.Selector, offRampAddress.String(), event.Event.SequenceNumber, event.Version, ) - if event.Event.State == EXECUTION_STATE_INPROGRESS { + if event.Event.State == ExecutionStateInProgress { continue } executionStates[event.Event.SequenceNumber] = int(event.Event.State) diff --git a/deployment/ccip/changeset/testhelpers/test_adapter_evm.go b/deployment/ccip/changeset/testhelpers/test_adapter_evm.go index 4bdeba6a145..37cc410aee9 100644 --- a/deployment/ccip/changeset/testhelpers/test_adapter_evm.go +++ b/deployment/ccip/changeset/testhelpers/test_adapter_evm.go @@ -205,7 +205,6 @@ func ConfirmCommitWithExpectedSeqNumRange( iter, err := offRamp.FilterCommitReportAccepted(&bind.FilterOpts{ Context: t.Context(), }) - // In some test case the test ends while the filter is still running resulting in a context.Canceled error. if err != nil { if errors.Is(err, context.Canceled) { @@ -304,7 +303,7 @@ func ConfirmExecWithSeqNrs( scc, executionState := getExecutionState(t, sourceSelector, offRamp, expectedSeqNr) t.Logf("Waiting for ExecutionStateChanged on chain %d (offramp %s) from chain %d with expected sequence number %d, current onchain minSeqNr: %d, execution state: %s", dest.Selector, offRamp.Address().String(), sourceSelector, expectedSeqNr, scc.MinSeqNr, executionStateToString(executionState)) - if executionState == EXECUTION_STATE_SUCCESS || executionState == EXECUTION_STATE_FAILURE { + if executionState == ExecutionStateSuccess || executionState == ExecutionStateFailure { t.Logf("Observed %s execution state on chain %d (offramp %s) from chain %d with expected sequence number %d", executionStateToString(executionState), dest.Selector, offRamp.Address().String(), sourceSelector, expectedSeqNr) executionStates[expectedSeqNr] = int(executionState) diff --git a/deployment/ccip/changeset/testhelpers/test_adapter_sui.go b/deployment/ccip/changeset/testhelpers/test_adapter_sui.go index 3f3cda34e61..4b42b8f684b 100644 --- a/deployment/ccip/changeset/testhelpers/test_adapter_sui.go +++ b/deployment/ccip/changeset/testhelpers/test_adapter_sui.go @@ -115,7 +115,8 @@ func SuiEventEmitter[T any]( ) (<-chan struct { Event T Version string -}, <-chan error) { +}, <-chan error, +) { startTime := time.Now() t.Logf("[DEBUG] SuiEventEmitter: Starting at %s - polling checkpoints for events", startTime.Format(time.RFC3339)) ch := make(chan struct { @@ -384,7 +385,7 @@ func confirmExecWithExpectedSeqNrsSui( t.Logf("(Sui) received ExecutionStateChanged (state %s) on chain %d (offramp %s) with expected sequence number %d (tx %s)", executionStateToString(event.Event.State), dest.Selector, offRampAddress, event.Event.SequenceNumber, event.Version, ) - if event.Event.State == EXECUTION_STATE_INPROGRESS { + if event.Event.State == ExecutionStateInProgress { continue } executionStates[event.Event.SequenceNumber] = int(event.Event.State) diff --git a/deployment/ccip/changeset/testhelpers/test_assertions.go b/deployment/ccip/changeset/testhelpers/test_assertions.go index e79960af9aa..f02a10ec2cc 100644 --- a/deployment/ccip/changeset/testhelpers/test_assertions.go +++ b/deployment/ccip/changeset/testhelpers/test_assertions.go @@ -14,7 +14,7 @@ import ( "github.com/smartcontractkit/chainlink-ccip/chains/evm/gobindings/generated/v1_6_0/offramp" "github.com/smartcontractkit/chainlink-ccip/chains/evm/gobindings/generated/v1_6_3/fee_quoter" - "github.com/smartcontractkit/chainlink-ccip/pkg/types/ccipocr3" + "github.com/smartcontractkit/chainlink-common/pkg/types/ccipocr3" chainsel "github.com/smartcontractkit/chain-selectors" @@ -159,7 +159,7 @@ func NewCommitReportTracker(sourceChainSelector uint64, seqNrs ccipocr3.SeqNumRa return CommitReportTracker{seenMessages: seenMessages} } -func (c *CommitReportTracker) visitCommitReport(sourceChainSelector uint64, minSeqNr uint64, maxSeqNr uint64) { +func (c *CommitReportTracker) visitCommitReport(sourceChainSelector, minSeqNr, maxSeqNr uint64) { if _, ok := c.seenMessages[sourceChainSelector]; !ok { return } @@ -372,7 +372,7 @@ func ConfirmNoExecSuccessConsistentlyWithSeqNr( scc, executionState := getExecutionState(t, sourceSelector, offRamp, expectedSeqNr) t.Logf("Waiting for ExecutionStateChanged on chain %d (offramp %s) from chain %d with expected sequence number %d, current onchain minSeqNr: %d, execution state: %s", dest.Selector, offRamp.Address().String(), sourceSelector, expectedSeqNr, scc.MinSeqNr, executionStateToString(executionState)) - if executionState == EXECUTION_STATE_SUCCESS { + if executionState == ExecutionStateSuccess { t.Logf("Observed %s execution state on chain %d (offramp %s) from chain %d with expected sequence number %d", executionStateToString(executionState), dest.Selector, offRamp.Address().String(), sourceSelector, expectedSeqNr) return false @@ -389,7 +389,7 @@ func getExecutionState(t *testing.T, sourceSelector uint64, offRamp offramp.OffR return scc, executionState } -func RequireConsistently(t *testing.T, condition func() bool, duration time.Duration, tick time.Duration, msgAndArgs ...any) { +func RequireConsistently(t *testing.T, condition func() bool, duration, tick time.Duration, msgAndArgs ...any) { timer := time.NewTimer(duration) defer timer.Stop() tickTimer := time.NewTicker(tick) @@ -423,21 +423,21 @@ func SeqNumberRangeToSlice(seqRanges map[SourceDestPair]ccipocr3.SeqNumRange) ma } const ( - EXECUTION_STATE_UNTOUCHED = 0 - EXECUTION_STATE_INPROGRESS = 1 - EXECUTION_STATE_SUCCESS = 2 - EXECUTION_STATE_FAILURE = 3 + ExecutionStateUntouched = 0 + ExecutionStateInProgress = 1 + ExecutionStateSuccess = 2 + ExecutionStateFailure = 3 ) func executionStateToString(state uint8) string { switch state { - case EXECUTION_STATE_UNTOUCHED: + case ExecutionStateUntouched: return "UNTOUCHED" - case EXECUTION_STATE_INPROGRESS: + case ExecutionStateInProgress: return "IN_PROGRESS" - case EXECUTION_STATE_SUCCESS: + case ExecutionStateSuccess: return "SUCCESS" - case EXECUTION_STATE_FAILURE: + case ExecutionStateFailure: return "FAILURE" default: return "UNKNOWN" diff --git a/deployment/ccip/changeset/testhelpers/test_environment.go b/deployment/ccip/changeset/testhelpers/test_environment.go index 0980f295581..02f6f5ce317 100644 --- a/deployment/ccip/changeset/testhelpers/test_environment.go +++ b/deployment/ccip/changeset/testhelpers/test_environment.go @@ -9,6 +9,7 @@ import ( "net/http" "net/http/httptest" "os" + "slices" "strconv" "testing" "time" @@ -71,7 +72,6 @@ import ( "github.com/smartcontractkit/chainlink-ccip/chainconfig" solFeeQuoterV0_1_1 "github.com/smartcontractkit/chainlink-ccip/chains/solana/gobindings/v0_1_1/fee_quoter" "github.com/smartcontractkit/chainlink-ccip/execute/tokendata/lbtc" - cciptypes "github.com/smartcontractkit/chainlink-ccip/pkg/types/ccipocr3" "github.com/smartcontractkit/chainlink-ccip/pluginconfig" "github.com/smartcontractkit/chainlink-common/keystore/corekeys/p2pkey" @@ -183,11 +183,12 @@ func (tc *TestConfigs) Validate() error { func (tc *TestConfigs) MustSetEnvTypeOrDefault(t *testing.T) { envType := os.Getenv(ENVTESTTYPE) - if envType == "" || envType == string(Memory) { + switch envType { + case "", string(Memory): tc.Type = Memory - } else if envType == string(Docker) { + case string(Docker): tc.Type = Docker - } else { + default: t.Fatalf("env var CCIP_V16_TEST_ENV must be either %s or %s, defaults to %s if unset, got: %s", Memory, Docker, Memory, envType) } } @@ -789,10 +790,7 @@ func NewEnvironmentWithJobsAndContracts(t *testing.T, tEnv TestEnvironment) Depl solChains := e.Env.BlockChains.ListChainSelectors(cldf_chain.WithFamily(chain_selectors.FamilySolana)) aptosChains := e.Env.BlockChains.ListChainSelectors(cldf_chain.WithFamily(chain_selectors.FamilyAptos)) suiChains := e.Env.BlockChains.ListChainSelectors(cldf_chain.WithFamily(chain_selectors.FamilySui)) - //nolint:gocritic // we need to segregate EVM and Solana chains - allChains := append(evmChains, solChains...) - allChains = append(allChains, aptosChains...) - allChains = append(allChains, suiChains...) + allChains := slices.Concat(evmChains, solChains, aptosChains, suiChains) mcmsCfg := make(map[uint64]cldfproposalutils.MCMSWithTimelockConfig) @@ -1094,12 +1092,12 @@ func AddCCIPContractsToEnvironment(t *testing.T, allChains []uint64, tEnv TestEn var tokenDataProviders []pluginconfig.TokenDataObserverConfig if tc.IsUSDC { endpoint := tEnv.MockUSDCAttestationServer(t, tc.IsUSDCAttestationMissing) - cctpContracts := make(map[cciptypes.ChainSelector]pluginconfig.USDCCCTPTokenConfig) + cctpContracts := make(map[ccipocr3common.ChainSelector]pluginconfig.USDCCCTPTokenConfig) for _, usdcChain := range evmChains { require.NotNil(t, state.MustGetEVMChainState(usdcChain).MockUSDCTokenMessenger) require.NotNil(t, state.MustGetEVMChainState(usdcChain).MockUSDCTransmitter) require.NotNil(t, state.MustGetEVMChainState(usdcChain).USDCTokenPools[deployment.Version1_5_1]) - cctpContracts[cciptypes.ChainSelector(usdcChain)] = pluginconfig.USDCCCTPTokenConfig{ + cctpContracts[ccipocr3common.ChainSelector(usdcChain)] = pluginconfig.USDCCCTPTokenConfig{ SourcePoolAddress: state.MustGetEVMChainState(usdcChain).USDCTokenPools[deployment.Version1_5_1].Address().String(), SourceMessageTransmitterAddr: state.MustGetEVMChainState(usdcChain).MockUSDCTransmitter.Address().String(), } @@ -1108,32 +1106,28 @@ func AddCCIPContractsToEnvironment(t *testing.T, allChains []uint64, tEnv TestEn Type: pluginconfig.USDCCCTPHandlerType, Version: "1.0", USDCCCTPObserverConfig: &pluginconfig.USDCCCTPObserverConfig{ - AttestationConfig: pluginconfig.AttestationConfig{ - AttestationAPI: endpoint, - AttestationAPITimeout: commonconfig.MustNewDuration(time.Second), - AttestationAPIInterval: commonconfig.MustNewDuration(500 * time.Millisecond), - }, - Tokens: cctpContracts, + AttestationAPI: endpoint, + AttestationAPITimeout: commonconfig.MustNewDuration(time.Second), + AttestationAPIInterval: commonconfig.MustNewDuration(500 * time.Millisecond), + Tokens: cctpContracts, }, }) } if tc.IsLBTC { endpoint := tEnv.MockLBTCAttestationServer(t, tc.IsUSDCAttestationMissing) - lbtcPools := make(map[cciptypes.ChainSelector]string) + lbtcPools := make(map[ccipocr3common.ChainSelector]string) for _, chain := range evmChains { lbtcPool := state.MustGetEVMChainState(chain).BurnMintTokenPools[shared.LBTCSymbol][deployment.Version1_5_1] require.NotNil(t, lbtcPool) - lbtcPools[cciptypes.ChainSelector(chain)] = lbtcPool.Address().String() + lbtcPools[ccipocr3common.ChainSelector(chain)] = lbtcPool.Address().String() } tokenDataProviders = append(tokenDataProviders, pluginconfig.TokenDataObserverConfig{ Type: pluginconfig.LBTCHandlerType, Version: "1.0", LBTCObserverConfig: &pluginconfig.LBTCObserverConfig{ - AttestationConfig: pluginconfig.AttestationConfig{ - AttestationAPI: endpoint, - AttestationAPITimeout: commonconfig.MustNewDuration(time.Second), - AttestationAPIInterval: commonconfig.MustNewDuration(500 * time.Millisecond), - }, + AttestationAPI: endpoint, + AttestationAPITimeout: commonconfig.MustNewDuration(time.Second), + AttestationAPIInterval: commonconfig.MustNewDuration(500 * time.Millisecond), SourcePoolAddressByChain: lbtcPools, }, }) @@ -1143,23 +1137,23 @@ func AddCCIPContractsToEnvironment(t *testing.T, allChains []uint64, tEnv TestEn require.NoError(t, err) // generate the chainToNodeMapping if we have a topology provided. - var chainToNodeMapping map[cciptypes.ChainSelector][][32]byte + var chainToNodeMapping map[ccipocr3common.ChainSelector][][32]byte if tc.Type == Memory && tc.RoleDONTopology != nil { - allSelectors := make([]cciptypes.ChainSelector, 0, len(evmChains)+len(solChains)) + allSelectors := make([]ccipocr3common.ChainSelector, 0, len(evmChains)+len(solChains)) for _, chain := range evmChains { // don't include the home chain, its supported by all nodes. if chain == e.HomeChainSel { continue } - allSelectors = append(allSelectors, cciptypes.ChainSelector(chain)) + allSelectors = append(allSelectors, ccipocr3common.ChainSelector(chain)) } for _, chain := range solChains { - allSelectors = append(allSelectors, cciptypes.ChainSelector(chain)) + allSelectors = append(allSelectors, ccipocr3common.ChainSelector(chain)) } chainToNodeMapping, err = tc.RoleDONTopology.ChainToNodeMapping( nodeInfo.NonBootstraps().PeerIDs(), allSelectors, - cciptypes.ChainSelector(e.HomeChainSel), + ccipocr3common.ChainSelector(e.HomeChainSel), ) require.NoError(t, err) } @@ -1195,9 +1189,9 @@ func AddCCIPContractsToEnvironment(t *testing.T, allChains []uint64, tEnv TestEn var readers [][32]byte if chainToNodeMapping != nil { - _, ok := chainToNodeMapping[cciptypes.ChainSelector(chain)] + _, ok := chainToNodeMapping[ccipocr3common.ChainSelector(chain)] require.True(t, ok, "chain %d not found in chainToNodeMapping", chain) - readers = chainToNodeMapping[cciptypes.ChainSelector(chain)] + readers = chainToNodeMapping[ccipocr3common.ChainSelector(chain)] t.Logf("setting readers for chain %d to %v due to topology %v", chain, readers, chainToNodeMapping) } else { t.Logf("setting readers for chain %d to %v due to no topology", chain, nodeInfo.NonBootstraps().PeerIDs()) @@ -1208,8 +1202,8 @@ func AddCCIPContractsToEnvironment(t *testing.T, allChains []uint64, tEnv TestEn // #nosec G115 - Overflow is not a concern in this test scenario FChain: uint8(len(readers) / 3), EncodableChainConfig: chainconfig.ChainConfig{ - GasPriceDeviationPPB: cciptypes.BigInt{Int: big.NewInt(DefaultGasPriceDeviationPPB)}, - DAGasPriceDeviationPPB: cciptypes.BigInt{Int: big.NewInt(DefaultDAGasPriceDeviationPPB)}, + GasPriceDeviationPPB: ccipocr3common.BigInt{Int: big.NewInt(DefaultGasPriceDeviationPPB)}, + DAGasPriceDeviationPPB: ccipocr3common.BigInt{Int: big.NewInt(DefaultDAGasPriceDeviationPPB)}, OptimisticConfirmations: globals.OptimisticConfirmations, ChainFeeDeviationDisabled: false, }, @@ -1218,10 +1212,10 @@ func AddCCIPContractsToEnvironment(t *testing.T, allChains []uint64, tEnv TestEn for _, chain := range solChains { // TODO: this is a workaround for tokenConfig.GetTokenInfo - tokenInfo := map[cciptypes.UnknownEncodedAddress]pluginconfig.TokenInfo{} - tokenInfo[cciptypes.UnknownEncodedAddress(state.SolChains[chain].LinkToken.String())] = tokenConfig.TokenSymbolToInfo[shared.LinkSymbol] + tokenInfo := map[ccipocr3common.UnknownEncodedAddress]ccipocr3common.TokenInfo{} + tokenInfo[ccipocr3common.UnknownEncodedAddress(state.SolChains[chain].LinkToken.String())] = tokenConfig.TokenSymbolToInfo[shared.LinkSymbol] // TODO: point this to proper SOL feed, apparently 0 signified SOL - tokenInfo[cciptypes.UnknownEncodedAddress(solanago.SolMint.String())] = tokenConfig.TokenSymbolToInfo[shared.WethSymbol] + tokenInfo[ccipocr3common.UnknownEncodedAddress(solanago.SolMint.String())] = tokenConfig.TokenSymbolToInfo[shared.WethSymbol] ocrOverride := tc.OCRConfigOverride commitOCRConfigs[chain] = v1_6.DeriveOCRParamsForCommit(v1_6.SimulationTest, e.FeedChainSel, tokenInfo, ocrOverride) @@ -1229,9 +1223,9 @@ func AddCCIPContractsToEnvironment(t *testing.T, allChains []uint64, tEnv TestEn var readers [][32]byte if chainToNodeMapping != nil { - _, ok := chainToNodeMapping[cciptypes.ChainSelector(chain)] + _, ok := chainToNodeMapping[ccipocr3common.ChainSelector(chain)] require.True(t, ok, "chain %d not found in chainToNodeMapping", chain) - readers = chainToNodeMapping[cciptypes.ChainSelector(chain)] + readers = chainToNodeMapping[ccipocr3common.ChainSelector(chain)] t.Logf("setting readers for chain %d to %v due to topology %v", chain, readers, chainToNodeMapping) } else { readers = nodeInfo.NonBootstraps().PeerIDs() @@ -1241,8 +1235,8 @@ func AddCCIPContractsToEnvironment(t *testing.T, allChains []uint64, tEnv TestEn // #nosec G115 - Overflow is not a concern in this test scenario FChain: uint8(len(readers) / 3), EncodableChainConfig: chainconfig.ChainConfig{ - GasPriceDeviationPPB: cciptypes.BigInt{Int: big.NewInt(DefaultGasPriceDeviationPPB)}, - DAGasPriceDeviationPPB: cciptypes.BigInt{Int: big.NewInt(DefaultDAGasPriceDeviationPPB)}, + GasPriceDeviationPPB: ccipocr3common.BigInt{Int: big.NewInt(DefaultGasPriceDeviationPPB)}, + DAGasPriceDeviationPPB: ccipocr3common.BigInt{Int: big.NewInt(DefaultDAGasPriceDeviationPPB)}, OptimisticConfirmations: globals.OptimisticConfirmations, ChainFeeDeviationDisabled: true, }, @@ -1286,9 +1280,9 @@ func AddCCIPContractsToEnvironment(t *testing.T, allChains []uint64, tEnv TestEn } for _, chain := range aptosChains { - tokenInfo := map[cciptypes.UnknownEncodedAddress]pluginconfig.TokenInfo{} + tokenInfo := map[ccipocr3common.UnknownEncodedAddress]ccipocr3common.TokenInfo{} linkTokenAddress := state.AptosChains[chain].LinkTokenAddress - tokenInfo[cciptypes.UnknownEncodedAddress(linkTokenAddress.String())] = tokenConfig.TokenSymbolToInfo[shared.LinkSymbol] + tokenInfo[ccipocr3common.UnknownEncodedAddress(linkTokenAddress.String())] = tokenConfig.TokenSymbolToInfo[shared.LinkSymbol] ocrOverride := func(params v1_6.CCIPOCRParams) v1_6.CCIPOCRParams { // Commit params.CommitOffChainConfig.RMNEnabled = false @@ -1309,8 +1303,8 @@ func AddCCIPContractsToEnvironment(t *testing.T, allChains []uint64, tEnv TestEn // #nosec G115 - Overflow is not a concern in this test scenario FChain: uint8(len(nodeInfo.NonBootstraps().PeerIDs()) / 3), EncodableChainConfig: chainconfig.ChainConfig{ - GasPriceDeviationPPB: cciptypes.BigInt{Int: big.NewInt(DefaultGasPriceDeviationPPB)}, - DAGasPriceDeviationPPB: cciptypes.BigInt{Int: big.NewInt(DefaultDAGasPriceDeviationPPB)}, + GasPriceDeviationPPB: ccipocr3common.BigInt{Int: big.NewInt(DefaultGasPriceDeviationPPB)}, + DAGasPriceDeviationPPB: ccipocr3common.BigInt{Int: big.NewInt(DefaultDAGasPriceDeviationPPB)}, OptimisticConfirmations: globals.OptimisticConfirmations, }, } @@ -1338,12 +1332,10 @@ func AddCCIPContractsToEnvironment(t *testing.T, allChains []uint64, tEnv TestEn // Add the DONs and candidate commit OCR instances for the chain. cldf.CreateLegacyChangeSet(v1_6.AddDonAndSetCandidateChangeset), v1_6.AddDonAndSetCandidateChangesetConfig{ - SetCandidateConfigBase: v1_6.SetCandidateConfigBase{ - HomeChainSelector: e.HomeChainSel, - // TODO: we dont know what this means for solana - FeedChainSelector: e.FeedChainSel, - MCMS: mcmsConfig, - }, + HomeChainSelector: e.HomeChainSel, + // TODO: we dont know what this means for solana + FeedChainSelector: e.FeedChainSel, + MCMS: mcmsConfig, PluginInfo: v1_6.SetCandidatePluginInfo{ OCRConfigPerRemoteChainSelector: commitOCRConfigs, PluginType: types.PluginTypeCCIPCommit, @@ -1354,12 +1346,10 @@ func AddCCIPContractsToEnvironment(t *testing.T, allChains []uint64, tEnv TestEn // Add the exec OCR instances for the new chains. cldf.CreateLegacyChangeSet(v1_6.SetCandidateChangeset), v1_6.SetCandidateChangesetConfig{ - SetCandidateConfigBase: v1_6.SetCandidateConfigBase{ - HomeChainSelector: e.HomeChainSel, - // TODO: we dont know what this means for solana - FeedChainSelector: e.FeedChainSel, - MCMS: mcmsConfig, - }, + HomeChainSelector: e.HomeChainSel, + // TODO: we dont know what this means for solana + FeedChainSelector: e.FeedChainSel, + MCMS: mcmsConfig, PluginInfo: []v1_6.SetCandidatePluginInfo{ { OCRConfigPerRemoteChainSelector: execOCRConfigs, diff --git a/deployment/ccip/changeset/testhelpers/test_helpers_solana_v0_1_0.go b/deployment/ccip/changeset/testhelpers/test_helpers_solana_v0_1_0.go index d5a797c4d6a..e7c3d332582 100644 --- a/deployment/ccip/changeset/testhelpers/test_helpers_solana_v0_1_0.go +++ b/deployment/ccip/changeset/testhelpers/test_helpers_solana_v0_1_0.go @@ -53,9 +53,9 @@ import ( ccipsolstate "github.com/smartcontractkit/chainlink-ccip/chains/solana/utils/state" soltokens "github.com/smartcontractkit/chainlink-ccip/chains/solana/utils/tokens" "github.com/smartcontractkit/chainlink-ccip/pkg/reader" - cciptypes "github.com/smartcontractkit/chainlink-ccip/pkg/types/ccipocr3" "github.com/smartcontractkit/chainlink-common/pkg/logger" "github.com/smartcontractkit/chainlink-common/pkg/types/ccip/consts" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccipocr3" "github.com/smartcontractkit/chainlink-common/pkg/utils/tests" cldf_chain "github.com/smartcontractkit/chainlink-deployments-framework/chain" cldf_aptos "github.com/smartcontractkit/chainlink-deployments-framework/chain/aptos" @@ -112,8 +112,7 @@ var ( func Context(tb testing.TB) context.Context { ctx := context.Background() var cancel func() - switch t := tb.(type) { - case *testing.T: + if t, ok := tb.(*testing.T); ok { if d, ok := t.Deadline(); ok { ctx, cancel = context.WithDeadline(ctx, d) } @@ -858,7 +857,7 @@ func SendRequestSol( if idx > math.MaxUint8 { return nil, fmt.Errorf("too many token accounts, overflows uint8: %d", idx) } - tokenIndexes = append(tokenIndexes, byte(idx)) //nolint:gosec // G115 + tokenIndexes = append(tokenIndexes, byte(idx)) //nolint:gosec // G115: guarded above base.AccountMetaSlice = append(base.AccountMetaSlice, tokenMetas...) maps.Copy(addressTables, tokenAddressTables) } @@ -2025,7 +2024,7 @@ func TransferMultiple( for _, tt := range requests { t.Run(tt.Name, func(t *testing.T) { - pairId := SourceDestPair{ + pairID := SourceDestPair{ SourceChainSelector: tt.SourceChain, DestChainSelector: tt.DestChain, } @@ -2072,22 +2071,22 @@ func TransferMultiple( msg, blocks := Transfer( ctx, t, env, state, tt.SourceChain, tt.DestChain, tokens, tt.Receiver, tt.UseTestRouter, tt.Data, tt.ExtraArgs, tt.FeeToken, ) - if _, ok := expectedExecutionStates[pairId]; !ok { - expectedExecutionStates[pairId] = make(map[uint64]int) + if _, ok := expectedExecutionStates[pairID]; !ok { + expectedExecutionStates[pairID] = make(map[uint64]int) } - expectedExecutionStates[pairId][msg.SequenceNumber] = tt.ExpectedStatus + expectedExecutionStates[pairID][msg.SequenceNumber] = tt.ExpectedStatus if prev, ok := startBlocks[tt.DestChain]; !ok || *blocks[tt.DestChain] < *prev { startBlocks[tt.DestChain] = blocks[tt.DestChain] } - seqNr, ok := expectedSeqNums[pairId] + seqNr, ok := expectedSeqNums[pairID] if ok { - expectedSeqNums[pairId] = cciptypes.NewSeqNumRange( + expectedSeqNums[pairID] = cciptypes.NewSeqNumRange( seqNr.Start(), cciptypes.SeqNum(msg.SequenceNumber), ) } else { - expectedSeqNums[pairId] = cciptypes.NewSeqNumRange( + expectedSeqNums[pairID] = cciptypes.NewSeqNumRange( cciptypes.SeqNum(msg.SequenceNumber), cciptypes.SeqNum(msg.SequenceNumber), ) } @@ -2247,7 +2246,7 @@ func WaitForTheTokenBalanceSol( "token", token, "receiver", receiver, ) - return uint64(balance) == expected //nolint:gosec // value is always unsigned + return uint64(balance) == expected //nolint:gosec // G115: token balances are always non-negative }, tests.WaitTimeout(t), 100*time.Millisecond) } diff --git a/deployment/ccip/changeset/testhelpers/test_helpers_sui_solana_lanes.go b/deployment/ccip/changeset/testhelpers/test_helpers_sui_solana_lanes.go index e8f48ff6901..55a152caf8c 100644 --- a/deployment/ccip/changeset/testhelpers/test_helpers_sui_solana_lanes.go +++ b/deployment/ccip/changeset/testhelpers/test_helpers_sui_solana_lanes.go @@ -34,7 +34,6 @@ import ( offrampops "github.com/smartcontractkit/chainlink-sui/deployment/ops/ccip_offramp" onrampops "github.com/smartcontractkit/chainlink-sui/deployment/ops/ccip_onramp" routerops "github.com/smartcontractkit/chainlink-sui/deployment/ops/ccip_router" - mcmsops "github.com/smartcontractkit/chainlink-sui/deployment/ops/mcms" ownershipops "github.com/smartcontractkit/chainlink-sui/deployment/ops/ownership" sui_utils "github.com/smartcontractkit/chainlink-sui/deployment/utils" @@ -312,12 +311,10 @@ func completeSuiCCIPMCMSOwnership(t *testing.T, e *DeployedEnv, suiSel uint64) e // unconditionally returns is discarded. (A composite literal in an if-init would need // parenthesizing, so assign to a variable first, matching the AcceptOwnershipEOA{} convention.) mcmsOut, err := sui_cs.ConfigureMCMS{}.Apply(e.Env, sui_cs.ConfigureMCMSConfig{ - ConfigureMCMSSeqInput: mcmsops.ConfigureMCMSSeqInput{ - ChainSelector: suiSel, - Proposer: &proposerCfg, - Bypasser: &bypasserCfg, - Canceller: &cancellerCfg, - }, + ChainSelector: suiSel, + Proposer: &proposerCfg, + Bypasser: &bypasserCfg, + Canceller: &cancellerCfg, // TimelockConfig nil -> SetConfig executes directly via the deployer signer. }) if err != nil { diff --git a/deployment/ccip/changeset/testhelpers/test_sui_helpers.go b/deployment/ccip/changeset/testhelpers/test_sui_helpers.go index 656a0cc6c6a..a5a2f88c816 100644 --- a/deployment/ccip/changeset/testhelpers/test_sui_helpers.go +++ b/deployment/ccip/changeset/testhelpers/test_sui_helpers.go @@ -32,6 +32,7 @@ import ( "github.com/smartcontractkit/chainlink-evm/gethwrappers/shared/generated/initial/burn_mint_erc677" suiBind "github.com/smartcontractkit/chainlink-sui/bindings/bind" + suicodec "github.com/smartcontractkit/chainlink-sui/codec" sui_deployment "github.com/smartcontractkit/chainlink-sui/deployment" sui_cs "github.com/smartcontractkit/chainlink-sui/deployment/changesets" sui_ops "github.com/smartcontractkit/chainlink-sui/deployment/ops" @@ -39,7 +40,6 @@ import ( burnminttokenpoolops "github.com/smartcontractkit/chainlink-sui/deployment/ops/ccip_burn_mint_token_pool" lockreleasetokenpoolops "github.com/smartcontractkit/chainlink-sui/deployment/ops/ccip_lock_release_token_pool" managedtokenpoolops "github.com/smartcontractkit/chainlink-sui/deployment/ops/ccip_managed_token_pool" - managedtokenops "github.com/smartcontractkit/chainlink-sui/deployment/ops/managed_token" suiofframp_helper "github.com/smartcontractkit/chainlink-sui/relayer/chainwriter/ptb/offramp" cslclient "github.com/smartcontractkit/chainlink-sui/relayer/client" @@ -398,32 +398,32 @@ func SendSuiCCIPRequest(e cldf.Environment, cfg *ccipclient.CCIPSendReqConfig) ( switch msg.TokenAmounts[0].TokenPoolType { case sui_deployment.TokenPoolTypeBurnMint: paramValuesLockBurn = []any{ - suiBind.Object{Id: ccipObjectRefID}, // ref - createTokenTransferParamsResult, // token_params - splitCoinArg, // exact-amount coin to send to EVM + suicodec.Object{Id: ccipObjectRefID}, // ref + createTokenTransferParamsResult, // token_params + splitCoinArg, // exact-amount coin to send to EVM cfg.DestChain, - suiBind.Object{Id: "0x6"}, // clock - suiBind.Object{Id: tokenPoolStateObjectID}, // BM TP state object id + suicodec.Object{Id: "0x6"}, // clock + suicodec.Object{Id: tokenPoolStateObjectID}, // BM TP state object id } case sui_deployment.TokenPoolTypeManaged: paramValuesLockBurn = []any{ - suiBind.Object{Id: ccipObjectRefID}, // ref - createTokenTransferParamsResult, // token_params - splitCoinArg, // exact-amount coin to send to EVM + suicodec.Object{Id: ccipObjectRefID}, // ref + createTokenTransferParamsResult, // token_params + splitCoinArg, // exact-amount coin to send to EVM cfg.DestChain, - suiBind.Object{Id: "0x6"}, // clock - suiBind.Object{Id: "0x403"}, // deny list - suiBind.Object{Id: state.SuiChains[cfg.SourceChain].ManagedTokens[TokenSymbolLINK].StateObjectId}, // Managed token state object id - suiBind.Object{Id: tokenPoolStateObjectID}, // Managed TP state object id + suicodec.Object{Id: "0x6"}, // clock + suicodec.Object{Id: "0x403"}, // deny list + suicodec.Object{Id: state.SuiChains[cfg.SourceChain].ManagedTokens[TokenSymbolLINK].StateObjectId}, // Managed token state object id + suicodec.Object{Id: tokenPoolStateObjectID}, // Managed TP state object id } case sui_deployment.TokenPoolTypeLockRelease: paramValuesLockBurn = []any{ - suiBind.Object{Id: ccipObjectRefID}, // ref - createTokenTransferParamsResult, // token_params - splitCoinArg, // exact-amount coin to lock for EVM + suicodec.Object{Id: ccipObjectRefID}, // ref + createTokenTransferParamsResult, // token_params + splitCoinArg, // exact-amount coin to lock for EVM cfg.DestChain, - suiBind.Object{Id: "0x6"}, // clock - suiBind.Object{Id: tokenPoolStateObjectID}, // LnR TP state object id + suicodec.Object{Id: "0x6"}, // clock + suicodec.Object{Id: tokenPoolStateObjectID}, // LnR TP state object id } default: return nil, fmt.Errorf("unsupported token pool type: %s", msg.TokenAmounts[0].TokenPoolType) @@ -464,15 +464,15 @@ func SendSuiCCIPRequest(e cldf.Environment, cfg *ccipclient.CCIPSendReqConfig) ( } paramValuesCCIPSend := []any{ - suiBind.Object{Id: ccipObjectRefID}, - suiBind.Object{Id: onRampStateObjectID}, - suiBind.Object{Id: "0x6"}, + suicodec.Object{Id: ccipObjectRefID}, + suicodec.Object{Id: onRampStateObjectID}, + suicodec.Object{Id: "0x6"}, cfg.DestChain, msg.Receiver, // receiver msg.Data, - createTokenTransferParamsResult, // tokenParams from the original create_token_transfer_params - suiBind.Object{Id: linkTokenObjectMetadataID}, // feeTokenMetadata - suiBind.Object{Id: msg.FeeToken}, + createTokenTransferParamsResult, // tokenParams from the original create_token_transfer_params + suicodec.Object{Id: linkTokenObjectMetadataID}, // feeTokenMetadata + suicodec.Object{Id: msg.FeeToken}, msg.ExtraArgs, // extraArgs } @@ -602,15 +602,15 @@ func SendSuiCCIPRequest(e cldf.Environment, cfg *ccipclient.CCIPSendReqConfig) ( typeArgsList = []string{linkTokenPkgID + "::link::LINK"} typeParamsList = []string{} paramValues = []any{ - suiBind.Object{Id: ccipObjectRefID}, - suiBind.Object{Id: onRampStateObjectID}, - suiBind.Object{Id: "0x6"}, + suicodec.Object{Id: ccipObjectRefID}, + suicodec.Object{Id: onRampStateObjectID}, + suicodec.Object{Id: "0x6"}, cfg.DestChain, msg.Receiver, // receiver (TODO: replace this with sender Address use environment.NormalizeTo32Bytes(ethereumAddress) from sui repo) msg.Data, - extractedAny2SuiMessageResult, // tokenParams - suiBind.Object{Id: linkTokenObjectMetadataID}, // feeTokenMetadata - suiBind.Object{Id: msg.FeeToken}, + extractedAny2SuiMessageResult, // tokenParams + suicodec.Object{Id: linkTokenObjectMetadataID}, // feeTokenMetadata + suicodec.Object{Id: msg.FeeToken}, msg.ExtraArgs, // extraArgs } @@ -711,8 +711,8 @@ func MakeSuiSourceSVMExtraArgsV1(computeUnits uint32, writableBitmap uint64, all s.U64(writableBitmap) s.Bool(allowOOO) s.WriteBytes(tokenReceiver[:]) // vector: ULEB128(32) + 32 bytes - bcs.SerializeSequenceWithFunction(accounts, s, func(ser *bcs.Serializer, acct [32]byte) { - ser.WriteBytes(acct[:]) // each account: vector of length 32 + bcs.SerializeSequenceWithFunction(accounts, s, func(serial *bcs.Serializer, acct [32]byte) { + serial.WriteBytes(acct[:]) // each account: vector of length 32 }) if err := s.Error(); err != nil { panic(fmt.Errorf("encode Sui-source SVMExtraArgsV1: %w", err)) @@ -996,14 +996,12 @@ func HandleTokenAndManagedTokenPoolDeploymentForSUI(e cldf.Environment, suiChain // Deploy & Configure Managed Token on SUI e, _, err = commoncs.ApplyChangesets(&testing.T{}, e, []commoncs.ConfiguredChangeSet{ commoncs.Configure(sui_cs.DeployManagedToken{}, sui_cs.DeployManagedTokenConfig{ - DeployAndInitManagedTokenInput: managedtokenops.DeployAndInitManagedTokenInput{ - CoinObjectTypeArg: linkTokenPkgID + "::link::LINK", - TreasuryCapObjectId: linkTokenTreasuryCapID, - MinterAddress: deployerAddr, - Allowance: 0, - IsUnlimited: true, - }, - ChainSelector: suiChainSel, + CoinObjectTypeArg: linkTokenPkgID + "::link::LINK", + TreasuryCapObjectId: linkTokenTreasuryCapID, + MinterAddress: deployerAddr, + Allowance: 0, + IsUnlimited: true, + ChainSelector: suiChainSel, }), }) if err != nil { @@ -1270,7 +1268,7 @@ func UpgradeContractDirect( } paramValues := []any{ - suiBind.Object{Id: upgradeCapID}, + suicodec.Object{Id: upgradeCapID}, policy, digest, } @@ -1316,7 +1314,7 @@ func UpgradeContractDirect( } paramValuesCommit := []any{ - suiBind.Object{Id: upgradeCapID}, + suicodec.Object{Id: upgradeCapID}, upgradeReceiptArg, } diff --git a/deployment/ccip/changeset/testhelpers/test_usdc_helpers.go b/deployment/ccip/changeset/testhelpers/test_usdc_helpers.go index 1c5ad9af945..9548cba848b 100644 --- a/deployment/ccip/changeset/testhelpers/test_usdc_helpers.go +++ b/deployment/ccip/changeset/testhelpers/test_usdc_helpers.go @@ -23,9 +23,9 @@ func ConfigureUSDCTokenPools( chains map[uint64]cldf_evm.Chain, src, dst uint64, state stateview.CCIPOnChainState, -) (*burn_mint_erc677.BurnMintERC677, *burn_mint_erc677.BurnMintERC677, error) { - srcToken := state.MustGetEVMChainState(src).BurnMintTokens677[shared.USDCSymbol] - dstToken := state.MustGetEVMChainState(dst).BurnMintTokens677[shared.USDCSymbol] +) (srcToken *burn_mint_erc677.BurnMintERC677, dstToken *burn_mint_erc677.BurnMintERC677, err error) { + srcToken = state.MustGetEVMChainState(src).BurnMintTokens677[shared.USDCSymbol] + dstToken = state.MustGetEVMChainState(dst).BurnMintTokens677[shared.USDCSymbol] srcPool := state.MustGetEVMChainState(src).USDCTokenPools[deployment.Version1_5_1] dstPool := state.MustGetEVMChainState(dst).USDCTokenPools[deployment.Version1_5_1] diff --git a/deployment/ccip/changeset/testhelpers/v1_5/test_helpers.go b/deployment/ccip/changeset/testhelpers/v1_5/test_helpers.go index ffc0e94e8c1..96f73c89a2a 100644 --- a/deployment/ccip/changeset/testhelpers/v1_5/test_helpers.go +++ b/deployment/ccip/changeset/testhelpers/v1_5/test_helpers.go @@ -693,7 +693,8 @@ func SetOCR2ConfigForTestChangeset(env cldf.Environment, c OCR2Config) (cldf.Cha for _, exec := range c.ExecConfigs { if err := exec.PopulateOffChainAndOnChainCfg( state.MustGetEVMChainState(exec.DestinationChainSelector).Router.Address(), - state.MustGetEVMChainState(exec.DestinationChainSelector).PriceRegistry.Address()); err != nil { + state.MustGetEVMChainState(exec.DestinationChainSelector).PriceRegistry.Address(), + ); err != nil { return cldf.ChangesetOutput{}, fmt.Errorf("failed to populate offchain and onchain config for offramp: %w", err) } finalCfg, err := deriveOCR2Config(env, exec.DestinationChainSelector, exec.OCR2ConfigParams) @@ -744,12 +745,10 @@ func deriveOCR2Config( return FinalOCR2Config{}, fmt.Errorf("no OCR config for chain %d", chainSel) } oracles = append(oracles, confighelper.OracleIdentityExtra{ - OracleIdentity: confighelper.OracleIdentity{ - OnchainPublicKey: cfg.OnchainPublicKey, - TransmitAccount: cfg.TransmitAccount, - OffchainPublicKey: cfg.OffchainPublicKey, - PeerID: cfg.PeerID.Raw(), - }, + OnchainPublicKey: cfg.OnchainPublicKey, + TransmitAccount: cfg.TransmitAccount, + OffchainPublicKey: cfg.OffchainPublicKey, + PeerID: cfg.PeerID.Raw(), ConfigEncryptionPublicKey: cfg.ConfigEncryptionPublicKey, }) } @@ -1126,7 +1125,8 @@ func WaitForExecute( it, err := offRamp.FilterExecutionStateChanged( &bind.FilterOpts{ Start: blockNum, - }, seqNrs, [][32]byte{}) + }, seqNrs, [][32]byte{}, + ) require.NoError(t, err) for it.Next() { t.Logf("Execution state changed for sequence number=%d current state=%d", it.Event.SequenceNumber, it.Event.State) diff --git a/deployment/ccip/changeset/v1_5/cs_burn_mint_erc20_pausable_freezable_transparent.go b/deployment/ccip/changeset/v1_5/cs_burn_mint_erc20_pausable_freezable_transparent.go index 46ce9475ea4..2a955212d4c 100644 --- a/deployment/ccip/changeset/v1_5/cs_burn_mint_erc20_pausable_freezable_transparent.go +++ b/deployment/ccip/changeset/v1_5/cs_burn_mint_erc20_pausable_freezable_transparent.go @@ -101,7 +101,6 @@ func DeployBurnMintERC20PausableFreezableTransparent(e cldf.Environment, c BurnM } }, ) - if err != nil { return cldf.ChangesetOutput{}, fmt.Errorf("failed to deploy BurnMintERC20PausableFreezableTransparent for %s token on %s: %w", token, chain, err) } diff --git a/deployment/ccip/changeset/v1_5/cs_burn_mint_erc20_transparent.go b/deployment/ccip/changeset/v1_5/cs_burn_mint_erc20_transparent.go index 2f51d558429..7985e460a66 100644 --- a/deployment/ccip/changeset/v1_5/cs_burn_mint_erc20_transparent.go +++ b/deployment/ccip/changeset/v1_5/cs_burn_mint_erc20_transparent.go @@ -85,7 +85,6 @@ func DeployBurnMintERC20Transparent(e cldf.Environment, c BurnMintERC20Transpare } }, ) - if err != nil { return cldf.ChangesetOutput{}, fmt.Errorf("failed to deploy BurnMintERC20Transparent for %s token on %s: %w", token, chain, err) } diff --git a/deployment/ccip/changeset/v1_5/cs_rmn.go b/deployment/ccip/changeset/v1_5/cs_rmn.go index add5c88c91f..8693341d920 100644 --- a/deployment/ccip/changeset/v1_5/cs_rmn.go +++ b/deployment/ccip/changeset/v1_5/cs_rmn.go @@ -10,9 +10,10 @@ import ( cldfproposalutils "github.com/smartcontractkit/chainlink-deployments-framework/engine/cld/mcms/proposalutils" - cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment" proposeutils "github.com/smartcontractkit/cld-changesets/legacy/mcms/proposeutils" + cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment" + mcmslib "github.com/smartcontractkit/mcms" mcmssdk "github.com/smartcontractkit/mcms/sdk" mcmstypes "github.com/smartcontractkit/mcms/types" diff --git a/deployment/ccip/changeset/v1_5_1/cs_add_token_e2e.go b/deployment/ccip/changeset/v1_5_1/cs_add_token_e2e.go index b414864ad46..406915581dd 100644 --- a/deployment/ccip/changeset/v1_5_1/cs_add_token_e2e.go +++ b/deployment/ccip/changeset/v1_5_1/cs_add_token_e2e.go @@ -344,7 +344,7 @@ func addTokenE2ELogic(env cldf.Environment, config AddTokensE2EConfig) (cldf.Cha if err := ccipcommoncs.MergeChangesetOutput(e, finalCSOut, output); err != nil { return cldf.ChangesetOutput{}, fmt.Errorf("failed to merge address book for token %s: %w", token, err) } - newAddresses, err := output.AddressBook.Addresses() //nolint:staticcheck // Addressbook is deprecated, but we still use it for the time being + newAddresses, err := output.AddressBook.Addresses() if err != nil { return cldf.ChangesetOutput{}, fmt.Errorf("failed to get addresses from address book: %w", err) } @@ -460,7 +460,7 @@ func addTokenE2ELogic(env cldf.Environment, config AddTokensE2EConfig) (cldf.Cha } // if there are multiple proposals, aggregate them so that we don't have to propose them separately if len(finalCSOut.MCMSTimelockProposals) > 1 { - aggregatedProposals, err := proposeutils.AggregateProposals( //nolint:staticcheck // SA1019: not migrating to AggregateProposalsV2 in this PR + aggregatedProposals, err := proposeutils.AggregateProposals( //nolint:staticcheck // SA1019: AggregateProposalsV2 migration is tracked separately e, state.EVMMCMSStateByChain(), nil, @@ -721,12 +721,12 @@ func addMinterAndMintTokenHelper(env cldf.Environment, selector uint64, token *b } // addMinterAndBurnerForBurnMintERC20Token adds the burner and minter role to the specified address. -func addMinterAndBurnerForBurnMintERC20Token(env cldf.Environment, selector uint64, tokenAddress common.Address, poolAddress common.Address) error { +func addMinterAndBurnerForBurnMintERC20Token(env cldf.Environment, selector uint64, tokenAddress, poolAddress common.Address) error { return addMinterAndBurnerForBurnMintERC20TokenHelper(env, selector, tokenAddress, poolAddress) } // addMinterAndBurnerForBurnMintERC20TokenHelper is a helper function that adds the minter and burner role to the specified address for BurnMintERC20 token. -func addMinterAndBurnerForBurnMintERC20TokenHelper(env cldf.Environment, selector uint64, tokenAddress common.Address, poolAddress common.Address) error { +func addMinterAndBurnerForBurnMintERC20TokenHelper(env cldf.Environment, selector uint64, tokenAddress, poolAddress common.Address) error { deployerKey := env.BlockChains.EVMChains()[selector].DeployerKey ctx := env.GetContext() @@ -825,7 +825,7 @@ func grantDefaultAdminRoleForBurnMintERC20Token(env cldf.Environment, selector u return nil } -func addMinterForERC677Token(env cldf.Environment, chain cldf_evm.Chain, tokenAddress common.Address, poolAddress common.Address) error { +func addMinterForERC677Token(env cldf.Environment, chain cldf_evm.Chain, tokenAddress, poolAddress common.Address) error { _, err := operations.ExecuteOperation(env.OperationsBundle, ccipops.GrantMintAndBurnRolesERC677Op, chain, opsutils.EVMCallInput[common.Address]{ Address: tokenAddress, ChainSelector: chain.Selector, diff --git a/deployment/ccip/changeset/v1_5_1/cs_configure_token_pools.go b/deployment/ccip/changeset/v1_5_1/cs_configure_token_pools.go index 42715855cd4..7dfa9f722d1 100644 --- a/deployment/ccip/changeset/v1_5_1/cs_configure_token_pools.go +++ b/deployment/ccip/changeset/v1_5_1/cs_configure_token_pools.go @@ -124,7 +124,7 @@ func resolvePartialRateLimiterConfig( tokenPool *token_pool.TokenPool, remoteChainSelector uint64, chainUpdate RateLimiterConfig, -) (inbound token_pool.RateLimiterConfig, outbound token_pool.RateLimiterConfig, err error) { +) (inbound, outbound token_pool.RateLimiterConfig, err error) { if chainUpdate.Inbound == nil && chainUpdate.Outbound == nil { return token_pool.RateLimiterConfig{}, token_pool.RateLimiterConfig{}, errors.New("at least one of inbound or outbound rate limiter config must be set") } @@ -204,10 +204,10 @@ type SolChainUpdate struct { Metadata string `json:"metadata"` } -func (c SolChainUpdate) GetSolanaTokenAndTokenPool(state solanastateview.CCIPChainState) (token solana.PublicKey, tokenPool solana.PublicKey, err error) { +func (c SolChainUpdate) GetSolanaTokenAndTokenPool(state solanastateview.CCIPChainState) (token, tokenPool solana.PublicKey, err error) { if c.Metadata == "" { err = errors.New("metadata must be defined for solana token pool in SolChainUpdate") - return + return token, tokenPool, err } var tokenPoolProgram solana.PublicKey @@ -220,15 +220,15 @@ func (c SolChainUpdate) GetSolanaTokenAndTokenPool(state solanastateview.CCIPCha tokenPoolProgram = state.CCTPTokenPool default: err = fmt.Errorf("unknown solana token pool type %s", c.Type) - return + return token, tokenPool, err } if c.TokenAddress == "" { err = errors.New("token address must be defined") - return + return token, tokenPool, err } if tokenPoolProgram.IsZero() { err = fmt.Errorf("token pool program %s is not defined for metadata %s", tokenPoolProgram, c.Metadata) - return + return token, tokenPool, err } token = solana.MustPublicKeyFromBase58(c.TokenAddress) tokenPool, err = solTokenUtil.TokenPoolConfigAddress(token, tokenPoolProgram) @@ -236,9 +236,9 @@ func (c SolChainUpdate) GetSolanaTokenAndTokenPool(state solanastateview.CCIPCha token = solana.PublicKey{} tokenPool = solana.PublicKey{} err = fmt.Errorf("failed to get token pool address for token %s on solana chain: %w", c.TokenAddress, err) - return + return token, tokenPool, err } - return + return token, tokenPool, err } func (c SolChainUpdate) Validate(state solanastateview.CCIPChainState) error { @@ -261,7 +261,7 @@ type AptosChainUpdate struct { Type cldf.ContractType } -func (c AptosChainUpdate) GetAptosTokenAndTokenPool(state aptosstate.CCIPChainState) (token aptos.AccountAddress, tokenPoolAddress aptos.AccountAddress, err error) { +func (c AptosChainUpdate) GetAptosTokenAndTokenPool(state aptosstate.CCIPChainState) (token, tokenPoolAddress aptos.AccountAddress, err error) { if c.TokenAddress == "" { return aptos.AccountAddress{}, aptos.AccountAddress{}, errors.New("token address must be defined") } @@ -307,7 +307,7 @@ type SuiChainUpdate struct { Type cldf.ContractType } -func (c SuiChainUpdate) GetSuiTokenAndTokenPool(state suistate.CCIPChainState) (tokenAddress string, tokenPoolAddress string, err error) { +func (c SuiChainUpdate) GetSuiTokenAndTokenPool(state suistate.CCIPChainState) (tokenAddress, tokenPoolAddress string, err error) { var tpAddress string if c.TokenAddress == "" { return "", "", errors.New("token address must be defined") @@ -1043,7 +1043,7 @@ func ConfigureMultiplePoolLogic(env cldf.Environment, c ConfigureMultipleTokenPo } // if there are multiple proposals, aggregate them so that we don't have to propose them separately if len(finalOutput.MCMSTimelockProposals) > 1 { - aggregatedProposals, err := proposeutils.AggregateProposals( //nolint:staticcheck // SA1019: not migrating to AggregateProposalsV2 in this PR + aggregatedProposals, err := proposeutils.AggregateProposals( //nolint:staticcheck // SA1019: AggregateProposalsV2 migration is tracked separately env, state.EVMMCMSStateByChain(), nil, diff --git a/deployment/ccip/changeset/v1_5_1/cs_sync_usdc_domains_with_chains_test.go b/deployment/ccip/changeset/v1_5_1/cs_sync_usdc_domains_with_chains_test.go index f86b11f6f83..f755ddb46ea 100644 --- a/deployment/ccip/changeset/v1_5_1/cs_sync_usdc_domains_with_chains_test.go +++ b/deployment/ccip/changeset/v1_5_1/cs_sync_usdc_domains_with_chains_test.go @@ -22,7 +22,6 @@ import ( "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/v1_5_1" "github.com/smartcontractkit/chainlink/deployment/ccip/shared" "github.com/smartcontractkit/chainlink/deployment/ccip/shared/stateview" - commonchangeset "github.com/smartcontractkit/chainlink/deployment/common/changeset" commoncs "github.com/smartcontractkit/chainlink/deployment/common/changeset" ) @@ -149,7 +148,7 @@ func TestValidateSyncUSDCDomainsWithChainsConfig(t *testing.T) { if test.DeployUSDC { var err error e, err = commoncs.Apply(t, e, - commonchangeset.Configure( + commoncs.Configure( cldf.CreateLegacyChangeSet(v1_5_1.ConfigureTokenPoolContractsChangeset), v1_5_1.ConfigureTokenPoolContractsConfig{ PoolUpdates: map[uint64]v1_5_1.TokenPoolConfig{ @@ -217,7 +216,7 @@ func TestSyncUSDCDomainsWithChainsChangeset(t *testing.T) { if mcmsConfig != nil { // Transfer ownership of token pools to timelock e, err = commoncs.Apply(t, e, - commonchangeset.Configure( + commoncs.Configure( cldf.CreateLegacyChangeSet(mcmschangesets.TransferToMCMSWithTimelockV2), mcmschangesets.TransferToMCMSWithTimelockConfig{ ContractsByChain: timelockOwnedContractsByChain, @@ -229,7 +228,7 @@ func TestSyncUSDCDomainsWithChainsChangeset(t *testing.T) { } e, err = commoncs.Apply(t, e, - commonchangeset.Configure( + commoncs.Configure( cldf.CreateLegacyChangeSet(v1_5_1.ConfigureTokenPoolContractsChangeset), v1_5_1.ConfigureTokenPoolContractsConfig{ MCMS: mcmsConfig, @@ -256,7 +255,7 @@ func TestSyncUSDCDomainsWithChainsChangeset(t *testing.T) { require.NoError(t, err) e, err = commoncs.Apply(t, e, - commonchangeset.Configure( + commoncs.Configure( cldf.CreateLegacyChangeSet(v1_5_1.SyncUSDCDomainsWithChainsChangeset), v1_5_1.SyncUSDCDomainsWithChainsConfig{ MCMS: mcmsConfig, diff --git a/deployment/ccip/changeset/v1_6/config.go b/deployment/ccip/changeset/v1_6/config.go index 18fd500612d..bb240f87740 100644 --- a/deployment/ccip/changeset/v1_6/config.go +++ b/deployment/ccip/changeset/v1_6/config.go @@ -6,8 +6,8 @@ import ( "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink-common/pkg/merklemulti" - "github.com/smartcontractkit/chainlink-ccip/pkg/types/ccipocr3" "github.com/smartcontractkit/chainlink-ccip/pluginconfig" + ccipocr3 "github.com/smartcontractkit/chainlink-common/pkg/types/ccipocr3" "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/globals" "github.com/smartcontractkit/chainlink/deployment/ccip/shared" @@ -116,7 +116,7 @@ func (c OCRConfigChainType) ExecuteOCRParams() CCIPOCRParams { func DeriveOCRParamsForCommit( ocrChainType OCRConfigChainType, feedChain uint64, - feeTokenInfo map[ccipocr3.UnknownEncodedAddress]pluginconfig.TokenInfo, + feeTokenInfo map[ccipocr3.UnknownEncodedAddress]ccipocr3.TokenInfo, override func(params CCIPOCRParams) CCIPOCRParams, ) CCIPOCRParams { params := ocrChainType.CommitOCRParams() diff --git a/deployment/ccip/changeset/v1_6/cs_active_candidate_test.go b/deployment/ccip/changeset/v1_6/cs_active_candidate_test.go index 4b9ad80dbd7..972823f7eb3 100644 --- a/deployment/ccip/changeset/v1_6/cs_active_candidate_test.go +++ b/deployment/ccip/changeset/v1_6/cs_active_candidate_test.go @@ -197,12 +197,10 @@ func Test_ActiveCandidate(t *testing.T) { commonchangeset.Configure( cldf.CreateLegacyChangeSet(v1_6.SetCandidateChangeset), v1_6.SetCandidateChangesetConfig{ - SetCandidateConfigBase: v1_6.SetCandidateConfigBase{ - HomeChainSelector: tenv.HomeChainSel, - FeedChainSelector: tenv.FeedChainSel, - MCMS: &cldfproposalutils.TimelockConfig{ - MinDelay: 0, - }, + HomeChainSelector: tenv.HomeChainSel, + FeedChainSelector: tenv.FeedChainSel, + MCMS: &cldfproposalutils.TimelockConfig{ + MinDelay: 0, }, PluginInfo: []v1_6.SetCandidatePluginInfo{ { diff --git a/deployment/ccip/changeset/v1_6/cs_add_lane_test.go b/deployment/ccip/changeset/v1_6/cs_add_lane_test.go index 52cf503d20b..a4eb26287f7 100644 --- a/deployment/ccip/changeset/v1_6/cs_add_lane_test.go +++ b/deployment/ccip/changeset/v1_6/cs_add_lane_test.go @@ -27,7 +27,7 @@ func TestAddLanesWithTestRouter(t *testing.T) { selectors := e.Env.BlockChains.ListChainSelectors(cldf_chain.WithFamily(chain_selectors.FamilyEVM)) chain1, chain2 := selectors[0], selectors[1] - testhelpers.AddLaneWithDefaultPricesAndFeeQuoterConfig(t, &e, state, chain1, chain2, true) + require.NoError(t, testhelpers.AddLaneWithDefaultPricesAndFeeQuoterConfig(t, &e, state, chain1, chain2, true)) // Need to keep track of the block number for each chain so that event subscription can be done from that block. startBlocks := make(map[uint64]*uint64) // Send a message from each chain to every other chain. @@ -62,11 +62,11 @@ func TestAddLanesWithSolana(t *testing.T) { chain1, chain2 := evmSelectors[0], evmSelectors[1] solSelectors := e.Env.BlockChains.ListChainSelectors(cldf_chain.WithFamily(chain_selectors.FamilySolana)) solChain := solSelectors[0] - testhelpers.AddLaneWithDefaultPricesAndFeeQuoterConfig(t, &e, state, chain1, solChain, true) + require.NoError(t, testhelpers.AddLaneWithDefaultPricesAndFeeQuoterConfig(t, &e, state, chain1, solChain, true)) // AddLaneWithDefaultPricesAndFeeQuoterConfig involves calling AddRemoteChainToSolana // which adds chain1 to solana // so we can not call AddRemoteChainToSolana again with chain1 again, hence using chain2 below - testhelpers.AddLaneWithDefaultPricesAndFeeQuoterConfig(t, &e, state, solChain, chain2, true) + require.NoError(t, testhelpers.AddLaneWithDefaultPricesAndFeeQuoterConfig(t, &e, state, solChain, chain2, true)) _, _, _, err = testhelpers.DeployTransferableTokenSolanaV0_1_1(e.Env.Logger, &e.Env, chain1, solChain, e.Env.BlockChains.EVMChains()[chain1].DeployerKey, "MY_TOKEN") require.NoError(t, err) } diff --git a/deployment/ccip/changeset/v1_6/cs_add_new_chain_e2e.go b/deployment/ccip/changeset/v1_6/cs_add_new_chain_e2e.go index 1ef0a7a4190..b34ab9b43da 100644 --- a/deployment/ccip/changeset/v1_6/cs_add_new_chain_e2e.go +++ b/deployment/ccip/changeset/v1_6/cs_add_new_chain_e2e.go @@ -411,11 +411,9 @@ func addCandidatesForNewChainLogic(e cldf.Environment, c AddCandidatesForNewChai // Add the DON to the registry and set candidate for the commit plugin out, err = AddDonAndSetCandidateChangeset(e, AddDonAndSetCandidateChangesetConfig{ - SetCandidateConfigBase: SetCandidateConfigBase{ - HomeChainSelector: c.HomeChainSelector, - FeedChainSelector: c.FeedChainSelector, - MCMS: c.MCMSConfig, - }, + HomeChainSelector: c.HomeChainSelector, + FeedChainSelector: c.FeedChainSelector, + MCMS: c.MCMSConfig, PluginInfo: SetCandidatePluginInfo{ PluginType: types.PluginTypeCCIPCommit, OCRConfigPerRemoteChainSelector: map[uint64]CCIPOCRParams{ @@ -433,11 +431,9 @@ func addCandidatesForNewChainLogic(e cldf.Environment, c AddCandidatesForNewChai // Set the candidate for the exec plugin out, err = SetCandidateChangeset(e, SetCandidateChangesetConfig{ - SetCandidateConfigBase: SetCandidateConfigBase{ - HomeChainSelector: c.HomeChainSelector, - FeedChainSelector: c.FeedChainSelector, - MCMS: c.MCMSConfig, - }, + HomeChainSelector: c.HomeChainSelector, + FeedChainSelector: c.FeedChainSelector, + MCMS: c.MCMSConfig, PluginInfo: []SetCandidatePluginInfo{ { PluginType: types.PluginTypeCCIPExec, @@ -474,7 +470,7 @@ func addCandidatesForNewChainLogic(e cldf.Environment, c AddCandidatesForNewChai var proposal *mcmslib.TimelockProposal if c.MCMSConfig != nil && len(allProposals) > 0 { - proposal, err = proposeutils.AggregateProposals( //nolint:staticcheck // SA1019: not migrating to AggregateProposalsV2 yet + proposal, err = proposeutils.AggregateProposals( //nolint:staticcheck // SA1019: AggregateProposalsV2 migration is tracked separately e, state.EVMMCMSStateByChain(), nil, @@ -494,7 +490,10 @@ func addCandidatesForNewChainLogic(e cldf.Environment, c AddCandidatesForNewChai ds := finalDS if proposal == nil { - return cldf.ChangesetOutput{AddressBook: newAddresses, DataStore: ds}, nil + return cldf.ChangesetOutput{ + AddressBook: newAddresses, + DataStore: ds, + }, nil } return cldf.ChangesetOutput{ AddressBook: newAddresses, @@ -667,7 +666,7 @@ func promoteNewChainForConfigLogic(e cldf.Environment, c PromoteNewChainForConfi if c.MCMSConfig == nil || len(allProposals) == 0 { return cldf.ChangesetOutput{}, nil } - proposal, err := proposeutils.AggregateProposals( //nolint:staticcheck // SA1019: not migrating to AggregateProposalsV2 in this PR + proposal, err := proposeutils.AggregateProposals( //nolint:staticcheck // SA1019: AggregateProposalsV2 migration is tracked separately e, state.EVMMCMSStateByChain(), nil, @@ -890,7 +889,7 @@ func connectNewChainLogic(env cldf.Environment, c ConnectNewChainConfig) (cldf.C if c.MCMSConfig == nil || len(allProposals) == 0 { return cldf.ChangesetOutput{}, nil } - proposal, err := proposeutils.AggregateProposals( //nolint:staticcheck // SA1019: not migrating to AggregateProposalsV2 in this PR + proposal, err := proposeutils.AggregateProposals( //nolint:staticcheck // SA1019: AggregateProposalsV2 migration is tracked separately env, state.EVMMCMSStateByChain(), nil, diff --git a/deployment/ccip/changeset/v1_6/cs_add_new_chain_e2e_test.go b/deployment/ccip/changeset/v1_6/cs_add_new_chain_e2e_test.go index 77c23a3ed95..1a28f6cf536 100644 --- a/deployment/ccip/changeset/v1_6/cs_add_new_chain_e2e_test.go +++ b/deployment/ccip/changeset/v1_6/cs_add_new_chain_e2e_test.go @@ -33,7 +33,6 @@ import ( "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/testhelpers" "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/v1_6" ccipops "github.com/smartcontractkit/chainlink/deployment/ccip/operation/evm/v1_6" - ccipseq "github.com/smartcontractkit/chainlink/deployment/ccip/sequence/evm/v1_6" "github.com/smartcontractkit/chainlink/deployment/ccip/shared/stateview" commonchangeset "github.com/smartcontractkit/chainlink/deployment/common/changeset" @@ -395,10 +394,8 @@ func TestAddAndPromoteCandidatesForNewChain(t *testing.T) { remoteChains := make([]v1_6.ChainDefinition, len(remoteChainSelectors)) for i, selector := range remoteChainSelectors { remoteChains[i] = v1_6.ChainDefinition{ - ConnectionConfig: v1_6.ConnectionConfig{ - RMNVerificationDisabled: true, - AllowListEnabled: false, - }, + RMNVerificationDisabled: true, + AllowListEnabled: false, Selector: selector, GasPrice: big.NewInt(1e17), TokenPrices: map[common.Address]*big.Int{}, @@ -644,10 +641,8 @@ func TestValidateTransmitterAddresses(t *testing.T) { remoteChains := make([]v1_6.ChainDefinition, 1) // test remoteChains[0] = v1_6.ChainDefinition{ - ConnectionConfig: v1_6.ConnectionConfig{ - RMNVerificationDisabled: true, - AllowListEnabled: false, - }, + RMNVerificationDisabled: true, + AllowListEnabled: false, Selector: chain_selectors.ETHEREUM_TESTNET_SEPOLIA.Selector, GasPrice: big.NewInt(1e17), TokenPrices: map[common.Address]*big.Int{}, @@ -683,20 +678,14 @@ func TestValidateTransmitterAddresses(t *testing.T) { func newChainConfigHelper(newChainSel, feedChainSel uint64, linkTokenAddr common.Address, nodeInfo *deployment.Nodes, noOfPeers int) v1_6.NewChainDefinition { return v1_6.NewChainDefinition{ - ChainDefinition: v1_6.ChainDefinition{ - ConnectionConfig: v1_6.ConnectionConfig{ - RMNVerificationDisabled: true, - AllowListEnabled: false, - }, - Selector: newChainSel, - GasPrice: big.NewInt(1e17), - TokenPrices: map[common.Address]*big.Int{}, - FeeQuoterDestChainConfig: v1_6.DefaultFeeQuoterDestChainConfig(true), - }, - ChainContractParams: ccipseq.ChainContractParams{ - FeeQuoterParams: ccipops.DefaultFeeQuoterParams(), - OffRampParams: ccipops.DefaultOffRampParams(), - }, + RMNVerificationDisabled: true, + AllowListEnabled: false, + Selector: newChainSel, + GasPrice: big.NewInt(1e17), + TokenPrices: map[common.Address]*big.Int{}, + FeeQuoterDestChainConfig: v1_6.DefaultFeeQuoterDestChainConfig(true), + FeeQuoterParams: ccipops.DefaultFeeQuoterParams(), + OffRampParams: ccipops.DefaultOffRampParams(), ExistingContracts: changeset.ExistingContractsConfig{ ExistingContracts: []changeset.Contract{ { diff --git a/deployment/ccip/changeset/v1_6/cs_add_registry_module.go b/deployment/ccip/changeset/v1_6/cs_add_registry_module.go index 18f1ce39556..feeb5b5367a 100644 --- a/deployment/ccip/changeset/v1_6/cs_add_registry_module.go +++ b/deployment/ccip/changeset/v1_6/cs_add_registry_module.go @@ -16,9 +16,10 @@ import ( "github.com/smartcontractkit/chainlink-ccip/chains/evm/gobindings/generated/v1_5_0/token_admin_registry" - cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment" proposeutils "github.com/smartcontractkit/cld-changesets/legacy/mcms/proposeutils" + cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment" + "github.com/smartcontractkit/chainlink/deployment/ccip/shared" "github.com/smartcontractkit/chainlink/deployment/ccip/shared/deployergroup" "github.com/smartcontractkit/chainlink/deployment/ccip/shared/stateview" diff --git a/deployment/ccip/changeset/v1_6/cs_ccip_home.go b/deployment/ccip/changeset/v1_6/cs_ccip_home.go index 9ec610acd5a..62e7d9f7c43 100644 --- a/deployment/ccip/changeset/v1_6/cs_ccip_home.go +++ b/deployment/ccip/changeset/v1_6/cs_ccip_home.go @@ -23,8 +23,8 @@ import ( "github.com/smartcontractkit/chainlink-ccip/chains/evm/gobindings/generated/v1_6_0/ccip_home" "github.com/smartcontractkit/chainlink-ccip/chains/evm/gobindings/generated/v1_6_0/don_id_claimer" "github.com/smartcontractkit/chainlink-ccip/chains/solana/utils/tokens" - "github.com/smartcontractkit/chainlink-ccip/pkg/types/ccipocr3" "github.com/smartcontractkit/chainlink-ccip/pluginconfig" + ccipocr3 "github.com/smartcontractkit/chainlink-common/pkg/types/ccipocr3" cldf_evm "github.com/smartcontractkit/chainlink-deployments-framework/chain/evm" "github.com/smartcontractkit/chainlink-deployments-framework/datastore" @@ -111,7 +111,7 @@ func validateExecOffchainConfig(e cldf.Environment, c *pluginconfig.ExecuteOffch return nil } -func validateCommitOffchainConfig(c *pluginconfig.CommitOffchainConfig, selector uint64, feedChainSel uint64, state stateview.CCIPOnChainState) error { +func validateCommitOffchainConfig(c *pluginconfig.CommitOffchainConfig, selector, feedChainSel uint64, state stateview.CCIPOnChainState) error { if err := c.Validate(); err != nil { return fmt.Errorf("invalid commit off-chain config: %w", err) } @@ -330,7 +330,7 @@ func (c CCIPOCRParams) Copy() CCIPOCRParams { return newC } -func (c CCIPOCRParams) Validate(e cldf.Environment, selector uint64, feedChainSel uint64, state stateview.CCIPOnChainState) error { +func (c CCIPOCRParams) Validate(e cldf.Environment, selector, feedChainSel uint64, state stateview.CCIPOnChainState) error { if err := c.OCRParameters.Validate(); err != nil { return fmt.Errorf("invalid OCR parameters: %w", err) } @@ -534,7 +534,7 @@ func (p SetCandidatePluginInfo) String() string { return fmt.Sprintf("PluginType: %s, Chains: %v", p.PluginType.String(), allchains) } -func (p SetCandidatePluginInfo) Validate(e cldf.Environment, state stateview.CCIPOnChainState, homeChain uint64, feedChain uint64) error { +func (p SetCandidatePluginInfo) Validate(e cldf.Environment, state stateview.CCIPOnChainState, homeChain, feedChain uint64) error { if p.PluginType != types.PluginTypeCCIPCommit && p.PluginType != types.PluginTypeCCIPExec { return errors.New("PluginType must be set to either CCIPCommit or CCIPExec") @@ -1074,7 +1074,8 @@ func revokeCandidateOps( if !mcmsEnabled { _, err = cldf.ConfirmIfNoErrorWithABI( homeChain, updateDonTx, - capabilities_registry.CapabilitiesRegistryABI, err) + capabilities_registry.CapabilitiesRegistryABI, err, + ) if err != nil { return nil, fmt.Errorf("error confirming UpdateDON call in revoke candidate (don: %d; ptype: %s): %w", donID, types.PluginType(pluginType).String(), err) diff --git a/deployment/ccip/changeset/v1_6/cs_ccip_home_test.go b/deployment/ccip/changeset/v1_6/cs_ccip_home_test.go index f49ea4fa1ee..57dbe5f9d43 100644 --- a/deployment/ccip/changeset/v1_6/cs_ccip_home_test.go +++ b/deployment/ccip/changeset/v1_6/cs_ccip_home_test.go @@ -19,7 +19,6 @@ import ( cldfproposalutils "github.com/smartcontractkit/chainlink-deployments-framework/engine/cld/mcms/proposalutils" "github.com/smartcontractkit/chainlink-ccip/chainconfig" - cciptypes "github.com/smartcontractkit/chainlink-ccip/pkg/types/ccipocr3" "github.com/smartcontractkit/chainlink-testing-framework/lib/utils/testcontext" cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment" @@ -256,11 +255,9 @@ func Test_SetCandidate(t *testing.T) { _, err = commonchangeset.Apply(t, tenv.Env, commonchangeset.Configure( cldf.CreateLegacyChangeSet(v1_6.SetCandidateChangeset), v1_6.SetCandidateChangesetConfig{ - SetCandidateConfigBase: v1_6.SetCandidateConfigBase{ - HomeChainSelector: tenv.HomeChainSel, - FeedChainSelector: tenv.FeedChainSel, - MCMS: mcmsConfig, - }, + HomeChainSelector: tenv.HomeChainSel, + FeedChainSelector: tenv.FeedChainSel, + MCMS: mcmsConfig, PluginInfo: []v1_6.SetCandidatePluginInfo{ { OCRConfigPerRemoteChainSelector: map[uint64]v1_6.CCIPOCRParams{ @@ -281,11 +278,9 @@ func Test_SetCandidate(t *testing.T) { ), commonchangeset.Configure( cldf.CreateLegacyChangeSet(v1_6.SetCandidateChangeset), v1_6.SetCandidateChangesetConfig{ - SetCandidateConfigBase: v1_6.SetCandidateConfigBase{ - HomeChainSelector: tenv.HomeChainSel, - FeedChainSelector: tenv.FeedChainSel, - MCMS: mcmsConfig, - }, + HomeChainSelector: tenv.HomeChainSel, + FeedChainSelector: tenv.FeedChainSel, + MCMS: mcmsConfig, PluginInfo: []v1_6.SetCandidatePluginInfo{ { OCRConfigPerRemoteChainSelector: map[uint64]v1_6.CCIPOCRParams{ @@ -385,11 +380,9 @@ func Test_RevokeCandidate(t *testing.T) { commonchangeset.Configure( cldf.CreateLegacyChangeSet(v1_6.SetCandidateChangeset), v1_6.SetCandidateChangesetConfig{ - SetCandidateConfigBase: v1_6.SetCandidateConfigBase{ - HomeChainSelector: tenv.HomeChainSel, - FeedChainSelector: tenv.FeedChainSel, - MCMS: mcmsConfig, - }, + HomeChainSelector: tenv.HomeChainSel, + FeedChainSelector: tenv.FeedChainSel, + MCMS: mcmsConfig, PluginInfo: []v1_6.SetCandidatePluginInfo{ { OCRConfigPerRemoteChainSelector: map[uint64]v1_6.CCIPOCRParams{ @@ -531,8 +524,8 @@ func Test_UpdateChainConfigs(t *testing.T) { RemoteChainAdds: map[uint64]v1_6.ChainConfig{ otherChain: { EncodableChainConfig: chainconfig.ChainConfig{ - GasPriceDeviationPPB: cciptypes.BigInt{Int: big.NewInt(testhelpers.DefaultGasPriceDeviationPPB)}, - DAGasPriceDeviationPPB: cciptypes.BigInt{Int: big.NewInt(testhelpers.DefaultDAGasPriceDeviationPPB)}, + GasPriceDeviationPPB: ccipocr3.BigInt{Int: big.NewInt(testhelpers.DefaultGasPriceDeviationPPB)}, + DAGasPriceDeviationPPB: ccipocr3.BigInt{Int: big.NewInt(testhelpers.DefaultDAGasPriceDeviationPPB)}, OptimisticConfirmations: globals.OptimisticConfirmations, }, FChain: otherChainConfig.FChain, @@ -628,10 +621,8 @@ func Test_SetCandidateErrorsOnDuplicateUSDCTokenPoolProxyInDataStore(t *testing. func setCandidateExecConfig(homeChainSel, feedChainSel, dest uint64, sourcePoolAddress string) v1_6.SetCandidateChangesetConfig { return v1_6.SetCandidateChangesetConfig{ - SetCandidateConfigBase: v1_6.SetCandidateConfigBase{ - HomeChainSelector: homeChainSel, - FeedChainSelector: feedChainSel, - }, + HomeChainSelector: homeChainSel, + FeedChainSelector: feedChainSel, PluginInfo: []v1_6.SetCandidatePluginInfo{ { PluginType: types.PluginTypeCCIPExec, @@ -641,9 +632,7 @@ func setCandidateExecConfig(homeChainSel, feedChainSel, dest uint64, sourcePoolA Type: pluginconfig.USDCCCTPHandlerType, Version: "1.0", USDCCCTPObserverConfig: &pluginconfig.USDCCCTPObserverConfig{ - AttestationConfig: pluginconfig.AttestationConfig{ - AttestationAPI: "http://example.com", - }, + AttestationAPI: "http://example.com", Tokens: map[ccipocr3.ChainSelector]pluginconfig.USDCCCTPTokenConfig{ ccipocr3.ChainSelector(dest): { SourcePoolAddress: sourcePoolAddress, diff --git a/deployment/ccip/changeset/v1_6/cs_chain_contracts.go b/deployment/ccip/changeset/v1_6/cs_chain_contracts.go index 91677b3394d..3adfc826ee0 100644 --- a/deployment/ccip/changeset/v1_6/cs_chain_contracts.go +++ b/deployment/ccip/changeset/v1_6/cs_chain_contracts.go @@ -1223,19 +1223,20 @@ func (cfg UpdateRouterRampsConfig) Validate(e cldf.Environment, state stateview. return fmt.Errorf("missing onramp onramp for chain %d", chainSel) } if !cfg.SkipOwnershipCheck { - if cfg.TestRouter { + switch { + case cfg.TestRouter: // If activating on the test router, we don't need the other CCIP contracts to have proper ownership. if err := mcmschangesets.ValidateOwnership(e.GetContext(), cfg.MCMS != nil, e.BlockChains.EVMChains()[chainSel].DeployerKey.From, chainState.Timelock.Address(), chainState.TestRouter); err != nil { return err } - } else if cfg.MCMS == nil { + case cfg.MCMS == nil: // If we are not using MCMS, then we know we aren't in a production environment given the EnforceMCMSUsageIfProd check above. // In this case, we only need to validate that the router contract is owned by the deployer key. // We don't care about uniform ownership in non-production environments. if err := mcmschangesets.ValidateOwnership(e.GetContext(), cfg.MCMS != nil, e.BlockChains.EVMChains()[chainSel].DeployerKey.From, chainState.Timelock.Address(), chainState.Router); err != nil { return err } - } else { + default: // If we are activating ramps on the main router in a production environment, we should validate two things: // 1. All expected CCIP contracts exist on the chain. // 2. All contracts have the expected owner. diff --git a/deployment/ccip/changeset/v1_6/cs_chain_contracts_test.go b/deployment/ccip/changeset/v1_6/cs_chain_contracts_test.go index 5b51b731685..9b6617190cf 100644 --- a/deployment/ccip/changeset/v1_6/cs_chain_contracts_test.go +++ b/deployment/ccip/changeset/v1_6/cs_chain_contracts_test.go @@ -15,7 +15,7 @@ import ( cldfproposalutils "github.com/smartcontractkit/chainlink-deployments-framework/engine/cld/mcms/proposalutils" "github.com/smartcontractkit/chainlink-ccip/chainconfig" - cciptypes "github.com/smartcontractkit/chainlink-ccip/pkg/types/ccipocr3" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccipocr3" "github.com/smartcontractkit/chainlink-testing-framework/lib/utils/testcontext" @@ -547,10 +547,8 @@ func TestUpdateFeeQuoterDestsConfig_Validate_MultipleReportsEnabled(t *testing.T commonchangeset.Configure( cldf.CreateLegacyChangeSet(v1_6.SetCandidateChangeset), v1_6.SetCandidateChangesetConfig{ - SetCandidateConfigBase: v1_6.SetCandidateConfigBase{ - HomeChainSelector: homeChainSelector, - FeedChainSelector: tenv.FeedChainSel, - }, + HomeChainSelector: homeChainSelector, + FeedChainSelector: tenv.FeedChainSel, PluginInfo: []v1_6.SetCandidatePluginInfo{ { OCRConfigPerRemoteChainSelector: map[uint64]v1_6.CCIPOCRParams{ @@ -946,7 +944,8 @@ func TestUpdateNonceManagersCSApplyPreviousRampsUpdates(t *testing.T) { func TestSetOCR3ConfigValidations(t *testing.T) { e, _ := testhelpers.NewMemoryEnvironment( t, - testhelpers.WithPrerequisiteDeploymentOnly(nil)) + testhelpers.WithPrerequisiteDeploymentOnly(nil), + ) envNodes, err := deployment.NodeInfo(e.Env.NodeIDs, e.Env.Offchain) require.NoError(t, err) allChains := e.Env.BlockChains.ListChainSelectors(cldf_chain.WithFamily(chainselectors.FamilyEVM)) @@ -1022,8 +1021,7 @@ func TestSetOCR3ConfigValidations(t *testing.T) { // set wrong chain config with incorrect value of FChain wrongChainConfigs[chain] = v1_6.ChainConfig{ Readers: envNodes.NonBootstraps().PeerIDs(), - //nolint:gosec // disable G115 - FChain: uint8(len(envNodes.NonBootstraps().PeerIDs())), + FChain: uint8(len(envNodes.NonBootstraps().PeerIDs())), //nolint:gosec // G115: node count in tests is always far below MaxUint8 EncodableChainConfig: chainconfig.ChainConfig{ GasPriceDeviationPPB: cciptypes.BigInt{Int: big.NewInt(testhelpers.DefaultGasPriceDeviationPPB)}, DAGasPriceDeviationPPB: cciptypes.BigInt{Int: big.NewInt(testhelpers.DefaultDAGasPriceDeviationPPB)}, @@ -1046,10 +1044,8 @@ func TestSetOCR3ConfigValidations(t *testing.T) { // Add the DONs and candidate commit OCR instances for the chain. cldf.CreateLegacyChangeSet(v1_6.AddDonAndSetCandidateChangeset), v1_6.AddDonAndSetCandidateChangesetConfig{ - SetCandidateConfigBase: v1_6.SetCandidateConfigBase{ - HomeChainSelector: e.HomeChainSel, - FeedChainSelector: e.FeedChainSel, - }, + HomeChainSelector: e.HomeChainSel, + FeedChainSelector: e.FeedChainSel, PluginInfo: v1_6.SetCandidatePluginInfo{ OCRConfigPerRemoteChainSelector: commitOCRConfigs, PluginType: types.PluginTypeCCIPCommit, @@ -1197,7 +1193,8 @@ func TestApplyPremiumMultiplierWeiPerEthUpdatesFeeQuoterChangeset(t *testing.T) }, }, MCMS: mcmsConfig, - }), + }, + ), ) require.Error(t, err) require.Contains(t, err.Error(), "token TEST not found in state for chain") @@ -1260,7 +1257,8 @@ func TestApplyPremiumMultiplierWeiPerEthUpdatesFeeQuoterChangeset(t *testing.T) }, }, MCMS: mcmsConfig, - }), + }, + ), ) require.NoError(t, err) tokenAddress, err := state.Chains[source].TokenAddressBySymbol() @@ -1350,7 +1348,8 @@ func TestUpdateTokenPriceFeedsFeeQuoterChangeset(t *testing.T) { }, FeedChainSelector: tenv.FeedChainSel, MCMS: mcmsConfig, - }), + }, + ), ) require.Error(t, err) require.Contains(t, err.Error(), "price feed for token TEST not found in state for chain") @@ -1375,7 +1374,8 @@ func TestUpdateTokenPriceFeedsFeeQuoterChangeset(t *testing.T) { }, FeedChainSelector: tenv.FeedChainSel, MCMS: mcmsConfig, - }), + }, + ), ) require.NoError(t, err) tokenAddress, err := state.Chains[source].TokenAddressBySymbol() @@ -1460,7 +1460,8 @@ func TestApplyTokenTransferFeeConfigUpdatesFeeQuoterChangeset(t *testing.T) { }, }, MCMS: mcmsConfig, - }), + }, + ), ) require.Error(t, err) require.Contains(t, err.Error(), "min fee must be less than max fee for token") @@ -1496,7 +1497,8 @@ func TestApplyTokenTransferFeeConfigUpdatesFeeQuoterChangeset(t *testing.T) { }, }, MCMS: mcmsConfig, - }), + }, + ), ) require.NoError(t, err) }) @@ -1569,7 +1571,8 @@ func TestApplyTokenTransferFeeConfigUpdatesFeeQuoterChangesetV2(t *testing.T) { }, }, MCMS: mcmsConfig, - }), + }, + ), ) require.Error(t, err) require.Contains(t, err.Error(), "min fee must be less than max fee") @@ -1613,7 +1616,8 @@ func TestApplyTokenTransferFeeConfigUpdatesFeeQuoterChangesetV2(t *testing.T) { }, }, MCMS: mcmsConfig, - }), + }, + ), ) require.NoError(t, err) diff --git a/deployment/ccip/changeset/v1_6/cs_deploy_chain.go b/deployment/ccip/changeset/v1_6/cs_deploy_chain.go index 2d9c58c814f..971399a1077 100644 --- a/deployment/ccip/changeset/v1_6/cs_deploy_chain.go +++ b/deployment/ccip/changeset/v1_6/cs_deploy_chain.go @@ -67,7 +67,8 @@ func ValidateHomeChainState(e cldf.Environment, homeChainSel uint64, existingSta return errors.New("capability registry not found") } cr, err := capReg.GetHashedCapabilityId( - &bind.CallOpts{}, shared.CapabilityLabelledName, shared.CapabilityVersion) + &bind.CallOpts{}, shared.CapabilityLabelledName, shared.CapabilityVersion, + ) if err != nil { e.Logger.Errorw("Failed to get hashed capability id", "err", err) return err diff --git a/deployment/ccip/changeset/v1_6/cs_deploy_chain_test.go b/deployment/ccip/changeset/v1_6/cs_deploy_chain_test.go index 433f13cc992..8a8b5b1f2e8 100644 --- a/deployment/ccip/changeset/v1_6/cs_deploy_chain_test.go +++ b/deployment/ccip/changeset/v1_6/cs_deploy_chain_test.go @@ -51,7 +51,7 @@ func testDeployChainContractsChangesetWithEnv(t *testing.T, e cldf.Environment, evmSelectors := e.BlockChains.ListChainSelectors(cldf_chain.WithFamily(chain_selectors.FamilyEVM)) nodes, err := deployment.NodeInfo(e.NodeIDs, e.Offchain) require.NoError(t, err) - p2pIds := nodes.NonBootstraps().PeerIDs() + p2pIDs := nodes.NonBootstraps().PeerIDs() cfg := make(map[uint64]cldfproposalutils.MCMSWithTimelockConfig) contractParams := make(map[uint64]ccipseq.ChainContractParams) for _, chain := range e.BlockChains.ListChainSelectors(cldf_chain.WithFamily(chain_selectors.FamilyEVM)) { @@ -80,7 +80,7 @@ func testDeployChainContractsChangesetWithEnv(t *testing.T, e cldf.Environment, RMNDynamicConfig: testhelpers.NewTestRMNDynamicConfig(), NodeOperators: testhelpers.NewTestNodeOperator(e.BlockChains.EVMChains()[homeChainSel].DeployerKey.From), NodeP2PIDsPerNodeOpAdmin: map[string][][32]byte{ - "NodeOperator": p2pIds, + "NodeOperator": p2pIDs, }, }, ), commonchangeset.Configure( diff --git a/deployment/ccip/changeset/v1_6/cs_deploy_registry_module.go b/deployment/ccip/changeset/v1_6/cs_deploy_registry_module.go index 1e1ccd2de14..e20cc60c678 100644 --- a/deployment/ccip/changeset/v1_6/cs_deploy_registry_module.go +++ b/deployment/ccip/changeset/v1_6/cs_deploy_registry_module.go @@ -99,7 +99,6 @@ func DeployRegistryModuleChangeset(e cldf.Environment, cfg DeployRegistryModuleC Err: err2, } }) - if err != nil { return cldf.ChangesetOutput{DataStore: ds}, fmt.Errorf("failed to deploy registry module on chain %d: %w", chainSel, err) } diff --git a/deployment/ccip/changeset/v1_6/cs_home_chain.go b/deployment/ccip/changeset/v1_6/cs_home_chain.go index f9ba67a5ffd..996afd30369 100644 --- a/deployment/ccip/changeset/v1_6/cs_home_chain.go +++ b/deployment/ccip/changeset/v1_6/cs_home_chain.go @@ -341,7 +341,8 @@ func deployHomeChain( if setCandidate { tx, err := rmnHome.SetCandidate( - chain.DeployerKey, rmnHomeStatic, rmnHomeDynamic, configs.CandidateConfig.ConfigDigest) + chain.DeployerKey, rmnHomeStatic, rmnHomeDynamic, configs.CandidateConfig.ConfigDigest, + ) if _, err := cldf.ConfirmIfNoErrorWithABI(chain, tx, rmn_home.RMNHomeABI, err); err != nil { lggr.Errorw("Failed to set candidate on RMNHome", "err", err) return nil, err @@ -401,7 +402,8 @@ func deployHomeChain( tx, err := capReg.Contract.AddCapabilities( chain.DeployerKey, []capabilities_registry.CapabilitiesRegistryCapability{ capabilityToAdd, - }) + }, + ) if _, err := cldf.ConfirmIfNoErrorWithABI(chain, tx, capabilities_registry.CapabilitiesRegistryABI, err); err != nil { lggr.Errorw("Failed to add capabilities", "chain", chain.String(), "err", err) return nil, err @@ -511,7 +513,7 @@ func addNodes( lggr logger.Logger, capReg *capabilities_registry.CapabilitiesRegistry, chain cldf_evm.Chain, - p2pIDsByNodeOpId map[uint32][][32]byte, + p2pIDsByNodeOpID map[uint32][][32]byte, ) error { var nodeParams []capabilities_registry.CapabilitiesRegistryNodeParams nodes, err := capReg.GetNodes(nil) @@ -528,7 +530,7 @@ func addNodes( HashedCapabilityIds: node.HashedCapabilityIds, } } - for nopID, p2pIDs := range p2pIDsByNodeOpId { + for nopID, p2pIDs := range p2pIDsByNodeOpID { for _, p2pID := range p2pIDs { // if any p2pIDs are empty throw error if p2pID == ([32]byte{}) { @@ -555,7 +557,7 @@ func addNodes( lggr.Infow("No new nodes to add") return nil } - lggr.Infow("Adding nodes", "chain", chain.String(), "nodes", p2pIDsByNodeOpId) + lggr.Infow("Adding nodes", "chain", chain.String(), "nodes", p2pIDsByNodeOpID) tx, err := capReg.AddNodes(chain.DeployerKey, nodeParams) if err != nil { lggr.Errorw("Failed to add nodes", "chain", chain.String(), @@ -586,10 +588,7 @@ func (c RemoveDONsConfig) Validate(homeChain evm.CCIPChainState) error { if homeChain.CCIPHome == nil { return errors.New("ccip home does not exist") } - if err := internal.DONIdExists(homeChain.CapabilityRegistry, c.DonIDs); err != nil { - return err - } - return nil + return internal.DONIdExists(homeChain.CapabilityRegistry, c.DonIDs) } // RemoveDONs removes DONs from the CapabilitiesRegistry contract. diff --git a/deployment/ccip/changeset/v1_6/cs_home_chain_test.go b/deployment/ccip/changeset/v1_6/cs_home_chain_test.go index 324bf9dafc6..ce1ebdbde47 100644 --- a/deployment/ccip/changeset/v1_6/cs_home_chain_test.go +++ b/deployment/ccip/changeset/v1_6/cs_home_chain_test.go @@ -45,14 +45,14 @@ func TestDeployHomeChain(t *testing.T) { nodes, err := deployment.NodeInfo(e.NodeIDs, e.Offchain) require.NoError(t, err) - p2pIds := nodes.NonBootstraps().PeerIDs() + p2pIDs := nodes.NonBootstraps().PeerIDs() homeChainCfg := v1_6.DeployHomeChainConfig{ HomeChainSel: homeChainSel, RMNStaticConfig: testhelpers.NewTestRMNStaticConfig(), RMNDynamicConfig: testhelpers.NewTestRMNDynamicConfig(), NodeOperators: testhelpers.NewTestNodeOperator(e.BlockChains.EVMChains()[homeChainSel].DeployerKey.From), NodeP2PIDsPerNodeOpAdmin: map[string][][32]byte{ - "NodeOperator": p2pIds, + "NodeOperator": p2pIDs, }, } output, err := v1_6.DeployHomeChainChangeset(e, homeChainCfg) @@ -81,7 +81,7 @@ func TestDeployHomeChain(t *testing.T) { Name: "NodeOperator", }, }, capRegSnap.Nops) - require.Len(t, capRegSnap.Nodes, len(p2pIds)) + require.Len(t, capRegSnap.Nodes, len(p2pIDs)) } func TestDeployHomeChainIdempotent(t *testing.T) { @@ -177,7 +177,7 @@ func TestRemoveDonsValidate(t *testing.T) { s, err := stateview.LoadOnchainState(e.Env) require.NoError(t, err) homeChain := s.Chains[e.HomeChainSel] - var tt = []struct { + tt := []struct { name string config v1_6.RemoveDONsConfig expectErr bool @@ -333,10 +333,8 @@ func TestAddDonAfterRemoveDons(t *testing.T) { commoncs.Configure( cldf.CreateLegacyChangeSet(v1_6.AddDonAndSetCandidateChangeset), v1_6.AddDonAndSetCandidateChangesetConfig{ - SetCandidateConfigBase: v1_6.SetCandidateConfigBase{ - HomeChainSelector: e.HomeChainSel, - FeedChainSelector: e.FeedChainSel, - }, + HomeChainSelector: e.HomeChainSel, + FeedChainSelector: e.FeedChainSel, PluginInfo: v1_6.SetCandidatePluginInfo{ OCRConfigPerRemoteChainSelector: ocrConfigs, PluginType: types.PluginTypeCCIPCommit, diff --git a/deployment/ccip/changeset/v1_6/cs_migration_from_v1_5_test.go b/deployment/ccip/changeset/v1_6/cs_migration_from_v1_5_test.go index 92ab9b9fdf2..da924499150 100644 --- a/deployment/ccip/changeset/v1_6/cs_migration_from_v1_5_test.go +++ b/deployment/ccip/changeset/v1_6/cs_migration_from_v1_5_test.go @@ -35,7 +35,7 @@ import ( "github.com/smartcontractkit/chainlink/deployment/ccip/shared/stateview" commonchangeset "github.com/smartcontractkit/chainlink/deployment/common/changeset" - ccipocr3types "github.com/smartcontractkit/chainlink-ccip/pkg/types/ccipocr3" + ccipocr3common "github.com/smartcontractkit/chainlink-common/pkg/types/ccipocr3" "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/ccipevm" cciptypes "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/types" @@ -411,10 +411,8 @@ func TestInitAndPromoteChainUpgrades(t *testing.T) { // #nosec G115 - Overflow is not a concern in this test scenario FChain: uint8(len(readers) / 3), EncodableChainConfig: chainconfig.ChainConfig{ - //nolint:staticcheck // SA1019: Type required by ChainConfig - GasPriceDeviationPPB: ccipocr3types.BigInt{Int: big.NewInt(testhelpers.DefaultGasPriceDeviationPPB)}, - //nolint:staticcheck // SA1019: Type required by ChainConfig - DAGasPriceDeviationPPB: ccipocr3types.BigInt{Int: big.NewInt(testhelpers.DefaultDAGasPriceDeviationPPB)}, + GasPriceDeviationPPB: ccipocr3common.BigInt{Int: big.NewInt(testhelpers.DefaultGasPriceDeviationPPB)}, + DAGasPriceDeviationPPB: ccipocr3common.BigInt{Int: big.NewInt(testhelpers.DefaultDAGasPriceDeviationPPB)}, OptimisticConfirmations: globals.OptimisticConfirmations, ChainFeeDeviationDisabled: true, }, diff --git a/deployment/ccip/changeset/v1_6/cs_update_bidirectional_lanes_test.go b/deployment/ccip/changeset/v1_6/cs_update_bidirectional_lanes_test.go index 2c83d737458..66570c78199 100644 --- a/deployment/ccip/changeset/v1_6/cs_update_bidirectional_lanes_test.go +++ b/deployment/ccip/changeset/v1_6/cs_update_bidirectional_lanes_test.go @@ -171,10 +171,8 @@ func TestBuildConfigs(t *testing.T) { chains := make([]v1_6.ChainDefinition, len(selectors)) for i, selector := range selectors { chains[i] = v1_6.ChainDefinition{ - ConnectionConfig: v1_6.ConnectionConfig{ - RMNVerificationDisabled: true, - AllowListEnabled: false, - }, + RMNVerificationDisabled: true, + AllowListEnabled: false, Selector: selector, GasPrice: big.NewInt(1e17), FeeQuoterDestChainConfig: v1_6.DefaultFeeQuoterDestChainConfig(true), @@ -362,10 +360,8 @@ func TestUpdateBidirectionalLanesChangeset(t *testing.T) { chains := make([]v1_6.ChainDefinition, len(selectors)) for i, selector := range selectors { chains[i] = v1_6.ChainDefinition{ - ConnectionConfig: v1_6.ConnectionConfig{ - RMNVerificationDisabled: true, - AllowListEnabled: false, - }, + RMNVerificationDisabled: true, + AllowListEnabled: false, Selector: selector, GasPrice: big.NewInt(1e17), FeeQuoterDestChainConfig: v1_6.DefaultFeeQuoterDestChainConfig(true), @@ -473,10 +469,8 @@ func TestUpdateBidirectionalLanesChangesetWithV2FeeQuoter(t *testing.T) { chains := make([]v1_6.ChainDefinition, len(selectors)) for i, selector := range selectors { chains[i] = v1_6.ChainDefinition{ - ConnectionConfig: v1_6.ConnectionConfig{ - RMNVerificationDisabled: true, - AllowListEnabled: false, - }, + RMNVerificationDisabled: true, + AllowListEnabled: false, Selector: selector, GasPrice: big.NewInt(1e17), FeeQuoterDestChainConfig: v1_6.DefaultFeeQuoterDestChainConfig(true), @@ -612,10 +606,8 @@ func TestUpdateBidirectionalLanesIdempotentWithV2FeeQuoter(t *testing.T) { chains := make([]v1_6.ChainDefinition, len(selectors)) for i, selector := range selectors { chains[i] = v1_6.ChainDefinition{ - ConnectionConfig: v1_6.ConnectionConfig{ - RMNVerificationDisabled: true, - AllowListEnabled: false, - }, + RMNVerificationDisabled: true, + AllowListEnabled: false, Selector: selector, GasPrice: big.NewInt(1e17), FeeQuoterDestChainConfig: v1_6.DefaultFeeQuoterDestChainConfig(true), @@ -892,10 +884,8 @@ func TestUpdateBidirectionalLanesChangesetWithV2FeeQuoterWithMCMS(t *testing.T) chains := make([]v1_6.ChainDefinition, len(selectors)) for i, selector := range selectors { chains[i] = v1_6.ChainDefinition{ - ConnectionConfig: v1_6.ConnectionConfig{ - RMNVerificationDisabled: true, - AllowListEnabled: false, - }, + RMNVerificationDisabled: true, + AllowListEnabled: false, Selector: selector, GasPrice: big.NewInt(1e17), FeeQuoterDestChainConfig: v1_6.DefaultFeeQuoterDestChainConfig(true), diff --git a/deployment/ccip/changeset/v1_6/cs_update_rmn_config.go b/deployment/ccip/changeset/v1_6/cs_update_rmn_config.go index edc7532e3d0..2fc899d68e6 100644 --- a/deployment/ccip/changeset/v1_6/cs_update_rmn_config.go +++ b/deployment/ccip/changeset/v1_6/cs_update_rmn_config.go @@ -109,12 +109,12 @@ type RMNNopConfig struct { NodeIndex uint64 OffchainPublicKey [32]byte EVMOnChainPublicKey common.Address - PeerId p2pkey.PeerID + PeerID p2pkey.PeerID `json:"PeerId"` } func (c RMNNopConfig) ToRMNHomeNode() rmn_home.RMNHomeNode { return rmn_home.RMNHomeNode{ - PeerId: c.PeerId, + PeerId: c.PeerID, OffchainPublicKey: c.OffchainPublicKey, } } @@ -172,15 +172,15 @@ func (c SetRMNHomeCandidateConfig) Validate(state stateview.CCIPOnChainState) er } var ( - peerIds = make(map[[32]byte]struct{}) + peerIDs = make(map[[32]byte]struct{}) offchainPublicKeys = make(map[[32]byte]struct{}) ) for _, node := range c.RMNStaticConfig.Nodes { - if _, exists := peerIds[node.PeerId]; exists { + if _, exists := peerIDs[node.PeerId]; exists { return fmt.Errorf("peerId %x is duplicated", node.PeerId) } - peerIds[node.PeerId] = struct{}{} + peerIDs[node.PeerId] = struct{}{} if _, exists := offchainPublicKeys[node.OffchainPublicKey]; exists { return fmt.Errorf("offchainPublicKey %x is duplicated", node.OffchainPublicKey) @@ -529,7 +529,6 @@ func SetRMNHomeDynamicConfigChangeset(e cldf.Environment, cfg SetRMNHomeDynamicC } _, err = rmnHome.SetDynamicConfig(deployer, cfg.RMNDynamicConfig, cfg.ActiveDigest) - if err != nil { return cldf.ChangesetOutput{}, fmt.Errorf("failed to set RMNHome dynamic config for chain %s: %w", chain.String(), err) } diff --git a/deployment/ccip/changeset/v1_6_1/cs_transparent_upgradeable_proxy.go b/deployment/ccip/changeset/v1_6_1/cs_transparent_upgradeable_proxy.go index a88efa4b635..49b2f29b36e 100644 --- a/deployment/ccip/changeset/v1_6_1/cs_transparent_upgradeable_proxy.go +++ b/deployment/ccip/changeset/v1_6_1/cs_transparent_upgradeable_proxy.go @@ -228,7 +228,6 @@ func DeployTransparentUpgradeableProxy(e cldf.Environment, c TransparentUpgradea config.PreMint, chain.DeployerKey.From, ) - if err != nil { errs = append(errs, fmt.Errorf("failed to pack initialize data: %w", err)) } @@ -247,7 +246,6 @@ func DeployTransparentUpgradeableProxy(e cldf.Environment, c TransparentUpgradea } }, ) - if err != nil { return cldf.ChangesetOutput{}, fmt.Errorf("failed to deploy TransparentUpgradeableProxy for %s token on %s: %w", token, chain.Name(), err) } diff --git a/deployment/ccip/internal/opsutils/evm.go b/deployment/ccip/internal/opsutils/evm.go index d7839c0b020..45d2db8eb74 100644 --- a/deployment/ccip/internal/opsutils/evm.go +++ b/deployment/ccip/internal/opsutils/evm.go @@ -57,7 +57,7 @@ type EVMCallOutput struct { // NewEVMCallOperation creates a new operation that performs an EVM call. // Any interfacing with gethwrappers should happen in the call function. -func NewEVMCallOperation[IN any, C any]( +func NewEVMCallOperation[IN, C any]( name string, version *semver.Version, description string, @@ -193,7 +193,7 @@ func AddEVMCallSequenceToCSOutput[IN any]( builder.WriteString(", ") } } - aggProposal, err := proposeutils.AggregateProposals( //nolint:staticcheck // SA1019: not migrating to AggregateProposalsV2 yet + aggProposal, err := proposeutils.AggregateProposals( //nolint:staticcheck // SA1019: AggregateProposalsV2 migration is tracked separately e, mcmsStateByChain, nil, @@ -321,7 +321,7 @@ func NewEVMDeployOperation[IN any]( } // cloneTransactOptsWithGas ensures that we don't impact the transact opts used by other operations. -func CloneTransactOptsWithGas(opts *bind.TransactOpts, gasLimit uint64, gasPrice uint64) *bind.TransactOpts { +func CloneTransactOptsWithGas(opts *bind.TransactOpts, gasLimit, gasPrice uint64) *bind.TransactOpts { if opts == nil { return nil } @@ -400,7 +400,7 @@ func RetryCallWithGasBoost[IN any](cfg *cldfproposalutils.GasBoostConfig) operat }) } -func GetBoostedGasForAttempt(cfg cldfproposalutils.GasBoostConfig, attempt uint) (gasLimit uint64, gasPrice uint64) { +func GetBoostedGasForAttempt(cfg cldfproposalutils.GasBoostConfig, attempt uint) (gasLimit, gasPrice uint64) { initialGasLimit := uint64(200_000) // 200k gasLimitIncrement := uint64(50_000) // 50k initialGasPrice := uint64(20_000_000_000) // 20 Gwei @@ -424,5 +424,5 @@ func GetBoostedGasForAttempt(cfg cldfproposalutils.GasBoostConfig, attempt uint) gasLimit = initialGasLimit + uint64(attempt)*gasLimitIncrement gasPrice = initialGasPrice + uint64(attempt)*gasPriceIncrement - return + return gasLimit, gasPrice } diff --git a/deployment/ccip/internal/opsutils/evm_test.go b/deployment/ccip/internal/opsutils/evm_test.go index 4d9d7049591..ba9e49290ad 100644 --- a/deployment/ccip/internal/opsutils/evm_test.go +++ b/deployment/ccip/internal/opsutils/evm_test.go @@ -197,9 +197,7 @@ func TestAddEVMCallSequenceToCSOutput_ProposalCombination(t *testing.T) { // Create initial changeset output with existing proposals to test combination logic existingProposal1 := mcmslib.TimelockProposal{ - BaseProposal: mcmslib.BaseProposal{ - Description: "First proposal", - }, + Description: "First proposal", Operations: []mcmstypes.BatchOperation{ { ChainSelector: mcmstypes.ChainSelector(selector1), @@ -215,9 +213,7 @@ func TestAddEVMCallSequenceToCSOutput_ProposalCombination(t *testing.T) { } existingProposal2 := mcmslib.TimelockProposal{ - BaseProposal: mcmslib.BaseProposal{ - Description: "Second proposal", - }, + Description: "Second proposal", Operations: []mcmstypes.BatchOperation{ { ChainSelector: mcmstypes.ChainSelector(selector2), @@ -241,15 +237,13 @@ func TestAddEVMCallSequenceToCSOutput_ProposalCombination(t *testing.T) { // Create sequence report with unconfirmed calls to generate a new proposal seqReport := operations.SequenceReport[string, map[uint64][]EVMCallOutput]{ - Report: operations.Report[string, map[uint64][]EVMCallOutput]{ - Output: map[uint64][]EVMCallOutput{ - selector2: { - { - To: common.HexToAddress("0x3333333333333333333333333333333333333333"), - Data: []byte("new_call_data"), - ContractType: "TestContract", - Confirmed: false, // This will create a new proposal - }, + Output: map[uint64][]EVMCallOutput{ + selector2: { + { + To: common.HexToAddress("0x3333333333333333333333333333333333333333"), + Data: []byte("new_call_data"), + ContractType: "TestContract", + Confirmed: false, // This will create a new proposal }, }, }, diff --git a/deployment/ccip/manualexechelpers/exec.go b/deployment/ccip/manualexechelpers/exec.go index 2b77362d4cf..39d7cb02873 100644 --- a/deployment/ccip/manualexechelpers/exec.go +++ b/deployment/ccip/manualexechelpers/exec.go @@ -86,7 +86,7 @@ var ( // getStartBlock gets the starting block of a filter logs query based on the current head block and a lookback duration. // block time is used to calculate the number of blocks to go back. -func getStartBlock(srcChainSel uint64, currentHead uint64, lookbackDuration time.Duration) uint64 { +func getStartBlock(srcChainSel, currentHead uint64, lookbackDuration time.Duration) uint64 { blockTimeSeconds := blockTimeSecondsPerChain[srcChainSel] if blockTimeSeconds == 0 { blockTimeSeconds = defaultBlockTimeSeconds @@ -326,8 +326,8 @@ func manuallyExecuteSingle( return fmt.Errorf("failed to get execution state: %w", err) } - if execState == testhelpers.EXECUTION_STATE_SUCCESS || - (execState == testhelpers.EXECUTION_STATE_FAILURE && !reExecuteIfFailed) { + if execState == testhelpers.ExecutionStateSuccess || + (execState == testhelpers.ExecutionStateFailure && !reExecuteIfFailed) { lggr.Infow("message already executed", "execState", execState, "msgSeqNr", msgSeqNr) return nil } @@ -570,7 +570,7 @@ func ManuallyExecuteAll( env, srcChainSel, destChainSel, - uint64(seqNr), //nolint:gosec // seqNr is never <= 0. + uint64(seqNr), //nolint:gosec // G115: sequence numbers are always positive lookbackDurationMsgs, lookbackDurationCommitReport, stepDuration, @@ -600,13 +600,13 @@ func CheckAlreadyExecuted( execState, err := state.Chains[destChainSel].OffRamp.GetExecutionState( &bind.CallOpts{Context: ctx}, srcChainSel, - uint64(seqNr), //nolint:gosec // seqNr is never <= 0. + uint64(seqNr), //nolint:gosec // G115: sequence numbers are always positive ) if err != nil { return fmt.Errorf("failed to get execution state: %w", err) } - if execState == testhelpers.EXECUTION_STATE_SUCCESS || execState == testhelpers.EXECUTION_STATE_FAILURE { + if execState == testhelpers.ExecutionStateSuccess || execState == testhelpers.ExecutionStateFailure { lggr.Infow("message already executed", "execState", execState, "msgSeqNr", seqNr) } else { lggr.Infow("message not executed", "execState", execState, "msgSeqNr", seqNr) diff --git a/deployment/ccip/sequence/evm/v1_6/seq_rmn.go b/deployment/ccip/sequence/evm/v1_6/seq_rmn.go index 31a3aa3f39c..357513fc9bb 100644 --- a/deployment/ccip/sequence/evm/v1_6/seq_rmn.go +++ b/deployment/ccip/sequence/evm/v1_6/seq_rmn.go @@ -40,7 +40,8 @@ var ( } return out, nil - }) + }, + ) SetRMNRemoteOnRMNProxySequence = operations.NewSequence( "SetRMNRemoteOnRMNProxySequece", @@ -61,7 +62,8 @@ var ( opOutputs[chainSel] = []opsutils.EVMCallOutput{report.Output} } return opOutputs, nil - }) + }, + ) ) type SetRMNRemoteOnRMNProxySequenceInput struct { @@ -97,8 +99,7 @@ func (c SetRMNRemoteConfig) Validate(env cldf.Environment, state stateview.CCIPO } } - //nolint:gosec // G115 - if len(config.Signers) < 2*int(config.F)+1 { + if uint64(len(config.Signers)) < 2*config.F+1 { return fmt.Errorf("signers count (%d) must be greater than or equal to %d", len(config.Signers), 2*config.F+1) } } diff --git a/deployment/ccip/shared/analyze.go b/deployment/ccip/shared/analyze.go index c80e5668e10..82c5ddfa61f 100644 --- a/deployment/ccip/shared/analyze.go +++ b/deployment/ccip/shared/analyze.go @@ -16,8 +16,10 @@ import ( cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment" ) -const Indent = " " -const DoubleIndent = Indent + Indent +const ( + Indent = " " + DoubleIndent = Indent + Indent +) var ( _ Analyzer = BytesAndAddressAnalyzer @@ -291,7 +293,7 @@ func (p *TxCallDecoder) Analyze(address string, abi *abi.ABI, data []byte) (*Dec return p.analyzeMethodCall(address, method, args, outs) } -func (p *TxCallDecoder) analyzeMethodCall(address string, method *abi.Method, args map[string]any, outs map[string]any) (*DecodedCall, error) { +func (p *TxCallDecoder) analyzeMethodCall(address string, method *abi.Method, args, outs map[string]any) (*DecodedCall, error) { inputs := make([]NamedArgument, len(method.Inputs)) for i, input := range method.Inputs { arg, ok := args[input.Name] @@ -382,7 +384,7 @@ func BytesAndAddressAnalyzer(_ string, argAbi *abi.Type, argVal any, _ []Analyze argArrTyp := reflect.ValueOf(argVal) argArr := make([]byte, argArrTyp.Len()) for i := range argArrTyp.Len() { - argArr[i] = byte(argArrTyp.Index(i).Uint()) //nolint:gosec // G115 + argArr[i] = byte(argArrTyp.Index(i).Uint()) //nolint:gosec // G115: elements of a byte array, always fits in a byte } if argAbi.T == abi.AddressTy { return AddressArgument{Value: common.BytesToAddress(argArr).Hex()} @@ -403,7 +405,7 @@ func indentString(s string) string { return indentStringWith(s, Indent) } -func indentStringWith(s string, indent string) string { +func indentStringWith(s, indent string) string { result := &strings.Builder{} components := strings.Split(s, "\n") for i, component := range components { diff --git a/deployment/ccip/shared/deployergroup/deployer_group.go b/deployment/ccip/shared/deployergroup/deployer_group.go index 902d19aa672..25c0d2aa0b5 100644 --- a/deployment/ccip/shared/deployergroup/deployer_group.go +++ b/deployment/ccip/shared/deployergroup/deployer_group.go @@ -23,9 +23,10 @@ import ( mcmsSolana "github.com/smartcontractkit/mcms/sdk/solana" mcmstypes "github.com/smartcontractkit/mcms/types" - cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment" proposeutils "github.com/smartcontractkit/cld-changesets/legacy/mcms/proposeutils" + cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment" + "github.com/smartcontractkit/chainlink/deployment/ccip/shared" "github.com/smartcontractkit/chainlink/deployment/ccip/shared/stateview" solanastateview "github.com/smartcontractkit/chainlink/deployment/ccip/shared/stateview/solana" @@ -117,10 +118,16 @@ func (d *DeploymentContext) Fork(description string) *DeploymentContext { } } -type DeployerGroupWithContext interface { +type WithContext interface { WithDeploymentContext(description string) *DeployerGroup } +// DeployerGroupWithContext is a deprecated alias for WithContext, retained so +// existing external consumers keep compiling. +// +// Deprecated: use WithContext. +type DeployerGroupWithContext = WithContext //nolint:revive // stutter accepted to preserve the pre-rename API + type deployerGroupBuilder struct { e cldf.Environment state stateview.CCIPOnChainState @@ -152,7 +159,7 @@ func (d *deployerGroupBuilder) WithDeploymentContext(description string) *Deploy // state.Chains[selector].RMNRemote.Curse() // # Execute the transaction or create the proposal // deployerGroup.Enact("Curse RMNRemote") -func NewDeployerGroup(e cldf.Environment, state stateview.CCIPOnChainState, mcmConfig *cldfproposalutils.TimelockConfig) DeployerGroupWithContext { +func NewDeployerGroup(e cldf.Environment, state stateview.CCIPOnChainState, mcmConfig *cldfproposalutils.TimelockConfig) WithContext { addresses, _ := e.ExistingAddresses.Addresses() d := &deployerGroupBuilder{ e: e, @@ -268,7 +275,7 @@ func (d *DeployerGroup) GetDeployer(chain uint64) (*bind.TransactOpts, error) { type DeployerForSVM func(solana.PublicKey) (solana.Instruction, string, cldf.ContractType, error) func (d *DeployerGroup) GetDeployerForSVM(chain uint64) (func(DeployerForSVM) (solana.Instruction, error), error) { - var authority = d.e.BlockChains.SolanaChains()[chain].DeployerKey.PublicKey() + authority := d.e.BlockChains.SolanaChains()[chain].DeployerKey.PublicKey() if d.mcmConfig != nil { qualifier := shared.DefaultMCMSQualifier if d.mcmConfig.TimelockQualifierPerChain != nil && d.mcmConfig.TimelockQualifierPerChain[chain] != "" { diff --git a/deployment/ccip/shared/deployergroup/deployer_group_test.go b/deployment/ccip/shared/deployergroup/deployer_group_test.go index 35c7116ffae..7bab20b784f 100644 --- a/deployment/ccip/shared/deployergroup/deployer_group_test.go +++ b/deployment/ccip/shared/deployergroup/deployer_group_test.go @@ -326,13 +326,14 @@ func TestDeployerGroupWithTimelockAddressQualifier(t *testing.T) { // Deploy a new MCMS with qualifier and transfer the ownership of the link token to it e.Env, err = commonchangeset.Apply(t, e.Env, commonchangeset.Configure( - cldf.CreateLegacyChangeSet(mcmschangesets.DeployMCMSWithTimelockV2), mcmsCfg)) + cldf.CreateLegacyChangeSet(mcmschangesets.DeployMCMSWithTimelockV2), mcmsCfg, + )) require.NoError(t, err) // Delete the newly deployed MCMS addresses from addressbook so that the state loader does not pick them up // otherwise the mcms state will throw an error for duplicate MCMS contracts addressBookToDelete := cldf.NewMemoryAddressBook() - addressesToDelete, err := evmstate.LoadAddressesFromDataStore(e.Env.DataStore, chain, linktokenOwnerQualifier) //nolint:staticcheck // will be refactored once usages are removed + addressesToDelete, err := evmstate.LoadAddressesFromDataStore(e.Env.DataStore, chain, linktokenOwnerQualifier) //nolint:staticcheck // SA1019: to be refactored once remaining usages are removed require.NoError(t, err) for addr, tv := range addressesToDelete { require.NoError(t, addressBookToDelete.Save(chain, addr, tv)) diff --git a/deployment/ccip/shared/deploylink/deploy_link_token.go b/deployment/ccip/shared/deploylink/deploy_link_token.go index ddda38de01c..b589881bf5b 100644 --- a/deployment/ccip/shared/deploylink/deploy_link_token.go +++ b/deployment/ccip/shared/deploylink/deploy_link_token.go @@ -10,7 +10,7 @@ import ( // DeployLinkTokenChangeset wraps the upstream DeployLinkTokenChangeset and // additionally writes deployed addresses to AddressBook for backward compatibility. -type DeployLinkTokenChangeset struct{} //nolint:revive // intentional name match with upstream +type DeployLinkTokenChangeset struct{} //nolint:revive // intentional: name mirrors the upstream changeset var _ cldf.ChangeSetV2[linkchangesets.DeployLinkTokenInput] = DeployLinkTokenChangeset{} @@ -39,7 +39,7 @@ func (DeployLinkTokenChangeset) Apply(e cldf.Environment, input linkchangesets.D return out, fmt.Errorf("failed to save address to address book: %w", addErr) } } - out.AddressBook = ab //nolint:staticcheck // intentional use of deprecated AddressBook for backward compat + out.AddressBook = ab } return out, nil diff --git a/deployment/ccip/shared/stateview/evm/validate_feequoter.go b/deployment/ccip/shared/stateview/evm/validate_feequoter.go index 2e820d15dc4..9978a0b3dfc 100644 --- a/deployment/ccip/shared/stateview/evm/validate_feequoter.go +++ b/deployment/ccip/shared/stateview/evm/validate_feequoter.go @@ -427,7 +427,7 @@ func (c CCIPChainState) validateV16DestChainConfig( errs = append(errs, fmt.Errorf("failed to get staleness threshold from v1.5 PriceRegistry: %w", stErr)) } else if !st.IsUint64() || st.Uint64() > uint64(^uint32(0)) { errs = append(errs, fmt.Errorf("v1.5 PriceRegistry StalenessThreshold %s overflows uint32", st.String())) - } else if want := uint32(st.Uint64()); want != destCfg.GasPriceStalenessThreshold { //nolint:gosec // G115: safe, verified <= MaxUint32 + } else if want := st.Uint64(); want != uint64(destCfg.GasPriceStalenessThreshold) { errs = append(errs, fmt.Errorf("v1.5<->v1.6:\n GasPriceStalenessThreshold: got=%d, want=%d", destCfg.GasPriceStalenessThreshold, want)) } diff --git a/deployment/ccip/shared/stateview/evm/validate_feequoter_test.go b/deployment/ccip/shared/stateview/evm/validate_feequoter_test.go index 7435032311d..bdf9d3a4d9d 100644 --- a/deployment/ccip/shared/stateview/evm/validate_feequoter_test.go +++ b/deployment/ccip/shared/stateview/evm/validate_feequoter_test.go @@ -277,7 +277,7 @@ func TestValidateFeeQuoter_CrossVersionValidation(t *testing.T) { DefaultTokenDestGasOverhead: v15Cfg.DefaultTokenDestGasOverhead, DefaultTokenFeeUSDCents: 25, // topology: non-ETH EVM→EVM EnforceOutOfOrder: v15Cfg.EnforceOutOfOrder, - DestGasPerPayloadByteBase: uint8(v15Cfg.DestGasPerPayloadByte), //nolint:gosec // match v1.5 truncation + DestGasPerPayloadByteBase: uint8(v15Cfg.DestGasPerPayloadByte), //nolint:gosec // G115: intentional v1.5 uint16->uint8 truncation DestGasPerPayloadByteHigh: ccipevm.CalldataGasPerByteHigh, DestGasPerPayloadByteThreshold: ccipevm.CalldataGasPerByteThreshold, DefaultTxGasLimit: 200_000, diff --git a/deployment/ccip/shared/token_info.go b/deployment/ccip/shared/token_info.go index 37c22572996..e0c967a6aaf 100644 --- a/deployment/ccip/shared/token_info.go +++ b/deployment/ccip/shared/token_info.go @@ -8,11 +8,10 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" - "github.com/smartcontractkit/chainlink-ccip/pkg/types/ccipocr3" - "github.com/smartcontractkit/chainlink-ccip/pluginconfig" "github.com/smartcontractkit/chainlink/deployment/ccip/internal/bigint" "github.com/smartcontractkit/chainlink-common/pkg/logger" + ccipocr3common "github.com/smartcontractkit/chainlink-common/pkg/types/ccipocr3" "github.com/smartcontractkit/chainlink-evm/gethwrappers/shared/generated/initial/aggregator_v3_interface" ) @@ -166,7 +165,7 @@ var ( LinkSymbol: MockLinkAggregatorDescription, WethSymbol: MockWETHAggregatorDescription, } - TestDeviationPPB = ccipocr3.NewBigIntFromInt64(1e9) + TestDeviationPPB = ccipocr3common.NewBigIntFromInt64(1e9) TokenSymbolSubstitute = map[string]string{ "wS": WSSymbol.String(), @@ -176,27 +175,27 @@ var ( // TokenConfig mapping between token Symbol (e.g. LinkSymbol, WethSymbol) // and the respective token info. type TokenConfig struct { - TokenSymbolToInfo map[TokenSymbol]pluginconfig.TokenInfo + TokenSymbolToInfo map[TokenSymbol]ccipocr3common.TokenInfo } func NewTokenConfig() TokenConfig { return TokenConfig{ - TokenSymbolToInfo: make(map[TokenSymbol]pluginconfig.TokenInfo), + TokenSymbolToInfo: make(map[TokenSymbol]ccipocr3common.TokenInfo), } } func NewTestTokenConfig(feeds map[TokenSymbol]*aggregator_v3_interface.AggregatorV3Interface) TokenConfig { tc := NewTokenConfig() tc.UpsertTokenInfo(LinkSymbol, - pluginconfig.TokenInfo{ - AggregatorAddress: ccipocr3.UnknownEncodedAddress(feeds[LinkSymbol].Address().String()), + ccipocr3common.TokenInfo{ + AggregatorAddress: ccipocr3common.UnknownEncodedAddress(feeds[LinkSymbol].Address().String()), Decimals: LinkDecimals, DeviationPPB: TestDeviationPPB, }, ) tc.UpsertTokenInfo(WethSymbol, - pluginconfig.TokenInfo{ - AggregatorAddress: ccipocr3.UnknownEncodedAddress(feeds[WethSymbol].Address().String()), + ccipocr3common.TokenInfo{ + AggregatorAddress: ccipocr3common.UnknownEncodedAddress(feeds[WethSymbol].Address().String()), Decimals: WethDecimals, DeviationPPB: TestDeviationPPB, }, @@ -206,7 +205,7 @@ func NewTestTokenConfig(feeds map[TokenSymbol]*aggregator_v3_interface.Aggregato func (tc *TokenConfig) UpsertTokenInfo( symbol TokenSymbol, - info pluginconfig.TokenInfo, + info ccipocr3common.TokenInfo, ) { tc.TokenSymbolToInfo[symbol] = info } @@ -216,13 +215,13 @@ func (tc *TokenConfig) GetTokenInfo( lggr logger.Logger, linkTokenAddr, wethTokenAddr common.Address, -) map[ccipocr3.UnknownEncodedAddress]pluginconfig.TokenInfo { - tokenToAggregate := make(map[ccipocr3.UnknownEncodedAddress]pluginconfig.TokenInfo) +) map[ccipocr3common.UnknownEncodedAddress]ccipocr3common.TokenInfo { + tokenToAggregate := make(map[ccipocr3common.UnknownEncodedAddress]ccipocr3common.TokenInfo) if _, ok := tc.TokenSymbolToInfo[LinkSymbol]; !ok { lggr.Debugw("Link aggregator not found, deploy without mapping link token") } else { lggr.Debugw("Mapping LinkToken to Link aggregator") - acc := ccipocr3.UnknownEncodedAddress(linkTokenAddr.String()) + acc := ccipocr3common.UnknownEncodedAddress(linkTokenAddr.String()) tokenToAggregate[acc] = tc.TokenSymbolToInfo[LinkSymbol] } @@ -230,7 +229,7 @@ func (tc *TokenConfig) GetTokenInfo( lggr.Debugw("Weth aggregator not found, deploy without mapping link token") } else { lggr.Debugw("Mapping WethToken to Weth aggregator") - acc := ccipocr3.UnknownEncodedAddress(wethTokenAddr.String()) + acc := ccipocr3common.UnknownEncodedAddress(wethTokenAddr.String()) tokenToAggregate[acc] = tc.TokenSymbolToInfo[WethSymbol] } diff --git a/deployment/ccip/view/v1_0/link_token.go b/deployment/ccip/view/v1_0/link_token.go index 1ab96a537d2..d7f1702c17a 100644 --- a/deployment/ccip/view/v1_0/link_token.go +++ b/deployment/ccip/view/v1_0/link_token.go @@ -45,14 +45,12 @@ func GenerateLinkTokenView(lt *link_token.LinkToken) (LinkTokenView, error) { } return LinkTokenView{ - ContractMetaData: view.ContractMetaData{ - TypeAndVersion: cldf.TypeAndVersion{ - Type: linkcontracts.LinkToken, - Version: *semver.MustParse("1.0.0"), - }.String(), - Address: lt.Address(), - Owner: owner, - }, + TypeAndVersion: cldf.TypeAndVersion{ + Type: linkcontracts.LinkToken, + Version: *semver.MustParse("1.0.0"), + }.String(), + Address: lt.Address(), + Owner: owner, Decimals: decimals, Supply: totalSupply, Minters: minters, diff --git a/deployment/ccip/view/v1_0/mcms.go b/deployment/ccip/view/v1_0/mcms.go index b9fad432f91..8381e3a735b 100644 --- a/deployment/ccip/view/v1_0/mcms.go +++ b/deployment/ccip/view/v1_0/mcms.go @@ -91,11 +91,9 @@ func GenerateMCMSView(mcms owner_helpers.ManyChainMultiSig) (MCMSView, error) { return MCMSView{ // Has no type and version on the contract - ContractMetaData: view.ContractMetaData{ - Owner: owner, - Address: mcms.Address(), - }, - Config: *parsedConfig, + Owner: owner, + Address: mcms.Address(), + Config: *parsedConfig, }, nil } @@ -123,9 +121,7 @@ func GenerateTimelockView(tl owner_helpers.RBACTimelock) (TimelockView, error) { return TimelockView{ // Has no type and version or owner. - ContractMetaData: view.ContractMetaData{ - Address: tl.Address(), - }, + Address: tl.Address(), MembersByRole: membersByRole, }, nil } @@ -136,9 +132,7 @@ type CallProxyView struct { func GenerateCallProxyView(cp owner_helpers.CallProxy) (CallProxyView, error) { return CallProxyView{ - ContractMetaData: view.ContractMetaData{ - Address: cp.Address(), - }, + Address: cp.Address(), }, nil } diff --git a/deployment/ccip/view/v1_5/token_pool.go b/deployment/ccip/view/v1_5/token_pool.go index d781ef48597..342cdbac0e8 100644 --- a/deployment/ccip/view/v1_5/token_pool.go +++ b/deployment/ccip/view/v1_5/token_pool.go @@ -11,7 +11,6 @@ import ( "github.com/smartcontractkit/chainlink/deployment/ccip/view/shared" v1_5_1 "github.com/smartcontractkit/chainlink/deployment/ccip/view/v1_5_1" - "github.com/smartcontractkit/chainlink/deployment/internal/view" ) type TokenPoolContract interface { @@ -108,11 +107,9 @@ func GenerateTokenPoolView(pool TokenPoolContract, priceFeed common.Address) (v1 } return v1_5_1.TokenPoolView{ - ContractMetaData: view.ContractMetaData{ - TypeAndVersion: typeAndVersion, - Address: pool.Address(), - Owner: owner, - }, + TypeAndVersion: typeAndVersion, + Address: pool.Address(), + Owner: owner, Token: token, TokenPriceFeed: priceFeed, RemoteChainConfigs: remoteChainConfigs, diff --git a/deployment/ccip/view/v1_5_1/token_pool.go b/deployment/ccip/view/v1_5_1/token_pool.go index b022de38f09..f59574d97f2 100644 --- a/deployment/ccip/view/v1_5_1/token_pool.go +++ b/deployment/ccip/view/v1_5_1/token_pool.go @@ -190,11 +190,9 @@ func GenerateTokenPoolView(pool TokenPoolContract, priceFeed common.Address) (To } return TokenPoolView{ - ContractMetaData: view.ContractMetaData{ - TypeAndVersion: typeAndVersion, - Address: pool.Address(), - Owner: owner, - }, + TypeAndVersion: typeAndVersion, + Address: pool.Address(), + Owner: owner, Token: token, TokenPriceFeed: priceFeed, RemoteChainConfigs: remoteChainConfigs, diff --git a/deployment/ccip/view/v1_6/ccip_home.go b/deployment/ccip/view/v1_6/ccip_home.go index 1bd6531e3a2..e4215038f24 100644 --- a/deployment/ccip/view/v1_6/ccip_home.go +++ b/deployment/ccip/view/v1_6/ccip_home.go @@ -10,13 +10,13 @@ import ( libocrtypes "github.com/smartcontractkit/libocr/ragep2p/types" "github.com/smartcontractkit/chainlink-ccip/chainconfig" - "github.com/smartcontractkit/chainlink-ccip/pkg/types/ccipocr3" "github.com/smartcontractkit/chainlink-ccip/pluginconfig" "github.com/smartcontractkit/chainlink-ccip/chains/evm/gobindings/generated/v1_6_0/ccip_home" capabilities_registry "github.com/smartcontractkit/chainlink-evm/gethwrappers/keystone/generated/capabilities_registry_1_1_0" "github.com/smartcontractkit/chainlink-common/keystore/corekeys/p2pkey" + ccipocr3common "github.com/smartcontractkit/chainlink-common/pkg/types/ccipocr3" "github.com/smartcontractkit/chainlink/deployment/ccip/shared" "github.com/smartcontractkit/chainlink/deployment/internal/view" @@ -201,12 +201,12 @@ func toCCIPHomeVersionedConfig(cfg ccip_home.CCIPHomeVersionedConfig, pluginType peerID := p2pkey.PeerID(n.P2pId) nodes = append(nodes, CCIPHomeOCR3Node{ P2pID: peerID.String(), - SignerKey: ccipocr3.UnknownAddress(n.SignerKey).String(), - TransmitterKey: ccipocr3.UnknownAddress(n.TransmitterKey).String(), + SignerKey: ccipocr3common.UnknownAddress(n.SignerKey).String(), + TransmitterKey: ccipocr3common.UnknownAddress(n.TransmitterKey).String(), }) } - offRampAddr := ccipocr3.UnknownAddress(cfg.Config.OfframpAddress).String() - rmnAddr := ccipocr3.UnknownAddress(cfg.Config.RmnHomeAddress).String() + offRampAddr := ccipocr3common.UnknownAddress(cfg.Config.OfframpAddress).String() + rmnAddr := ccipocr3common.UnknownAddress(cfg.Config.RmnHomeAddress).String() c := CCIPHomeVersionedConfig{ Version: cfg.Version, ConfigDigest: cfg.ConfigDigest[:], @@ -238,10 +238,10 @@ func populateDecodedOCRParams(config *CCIPHomeOCR3Config, ccipHomeCfg ccip_home. identities := make([]OracleIdentity, 0, len(publicConfig.OracleIdentities)) for _, o := range publicConfig.OracleIdentities { identities = append(identities, OracleIdentity{ - OffchainPublicKey: ccipocr3.UnknownAddress(o.OffchainPublicKey[:]).String(), - OnchainPublicKey: ccipocr3.UnknownAddress(o.OnchainPublicKey[:]).String(), + OffchainPublicKey: ccipocr3common.UnknownAddress(o.OffchainPublicKey[:]).String(), + OnchainPublicKey: ccipocr3common.UnknownAddress(o.OnchainPublicKey[:]).String(), PeerID: o.PeerID, - TransmitAccount: ccipocr3.UnknownAddress(o.TransmitAccount[:]).String(), + TransmitAccount: ccipocr3common.UnknownAddress(o.TransmitAccount[:]).String(), }) } if pluginType == cciptypes.PluginTypeCCIPCommit { diff --git a/deployment/environment/crib/ccip_deployer.go b/deployment/environment/crib/ccip_deployer.go index 2f2d059ec4d..c2c845baf8f 100644 --- a/deployment/environment/crib/ccip_deployer.go +++ b/deployment/environment/crib/ccip_deployer.go @@ -73,7 +73,7 @@ const ( // DeployHomeChainContracts deploys the home chain contracts so that the chainlink nodes can use the CR address in Capabilities.ExternalRegistry // Afterward, we call DeployHomeChainChangeset changeset with nodeinfo ( the peer id and all) -func DeployHomeChainContracts(ctx context.Context, lggr logger.Logger, envConfig devenv.EnvironmentConfig, homeChainSel uint64, feedChainSel uint64) (deployment.CapabilityRegistryConfig, cldf.AddressBook, error) { +func DeployHomeChainContracts(ctx context.Context, lggr logger.Logger, envConfig devenv.EnvironmentConfig, homeChainSel, feedChainSel uint64) (deployment.CapabilityRegistryConfig, cldf.AddressBook, error) { lggr.Info("Deploying home chain contracts...") e, _, err := devenv.NewEnvironment(func() context.Context { return ctx }, lggr, envConfig) if err != nil { @@ -644,7 +644,8 @@ func setupSolLinkPools(e *cldf.Environment) (cldf.Environment, error) { link, billingSignerPDA, sourceAccount.PublicKey(), - []solana.PublicKey{}) + []solana.PublicKey{}, + ) if err != nil { return *e, fmt.Errorf("failed to create approve instruction: %w", err) } @@ -980,7 +981,7 @@ func setupEVM2EVMLanes(e *cldf.Environment, state stateview.CCIPOnChainState, la return *e, err } -func mustOCR(e *cldf.Environment, homeChainSel uint64, feedChainSel uint64, newDons bool, rmnEnabled bool) (cldf.Environment, error) { +func mustOCR(e *cldf.Environment, homeChainSel, feedChainSel uint64, newDons, rmnEnabled bool) (cldf.Environment, error) { evmSelectors := e.BlockChains.ListChainSelectors(cldf_chain.WithFamily(chainselectors.FamilyEVM)) solSelectors := e.BlockChains.ListChainSelectors(cldf_chain.WithFamily(chainselectors.FamilySolana)) // need to have extra definition here for golint @@ -1171,7 +1172,7 @@ func SetupRMNNodeOnAllChains(ctx context.Context, lggr logger.Logger, envConfig bitmap := new(big.Int) for i, node := range nodes { rmnNodes[i] = rmn_home.RMNHomeNode{ - PeerId: node.PeerId, + PeerId: node.PeerID, OffchainPublicKey: node.OffchainPublicKey, } bitmap.SetBit(bitmap, i, 1) @@ -1292,7 +1293,7 @@ func GenerateRMNNodeIdentities(rmnNodeCount uint, rageProxyImageURI, rageProxyIm NodeIndex: uint64(i), OffchainPublicKey: [32]byte(keys.OffchainPublicKey), EVMOnChainPublicKey: keys.EVMOnchainPublicKey, - PeerId: newPeerID, + PeerID: newPeerID, }, RageProxyKeystore: rawKeystore, RMNKeystore: rawRMNKeystore, diff --git a/integration-tests/load/ccip/aptos_helpers.go b/integration-tests/load/ccip/aptos_helpers.go index 633e8a75753..0291bb8ef78 100644 --- a/integration-tests/load/ccip/aptos_helpers.go +++ b/integration-tests/load/ccip/aptos_helpers.go @@ -531,7 +531,7 @@ func subscribeAptosExecutionEvents( event := eventWithVersion.Event // Skip events that are not in the Success state - if event.State != testhelpers.EXECUTION_STATE_SUCCESS { + if event.State != testhelpers.ExecutionStateSuccess { continue } diff --git a/integration-tests/smoke/ccip/ccip_aptos_messaging_test.go b/integration-tests/smoke/ccip/ccip_aptos_messaging_test.go index 4c91d358987..2e79266727b 100644 --- a/integration-tests/smoke/ccip/ccip_aptos_messaging_test.go +++ b/integration-tests/smoke/ccip/ccip_aptos_messaging_test.go @@ -144,7 +144,7 @@ func Test_CCIP_Messaging_EVM2Aptos(t *testing.T) { MsgData: message, // true for out of order execution, which is necessary and enforced for Aptos ExtraArgs: testhelpers.MakeEVMExtraArgsV2(100000, true), - ExpectedExecutionState: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedExecutionState: testhelpers.ExecutionStateSuccess, FeeToken: nativeFeeToken, ExtraAssertions: []func(t *testing.T){ func(t *testing.T) { assertAptosMessageReceivedMatchesSource(t, e, destChain, receiver, message, 0) }, @@ -164,7 +164,7 @@ func Test_CCIP_Messaging_EVM2Aptos(t *testing.T) { MsgData: message, // true for out of order execution, which is necessary and enforced for Aptos ExtraArgs: testhelpers.MakeEVMExtraArgsV2(100000, true), - ExpectedExecutionState: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedExecutionState: testhelpers.ExecutionStateSuccess, FeeToken: nativeFeeToken, ExtraAssertions: []func(t *testing.T){ func(t *testing.T) { assertAptosMessageReceivedMatchesSource(t, e, destChain, receiver, message, 1) }, @@ -185,7 +185,7 @@ func Test_CCIP_Messaging_EVM2Aptos(t *testing.T) { MsgData: message, // true for out of order execution, which is necessary and enforced for Aptos ExtraArgs: testhelpers.MakeEVMExtraArgsV2(uint64(srcFeeQuoterDestChainConfig.MaxPerMsgGasLimit), true), - ExpectedExecutionState: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedExecutionState: testhelpers.ExecutionStateSuccess, FeeToken: nativeFeeToken, ExtraAssertions: []func(t *testing.T){ func(t *testing.T) { assertAptosMessageReceivedMatchesSource(t, e, destChain, receiver, message, 2) }, @@ -208,7 +208,7 @@ func Test_CCIP_Messaging_EVM2Aptos(t *testing.T) { MsgData: message, // true for out of order execution, which is necessary and enforced for Aptos ExtraArgs: testhelpers.MakeEVMExtraArgsV2(gasLimit, true), - ExpectedExecutionState: testhelpers.EXECUTION_STATE_FAILURE, + ExpectedExecutionState: testhelpers.ExecutionStateFailure, FeeToken: nativeFeeToken, }, ) @@ -225,7 +225,7 @@ func Test_CCIP_Messaging_EVM2Aptos(t *testing.T) { MsgData: message, // true for out of order execution, which is necessary and enforced for Aptos ExtraArgs: testhelpers.MakeEVMExtraArgsV2(100000, true), - ExpectedExecutionState: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedExecutionState: testhelpers.ExecutionStateSuccess, FeeToken: evmLinkToken.Address().String(), ExtraAssertions: []func(t *testing.T){ func(t *testing.T) { assertAptosMessageReceivedMatchesSource(t, e, destChain, receiver, message, 2) }, @@ -246,7 +246,7 @@ func Test_CCIP_Messaging_EVM2Aptos(t *testing.T) { MsgData: message, // true for out of order execution, which is necessary and enforced for Aptos ExtraArgs: testhelpers.MakeEVMExtraArgsV2(100000, true), - ExpectedExecutionState: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedExecutionState: testhelpers.ExecutionStateSuccess, FeeToken: wethToken.Address().String(), ExtraAssertions: []func(t *testing.T){ func(t *testing.T) { assertAptosMessageReceivedMatchesSource(t, e, destChain, receiver, message, 2) }, @@ -422,7 +422,8 @@ func Test_CCIP_Messaging_Aptos2EVM(t *testing.T) { aptosFeeQuoter := aptos_feequoter.NewFeeQuoter( state.AptosChains[sourceChain].CCIPAddress, - e.Env.BlockChains.AptosChains()[sourceChain].Client) + e.Env.BlockChains.AptosChains()[sourceChain].Client, + ) aptosFeeQuoterDestChainConfig, err := aptosFeeQuoter.GetDestChainConfig(aptosCallOpts, destChain) require.NoError(t, err, "Failed to get destination chain config") @@ -492,7 +493,7 @@ func Test_CCIP_Messaging_Aptos2EVM(t *testing.T) { Receiver: ccipReceiverAddress, MsgData: message, ExtraArgs: nil, - ExpectedExecutionState: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedExecutionState: testhelpers.ExecutionStateSuccess, ExtraAssertions: []func(t *testing.T){ func(t *testing.T) { assertEvmMessageReceived(ctx, t, state, destChain, latestHead, message) }, }, @@ -513,7 +514,7 @@ func Test_CCIP_Messaging_Aptos2EVM(t *testing.T) { MsgData: message, // Just ensuring enough gas is provided to execute the message, doesn't matter if it's way too much ExtraArgs: testhelpers.MakeBCSEVMExtraArgsV2(big.NewInt(300000), false), - ExpectedExecutionState: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedExecutionState: testhelpers.ExecutionStateSuccess, ExtraAssertions: []func(t *testing.T){ func(t *testing.T) { assertEvmMessageReceived(ctx, t, state, destChain, latestHead, message) }, }, @@ -533,7 +534,7 @@ func Test_CCIP_Messaging_Aptos2EVM(t *testing.T) { Receiver: ccipReceiverAddress, MsgData: message, ExtraArgs: testhelpers.MakeBCSEVMExtraArgsV2(big.NewInt(int64(aptosFeeQuoterDestChainConfig.MaxPerMsgGasLimit)), false), - ExpectedExecutionState: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedExecutionState: testhelpers.ExecutionStateSuccess, ExtraAssertions: []func(t *testing.T){ func(t *testing.T) { assertEvmMessageReceived(ctx, t, state, destChain, latestHead, message) }, }, @@ -632,7 +633,7 @@ func Test_CCIP_Messaging_Aptos2EVM(t *testing.T) { }) } -func assertEvmMessageReceived(ctx context.Context, t *testing.T, state stateview.CCIPOnChainState, destChain uint64, latestHead uint64, message []byte) { +func assertEvmMessageReceived(ctx context.Context, t *testing.T, state stateview.CCIPOnChainState, destChain, latestHead uint64, message []byte) { iter, err := state.Chains[destChain].Receiver.FilterMessageReceived(&bind.FilterOpts{ Context: ctx, Start: latestHead + 1, diff --git a/integration-tests/smoke/ccip/ccip_aptos_regulated_token_transfer_test.go b/integration-tests/smoke/ccip/ccip_aptos_regulated_token_transfer_test.go index 522284201f3..99ee41d472b 100644 --- a/integration-tests/smoke/ccip/ccip_aptos_regulated_token_transfer_test.go +++ b/integration-tests/smoke/ccip/ccip_aptos_regulated_token_transfer_test.go @@ -71,7 +71,7 @@ func Test_CCIP_RegulatedTokenTransfer_EVM2Aptos(t *testing.T) { SourceChain: sourceChain, DestChain: destChain, Receiver: deployerDestChain[:], - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, Tokens: []router.ClientEVMTokenAmount{ { Token: evmToken.Address(), @@ -91,7 +91,7 @@ func Test_CCIP_RegulatedTokenTransfer_EVM2Aptos(t *testing.T) { SourceChain: sourceChain, DestChain: destChain, Receiver: deployerDestChain[:], - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, Tokens: []router.ClientEVMTokenAmount{ { Token: evmToken.Address(), @@ -111,7 +111,7 @@ func Test_CCIP_RegulatedTokenTransfer_EVM2Aptos(t *testing.T) { SourceChain: sourceChain, DestChain: destChain, Receiver: ccipChainState.ReceiverAddress[:], - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, Tokens: []router.ClientEVMTokenAmount{ { Token: evmToken.Address(), @@ -179,7 +179,7 @@ func Test_CCIP_RegulatedTokenTransfer_Aptos2EVM(t *testing.T) { require.NoError(t, err) // Fee Tokens - var NativeFeeToken = "0xa" // coin + NativeFeeToken := "0xa" // coin // Invalid Fee Token var aptosInvalidToken aptos.AccountAddress @@ -190,7 +190,7 @@ func Test_CCIP_RegulatedTokenTransfer_Aptos2EVM(t *testing.T) { SourceChain: sourceChain, DestChain: destChain, Receiver: deployerDestChain.From.Bytes(), - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, AptosTokens: []testhelpers.AptosTokenAmount{ { Token: aptosToken, @@ -211,7 +211,7 @@ func Test_CCIP_RegulatedTokenTransfer_Aptos2EVM(t *testing.T) { SourceChain: sourceChain, DestChain: destChain, Receiver: deployerDestChain.From.Bytes(), - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, AptosTokens: []testhelpers.AptosTokenAmount{ { Token: aptosToken, @@ -232,7 +232,7 @@ func Test_CCIP_RegulatedTokenTransfer_Aptos2EVM(t *testing.T) { SourceChain: sourceChain, DestChain: destChain, Receiver: deployerDestChain.From.Bytes(), - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, Data: []byte("Hello, World!"), AptosTokens: []testhelpers.AptosTokenAmount{ { @@ -254,7 +254,7 @@ func Test_CCIP_RegulatedTokenTransfer_Aptos2EVM(t *testing.T) { SourceChain: sourceChain, DestChain: destChain, Receiver: deployerDestChain.From.Bytes(), - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, Data: []byte("Hello, World!"), AptosTokens: []testhelpers.AptosTokenAmount{ { @@ -275,7 +275,7 @@ func Test_CCIP_RegulatedTokenTransfer_Aptos2EVM(t *testing.T) { SourceChain: sourceChain, DestChain: destChain, Receiver: ccipReceiverAddress.Bytes(), - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, AptosTokens: []testhelpers.AptosTokenAmount{ { Token: aptosToken, @@ -324,7 +324,8 @@ func Test_CCIP_RegulatedTokenTransfer_Aptos2EVM(t *testing.T) { aptosFeeQuoter := aptos_feequoter.NewFeeQuoter( state.AptosChains[sourceChain].CCIPAddress, - e.Env.BlockChains.AptosChains()[sourceChain].Client) + e.Env.BlockChains.AptosChains()[sourceChain].Client, + ) aptosFeeQuoterDestChainConfig, err := aptosFeeQuoter.GetDestChainConfig(aptosCallOpts, destChain) require.NoError(t, err, "Failed to get destination chain fee quoter config") @@ -340,7 +341,8 @@ func Test_CCIP_RegulatedTokenTransfer_Aptos2EVM(t *testing.T) { Token: aptosToken, Amount: 1e8, }, - }} + }, + } baseOpts := []ccipclient.SendReqOpts{ ccipclient.WithSourceChain(sourceChain), @@ -365,7 +367,8 @@ func Test_CCIP_RegulatedTokenTransfer_Aptos2EVM(t *testing.T) { Token: aptosToken, Amount: 0, }, - }} + }, + } baseOpts := []ccipclient.SendReqOpts{ ccipclient.WithSourceChain(sourceChain), @@ -390,7 +393,8 @@ func Test_CCIP_RegulatedTokenTransfer_Aptos2EVM(t *testing.T) { Token: aptosInvalidToken, Amount: 1e8, }, - }} + }, + } baseOpts := []ccipclient.SendReqOpts{ ccipclient.WithSourceChain(sourceChain), diff --git a/integration-tests/smoke/ccip/ccip_aptos_token_transfer_test.go b/integration-tests/smoke/ccip/ccip_aptos_token_transfer_test.go index e0f7cb072b3..ebbb87743d6 100644 --- a/integration-tests/smoke/ccip/ccip_aptos_token_transfer_test.go +++ b/integration-tests/smoke/ccip/ccip_aptos_token_transfer_test.go @@ -24,7 +24,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/logger" ) -func assertAptosSourceRevertExpectedError(t *testing.T, err error, execRevertErrorMsg string, execRevertCauseErrorMsg string) { +func assertAptosSourceRevertExpectedError(t *testing.T, err error, execRevertErrorMsg, execRevertCauseErrorMsg string) { require.Error(t, err) fmt.Println("Error: ", err.Error()) require.Contains(t, err.Error(), execRevertErrorMsg) @@ -80,7 +80,7 @@ func Test_CCIP_TokenTransfer_EVM2Aptos(t *testing.T) { SourceChain: sourceChain, DestChain: destChain, Receiver: deployerDestChain[:], - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, Tokens: []router.ClientEVMTokenAmount{ { Token: evmToken.Address(), @@ -100,7 +100,7 @@ func Test_CCIP_TokenTransfer_EVM2Aptos(t *testing.T) { SourceChain: sourceChain, DestChain: destChain, Receiver: deployerDestChain[:], - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, Tokens: []router.ClientEVMTokenAmount{ { Token: evmToken.Address(), @@ -120,7 +120,7 @@ func Test_CCIP_TokenTransfer_EVM2Aptos(t *testing.T) { SourceChain: sourceChain, DestChain: destChain, Receiver: ccipChainState.ReceiverAddress[:], - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, Tokens: []router.ClientEVMTokenAmount{ { Token: evmToken.Address(), @@ -141,7 +141,7 @@ func Test_CCIP_TokenTransfer_EVM2Aptos(t *testing.T) { DestChain: destChain, Receiver: deployerDestChain[:], Data: []byte("Hello, World!"), - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, Tokens: []router.ClientEVMTokenAmount{ { Token: evmToken.Address(), @@ -196,7 +196,8 @@ func Test_CCIP_TokenTransfer_EVM2Aptos(t *testing.T) { Token: evmToken.Address(), Amount: big.NewInt(1e8), }, - }} + }, + } baseOpts := []ccipclient.SendReqOpts{ ccipclient.WithSourceChain(sourceChain), @@ -222,7 +223,8 @@ func Test_CCIP_TokenTransfer_EVM2Aptos(t *testing.T) { Token: evmToken.Address(), Amount: big.NewInt(0), }, - }} + }, + } baseOpts := []ccipclient.SendReqOpts{ ccipclient.WithSourceChain(sourceChain), @@ -248,7 +250,8 @@ func Test_CCIP_TokenTransfer_EVM2Aptos(t *testing.T) { Token: common.HexToAddress("0x0000000000000000000000000000000000000000"), // Invalid token Amount: big.NewInt(1e8), }, - }} + }, + } baseOpts := []ccipclient.SendReqOpts{ ccipclient.WithSourceChain(sourceChain), @@ -303,7 +306,7 @@ func Test_CCIP_TokenTransfer_Aptos2EVM(t *testing.T) { require.NoError(t, err) // Fee Tokens - var NativeFeeToken = "0xa" // coin + NativeFeeToken := "0xa" // coin // Invalid Fee Token var aptosInvalidToken aptos.AccountAddress @@ -314,7 +317,7 @@ func Test_CCIP_TokenTransfer_Aptos2EVM(t *testing.T) { SourceChain: sourceChain, DestChain: destChain, Receiver: deployerDestChain.From.Bytes(), - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, AptosTokens: []testhelpers.AptosTokenAmount{ { Token: aptosToken, @@ -335,7 +338,7 @@ func Test_CCIP_TokenTransfer_Aptos2EVM(t *testing.T) { SourceChain: sourceChain, DestChain: destChain, Receiver: deployerDestChain.From.Bytes(), - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, AptosTokens: []testhelpers.AptosTokenAmount{ { Token: aptosToken, @@ -356,7 +359,7 @@ func Test_CCIP_TokenTransfer_Aptos2EVM(t *testing.T) { SourceChain: sourceChain, DestChain: destChain, Receiver: deployerDestChain.From.Bytes(), - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, Data: []byte("Hello, World!"), AptosTokens: []testhelpers.AptosTokenAmount{ { @@ -378,7 +381,7 @@ func Test_CCIP_TokenTransfer_Aptos2EVM(t *testing.T) { SourceChain: sourceChain, DestChain: destChain, Receiver: deployerDestChain.From.Bytes(), - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, Data: []byte("Hello, World!"), AptosTokens: []testhelpers.AptosTokenAmount{ { @@ -399,7 +402,7 @@ func Test_CCIP_TokenTransfer_Aptos2EVM(t *testing.T) { SourceChain: sourceChain, DestChain: destChain, Receiver: ccipReceiverAddress.Bytes(), - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, AptosTokens: []testhelpers.AptosTokenAmount{ { Token: aptosToken, @@ -449,7 +452,8 @@ func Test_CCIP_TokenTransfer_Aptos2EVM(t *testing.T) { aptosFeeQuoter := aptos_feequoter.NewFeeQuoter( state.AptosChains[sourceChain].CCIPAddress, - e.Env.BlockChains.AptosChains()[sourceChain].Client) + e.Env.BlockChains.AptosChains()[sourceChain].Client, + ) aptosFeeQuoterDestChainConfig, err := aptosFeeQuoter.GetDestChainConfig(aptosCallOpts, destChain) require.NoError(t, err, "Failed to get destination chain fee quoter config") @@ -465,7 +469,8 @@ func Test_CCIP_TokenTransfer_Aptos2EVM(t *testing.T) { Token: aptosToken, Amount: 1e8, }, - }} + }, + } baseOpts := []ccipclient.SendReqOpts{ ccipclient.WithSourceChain(sourceChain), @@ -490,7 +495,8 @@ func Test_CCIP_TokenTransfer_Aptos2EVM(t *testing.T) { Token: aptosToken, Amount: 0, }, - }} + }, + } baseOpts := []ccipclient.SendReqOpts{ ccipclient.WithSourceChain(sourceChain), @@ -515,7 +521,8 @@ func Test_CCIP_TokenTransfer_Aptos2EVM(t *testing.T) { Token: aptosInvalidToken, Amount: 1e8, }, - }} + }, + } baseOpts := []ccipclient.SendReqOpts{ ccipclient.WithSourceChain(sourceChain), @@ -583,7 +590,7 @@ func Test_CCIP_TokenTransfer_BnM_EVM2Aptos(t *testing.T) { SourceChain: sourceChain, DestChain: destChain, Receiver: deployerDestChain[:], - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, Tokens: []router.ClientEVMTokenAmount{ { Token: evmToken.Address(), @@ -603,7 +610,7 @@ func Test_CCIP_TokenTransfer_BnM_EVM2Aptos(t *testing.T) { SourceChain: sourceChain, DestChain: destChain, Receiver: deployerDestChain[:], - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, Tokens: []router.ClientEVMTokenAmount{ { Token: evmToken.Address(), @@ -623,7 +630,7 @@ func Test_CCIP_TokenTransfer_BnM_EVM2Aptos(t *testing.T) { SourceChain: sourceChain, DestChain: destChain, Receiver: ccipChainState.ReceiverAddress[:], - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, Tokens: []router.ClientEVMTokenAmount{ { Token: evmToken.Address(), @@ -644,7 +651,7 @@ func Test_CCIP_TokenTransfer_BnM_EVM2Aptos(t *testing.T) { DestChain: destChain, Receiver: deployerDestChain[:], Data: []byte("Hello, World!"), - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, Tokens: []router.ClientEVMTokenAmount{ { Token: evmToken.Address(), @@ -699,7 +706,8 @@ func Test_CCIP_TokenTransfer_BnM_EVM2Aptos(t *testing.T) { Token: evmToken.Address(), Amount: big.NewInt(1e8), }, - }} + }, + } baseOpts := []ccipclient.SendReqOpts{ ccipclient.WithSourceChain(sourceChain), @@ -725,7 +733,8 @@ func Test_CCIP_TokenTransfer_BnM_EVM2Aptos(t *testing.T) { Token: evmToken.Address(), Amount: big.NewInt(0), }, - }} + }, + } baseOpts := []ccipclient.SendReqOpts{ ccipclient.WithSourceChain(sourceChain), @@ -751,7 +760,8 @@ func Test_CCIP_TokenTransfer_BnM_EVM2Aptos(t *testing.T) { Token: common.HexToAddress("0x0000000000000000000000000000000000000000"), // Invalid token Amount: big.NewInt(1e8), }, - }} + }, + } baseOpts := []ccipclient.SendReqOpts{ ccipclient.WithSourceChain(sourceChain), @@ -806,7 +816,7 @@ func Test_CCIP_TokenTransfer_BnM_Aptos2EVM(t *testing.T) { require.NoError(t, err) // Fee Tokens - var NativeFeeToken = "0xa" // coin + NativeFeeToken := "0xa" // coin // Invalid Fee Token var aptosInvalidToken aptos.AccountAddress @@ -817,7 +827,7 @@ func Test_CCIP_TokenTransfer_BnM_Aptos2EVM(t *testing.T) { SourceChain: sourceChain, DestChain: destChain, Receiver: deployerDestChain.From.Bytes(), - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, AptosTokens: []testhelpers.AptosTokenAmount{ { Token: aptosToken, @@ -838,7 +848,7 @@ func Test_CCIP_TokenTransfer_BnM_Aptos2EVM(t *testing.T) { SourceChain: sourceChain, DestChain: destChain, Receiver: deployerDestChain.From.Bytes(), - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, AptosTokens: []testhelpers.AptosTokenAmount{ { Token: aptosToken, @@ -859,7 +869,7 @@ func Test_CCIP_TokenTransfer_BnM_Aptos2EVM(t *testing.T) { SourceChain: sourceChain, DestChain: destChain, Receiver: deployerDestChain.From.Bytes(), - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, Data: []byte("Hello, World!"), AptosTokens: []testhelpers.AptosTokenAmount{ { @@ -881,7 +891,7 @@ func Test_CCIP_TokenTransfer_BnM_Aptos2EVM(t *testing.T) { SourceChain: sourceChain, DestChain: destChain, Receiver: deployerDestChain.From.Bytes(), - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, Data: []byte("Hello, World!"), AptosTokens: []testhelpers.AptosTokenAmount{ { @@ -902,7 +912,7 @@ func Test_CCIP_TokenTransfer_BnM_Aptos2EVM(t *testing.T) { SourceChain: sourceChain, DestChain: destChain, Receiver: ccipReceiverAddress.Bytes(), - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, AptosTokens: []testhelpers.AptosTokenAmount{ { Token: aptosToken, @@ -952,7 +962,8 @@ func Test_CCIP_TokenTransfer_BnM_Aptos2EVM(t *testing.T) { aptosFeeQuoter := aptos_feequoter.NewFeeQuoter( state.AptosChains[sourceChain].CCIPAddress, - e.Env.BlockChains.AptosChains()[sourceChain].Client) + e.Env.BlockChains.AptosChains()[sourceChain].Client, + ) aptosFeeQuoterDestChainConfig, err := aptosFeeQuoter.GetDestChainConfig(aptosCallOpts, destChain) require.NoError(t, err, "Failed to get destination chain fee quoter config") @@ -968,7 +979,8 @@ func Test_CCIP_TokenTransfer_BnM_Aptos2EVM(t *testing.T) { Token: aptosToken, Amount: 1e8, }, - }} + }, + } baseOpts := []ccipclient.SendReqOpts{ ccipclient.WithSourceChain(sourceChain), @@ -993,7 +1005,8 @@ func Test_CCIP_TokenTransfer_BnM_Aptos2EVM(t *testing.T) { Token: aptosToken, Amount: 0, }, - }} + }, + } baseOpts := []ccipclient.SendReqOpts{ ccipclient.WithSourceChain(sourceChain), @@ -1018,7 +1031,8 @@ func Test_CCIP_TokenTransfer_BnM_Aptos2EVM(t *testing.T) { Token: aptosInvalidToken, Amount: 1e8, }, - }} + }, + } baseOpts := []ccipclient.SendReqOpts{ ccipclient.WithSourceChain(sourceChain), @@ -1110,7 +1124,7 @@ func Test_CCIP_TokenTransfer_LnR_EVM2Aptos(t *testing.T) { SourceChain: sourceChain, DestChain: destChain, Receiver: deployerAddressDestChain[:], - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, Tokens: []router.ClientEVMTokenAmount{ { Token: evmToken.Address(), @@ -1130,7 +1144,7 @@ func Test_CCIP_TokenTransfer_LnR_EVM2Aptos(t *testing.T) { SourceChain: sourceChain, DestChain: destChain, Receiver: deployerAddressDestChain[:], - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, Tokens: []router.ClientEVMTokenAmount{ { Token: evmToken.Address(), @@ -1150,7 +1164,7 @@ func Test_CCIP_TokenTransfer_LnR_EVM2Aptos(t *testing.T) { SourceChain: sourceChain, DestChain: destChain, Receiver: ccipChainState.ReceiverAddress[:], - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, Tokens: []router.ClientEVMTokenAmount{ { Token: evmToken.Address(), @@ -1171,7 +1185,7 @@ func Test_CCIP_TokenTransfer_LnR_EVM2Aptos(t *testing.T) { DestChain: destChain, Receiver: deployerAddressDestChain[:], Data: []byte("Hello, World!"), - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, Tokens: []router.ClientEVMTokenAmount{ { Token: evmToken.Address(), @@ -1226,7 +1240,8 @@ func Test_CCIP_TokenTransfer_LnR_EVM2Aptos(t *testing.T) { Token: evmToken.Address(), Amount: big.NewInt(1e8), }, - }} + }, + } baseOpts := []ccipclient.SendReqOpts{ ccipclient.WithSourceChain(sourceChain), @@ -1252,7 +1267,8 @@ func Test_CCIP_TokenTransfer_LnR_EVM2Aptos(t *testing.T) { Token: evmToken.Address(), Amount: big.NewInt(0), }, - }} + }, + } baseOpts := []ccipclient.SendReqOpts{ ccipclient.WithSourceChain(sourceChain), @@ -1278,7 +1294,8 @@ func Test_CCIP_TokenTransfer_LnR_EVM2Aptos(t *testing.T) { Token: common.HexToAddress("0x0000000000000000000000000000000000000000"), // Invalid token Amount: big.NewInt(1e8), }, - }} + }, + } baseOpts := []ccipclient.SendReqOpts{ ccipclient.WithSourceChain(sourceChain), @@ -1336,7 +1353,7 @@ func Test_CCIP_TokenTransfer_LnR_Aptos2EVM(t *testing.T) { require.NoError(t, err) // Fee Tokens - var NativeFeeToken = "0xa" // coin + NativeFeeToken := "0xa" // coin // Invalid Fee Token var aptosInvalidToken aptos.AccountAddress @@ -1347,7 +1364,7 @@ func Test_CCIP_TokenTransfer_LnR_Aptos2EVM(t *testing.T) { SourceChain: sourceChain, DestChain: destChain, Receiver: deployerDestChain.From.Bytes(), - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, AptosTokens: []testhelpers.AptosTokenAmount{ { Token: aptosToken, @@ -1368,7 +1385,7 @@ func Test_CCIP_TokenTransfer_LnR_Aptos2EVM(t *testing.T) { SourceChain: sourceChain, DestChain: destChain, Receiver: deployerDestChain.From.Bytes(), - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, AptosTokens: []testhelpers.AptosTokenAmount{ { Token: aptosToken, @@ -1389,7 +1406,7 @@ func Test_CCIP_TokenTransfer_LnR_Aptos2EVM(t *testing.T) { SourceChain: sourceChain, DestChain: destChain, Receiver: deployerDestChain.From.Bytes(), - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, Data: []byte("Hello, World!"), AptosTokens: []testhelpers.AptosTokenAmount{ { @@ -1411,7 +1428,7 @@ func Test_CCIP_TokenTransfer_LnR_Aptos2EVM(t *testing.T) { SourceChain: sourceChain, DestChain: destChain, Receiver: deployerDestChain.From.Bytes(), - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, Data: []byte("Hello, World!"), AptosTokens: []testhelpers.AptosTokenAmount{ { @@ -1432,7 +1449,7 @@ func Test_CCIP_TokenTransfer_LnR_Aptos2EVM(t *testing.T) { SourceChain: sourceChain, DestChain: destChain, Receiver: ccipReceiverAddress.Bytes(), - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, AptosTokens: []testhelpers.AptosTokenAmount{ { Token: aptosToken, @@ -1482,7 +1499,8 @@ func Test_CCIP_TokenTransfer_LnR_Aptos2EVM(t *testing.T) { aptosFeeQuoter := aptos_feequoter.NewFeeQuoter( state.AptosChains[sourceChain].CCIPAddress, - e.Env.BlockChains.AptosChains()[sourceChain].Client) + e.Env.BlockChains.AptosChains()[sourceChain].Client, + ) aptosFeeQuoterDestChainConfig, err := aptosFeeQuoter.GetDestChainConfig(aptosCallOpts, destChain) require.NoError(t, err, "Failed to get destination chain fee quoter config") @@ -1498,7 +1516,8 @@ func Test_CCIP_TokenTransfer_LnR_Aptos2EVM(t *testing.T) { Token: aptosToken, Amount: 1e8, }, - }} + }, + } baseOpts := []ccipclient.SendReqOpts{ ccipclient.WithSourceChain(sourceChain), @@ -1523,7 +1542,8 @@ func Test_CCIP_TokenTransfer_LnR_Aptos2EVM(t *testing.T) { Token: aptosToken, Amount: 0, }, - }} + }, + } baseOpts := []ccipclient.SendReqOpts{ ccipclient.WithSourceChain(sourceChain), @@ -1548,7 +1568,8 @@ func Test_CCIP_TokenTransfer_LnR_Aptos2EVM(t *testing.T) { Token: aptosInvalidToken, Amount: 1e8, }, - }} + }, + } baseOpts := []ccipclient.SendReqOpts{ ccipclient.WithSourceChain(sourceChain), @@ -1640,7 +1661,7 @@ func Test_CCIP_TokenTransfer_LnR_without_TransferRef_EVM2Aptos(t *testing.T) { SourceChain: sourceChain, DestChain: destChain, Receiver: deployerAddressDestChain[:], - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, Tokens: []router.ClientEVMTokenAmount{ { Token: evmToken.Address(), @@ -1660,7 +1681,7 @@ func Test_CCIP_TokenTransfer_LnR_without_TransferRef_EVM2Aptos(t *testing.T) { SourceChain: sourceChain, DestChain: destChain, Receiver: deployerAddressDestChain[:], - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, Tokens: []router.ClientEVMTokenAmount{ { Token: evmToken.Address(), @@ -1680,7 +1701,7 @@ func Test_CCIP_TokenTransfer_LnR_without_TransferRef_EVM2Aptos(t *testing.T) { SourceChain: sourceChain, DestChain: destChain, Receiver: ccipChainState.ReceiverAddress[:], - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, Tokens: []router.ClientEVMTokenAmount{ { Token: evmToken.Address(), @@ -1701,7 +1722,7 @@ func Test_CCIP_TokenTransfer_LnR_without_TransferRef_EVM2Aptos(t *testing.T) { DestChain: destChain, Receiver: deployerAddressDestChain[:], Data: []byte("Hello, World!"), - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, Tokens: []router.ClientEVMTokenAmount{ { Token: evmToken.Address(), @@ -1756,7 +1777,8 @@ func Test_CCIP_TokenTransfer_LnR_without_TransferRef_EVM2Aptos(t *testing.T) { Token: evmToken.Address(), Amount: big.NewInt(1e8), }, - }} + }, + } baseOpts := []ccipclient.SendReqOpts{ ccipclient.WithSourceChain(sourceChain), @@ -1782,7 +1804,8 @@ func Test_CCIP_TokenTransfer_LnR_without_TransferRef_EVM2Aptos(t *testing.T) { Token: evmToken.Address(), Amount: big.NewInt(0), }, - }} + }, + } baseOpts := []ccipclient.SendReqOpts{ ccipclient.WithSourceChain(sourceChain), @@ -1808,7 +1831,8 @@ func Test_CCIP_TokenTransfer_LnR_without_TransferRef_EVM2Aptos(t *testing.T) { Token: common.HexToAddress("0x0000000000000000000000000000000000000000"), // Invalid token Amount: big.NewInt(1e8), }, - }} + }, + } baseOpts := []ccipclient.SendReqOpts{ ccipclient.WithSourceChain(sourceChain), @@ -1866,7 +1890,7 @@ func Test_CCIP_TokenTransfer_LnR_without_TransferRef_Aptos2EVM(t *testing.T) { require.NoError(t, err) // Fee Tokens - var NativeFeeToken = "0xa" // coin + NativeFeeToken := "0xa" // coin // Invalid Fee Token var aptosInvalidToken aptos.AccountAddress @@ -1877,7 +1901,7 @@ func Test_CCIP_TokenTransfer_LnR_without_TransferRef_Aptos2EVM(t *testing.T) { SourceChain: sourceChain, DestChain: destChain, Receiver: deployerDestChain.From.Bytes(), - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, AptosTokens: []testhelpers.AptosTokenAmount{ { Token: aptosToken, @@ -1898,7 +1922,7 @@ func Test_CCIP_TokenTransfer_LnR_without_TransferRef_Aptos2EVM(t *testing.T) { SourceChain: sourceChain, DestChain: destChain, Receiver: deployerDestChain.From.Bytes(), - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, AptosTokens: []testhelpers.AptosTokenAmount{ { Token: aptosToken, @@ -1919,7 +1943,7 @@ func Test_CCIP_TokenTransfer_LnR_without_TransferRef_Aptos2EVM(t *testing.T) { SourceChain: sourceChain, DestChain: destChain, Receiver: deployerDestChain.From.Bytes(), - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, Data: []byte("Hello, World!"), AptosTokens: []testhelpers.AptosTokenAmount{ { @@ -1941,7 +1965,7 @@ func Test_CCIP_TokenTransfer_LnR_without_TransferRef_Aptos2EVM(t *testing.T) { SourceChain: sourceChain, DestChain: destChain, Receiver: deployerDestChain.From.Bytes(), - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, Data: []byte("Hello, World!"), AptosTokens: []testhelpers.AptosTokenAmount{ { @@ -1962,7 +1986,7 @@ func Test_CCIP_TokenTransfer_LnR_without_TransferRef_Aptos2EVM(t *testing.T) { SourceChain: sourceChain, DestChain: destChain, Receiver: ccipReceiverAddress.Bytes(), - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, AptosTokens: []testhelpers.AptosTokenAmount{ { Token: aptosToken, @@ -2012,7 +2036,8 @@ func Test_CCIP_TokenTransfer_LnR_without_TransferRef_Aptos2EVM(t *testing.T) { aptosFeeQuoter := aptos_feequoter.NewFeeQuoter( state.AptosChains[sourceChain].CCIPAddress, - e.Env.BlockChains.AptosChains()[sourceChain].Client) + e.Env.BlockChains.AptosChains()[sourceChain].Client, + ) aptosFeeQuoterDestChainConfig, err := aptosFeeQuoter.GetDestChainConfig(aptosCallOpts, destChain) require.NoError(t, err, "Failed to get destination chain fee quoter config") @@ -2028,7 +2053,8 @@ func Test_CCIP_TokenTransfer_LnR_without_TransferRef_Aptos2EVM(t *testing.T) { Token: aptosToken, Amount: 1e8, }, - }} + }, + } baseOpts := []ccipclient.SendReqOpts{ ccipclient.WithSourceChain(sourceChain), @@ -2053,7 +2079,8 @@ func Test_CCIP_TokenTransfer_LnR_without_TransferRef_Aptos2EVM(t *testing.T) { Token: aptosToken, Amount: 0, }, - }} + }, + } baseOpts := []ccipclient.SendReqOpts{ ccipclient.WithSourceChain(sourceChain), @@ -2078,7 +2105,8 @@ func Test_CCIP_TokenTransfer_LnR_without_TransferRef_Aptos2EVM(t *testing.T) { Token: aptosInvalidToken, Amount: 1e8, }, - }} + }, + } baseOpts := []ccipclient.SendReqOpts{ ccipclient.WithSourceChain(sourceChain), diff --git a/integration-tests/smoke/ccip/ccip_batching_test.go b/integration-tests/smoke/ccip/ccip_batching_test.go index 1dd548ef9d2..b1aeb1caab5 100644 --- a/integration-tests/smoke/ccip/ccip_batching_test.go +++ b/integration-tests/smoke/ccip/ccip_batching_test.go @@ -11,8 +11,8 @@ import ( "github.com/stretchr/testify/require" "golang.org/x/exp/maps" - "github.com/smartcontractkit/chainlink-ccip/pkg/types/ccipocr3" "github.com/smartcontractkit/chainlink-common/pkg/merklemulti" + "github.com/smartcontractkit/chainlink-common/pkg/types/ccipocr3" cldf_evm "github.com/smartcontractkit/chainlink-deployments-framework/chain/evm" cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment" @@ -117,7 +117,7 @@ func Test_CCIPBatching_MaxBatchSizeEVM(t *testing.T) { }() } - var i = 0 + i := 0 for i < len(transactors) { select { case err := <-errs: @@ -300,7 +300,7 @@ func ccipBatchingMultiSource(t *testing.T, opts ...testhelpers.TestOps) { // assert that all states are successful for _, states := range execStates { for _, state := range states { - require.Equal(t, testhelpers.EXECUTION_STATE_SUCCESS, state) + require.Equal(t, testhelpers.ExecutionStateSuccess, state) } } } @@ -312,16 +312,12 @@ func ccipBatchingSingleSource(t *testing.T, opts ...testhelpers.TestOps) { sourceChain1, sourceChain2, destChain, e, state := setup.sourceChain1, setup.sourceChain2, setup.destChain, setup.e, setup.state evmChains := e.Env.BlockChains.EVMChains() - var ( - startSeqNum = map[uint64]ccipocr3.SeqNum{ - sourceChain1: 1, - sourceChain2: 1, - } - ) + startSeqNum := map[uint64]ccipocr3.SeqNum{ + sourceChain1: 1, + sourceChain2: 1, + } - var ( - sourceChain = sourceChain1 - ) + sourceChain := sourceChain1 err := sendMessages( ctx, t, @@ -358,7 +354,7 @@ func ccipBatchingSingleSource(t *testing.T, opts ...testhelpers.TestOps) { require.NoError(t, err) // assert that all states are successful for _, state := range states { - require.Equal(t, testhelpers.EXECUTION_STATE_SUCCESS, state) + require.Equal(t, testhelpers.ExecutionStateSuccess, state) } } diff --git a/integration-tests/smoke/ccip/ccip_cs_update_rmn_config_test.go b/integration-tests/smoke/ccip/ccip_cs_update_rmn_config_test.go index 4473ec818b7..9b3fadd97cf 100644 --- a/integration-tests/smoke/ccip/ccip_cs_update_rmn_config_test.go +++ b/integration-tests/smoke/ccip/ccip_cs_update_rmn_config_test.go @@ -37,19 +37,19 @@ import ( var ( rmnStaging1 = v1_6.RMNNopConfig{ NodeIndex: 0, - PeerId: deployment.MustPeerIDFromString("p2p_12D3KooWRXxZq3pd4a3ZGkKj7Nt1SQQrnB8CuvbPnnV9KVeMeWqg"), + PeerID: deployment.MustPeerIDFromString("p2p_12D3KooWRXxZq3pd4a3ZGkKj7Nt1SQQrnB8CuvbPnnV9KVeMeWqg"), OffchainPublicKey: [32]byte(common.FromHex("0xb34944857a42444d1b285d7940d6e06682309e0781e43a69676ee9f85c73c2d1")), EVMOnChainPublicKey: common.HexToAddress("0x5af8ee32316a6427f169a45fdc1b3a91a85ac459e3c1cb91c69e1c51f0c1fc21"), } rmnStaging2 = v1_6.RMNNopConfig{ NodeIndex: 1, - PeerId: deployment.MustPeerIDFromString("p2p_12D3KooWEmdxYQFsRbD9aFczF32zA3CcUwuSiWCk2CrmACo4v9RL"), + PeerID: deployment.MustPeerIDFromString("p2p_12D3KooWEmdxYQFsRbD9aFczF32zA3CcUwuSiWCk2CrmACo4v9RL"), OffchainPublicKey: [32]byte(common.FromHex("0x68d9f3f274e3985528a923a9bace3d39c55dd778b187b4120b384cc48c892859")), EVMOnChainPublicKey: common.HexToAddress("0x858589216956f482a0f68b282a7050af4cd48ed2"), } rmnStaging3 = v1_6.RMNNopConfig{ NodeIndex: 2, - PeerId: deployment.MustPeerIDFromString("p2p_12D3KooWJS42cNXKJvj6DeZnxEX7aGxhEuap6uNFrz554AbUDw6Q"), + PeerID: deployment.MustPeerIDFromString("p2p_12D3KooWJS42cNXKJvj6DeZnxEX7aGxhEuap6uNFrz554AbUDw6Q"), OffchainPublicKey: [32]byte(common.FromHex("0x5af8ee32316a6427f169a45fdc1b3a91a85ac459e3c1cb91c69e1c51f0c1fc21")), EVMOnChainPublicKey: common.HexToAddress("0x7c5e94162c6fabbdeb3bfe83ae532846e337bfae"), } diff --git a/integration-tests/smoke/ccip/ccip_lbtc_test.go b/integration-tests/smoke/ccip/ccip_lbtc_test.go index 8477a34054a..f1348a26d46 100644 --- a/integration-tests/smoke/ccip/ccip_lbtc_test.go +++ b/integration-tests/smoke/ccip/ccip_lbtc_test.go @@ -120,11 +120,12 @@ func TestLBTCTokenTransfer(t *testing.T) { { Token: cChainLBTC.Address(), Amount: tinyOneCoin, - }}, + }, + }, ExpectedTokenBalances: []testhelpers.ExpectedBalance{ {Token: aChainLBTC.Address().Bytes(), Amount: tinyOneCoin}, }, - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, }, { Name: "multiple LBTC tokens within the same message", @@ -145,7 +146,7 @@ func TestLBTCTokenTransfer(t *testing.T) { // 2 coins because of the same Receiver {Token: aChainLBTC.Address().Bytes(), Amount: new(big.Int).Add(tinyOneCoin, tinyOneCoin)}, }, - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, }, { Name: "LBTC token together with another token transferred to EOA", @@ -166,7 +167,7 @@ func TestLBTCTokenTransfer(t *testing.T) { {Token: cChainLBTC.Address().Bytes(), Amount: tinyOneCoin}, {Token: cChainToken.Address().Bytes(), Amount: new(big.Int).Mul(tinyOneCoin, big.NewInt(10))}, }, - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, }, { Name: "LBTC programmable token transfer to valid contract receiver", @@ -183,7 +184,7 @@ func TestLBTCTokenTransfer(t *testing.T) { ExpectedTokenBalances: []testhelpers.ExpectedBalance{ {Token: cChainLBTC.Address().Bytes(), Amount: tinyOneCoin}, }, - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, }, { Name: "LBTC programmable token transfer with too little gas", @@ -201,7 +202,7 @@ func TestLBTCTokenTransfer(t *testing.T) { {Token: bChainLBTC.Address().Bytes(), Amount: new(big.Int).SetUint64(0)}, }, ExtraArgs: testhelpers.MakeEVMExtraArgsV2(1, false), - ExpectedStatus: testhelpers.EXECUTION_STATE_FAILURE, + ExpectedStatus: testhelpers.ExecutionStateFailure, }, { Name: "LBTC token transfer from a different source chain", @@ -218,12 +219,11 @@ func TestLBTCTokenTransfer(t *testing.T) { ExpectedTokenBalances: []testhelpers.ExpectedBalance{ {Token: cChainLBTC.Address().Bytes(), Amount: tinyOneCoin}, }, - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, }, } - startBlocks, expectedSeqNums, expectedExecutionStates, expectedTokenBalances := - testhelpers.TransferMultiple(ctx, t, e, state, tcs) + startBlocks, expectedSeqNums, expectedExecutionStates, expectedTokenBalances := testhelpers.TransferMultiple(ctx, t, e, state, tcs) err = testhelpers.ConfirmMultipleCommits( t, diff --git a/integration-tests/smoke/ccip/ccip_messaging_test.go b/integration-tests/smoke/ccip/ccip_messaging_test.go index 6b0aea598aa..ec40336bb09 100644 --- a/integration-tests/smoke/ccip/ccip_messaging_test.go +++ b/integration-tests/smoke/ccip/ccip_messaging_test.go @@ -53,7 +53,7 @@ func Test_CCIPMessaging_EVM2EVM(t *testing.T) { chainsel.GETH_TESTNET, // source chainsel.TEST_90000001, // dest } - var chainIDs = []uint64{ + chainIDs := []uint64{ chains[0].Selector, chains[1].Selector, } @@ -120,8 +120,8 @@ func Test_CCIPMessaging_EVM2EVM(t *testing.T) { Nonce: &nonce, Receiver: common.HexToAddress("0xdead").Bytes(), MsgData: []byte("hello eoa"), - ExtraArgs: nil, // default extraArgs - ExpectedExecutionState: testhelpers.EXECUTION_STATE_SUCCESS, // success because offRamp won't call an EOA + ExtraArgs: nil, // default extraArgs + ExpectedExecutionState: testhelpers.ExecutionStateSuccess, // success because offRamp won't call an EOA ExtraAssertions: []func(t *testing.T){ func(t *testing.T) { }, @@ -139,8 +139,8 @@ func Test_CCIPMessaging_EVM2EVM(t *testing.T) { Nonce: &out.Nonce, Receiver: state.MustGetEVMChainState(destChain).FeeQuoter.Address().Bytes(), MsgData: []byte("hello FeeQuoter"), - ExtraArgs: nil, // default extraArgs - ExpectedExecutionState: testhelpers.EXECUTION_STATE_SUCCESS, // success because offRamp won't call a contract not implementing CCIPReceiver + ExtraArgs: nil, // default extraArgs + ExpectedExecutionState: testhelpers.ExecutionStateSuccess, // success because offRamp won't call a contract not implementing CCIPReceiver }, ) }) @@ -157,7 +157,7 @@ func Test_CCIPMessaging_EVM2EVM(t *testing.T) { Receiver: state.MustGetEVMChainState(destChain).Receiver.Address().Bytes(), MsgData: []byte("hello CCIPReceiver"), ExtraArgs: nil, // default extraArgs - ExpectedExecutionState: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedExecutionState: testhelpers.ExecutionStateSuccess, ExtraAssertions: []func(t *testing.T){ func(t *testing.T) { iter, err := state.MustGetEVMChainState(destChain).Receiver.FilterMessageReceived(&bind.FilterOpts{ @@ -183,7 +183,7 @@ func Test_CCIPMessaging_EVM2EVM(t *testing.T) { Receiver: state.MustGetEVMChainState(destChain).Receiver.Address().Bytes(), MsgData: []byte("hello CCIPReceiver with low exec gas"), ExtraArgs: testhelpers.MakeEVMExtraArgsV2(1, false), // 1 gas is too low. - ExpectedExecutionState: testhelpers.EXECUTION_STATE_FAILURE, // state would be failed onchain due to low gas + ExpectedExecutionState: testhelpers.ExecutionStateFailure, // state would be failed onchain due to low gas }, ) msgSentEvent := out.MsgSentEvent.RawEvent.(*onramp.OnRampCCIPMessageSent) @@ -305,7 +305,7 @@ func Test_CCIPMessaging_MultiExecReports_EVM2Solana(t *testing.T) { Receiver: receiver, MsgData: []byte("hello CCIPReceiver"), ExtraArgs: extraArgs, - ExpectedExecutionState: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedExecutionState: testhelpers.ExecutionStateSuccess, NumberOfMessages: numMessages, }, ) @@ -444,7 +444,7 @@ func Test_CCIPMessaging_EVM2Solana(t *testing.T) { Receiver: receiver, MsgData: []byte("hello CCIPReceiver"), ExtraArgs: extraArgs, - ExpectedExecutionState: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedExecutionState: testhelpers.ExecutionStateSuccess, ExtraAssertions: []func(t *testing.T){ func(t *testing.T) { var receiverCounterAccount soltesthelpers.ReceiverCounter @@ -522,7 +522,7 @@ func Test_CCIPMessaging_EVM2Solana(t *testing.T) { Receiver: receiver, MsgData: []byte("hello CCIPReceiver that should succeed"), ExtraArgs: extraArgsSuccess, - ExpectedExecutionState: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedExecutionState: testhelpers.ExecutionStateSuccess, ExtraAssertions: []func(t *testing.T){ func(t *testing.T) { // Check counter is now 2 @@ -561,7 +561,7 @@ func Test_CCIPMessaging_EVM2Solana(t *testing.T) { Receiver: receiver, MsgData: make([]byte, 1233), // set large payload that cannot fit in single transaction but does not overflow memory allocation ExtraArgs: extraArgs, - ExpectedExecutionState: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedExecutionState: testhelpers.ExecutionStateSuccess, ExtraAssertions: []func(t *testing.T){ func(t *testing.T) { var receiverCounterAccount soltesthelpers.ReceiverCounter @@ -601,7 +601,7 @@ func Test_CCIPMessaging_EVM2Solana(t *testing.T) { ExtraArgs: extraArgs, NumberOfMessages: 3, UseMulticall3: true, - ExpectedExecutionState: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedExecutionState: testhelpers.ExecutionStateSuccess, }, ) }) @@ -666,7 +666,7 @@ func Test_CCIPMessaging_Solana2EVM(t *testing.T) { MsgData: []byte("hello CCIPReceiver"), FeeToken: "", // use native SOL - internally this will be converted to wSOL via Sync Native ExtraArgs: extraArgs, // default extraArgs - ExpectedExecutionState: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedExecutionState: testhelpers.ExecutionStateSuccess, ExtraAssertions: []func(t *testing.T){ func(t *testing.T) { iter, err := state.MustGetEVMChainState(destChain).Receiver.FilterMessageReceived(&bind.FilterOpts{ diff --git a/integration-tests/smoke/ccip/ccip_mixed_version_test.go b/integration-tests/smoke/ccip/ccip_mixed_version_test.go index 82cc6325942..ffaf112f03b 100644 --- a/integration-tests/smoke/ccip/ccip_mixed_version_test.go +++ b/integration-tests/smoke/ccip/ccip_mixed_version_test.go @@ -48,7 +48,7 @@ func Test_CCIPMixedVersionDON(t *testing.T) { chainsel.GETH_TESTNET, // source chainsel.GETH_DEVNET_2, // dest } - var chainIDs = []uint64{ + chainIDs := []uint64{ chains[0].Selector, chains[1].Selector, } @@ -103,8 +103,8 @@ func Test_CCIPMixedVersionDON(t *testing.T) { Nonce: &nonce, Receiver: common.HexToAddress("0xdead").Bytes(), MsgData: []byte("hello from mixed version DON"), - ExtraArgs: nil, // default extraArgs - ExpectedExecutionState: testhelpers.EXECUTION_STATE_SUCCESS, // success because offRamp won't call an EOA + ExtraArgs: nil, // default extraArgs + ExpectedExecutionState: testhelpers.ExecutionStateSuccess, // success because offRamp won't call an EOA }, ) }) @@ -119,7 +119,7 @@ func Test_CCIPMixedVersionDON(t *testing.T) { Receiver: state.MustGetEVMChainState(destChain).Receiver.Address().Bytes(), MsgData: []byte("hello CCIPReceiver from mixed version DON"), ExtraArgs: nil, // default extraArgs - ExpectedExecutionState: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedExecutionState: testhelpers.ExecutionStateSuccess, }, ) }) @@ -144,7 +144,7 @@ func Test_CCIPRollingUpgrade(t *testing.T) { chainsel.GETH_TESTNET, // source chainsel.GETH_DEVNET_2, // dest } - var chainIDs = []uint64{ + chainIDs := []uint64{ chains[0].Selector, chains[1].Selector, } @@ -206,7 +206,7 @@ func Test_CCIPRollingUpgrade(t *testing.T) { Receiver: common.HexToAddress("0xdead").Bytes(), MsgData: []byte("baseline before rolling upgrade"), ExtraArgs: nil, - ExpectedExecutionState: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedExecutionState: testhelpers.ExecutionStateSuccess, }, ) }) @@ -242,7 +242,7 @@ func Test_CCIPRollingUpgrade(t *testing.T) { Receiver: common.HexToAddress("0xdead").Bytes(), MsgData: []byte(fmt.Sprintf("message after upgrading node %d", i)), ExtraArgs: nil, - ExpectedExecutionState: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedExecutionState: testhelpers.ExecutionStateSuccess, Replayed: true, // skip replay after upgrade since the node restarts and the log poller starts fresh }, ) @@ -260,7 +260,7 @@ func Test_CCIPRollingUpgrade(t *testing.T) { Receiver: state.MustGetEVMChainState(destChain).Receiver.Address().Bytes(), MsgData: []byte("final message after rolling upgrade"), ExtraArgs: nil, - ExpectedExecutionState: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedExecutionState: testhelpers.ExecutionStateSuccess, Replayed: true, // skip replay after upgrades since the nodes restart and the log poller starts fresh }, ) diff --git a/integration-tests/smoke/ccip/ccip_ooo_execution_test.go b/integration-tests/smoke/ccip/ccip_ooo_execution_test.go index d619d571014..41204c57cea 100644 --- a/integration-tests/smoke/ccip/ccip_ooo_execution_test.go +++ b/integration-tests/smoke/ccip/ccip_ooo_execution_test.go @@ -132,7 +132,7 @@ func Test_OutOfOrderExecution(t *testing.T) { testhelpers.MakeEVMExtraArgsV2(0, true), "", ) - expectedStatuses[firstMessage.SequenceNumber] = testhelpers.EXECUTION_STATE_SUCCESS + expectedStatuses[firstMessage.SequenceNumber] = testhelpers.ExecutionStateSuccess t.Logf("Out of order messages sent from chain %d to chain %d with sequence number %d", sourceChain, destChain, firstMessage.SequenceNumber, ) @@ -193,7 +193,7 @@ func Test_OutOfOrderExecution(t *testing.T) { testhelpers.MakeEVMExtraArgsV2(300_000, true), "", ) - expectedStatuses[fourthMessage.SequenceNumber] = testhelpers.EXECUTION_STATE_SUCCESS + expectedStatuses[fourthMessage.SequenceNumber] = testhelpers.ExecutionStateSuccess t.Logf("Out of order programmable token transfer from chain %d to chain %d with sequence number %d", sourceChain, destChain, fourthMessage.SequenceNumber, ) @@ -212,7 +212,7 @@ func Test_OutOfOrderExecution(t *testing.T) { ExtraArgs: testhelpers.MakeEVMExtraArgsV2(0, false), })) require.NoError(t, err) - expectedStatuses[fifthMessage.SequenceNumber] = testhelpers.EXECUTION_STATE_SUCCESS + expectedStatuses[fifthMessage.SequenceNumber] = testhelpers.ExecutionStateSuccess t.Logf("Ordered message send by %v from chain %d to chain %d with sequence number %d", anotherSender.From, sourceChain, destChain, fifthMessage.SequenceNumber, ) @@ -250,11 +250,11 @@ func Test_OutOfOrderExecution(t *testing.T) { secondMsgState, err := state.MustGetEVMChainState(destChain).OffRamp.GetExecutionState(&bind.CallOpts{Context: ctx}, sourceChain, secondMsg.SequenceNumber) require.NoError(t, err) - require.Equal(t, uint8(testhelpers.EXECUTION_STATE_UNTOUCHED), secondMsgState) + require.Equal(t, uint8(testhelpers.ExecutionStateUntouched), secondMsgState) thirdMsgState, err := state.MustGetEVMChainState(destChain).OffRamp.GetExecutionState(&bind.CallOpts{Context: ctx}, sourceChain, thirdMessage.SequenceNumber) require.NoError(t, err) - require.Equal(t, uint8(testhelpers.EXECUTION_STATE_UNTOUCHED), thirdMsgState) + require.Equal(t, uint8(testhelpers.ExecutionStateUntouched), thirdMsgState) testhelpers.WaitForTheTokenBalance(ctx, t, destToken.Address(), firstReceiver, evmChains[destChain], oneE18) testhelpers.WaitForTheTokenBalance(ctx, t, destUSDC.Address(), secondReceiver, evmChains[destChain], big.NewInt(0)) diff --git a/integration-tests/smoke/ccip/ccip_solana_sui_messaging_test.go b/integration-tests/smoke/ccip/ccip_solana_sui_messaging_test.go index a651d965d8c..1f00a212b6e 100644 --- a/integration-tests/smoke/ccip/ccip_solana_sui_messaging_test.go +++ b/integration-tests/smoke/ccip/ccip_solana_sui_messaging_test.go @@ -169,7 +169,7 @@ func Test_CCIP_Messaging_Solana2Sui_Success(t *testing.T) { MsgData: message, FeeToken: "", // native SOL, converted to wSOL via Sync Native ExtraArgs: testhelpers.MakeSolanaSuiExtraArgsV1(1_000_000, true, fx.receiverObjectIDs, [32]byte{}), - ExpectedExecutionState: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedExecutionState: testhelpers.ExecutionStateSuccess, }, ) }) @@ -344,7 +344,7 @@ func Test_CCIP_Messaging_Sui2Solana_Success(t *testing.T) { MsgData: message, FeeToken: fx.suiLinkFeeToken, ExtraArgs: extraArgs, - ExpectedExecutionState: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedExecutionState: testhelpers.ExecutionStateSuccess, ExtraAssertions: []func(t *testing.T){ func(t *testing.T) { var after soltesthelpers.ReceiverCounter diff --git a/integration-tests/smoke/ccip/ccip_solana_sui_token_transfer_test.go b/integration-tests/smoke/ccip/ccip_solana_sui_token_transfer_test.go index 9e0bfff8846..6a9366d942f 100644 --- a/integration-tests/smoke/ccip/ccip_solana_sui_token_transfer_test.go +++ b/integration-tests/smoke/ccip/ccip_solana_sui_token_transfer_test.go @@ -172,7 +172,7 @@ func prepareSolana2SuiTokenTransferTest(t *testing.T) solana2SuiTokenFixtures { // // gas_limit = 0 (no receiver execution); token_receiver = Sui wallet (non-zero, required // // when tokens are present). receiverObjectIDs = nil (no ccip_receive, no receiver objects). // ExtraArgs: testhelpers.MakeSolanaSuiExtraArgsV1(0, true, nil, fx.suiAddr), -// ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, +// ExpectedStatus: testhelpers.ExecutionStateSuccess, // }, // } diff --git a/integration-tests/smoke/ccip/ccip_sui_messaging_test.go b/integration-tests/smoke/ccip/ccip_sui_messaging_test.go index 7be3d32f048..2d2c1d4cc9e 100644 --- a/integration-tests/smoke/ccip/ccip_sui_messaging_test.go +++ b/integration-tests/smoke/ccip/ccip_sui_messaging_test.go @@ -148,7 +148,7 @@ func Test_CCIP_Messaging_Sui2EVM_Success(t *testing.T) { ExtraArgs: nil, Replayed: true, FeeToken: fx.suiLinkFeeToken, - ExpectedExecutionState: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedExecutionState: testhelpers.ExecutionStateSuccess, }, ) }) @@ -168,7 +168,7 @@ func Test_CCIP_Messaging_Sui2EVM_Success(t *testing.T) { // Receiver: fx.state.Chains[fx.destChain].Receiver.Address().Bytes(), // MsgData: message, // ExtraArgs: testhelpers.MakeBCSEVMExtraArgsV2(big.NewInt(300000), false), - // ExpectedExecutionState: testhelpers.EXECUTION_STATE_SUCCESS, + // ExpectedExecutionState: testhelpers.ExecutionStateSuccess, // ExtraAssertions: []func(t *testing.T){ // func(t *testing.T) { // assertEvmMessageReceived(testhelpers.Context(t), t, fx.state, fx.destChain, latestHead, message) @@ -192,7 +192,7 @@ func Test_CCIP_Messaging_Sui2EVM_Success(t *testing.T) { // Receiver: fx.state.Chains[fx.destChain].Receiver.Address().Bytes(), // MsgData: fx.standardMessage, // ExtraArgs: testhelpers.MakeBCSEVMExtraArgsV2(big.NewInt(int64(fx.suiFQDestConfig.MaxPerMsgGasLimit)), false), - // ExpectedExecutionState: testhelpers.EXECUTION_STATE_SUCCESS, + // ExpectedExecutionState: testhelpers.ExecutionStateSuccess, // ExtraAssertions: []func(t *testing.T){ // func(t *testing.T) { // assertEvmMessageReceived(testhelpers.Context(t), t, fx.state, fx.destChain, latestHead, fx.standardMessage) @@ -476,7 +476,7 @@ func Test_CCIP_Messaging_EVM2Sui_Success(t *testing.T) { Receiver: fx.receiverByte, MsgData: message, ExtraArgs: testhelpers.MakeSuiExtraArgs(1000000, true, fx.receiverObjectIDs, [32]byte{}), - ExpectedExecutionState: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedExecutionState: testhelpers.ExecutionStateSuccess, }, ) }) @@ -553,7 +553,7 @@ func Test_CCIP_ReceiverReverts_EVM2Sui(t *testing.T) { Receiver: fx.receiverByte, MsgData: []byte("control: receiver works"), ExtraArgs: testhelpers.MakeSuiExtraArgs(1000000, true, fx.receiverObjectIDs, [32]byte{}), - ExpectedExecutionState: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedExecutionState: testhelpers.ExecutionStateSuccess, }, ) @@ -602,7 +602,7 @@ func Test_CCIP_ReceiverReverts_EVM2Sui(t *testing.T) { } _, err = offrampContract.DevInspect().GetExecutionState(ctx, devInspectOpts, offRampStateObj, fx.sourceChain, seqBogus) - require.Error(t, err, "reverting receiver leg must not persist EXECUTION_STATE_SUCCESS (execute PTB must roll back atomically)") + require.Error(t, err, "reverting receiver leg must not persist ExecutionStateSuccess (execute PTB must roll back atomically)") // Recovery: a subsequent message to the same receiver still succeeds, proving the reverted // leg did not corrupt receiver or lane state. @@ -614,7 +614,7 @@ func Test_CCIP_ReceiverReverts_EVM2Sui(t *testing.T) { Receiver: fx.receiverByte, MsgData: []byte("recovery: receiver still works after revert"), ExtraArgs: testhelpers.MakeSuiExtraArgs(1000000, true, fx.receiverObjectIDs, [32]byte{}), - ExpectedExecutionState: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedExecutionState: testhelpers.ExecutionStateSuccess, }, ) } @@ -767,7 +767,7 @@ func Test_CCIP_EVM2Sui_ZeroReceiver(t *testing.T) { Receiver: []byte{}, MsgData: message, ExtraArgs: testhelpers.MakeSuiExtraArgs(0, true, [][32]byte{}, [32]byte{}), - ExpectedExecutionState: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedExecutionState: testhelpers.ExecutionStateSuccess, }, ) }) @@ -950,7 +950,7 @@ func suiExecTransmitterAddress(t *testing.T, e testhelpers.DeployedEnv, destChai // transmitter-ownership guard end-to-end. A malicious Sui receiver declares &mut over a // transmitter-owned SUI gas coin handed in as a receiverObjectIds tail. The guard rejects that // tail object, the receiver leg is skipped, the execute PTB reverts on-chain, and the optimistic -// EXECUTION_STATE_SUCCESS rolls back atomically (get_execution_state aborts EUnknownSequenceNumber) +// ExecutionStateSuccess rolls back atomically (get_execution_state aborts EUnknownSequenceNumber) // with the transmitter's SUI balance unchanged (no drain). Mirrors Test_CCIP_ReceiverReverts_EVM2Sui. func Test_CCIP_Messaging_EVM2Sui_TransmitterOwnedTail_Rejected(t *testing.T) { fx := prepareEVM2SuiMaliciousReceiverTest(t) @@ -994,7 +994,7 @@ func Test_CCIP_Messaging_EVM2Sui_TransmitterOwnedTail_Rejected(t *testing.T) { // Let the DON attempt execution of the exploit message (it reverts atomically). messagingtest.SleepReplayAndSettle(t, fx.e.Env, 30*time.Second, fx.sourceChain) - // The reverted execute PTB rolls back the optimistic EXECUTION_STATE_SUCCESS, so the sequence + // The reverted execute PTB rolls back the optimistic ExecutionStateSuccess, so the sequence // is absent and get_execution_state aborts EUnknownSequenceNumber (atomic-rollback guarantee). ctx := testhelpers.Context(t) suiState, err := sui_deployment.LoadOnchainStatesui(fx.e.Env) @@ -1039,7 +1039,7 @@ func Test_CCIP_Messaging_EVM2Sui_TransmitterOwnedTail_Rejected(t *testing.T) { Receiver: fx.legitReceiverByte, MsgData: []byte("lane not stuck"), ExtraArgs: testhelpers.MakeSuiExtraArgs(1_000_000, true, fx.legitReceiverObjectIDs, [32]byte{}), - ExpectedExecutionState: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedExecutionState: testhelpers.ExecutionStateSuccess, }, ) } diff --git a/integration-tests/smoke/ccip/ccip_sui_token_transfer_test.go b/integration-tests/smoke/ccip/ccip_sui_token_transfer_test.go index 00507ce7283..0f11a4c9d58 100644 --- a/integration-tests/smoke/ccip/ccip_sui_token_transfer_test.go +++ b/integration-tests/smoke/ccip/ccip_sui_token_transfer_test.go @@ -73,7 +73,7 @@ func Test_CCIPTokenTransfer_Sui2EVM_LockReleaseTokenPool_Plain(t *testing.T) { SourceChain: sourceChain, DestChain: destChain, Receiver: updatedEnv.BlockChains.EVMChains()[destChain].DeployerKey.From.Bytes(), - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, FeeToken: feeTokenOutput.Objects.MintedLinkTokenObjectId, SuiTokens: []testhelpers.SuiTokenAmount{ { @@ -148,7 +148,7 @@ func Test_CCIPTokenTransfer_Sui2EVM_LockReleaseTokenPool_Revert(t *testing.T) { SourceChain: sourceChain, DestChain: destChain, Receiver: updatedEnv.BlockChains.EVMChains()[destChain].DeployerKey.From.Bytes(), - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, FeeToken: feeTokenOutput.Objects.MintedLinkTokenObjectId, SuiTokens: []testhelpers.SuiTokenAmount{ { @@ -300,7 +300,7 @@ func Test_CCIPTokenTransfer_Sui2EVM_BurnMintTokenPool_Plain(t *testing.T) { SourceChain: sourceChain, DestChain: destChain, Receiver: updatedEnv.BlockChains.EVMChains()[destChain].DeployerKey.From.Bytes(), // internally left padded to 32byte - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, FeeToken: feeTokenOutput.Objects.MintedLinkTokenObjectId, SuiTokens: []testhelpers.SuiTokenAmount{ { @@ -321,7 +321,7 @@ func Test_CCIPTokenTransfer_Sui2EVM_BurnMintTokenPool_Plain(t *testing.T) { SourceChain: sourceChain, DestChain: destChain, Receiver: ccipReceiverAddress.Bytes(), // internally left padded to 32byte - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, SuiTokens: []testhelpers.SuiTokenAmount{ { TokenPoolType: sui_deployment.TokenPoolTypeBurnMint, @@ -546,7 +546,7 @@ func Test_CCIPTokenTransfer_Sui2EVM_BurnMintTokenPool_ThenGloballyCursedUncursed SourceChain: sourceChain, DestChain: destChain, Receiver: evmDeployer.Bytes(), // internally left padded to 32byte - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, FeeToken: feeTokenOutput.Objects.MintedLinkTokenObjectId, SuiTokens: []testhelpers.SuiTokenAmount{ { @@ -720,7 +720,7 @@ func Test_CCIPTokenTransfer_Sui2EVM_BurnMintTokenPool_WithAllowlist_AfterSignerA SourceChain: sourceChain, DestChain: destChain, Receiver: ccipReceiverAddress.Bytes(), // internally left padded to 32byte - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, SuiTokens: []testhelpers.SuiTokenAmount{ { TokenPoolType: sui_deployment.TokenPoolTypeBurnMint, @@ -955,7 +955,7 @@ func Test_CCIPTokenTransfer_Sui2EVM_ManagedTokenPool_ThenCurseUncurse(t *testing SourceChain: sourceChain, DestChain: destChain, Receiver: evmDeployer.Bytes(), // internally left padded to 32byte - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, FeeToken: feeTokenOutput.Objects.MintedLinkTokenObjectId, SuiTokens: []testhelpers.SuiTokenAmount{ { @@ -1049,7 +1049,7 @@ func Test_CCIPTokenTransfer_EVM2Sui_ManagedTokenPool_NoRateLimit(t *testing.T) { DestChain: destChain, Receiver: emptyReceiver, TokenReceiverATA: suiAddr[:], // tokenReceiver extracted from extraArgs (the address that actually gets the token) - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, Tokens: []router.ClientEVMTokenAmount{ { Token: evmToken.Address(), @@ -1298,7 +1298,7 @@ func Test_CCIPTokenTransfer_EVM2Sui_BurnMintTokenPool(t *testing.T) { DestChain: destChain, Receiver: receiverByte, // receiver contract pkgId TokenReceiverATA: suiAddr[:], // tokenReceiver extracted from extraArgs (the address that actually gets the token) - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, Tokens: []router.ClientEVMTokenAmount{ { Token: evmToken.Address(), @@ -1520,7 +1520,7 @@ func Test_CCIP_EVM2Sui_DestTokenAmount_ReportsLocalAmount(t *testing.T) { Data: []byte("Hello Sui from EVM"), Receiver: receiverByte, // receiver contract pkgId -> ccip_receive runs TokenReceiverATA: suiAddr[:], // wallet that actually receives the minted token - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, Tokens: []router.ClientEVMTokenAmount{ { Token: evmToken.Address(), @@ -1677,7 +1677,7 @@ func Test_CCIP_ReceiverNotRegistered_EVM2Sui(t *testing.T) { DestChain: destChain, Data: []byte("msg to unregistered receiver"), Receiver: unregisteredReceiverByte, - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, ExtraArgs: testhelpers.MakeSuiExtraArgs(1000000, true, emptyReceiverObjectIDs, [32]byte{}), }, { @@ -1687,7 +1687,7 @@ func Test_CCIP_ReceiverNotRegistered_EVM2Sui(t *testing.T) { Data: []byte("token+msg to unregistered receiver"), Receiver: unregisteredReceiverByte, TokenReceiverATA: suiAddr[:], // wallet receives the minted token - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, Tokens: []router.ClientEVMTokenAmount{ {Token: evmToken.Address(), Amount: big.NewInt(1e18)}, }, @@ -1702,7 +1702,7 @@ func Test_CCIP_ReceiverNotRegistered_EVM2Sui(t *testing.T) { DestChain: destChain, Data: []byte("msg to nonexistent receiver"), Receiver: nonexistentReceiver[:], - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, ExtraArgs: testhelpers.MakeSuiExtraArgs(1000000, true, emptyReceiverObjectIDs, [32]byte{}), }, } @@ -1795,7 +1795,7 @@ func Test_CCIPPureTokenTransfer_EVM2Sui_BurnMintTokenPool(t *testing.T) { Data: []byte{}, Receiver: emptyReceiver, // empty Receiver TokenReceiverATA: suiAddr[:], // tokenReceiver extracted from extraArgs (the address that actually gets the token) - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, Tokens: []router.ClientEVMTokenAmount{ { Token: evmToken.Address(), @@ -1930,7 +1930,7 @@ func Test_CCIPProgrammableTokenTransfer_EVM2Sui_BurnMintTokenPool(t *testing.T) Data: []byte("Hello Sui From EVM"), Receiver: receiverByte, // receiver contract pkgId TokenReceiverATA: stateObj[:], // tokenReceiver extracted from extraArgs (the object that actually gets the token) - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, Tokens: []router.ClientEVMTokenAmount{ { Token: evmToken.Address(), @@ -2054,7 +2054,7 @@ func Test_CCIPZeroGasLimitTokenTransfer_EVM2Sui_BurnMintTokenPool(t *testing.T) Data: []byte("Hello Sui From EVM"), Receiver: receiverByte, // non empty Receiver TokenReceiverATA: suiAddr[:], // tokenReceiver extracted from extraArgs (the address that actually gets the token) - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, Tokens: []router.ClientEVMTokenAmount{ { Token: evmToken.Address(), @@ -2130,7 +2130,7 @@ func testSetupTokenTransferSui2Evm(t *testing.T) (e testhelpers.DeployedEnv, sou // EVM->Sui token transfer the production execute PTB builder appends that coin // to the pool callback under the transmitter's signature; the guard rejects the // transmitter-owned entry during PTB build, so the execute PTB is never -// submitted, EXECUTION_STATE_SUCCESS is never persisted, and the transmitter's +// submitted, ExecutionStateSuccess is never persisted, and the transmitter's // coin is not drained. Mirrors Test_CCIP_Messaging_EVM2Sui_TransmitterOwnedTail_Rejected. func Test_CCIP_TokenTransfer_EVM2Sui_PoolReleaseOrMintTransmitterOwned_Rejected(t *testing.T) { e, sourceChain, destChain, deployerSourceChain, _, suiAddr := testSetupHelperEvm2Sui(t) @@ -2219,7 +2219,7 @@ func Test_CCIP_TokenTransfer_EVM2Sui_PoolReleaseOrMintTransmitterOwned_Rejected( // assertion is the explicit GetExecutionState DevInspect below (require.Error). // UNTOUCHED is the honest expected state; TransferMultiple's expected-states // map is discarded here, so this field is documentary only. - ExpectedStatus: testhelpers.EXECUTION_STATE_UNTOUCHED, + ExpectedStatus: testhelpers.ExecutionStateUntouched, Tokens: []router.ClientEVMTokenAmount{ { Token: evmToken.Address(), @@ -2246,7 +2246,7 @@ func Test_CCIP_TokenTransfer_EVM2Sui_PoolReleaseOrMintTransmitterOwned_Rejected( // Let the DON replay + settle so the source event is OCR-committed and the // dest exec is attempted. The guard rejects the transmitter-owned // release_or_mint_params entry during PTB build, so no execute transaction is - // submitted and EXECUTION_STATE_SUCCESS never commits. + // submitted and ExecutionStateSuccess never commits. replayEvm2SuiTransferLane(t, e, sourceChain, destChain) // Confirm the report was committed, so the exec rejection below is meaningful. @@ -2296,7 +2296,7 @@ func Test_CCIP_TokenTransfer_EVM2Sui_PoolReleaseOrMintTransmitterOwned_Rejected( DestChain: destChain, Receiver: receiverByte, TokenReceiverATA: []byte{}, - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, Tokens: []router.ClientEVMTokenAmount{}, // arbitrary data, no token-pool command Data: []byte("lane not stuck"), // Message-only: token receiver must be zero. The Sui offramp asserts diff --git a/integration-tests/smoke/ccip/ccip_sui_upgrade_test.go b/integration-tests/smoke/ccip/ccip_sui_upgrade_test.go index dab23e8b97f..b951c36169e 100644 --- a/integration-tests/smoke/ccip/ccip_sui_upgrade_test.go +++ b/integration-tests/smoke/ccip/ccip_sui_upgrade_test.go @@ -120,7 +120,7 @@ func Test_CCIP_Upgrade_Sui2EVM(t *testing.T) { ExtraArgs: nil, Replayed: true, FeeToken: outputMap.Objects.MintedLinkTokenObjectId, - ExpectedExecutionState: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedExecutionState: testhelpers.ExecutionStateSuccess, }, ) }) @@ -268,7 +268,7 @@ func Test_CCIP_Upgrade_EVM2Sui(t *testing.T) { Receiver: receiverByte, MsgData: message, ExtraArgs: testhelpers.MakeSuiExtraArgs(1000000, true, receiverObjectIDs, [32]byte{}), - ExpectedExecutionState: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedExecutionState: testhelpers.ExecutionStateSuccess, }, ) }) @@ -384,7 +384,7 @@ func Test_CCIP_Upgrade_NoBlock_EVM2Sui(t *testing.T) { Receiver: receiverByte, MsgData: message, ExtraArgs: testhelpers.MakeSuiExtraArgs(1000000, true, receiverObjectIDs, [32]byte{}), - ExpectedExecutionState: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedExecutionState: testhelpers.ExecutionStateSuccess, }, ) }) @@ -527,7 +527,7 @@ func Test_CCIP_Upgrade_CommonPkg_EVM2Sui(t *testing.T) { Receiver: receiverByte, MsgData: message, ExtraArgs: testhelpers.MakeSuiExtraArgs(1000000, true, receiverObjectIDs, [32]byte{}), - ExpectedExecutionState: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedExecutionState: testhelpers.ExecutionStateSuccess, }, ) }) diff --git a/integration-tests/smoke/ccip/ccip_token_transfer_test.go b/integration-tests/smoke/ccip/ccip_token_transfer_test.go index f5ab48fe13b..4b8eab54138 100644 --- a/integration-tests/smoke/ccip/ccip_token_transfer_test.go +++ b/integration-tests/smoke/ccip/ccip_token_transfer_test.go @@ -117,7 +117,7 @@ func TestTokenTransfer_EVM2EVM(t *testing.T) { ExpectedTokenBalances: []testhelpers.ExpectedBalance{ {Token: destToken.Address().Bytes(), Amount: oneE18}, }, - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, }, { Name: "Send token to contract", @@ -133,7 +133,7 @@ func TestTokenTransfer_EVM2EVM(t *testing.T) { ExpectedTokenBalances: []testhelpers.ExpectedBalance{ {Token: destToken.Address().Bytes(), Amount: oneE18}, }, - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, }, { Name: "Send N tokens to contract", @@ -159,7 +159,7 @@ func TestTokenTransfer_EVM2EVM(t *testing.T) { {Token: selfServeSrcToken.Address().Bytes(), Amount: new(big.Int).Add(oneE18, oneE18)}, {Token: srcToken.Address().Bytes(), Amount: oneE18}, }, - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, }, { Name: "Sending token transfer with custom gasLimits to the EOA is successful", @@ -181,7 +181,7 @@ func TestTokenTransfer_EVM2EVM(t *testing.T) { {Token: selfServeSrcToken.Address().Bytes(), Amount: oneE18}, {Token: srcToken.Address().Bytes(), Amount: new(big.Int).Add(oneE18, oneE18)}, }, - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, }, { Name: "Sending PTT with too low gas limit leads to the revert when receiver is a contract", @@ -204,15 +204,14 @@ func TestTokenTransfer_EVM2EVM(t *testing.T) { {Token: selfServeSrcToken.Address().Bytes(), Amount: big.NewInt(0)}, {Token: srcToken.Address().Bytes(), Amount: big.NewInt(0)}, }, - ExpectedStatus: testhelpers.EXECUTION_STATE_FAILURE, + ExpectedStatus: testhelpers.ExecutionStateFailure, }, } // Wait for filter registration for CCIPMessageSent (onramp), CommitReportAccepted (offramp), and ExecutionStateChanged (offramp) testhelpers.WaitForEventFilterRegistrationOnLane(t, state, e.Offchain, sourceChain, destChain) - startBlocks, expectedSeqNums, expectedExecutionStates, expectedTokenBalances := - testhelpers.TransferMultiple(ctx, t, e, state, tcs) + startBlocks, expectedSeqNums, expectedExecutionStates, expectedTokenBalances := testhelpers.TransferMultiple(ctx, t, e, state, tcs) err = testhelpers.ConfirmMultipleCommits( t, @@ -318,15 +317,14 @@ func TestTokenTransfer_EVM2Solana(t *testing.T) { {Token: destToken.Bytes(), Amount: new(big.Int).Mul(big.NewInt(20), oneE9)}, }, ExtraArgs: extraArgs, - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, }, } // Wait for filter registration for CCIPMessageSent (onramp), CommitReportAccepted (offramp), and ExecutionStateChanged (offramp) testhelpers.WaitForEventFilterRegistrationOnLane(t, state, e.Offchain, sourceChain, destChain) - startBlocks, expectedSeqNums, expectedExecutionStates, expectedTokenBalances := - testhelpers.TransferMultiple(ctx, t, e, state, tcs) + startBlocks, expectedSeqNums, expectedExecutionStates, expectedTokenBalances := testhelpers.TransferMultiple(ctx, t, e, state, tcs) err = testhelpers.ConfirmMultipleCommits( t, @@ -469,7 +467,7 @@ func TestTokenTransfer_Solana2EVM(t *testing.T) { {Token: common.LeftPadBytes(destToken.Address().Bytes(), 32), Amount: new(big.Int).SetUint64(oneE9)}, }, ExtraArgs: extraArgs, - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, }, // { // Name: "Send N tokens to contract", @@ -495,15 +493,14 @@ func TestTokenTransfer_Solana2EVM(t *testing.T) { // {selfServeSrcToken.Address().Bytes(), new(big.Int).Add(oneE18, oneE18)}, // {srcToken.Address().Bytes(), oneE18}, // }, - // ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + // ExpectedStatus: testhelpers.ExecutionStateSuccess, // }, } // Wait for filter registration for CCIPMessageSent (onramp), CommitReportAccepted (offramp), and ExecutionStateChanged (offramp) testhelpers.WaitForEventFilterRegistrationOnLane(t, state, e.Offchain, sourceChain, destChain) - startBlocks, expectedSeqNums, expectedExecutionStates, expectedTokenBalances := - testhelpers.TransferMultiple(ctx, t, e, state, tcs) + startBlocks, expectedSeqNums, expectedExecutionStates, expectedTokenBalances := testhelpers.TransferMultiple(ctx, t, e, state, tcs) err = testhelpers.ConfirmMultipleCommits( t, diff --git a/integration-tests/smoke/ccip/ccip_topologies_test.go b/integration-tests/smoke/ccip/ccip_topologies_test.go index 266c6b2a2e6..c94200bbced 100644 --- a/integration-tests/smoke/ccip/ccip_topologies_test.go +++ b/integration-tests/smoke/ccip/ccip_topologies_test.go @@ -70,7 +70,8 @@ func runCCIPTopologiesTest(t *testing.T, fChainSource, fChainDest int) { ) // connect a single lane, source to dest testhelpers.AddLaneWithDefaultPricesAndFeeQuoterConfig( - t, &e, state, sourceChainSel, destChainSel, false) + t, &e, state, sourceChainSel, destChainSel, false, + ) var ( nonce uint64 @@ -98,8 +99,8 @@ func runCCIPTopologiesTest(t *testing.T, fChainSource, fChainDest int) { Nonce: &nonce, Receiver: common.HexToAddress("0xdead").Bytes(), MsgData: []byte("hello eoa"), - ExtraArgs: nil, // default extraArgs - ExpectedExecutionState: testhelpers.EXECUTION_STATE_SUCCESS, // success because offRamp won't call an EOA + ExtraArgs: nil, // default extraArgs + ExpectedExecutionState: testhelpers.ExecutionStateSuccess, // success because offRamp won't call an EOA ExtraAssertions: []func(t *testing.T){ func(t *testing.T) { }, diff --git a/integration-tests/smoke/ccip/ccip_usdc_test.go b/integration-tests/smoke/ccip/ccip_usdc_test.go index eb1e48778e1..f477a0ebb99 100644 --- a/integration-tests/smoke/ccip/ccip_usdc_test.go +++ b/integration-tests/smoke/ccip/ccip_usdc_test.go @@ -119,11 +119,12 @@ func TestUSDCTokenTransfer(t *testing.T) { { Token: cChainUSDC.Address(), Amount: tinyOneCoin, - }}, + }, + }, ExpectedTokenBalances: []testhelpers.ExpectedBalance{ {Token: aChainUSDC.Address().Bytes(), Amount: tinyOneCoin}, }, - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, }, { Name: "multiple USDC tokens within the same message", @@ -144,7 +145,7 @@ func TestUSDCTokenTransfer(t *testing.T) { // 2 coins because of the same Receiver {Token: aChainUSDC.Address().Bytes(), Amount: new(big.Int).Add(tinyOneCoin, tinyOneCoin)}, }, - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, }, { Name: "USDC token together with another token transferred to EOA", @@ -165,7 +166,7 @@ func TestUSDCTokenTransfer(t *testing.T) { {Token: cChainUSDC.Address().Bytes(), Amount: tinyOneCoin}, {Token: cChainToken.Address().Bytes(), Amount: new(big.Int).Mul(tinyOneCoin, big.NewInt(10))}, }, - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, }, { Name: "USDC programmable token transfer to valid contract receiver", @@ -182,7 +183,7 @@ func TestUSDCTokenTransfer(t *testing.T) { ExpectedTokenBalances: []testhelpers.ExpectedBalance{ {Token: cChainUSDC.Address().Bytes(), Amount: tinyOneCoin}, }, - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, }, { Name: "USDC programmable token transfer with too little gas", @@ -200,7 +201,7 @@ func TestUSDCTokenTransfer(t *testing.T) { {Token: bChainUSDC.Address().Bytes(), Amount: new(big.Int).SetUint64(0)}, }, ExtraArgs: testhelpers.MakeEVMExtraArgsV2(1, false), - ExpectedStatus: testhelpers.EXECUTION_STATE_FAILURE, + ExpectedStatus: testhelpers.ExecutionStateFailure, }, { Name: "USDC token transfer from a different source chain", @@ -217,12 +218,11 @@ func TestUSDCTokenTransfer(t *testing.T) { ExpectedTokenBalances: []testhelpers.ExpectedBalance{ {Token: cChainUSDC.Address().Bytes(), Amount: tinyOneCoin}, }, - ExpectedStatus: testhelpers.EXECUTION_STATE_SUCCESS, + ExpectedStatus: testhelpers.ExecutionStateSuccess, }, } - startBlocks, expectedSeqNums, expectedExecutionStates, expectedTokenBalances := - testhelpers.TransferMultiple(ctx, t, e, state, tcs) + startBlocks, expectedSeqNums, expectedExecutionStates, expectedTokenBalances := testhelpers.TransferMultiple(ctx, t, e, state, tcs) err = testhelpers.ConfirmMultipleCommits( t, diff --git a/system-tests/lib/cre/contracts/keystone.go b/system-tests/lib/cre/contracts/keystone.go index 63ca98df8ac..75efc5987f2 100644 --- a/system-tests/lib/cre/contracts/keystone.go +++ b/system-tests/lib/cre/contracts/keystone.go @@ -423,7 +423,7 @@ func toDons(input cre.ConfigureCapabilityRegistryInput) (*dons, error) { Name: fmt.Sprintf("NOP for %s DON", donMetadata.Name), Nodes: donPeerIDs, } - donName := donMetadata.Name + "-don" + donName := donMetadata.Name c := keystone_changeset.DonCapabilities{ Name: donName, F: libc.MustSafeUint8(forwarderF), @@ -542,14 +542,13 @@ func (r *capabilityRegistry) GetDONByName(opts *bind.CallOpts, donName string) ( }, nil } -// ResolveContractDonIDs retrieves contract donIDs using GetDONByName(don.Name + "-don"). +// ResolveContractDonIDs retrieves contract donIDs using GetDONByName(don.Name). func ResolveContractDonIDs(capReg CapabilityRegistry, donNames []string) (map[string]uint32, error) { result := make(map[string]uint32) for _, name := range donNames { - donName := name + "-don" - info, err := capReg.GetDONByName(nil, donName) + info, err := capReg.GetDONByName(nil, name) if err != nil { - return nil, errors.Wrapf(err, "failed to get DON by name %s", donName) + return nil, errors.Wrapf(err, "failed to get DON by name %s", name) } result[name] = info.ID } diff --git a/system-tests/lib/cre/topology_don_family.go b/system-tests/lib/cre/topology_don_family.go index 97a1e5b42e3..2c8dc071181 100644 --- a/system-tests/lib/cre/topology_don_family.go +++ b/system-tests/lib/cre/topology_don_family.go @@ -75,6 +75,10 @@ func (t *Topology) ensureGatewayConnectorIndex() { } // buildDonFamilyPairingState validates and materializes the pairing graph. +// +// A workflow DON is paired with a gateway DON if they share ANY don_family, not +// just their primary (first) one. Both maps are keyed by every family a DON +// belongs to, so a DON with N families can be discovered/paired via any of them. func (t *Topology) buildDonFamilyPairingState() (*gatewayDonFamilyPairingState, error) { wfDONs, err := t.DonsMetadata.WorkflowDONs() if err != nil { @@ -90,26 +94,36 @@ func (t *Topology) buildDonFamilyPairingState() (*gatewayDonFamilyPairingState, if _, hasGateway := d.Gateway(); !hasGateway { continue } - if d.DonFamily() == "" { + if len(d.DonFamilies) == 0 { return nil, fmt.Errorf("gateway DON %q has no don_family; set nodesets.don_families on every nodeset", d.Name) } - state.gatewayDONNamesByFamily[d.DonFamily()] = append(state.gatewayDONNamesByFamily[d.DonFamily()], d.Name) + for _, family := range d.DonFamilies { + state.gatewayDONNamesByFamily[family] = append(state.gatewayDONNamesByFamily[family], d.Name) + } } for _, wf := range wfDONs { - if wf.DonFamily() == "" { + if len(wf.DonFamilies) == 0 { return nil, fmt.Errorf("workflow DON %q has no don_family; set nodesets.don_families on every nodeset", wf.Name) } - if len(state.gatewayDONNamesByFamily[wf.DonFamily()]) == 0 { - return nil, fmt.Errorf("workflow DON %q is in don_family %q but no gateway DON is defined for that family", wf.Name, wf.DonFamily()) + + pairedGateways := make(map[string]struct{}) + for _, family := range wf.DonFamilies { + state.workflowDONNamesByFamily[family] = append(state.workflowDONNamesByFamily[family], wf.Name) + for _, gwName := range state.gatewayDONNamesByFamily[family] { + if _, ok := pairedGateways[gwName]; ok { + continue + } + pairedGateways[gwName] = struct{}{} + state.pairs = append(state.pairs, DonFamilyGatewayPair{ + DonFamily: family, + WorkflowDONName: wf.Name, + GatewayDONName: gwName, + }) + } } - state.workflowDONNamesByFamily[wf.DonFamily()] = append(state.workflowDONNamesByFamily[wf.DonFamily()], wf.Name) - for _, gwName := range state.gatewayDONNamesByFamily[wf.DonFamily()] { - state.pairs = append(state.pairs, DonFamilyGatewayPair{ - DonFamily: wf.DonFamily(), - WorkflowDONName: wf.Name, - GatewayDONName: gwName, - }) + if len(pairedGateways) == 0 { + return nil, fmt.Errorf("workflow DON %q is in don_families %v but no gateway DON shares any of them", wf.Name, wf.DonFamilies) } } @@ -175,14 +189,49 @@ func (t *Topology) GatewayConnectorsForDonFamily(donFamily string) GatewayConnec return GatewayConnectors{Configurations: configs} } -// GatewayServiceConfigsForGateway scopes gateway worker service configs to DONs in the -// gateway nodeset's don_family (workflow and capabilities DONs, e.g. vault handler routing). +// GatewayServiceConfigsForGateway scopes gateway worker service configs to DONs reachable +// from the gateway (workflow and capabilities DONs, e.g. vault handler routing). +// +// "Reachable" is the gateway nodeset's own don_families plus every don_family of any +// workflow DON already paired with it — not just the gateway's own families — so a +// capabilities DON that only shares a shard-specific family with the paired workflow DONs +// (not the gateway's own family) is still scoped in. This mirrors buildDonFamilyPairingState, +// which pairs gateways and workflow DONs by ANY shared family, not just the primary one. See +// the family layout in workflow-sharded-capabilities-don.toml for a worked example: a shared +// vault DON belongs only to per-shard families, while the gateway belongs to the common one. func (t *Topology) GatewayServiceConfigsForGateway(gatewayDONName string, services []GatewayServiceConfig) []GatewayServiceConfig { - return t.gatewayServiceConfigsForDonFamily(t.DonFamilyForDON(gatewayDONName), services) + return t.gatewayServiceConfigsForFamilies(t.reachableFamiliesForGateway(gatewayDONName), services) +} + +// reachableFamiliesForGateway returns gatewayDONName's own don_families union the +// don_families of every workflow DON paired with it. +func (t *Topology) reachableFamiliesForGateway(gatewayDONName string) map[string]struct{} { + families := make(map[string]struct{}) + if d := t.donByName(gatewayDONName); d != nil { + for _, family := range d.DonFamilies { + families[family] = struct{}{} + } + } + if t.gatewayDonFamilyPairing == nil { + return families + } + for _, pair := range t.gatewayDonFamilyPairing.pairs { + if pair.GatewayDONName != gatewayDONName { + continue + } + wf := t.donByName(pair.WorkflowDONName) + if wf == nil { + continue + } + for _, family := range wf.DonFamilies { + families[family] = struct{}{} + } + } + return families } -func (t *Topology) gatewayServiceConfigsForDonFamily(donFamily string, services []GatewayServiceConfig) []GatewayServiceConfig { - if t.gatewayDonFamilyPairing == nil || donFamily == "" { +func (t *Topology) gatewayServiceConfigsForFamilies(families map[string]struct{}, services []GatewayServiceConfig) []GatewayServiceConfig { + if t.gatewayDonFamilyPairing == nil || len(families) == 0 { return services } @@ -191,7 +240,14 @@ func (t *Topology) gatewayServiceConfigsForDonFamily(donFamily string, services out[i] = svc filtered := make([]string, 0, len(svc.DONs)) for _, donName := range svc.DONs { - if t.DonFamilyForDON(donName) == donFamily { + d := t.donByName(donName) + if d == nil { + continue + } + if slices.ContainsFunc(d.DonFamilies, func(family string) bool { + _, ok := families[family] + return ok + }) { filtered = append(filtered, donName) } } diff --git a/system-tests/lib/cre/topology_don_family_gateway_pairing_test.go b/system-tests/lib/cre/topology_don_family_gateway_pairing_test.go index 031e73bac42..6bae0e7b008 100644 --- a/system-tests/lib/cre/topology_don_family_gateway_pairing_test.go +++ b/system-tests/lib/cre/topology_don_family_gateway_pairing_test.go @@ -49,7 +49,7 @@ func TestTopology_validateDonFamilyGatewayPairing_missingGateway(t *testing.T) { err := topology.initDonFamilyGatewayPairing() require.Error(t, err) - require.Contains(t, err.Error(), "no gateway DON is defined for that family") + require.Contains(t, err.Error(), "no gateway DON shares any of them") } func TestTopology_validateDonFamilyGatewayPairing_gatewayMissingDonFamily(t *testing.T) { @@ -167,6 +167,37 @@ func TestGatewayServiceConfigsForGateway_preservesCapabilitiesDONForVault(t *tes require.Equal(t, []string{"capabilities"}, scoped[0].DONs) } +// TestGatewayServiceConfigsForGateway_reachesCapabilitiesDonViaWorkflowFamily proves a +// capabilities DON that shares no family with the gateway directly, but shares a +// shard-specific family with a workflow DON already paired to that gateway, is still +// scoped in — matching workflow-sharded-capabilities-don.toml, where a shared vault DON +// belongs only to per-shard families ("zone-a_shard-0", "zone-a_shard-1") while the +// gateway belongs only to the common family ("zone-a"). +func TestGatewayServiceConfigsForGateway_reachesCapabilitiesDonViaWorkflowFamily(t *testing.T) { + t.Parallel() + + topology := &Topology{ + DonsMetadata: &DonsMetadata{ + dons: []*DonMetadata{ + {Name: "workflow-1-zone-a", DonFamilies: []string{"zone-a_shard-0", "zone-a"}, Flags: []string{WorkflowDON, HTTPActionCapability}}, + {Name: "workflow-1-zone-a-shard-1", DonFamilies: []string{"zone-a_shard-1", "zone-a"}, Flags: []string{WorkflowDON, HTTPActionCapability}}, + {Name: "chain-capabilities-zone-a", DonFamilies: []string{"zone-a_shard-0", "zone-a_shard-1"}, Flags: []string{CapabilitiesDON, VaultCapability}}, + {Name: "bootstrap-gateway", DonFamilies: []string{"zone-a"}, NodesMetadata: []*NodeMetadata{{Roles: []string{GatewayNode}}}}, + }, + }, + } + require.NoError(t, topology.initDonFamilyGatewayPairing()) + + services := []GatewayServiceConfig{{ + ServiceName: "vault", + Handlers: []string{"vault"}, + DONs: []string{"chain-capabilities-zone-a"}, + }} + + scoped := topology.GatewayServiceConfigsForGateway("bootstrap-gateway", services) + require.Equal(t, []string{"chain-capabilities-zone-a"}, scoped[0].DONs) +} + func TestWorkflowDONFamilies(t *testing.T) { t.Parallel() diff --git a/system-tests/tests/smoke/cre/failover_test.go b/system-tests/tests/smoke/cre/failover_test.go index 96e6edc867c..3c8bf270313 100644 --- a/system-tests/tests/smoke/cre/failover_test.go +++ b/system-tests/tests/smoke/cre/failover_test.go @@ -25,7 +25,7 @@ func ExecuteFailoverManualSwapTest(t *testing.T, testEnv *ttypes.TestEnvironment require.GreaterOrEqual(t, len(shardDONs), 2, "Expected at least 2 shard DONs for failover test") shardLeaderDON := getShardZeroDon(t, testEnv) - primaryDonID := uint32(shardLeaderDON.ID) //nolint:gosec // G115: overflow is unrealistic + primaryShardIndex := uint32(shardLeaderDON.Metadata().ShardIndex) //nolint:gosec // G115: overflow is unrealistic var secondaryDON *cre.Don for _, don := range shardDONs { @@ -35,7 +35,7 @@ func ExecuteFailoverManualSwapTest(t *testing.T, testEnv *ttypes.TestEnvironment } } require.NotNil(t, secondaryDON, "Expected to find a second shard DON") - secondaryDonID := uint32(secondaryDON.ID) //nolint:gosec // G115: overflow is unrealistic + secondaryShardIndex := uint32(secondaryDON.Metadata().ShardIndex) //nolint:gosec // G115: overflow is unrealistic workflowFileLocation := "../../../../core/scripts/cre/environment/examples/workflows/cron/main.go" workflowConfig := crontypes.WorkflowConfig{ @@ -55,7 +55,7 @@ hashed_default_assignment = false [per_org_assignment] org_test_failover = [%d,%d] -`, primaryDonID, secondaryDonID, primaryDonID, secondaryDonID) +`, primaryShardIndex, secondaryShardIndex, primaryShardIndex, secondaryShardIndex) proposeAndApproveShardAssignmentJob(t, testEnv, shardLeaderDON, primaryAssignmentTOML, testLogger) @@ -68,9 +68,12 @@ hashed_default_assignment = false } testLogger.Info().Strs("workflowIDs", workflowIDs).Msg("Deployed workflows for failover test") + // nodeP2PIDToShardIndex (built below) reports each node's real DON ID, so + // the "expected" side of the comparison must be DON IDs too, even though + // the shard-assignment TOML above is authored in shard-index terms. workflowToShardIndex := make(map[string]uint32, len(workflowIDs)) for _, wfID := range workflowIDs { - workflowToShardIndex[wfID] = primaryDonID + workflowToShardIndex[wfID] = uint32(shardLeaderDON.ID) //nolint:gosec // G115: overflow is unrealistic } nodeP2PIDToShardIndex := buildNodeP2PIDToShardIndex(t, testEnv) @@ -109,7 +112,7 @@ hashed_default_assignment = false workflowName := fmt.Sprintf("failover_swap%d", i) workflowID := t_helpers.CompileAndDeployWorkflow(t, testEnv, testLogger, workflowName, &workflowConfig, workflowFileLocation) workflowIDs[i] = workflowID - workflowToShardIndex[workflowID] = secondaryDonID + workflowToShardIndex[workflowID] = uint32(secondaryDON.ID) //nolint:gosec // G115: overflow is unrealistic } testLogger.Info().Strs("workflowIDs", workflowIDs).Msg("Deployed fresh workflows for swap phase") @@ -119,7 +122,7 @@ hashed_default_assignment = false [per_org_assignment] org_test_failover = [%d,%d] -`, secondaryDonID, primaryDonID, secondaryDonID, primaryDonID) +`, secondaryShardIndex, primaryShardIndex, secondaryShardIndex, primaryShardIndex) for _, don := range shardDONs { proposeAndApproveShardAssignmentJob(t, testEnv, don, secondaryAssignmentTOML, testLogger) @@ -130,7 +133,7 @@ hashed_default_assignment = false swappedWorkflowIDs := workflowIDs swappedWorkflowToShardIndex := make(map[string]uint32, len(swappedWorkflowIDs)) for _, wfID := range swappedWorkflowIDs { - swappedWorkflowToShardIndex[wfID] = secondaryDonID + swappedWorkflowToShardIndex[wfID] = uint32(secondaryDON.ID) //nolint:gosec // G115: overflow is unrealistic } swapTimeout := 5 * time.Minute diff --git a/system-tests/tests/smoke/cre/shard_assignment_test.go b/system-tests/tests/smoke/cre/shard_assignment_test.go index 0fada2bce14..a2561ae4703 100644 --- a/system-tests/tests/smoke/cre/shard_assignment_test.go +++ b/system-tests/tests/smoke/cre/shard_assignment_test.go @@ -51,7 +51,7 @@ func ExecuteManualShardAssignmentTest(t *testing.T, testEnv *ttypes.TestEnvironm linkingService.SetOwnerOrg(defaultOwner, "org_test_manual") shardLeaderDON := getShardZeroDon(t, testEnv) - shardZeroDonID := uint32(shardLeaderDON.ID) //nolint:gosec // G115: overflow is unrealistic + shardZeroIndex := uint32(shardLeaderDON.Metadata().ShardIndex) //nolint:gosec // G115: overflow is unrealistic var shardOneDON *cre.Don for _, don := range shardDONs { @@ -61,7 +61,7 @@ func ExecuteManualShardAssignmentTest(t *testing.T, testEnv *ttypes.TestEnvironm } } require.NotNil(t, shardOneDON, "Expected to find a second shard DON") - shardOneDonID := uint32(shardOneDON.ID) //nolint:gosec // G115: overflow is unrealistic + shardOneIndex := uint32(shardOneDON.Metadata().ShardIndex) //nolint:gosec // G115: overflow is unrealistic shardAssignmentTOML := fmt.Sprintf(` static_default_assignment = [%d] @@ -69,7 +69,7 @@ hashed_default_assignment = false [per_org_assignment] org_test_manual = [%d] -`, shardOneDonID, shardZeroDonID) +`, shardOneIndex, shardZeroIndex) proposeAndApproveShardAssignmentJob(t, testEnv, shardLeaderDON, shardAssignmentTOML, testLogger) @@ -82,9 +82,12 @@ hashed_default_assignment = false } testLogger.Info().Strs("workflowIDs", workflowIDs).Msg("Deployed workflows for manual shard assignment test") + // nodeP2PIDToShardIndex (built below) reports each node's real DON ID, so + // the "expected" side of the comparison must be DON IDs too, even though + // the shard-assignment TOML above is authored in shard-index terms. workflowToShardIndex := make(map[string]uint32, len(workflowIDs)) for _, wfID := range workflowIDs { - workflowToShardIndex[wfID] = shardZeroDonID + workflowToShardIndex[wfID] = uint32(shardLeaderDON.ID) //nolint:gosec // G115: overflow is unrealistic } nodeP2PIDToShardIndex := buildNodeP2PIDToShardIndex(t, testEnv) @@ -129,7 +132,8 @@ func ExecuteManualShardAssignmentBothSpecs(t *testing.T, testEnv *ttypes.TestEnv linkingService.SetOwnerOrg(defaultOwner, "test_org_manual") shardLeaderDON := getShardZeroDon(t, testEnv) - shardZeroDonID := uint32(shardLeaderDON.ID) //nolint:gosec // G115: overflow is unrealistic + shardZeroDonID := uint32(shardLeaderDON.ID) //nolint:gosec // G115: overflow is unrealistic + shardZeroIndex := uint32(shardLeaderDON.Metadata().ShardIndex) //nolint:gosec // G115: overflow is unrealistic var shardOneDON *cre.Don for _, don := range shardDONs { @@ -139,17 +143,18 @@ func ExecuteManualShardAssignmentBothSpecs(t *testing.T, testEnv *ttypes.TestEnv } } require.NotNil(t, shardOneDON, "Expected to find a second shard DON") - shardOneDonID := uint32(shardOneDON.ID) //nolint:gosec // G115: overflow is unrealistic + shardOneIndex := uint32(shardOneDON.Metadata().ShardIndex) //nolint:gosec // G115: overflow is unrealistic // The static default points at shard zero, so the workflow only lands on shard one if the - // per-org entry is what routed it. + // per-org entry is what routed it. Values here are shard indices (0, 1, ...), not DON IDs: + // manualShardResolver translates the configured index to a real DON ID via ShardIndexMapper. shardAssignmentTOML := fmt.Sprintf(` static_default_assignment = [%d] hashed_default_assignment = false [per_org_assignment] non_existing_org= [%d] -`, shardZeroDonID, shardOneDonID) +`, shardZeroIndex, shardOneIndex) // Every shard resolves ownership from its own copy of the spec, so both the shard that must // run the workflow and the shard that must not need it. @@ -218,7 +223,7 @@ func ExecuteManualShardAssignmentWithEVMLogTriggerTest(t *testing.T, testEnv *tt require.GreaterOrEqual(t, len(shardDONs), 2, "Expected at least 2 shard DONs for manual assignment log trigger test") shardLeaderDON := getShardZeroDon(t, testEnv) - shardLeaderDonID := uint32(shardLeaderDON.ID) //nolint:gosec // G115: overflow is unrealistic + shardLeaderIndex := uint32(shardLeaderDON.Metadata().ShardIndex) //nolint:gosec // G115: overflow is unrealistic // Pin to a non-leader shard on purpose. The leader is where the static default below sends // anything the per-owner entry does not match, so an assignment that silently did not take @@ -228,7 +233,7 @@ func ExecuteManualShardAssignmentWithEVMLogTriggerTest(t *testing.T, testEnv *tt }) require.NotEmpty(t, nonLeaderDONs, "Expected to find a non-leader shard DON") targetDON := nonLeaderDONs[0] - targetDonID := uint32(targetDON.ID) //nolint:gosec // G115: overflow is unrealistic + targetShardIndex := uint32(targetDON.Metadata().ShardIndex) //nolint:gosec // G115: overflow is unrealistic // Both capability shards host the same EVM chain and the workflow shards host none, so the // only thing that can decide who serves the log trigger is the DON family the workflow shard @@ -243,9 +248,9 @@ func ExecuteManualShardAssignmentWithEVMLogTriggerTest(t *testing.T, testEnv *tt testLogger.Info(). Str("shardLeaderDON", shardLeaderDON.Name). - Uint32("shardLeaderDonID", shardLeaderDonID). + Uint32("shardLeaderShardIndex", shardLeaderIndex). Str("targetDON", targetDON.Name). - Uint32("targetDonID", targetDonID). + Uint32("targetShardIndex", targetShardIndex). Str("logTriggerChainID", logTriggerChainID). Str("workflowOwner", workflowOwnerAddress). Str("servingCapDON", servingCapDON.Name). @@ -267,7 +272,7 @@ hashed_default_assignment = false [per_owner_assignment] %q = [%d] -`, shardLeaderDonID, workflowOwnerAddress, targetDonID) +`, shardLeaderIndex, workflowOwnerAddress, targetShardIndex) // Every shard resolves ownership from its own copy of the spec, so both the shard that must // run the workflow and the shard that must not need it. @@ -280,7 +285,9 @@ hashed_default_assignment = false // would re-evaluate the same per_owner_assignment branch at the cost of another WASM compile. workflowID := t_helpers.CompileAndDeployWorkflow(t, testEnv, testLogger, "manualshard-evmlogtrigger", &workflowConfig, "./evm/logtrigger/main.go") workflowIDs := []string{workflowID} - workflowToShardIndex := map[string]uint32{workflowID: targetDonID} + // nodeP2PIDToShardIndex reports each node's real DON ID, so the "expected" + // side must be a DON ID too, even though the TOML above is shard-index terms. + workflowToShardIndex := map[string]uint32{workflowID: uint32(targetDON.ID)} //nolint:gosec // G115: overflow is unrealistic testLogger.Info().Str("workflowID", workflowID).Msg("Deployed workflow for manual shard assignment log trigger test") nodeP2PIDToShardIndex := buildNodeP2PIDToShardIndex(t, testEnv) @@ -430,8 +437,8 @@ func ExecuteRingOCROverridesTest(t *testing.T, testEnv *ttypes.TestEnvironment) } } require.NotNil(t, shardOne, "Expected to find a second shard DON") - shardZeroDonID := uint32(shardZero.ID) //nolint:gosec // G115: overflow is unrealistic - shardOneDonID := uint32(shardOne.ID) //nolint:gosec // G115: overflow is unrealistic + shardZeroIndex := uint32(shardZero.Metadata().ShardIndex) //nolint:gosec // G115: overflow is unrealistic + shardOneIndex := uint32(shardOne.Metadata().ShardIndex) //nolint:gosec // G115: overflow is unrealistic topology, tErr := cre.NewTopology(testEnv.Config.NodeSets, *testEnv.Config.Infra, testEnv.Config.CapabilityConfigs) require.NoError(t, tErr, "Failed to recreate topology") @@ -471,7 +478,7 @@ hashed_default_assignment = true [per_org_assignment] org_test_override = [%d] -`, shardZeroDonID, shardOneDonID) +`, shardZeroIndex, shardOneIndex) for _, don := range shardDONs { proposeAndApproveShardAssignmentJob(t, testEnv, don, shardAssignmentTOML, testLogger) @@ -488,7 +495,7 @@ hashed_default_assignment = true var rpcHost string for _, nodeSet := range testEnv.Config.NodeSets { - if nodeSet.Name == "shard0" && nodeSet.Out != nil && len(nodeSet.Out.CLNodes) > 0 { + if nodeSet.Name == "workflow-1-zone-a" && nodeSet.Out != nil && len(nodeSet.Out.CLNodes) > 0 { externalURL := nodeSet.Out.CLNodes[0].Node.ExternalURL parsedURL, parseErr := url.Parse(externalURL) require.NoError(t, parseErr, "Failed to parse ExternalURL") @@ -521,7 +528,9 @@ hashed_default_assignment = true testLogger.Info().Interface("mappings", resp.Mappings).Msg("Ring OCR workflow mappings") require.Len(t, resp.Mappings, len(workflowIDs), "All deployed workflows should be mapped") - overrideShard := shardOneDonID + // nodeP2PIDToShardIndex reports each node's real DON ID, so the "expected" + // side must be a DON ID too, even though the TOML above is shard-index terms. + overrideShard := uint32(shardOne.ID) //nolint:gosec // G115: overflow is unrealistic workflowToShardIndex := make(map[string]uint32, len(workflowIDs)) for _, wfID := range workflowIDs { diff --git a/system-tests/tests/smoke/cre/sharding_test.go b/system-tests/tests/smoke/cre/sharding_test.go index b00be223f00..e197d50e10d 100644 --- a/system-tests/tests/smoke/cre/sharding_test.go +++ b/system-tests/tests/smoke/cre/sharding_test.go @@ -222,7 +222,7 @@ func ExecuteShardingTemplate[T t_helpers.WorkflowConfig](t *testing.T, testEnv * var rpcHost string for _, nodeSet := range testEnv.Config.NodeSets { - if nodeSet.Name == "shard0" && nodeSet.Out != nil && len(nodeSet.Out.CLNodes) > 0 { + if nodeSet.Name == "workflow-1-zone-a" && nodeSet.Out != nil && len(nodeSet.Out.CLNodes) > 0 { externalURL := nodeSet.Out.CLNodes[0].Node.ExternalURL parsedURL, parseErr := url.Parse(externalURL) require.NoError(t, parseErr, "Failed to parse ExternalURL")