Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion system-tests/tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ require (
github.com/smartcontractkit/chainlink-common/keystore v1.0.2
github.com/smartcontractkit/chainlink-data-streams v0.1.13
github.com/smartcontractkit/chainlink-deployments-framework v0.86.3
github.com/smartcontractkit/chainlink-evm/contracts/cre/gobindings v0.0.0-20260107191744-4b93f62cffe3
github.com/smartcontractkit/chainlink-evm/gethwrappers v0.0.0-20260119171452-39c98c3b33cd
github.com/smartcontractkit/chainlink-protos/cre/go v0.0.0-20260226130359-963f935e0396
github.com/smartcontractkit/chainlink-protos/job-distributor v0.18.0
Expand Down Expand Up @@ -130,7 +131,6 @@ require (
github.com/smartcontractkit/chainlink-ccip/chains/solana/gobindings v0.0.0-20260310183131-8d0f0e383288 // indirect
github.com/smartcontractkit/chainlink-ccip/deployment v0.0.0-20260317185256-d5f7db87ae70 // indirect
github.com/smartcontractkit/chainlink-ccv v0.0.0-20260320145055-eb20b529ff95 // indirect
github.com/smartcontractkit/chainlink-evm/contracts/cre/gobindings v0.0.0-20260107191744-4b93f62cffe3 // indirect
github.com/smartcontractkit/chainlink-protos/chainlink-ccv/committee-verifier v0.0.0-20251211142334-5c3421fe2c8d // indirect
github.com/smartcontractkit/chainlink-protos/chainlink-ccv/heartbeat v0.0.0-20260115142640-f6b99095c12e // indirect
github.com/smartcontractkit/chainlink-protos/chainlink-ccv/message-discovery v0.0.0-20251211142334-5c3421fe2c8d // indirect
Expand Down
45 changes: 36 additions & 9 deletions system-tests/tests/smoke/cre/v2_sharding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,24 @@ import (
"time"

"github.com/Masterminds/semver/v3"
"github.com/ethereum/go-ethereum/common"
"github.com/rs/zerolog"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"

"github.com/smartcontractkit/chainlink-testing-framework/framework"

"github.com/smartcontractkit/chainlink-deployments-framework/datastore"
shard_config "github.com/smartcontractkit/chainlink-evm/contracts/cre/gobindings/shardconfig/generated/v1_0_0/shard_config"
ringpb "github.com/smartcontractkit/chainlink-protos/ring/go"
commonevents "github.com/smartcontractkit/chainlink-protos/workflows/go/common"
workflowevents "github.com/smartcontractkit/chainlink-protos/workflows/go/events"
"github.com/smartcontractkit/chainlink-testing-framework/framework"

"github.com/smartcontractkit/chainlink-deployments-framework/datastore"
crontypes "github.com/smartcontractkit/chainlink/core/scripts/cre/environment/examples/workflows/v2/cron/types"
commonchangeset "github.com/smartcontractkit/chainlink/deployment/common/changeset"
deployment_contracts "github.com/smartcontractkit/chainlink/deployment/cre/contracts"
shard_config_changeset "github.com/smartcontractkit/chainlink/deployment/cre/shard_config/v1/changeset"

crontypes "github.com/smartcontractkit/chainlink/core/scripts/cre/environment/examples/workflows/v2/cron/types"
"github.com/smartcontractkit/chainlink/system-tests/lib/cre"
"github.com/smartcontractkit/chainlink/system-tests/lib/cre/sharding"
t_helpers "github.com/smartcontractkit/chainlink/system-tests/tests/test-helpers"
Expand Down Expand Up @@ -250,12 +250,19 @@ func validateShardingScaleScenario(t *testing.T, testEnv *ttypes.TestEnvironment

logger.Info().Msg("Step 2: Set ShardConfig to 1 shard (only shard-zero)")
updateShardCount(t, testEnv, chainSelector, shardConfigRef, 1)
contractCount := getShardCountFromContract(t, testEnv, chainSelector, shardConfigRef)
require.Equal(t, uint64(1), contractCount, "ShardConfig contract should report 1 shard")

shardZero := getShardZeroDon(t, testEnv)
initializeAllArbiterStates(t, testEnv, shardZero, 1)

logger.Info().Msg("Step 3: Verify Arbiter returns WantShards=1")
waitForArbiterShardCount(t, arbiterClient, 1, 60*time.Second)
logger.Info().Msg("Step 3: Verify Arbiter WantShards equals contract shard count")
waitForArbiterShardCount(t, arbiterClient, uint32(contractCount), 60*time.Second) //nolint:gosec // G115: test only uses 1 or 2 shards
ctxShort, cancel := context.WithTimeout(ctx, 5*time.Second)
arbiterResp, err := arbiterClient.GetDesiredReplicas(ctxShort, &ringpb.ShardStatusRequest{})
cancel()
require.NoError(t, err)
require.Equal(t, uint32(contractCount), arbiterResp.WantShards, "Arbiter WantShards must equal contract getDesiredShardCount()") //nolint:gosec // G115: test only uses 1 or 2 shards

logger.Info().Msg("Step 4: Wait for all workflows to be remapped to shard 0")
waitForAllWorkflowsOnShard(t, shardOrchClient, workflowIDs, 0)
Expand All @@ -268,11 +275,18 @@ func validateShardingScaleScenario(t *testing.T, testEnv *ttypes.TestEnvironment

logger.Info().Msg("Step 5: Scale up - Set ShardConfig to 2 shards")
updateShardCount(t, testEnv, chainSelector, shardConfigRef, 2)
contractCount = getShardCountFromContract(t, testEnv, chainSelector, shardConfigRef)
require.Equal(t, uint64(2), contractCount, "ShardConfig contract should report 2 shards")

initializeAllArbiterStates(t, testEnv, shardZero, 2)

logger.Info().Msg("Step 6: Verify Arbiter returns WantShards=2")
waitForArbiterShardCount(t, arbiterClient, 2, 60*time.Second)
logger.Info().Msg("Step 6: Verify Arbiter WantShards equals contract shard count")
waitForArbiterShardCount(t, arbiterClient, uint32(contractCount), 60*time.Second) //nolint:gosec // G115: test only uses 1 or 2 shards
ctxShort, cancel = context.WithTimeout(ctx, 5*time.Second)
arbiterResp, err = arbiterClient.GetDesiredReplicas(ctxShort, &ringpb.ShardStatusRequest{})
cancel()
require.NoError(t, err)
require.Equal(t, uint32(contractCount), arbiterResp.WantShards, "Arbiter WantShards must equal contract getDesiredShardCount()") //nolint:gosec // G115: test only uses 1 or 2 shards

logger.Info().Msg("Step 7: Wait for workflow redistribution after scaling")
waitForWorkflowsDistributed(t, shardOrchClient, workflowIDs, 2)
Expand Down Expand Up @@ -344,6 +358,19 @@ func getShardConfigRef(t *testing.T, testEnv *ttypes.TestEnvironment) datastore.
)
}

func getShardCountFromContract(t *testing.T, testEnv *ttypes.TestEnvironment, chainSelector uint64, shardConfigRef datastore.AddressRefKey) uint64 {
t.Helper()
addrRef, err := testEnv.CreEnvironment.CldfEnvironment.DataStore.Addresses().Get(shardConfigRef)
require.NoError(t, err)
chain, ok := testEnv.CreEnvironment.CldfEnvironment.BlockChains.EVMChains()[chainSelector]
require.True(t, ok, "EVM chain %d not found", chainSelector)
contract, err := shard_config.NewShardConfig(common.HexToAddress(addrRef.Address), chain.Client)
require.NoError(t, err)
count, err := contract.GetDesiredShardCount(nil)
require.NoError(t, err)
return count.Uint64()
}

func updateShardCount(t *testing.T, testEnv *ttypes.TestEnvironment, chainSelector uint64, shardConfigRef datastore.AddressRefKey, count uint64) {
t.Helper()
_, err := commonchangeset.RunChangeset(
Expand Down
Loading