Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: Allow inactive provider chain validators to validate on consumer chains #2079

Merged
merged 54 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from 52 commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
b9928d4
refactor!: Refactor the validator set storage and add provider consen…
p-offtermatt Jul 2, 2024
b28b139
feat!: Introduce the MaxProviderConsensusValidators param (#1992)
p-offtermatt Jul 2, 2024
e71129e
feat!: Wire the provider module to return ValidatorUpdates, instead o…
p-offtermatt Jul 15, 2024
9788053
test: enable the simulator for the provider module (#2005)
p-offtermatt Jul 15, 2024
3db7f3d
feat!: Let consumer chains choose a minimum stake and validator rank …
p-offtermatt Jul 17, 2024
934550f
feat!: Rewire dependencies on the staking module (#2056)
p-offtermatt Jul 18, 2024
1b40c17
feat: Calculate Top N based on active validators only (#2070)
p-offtermatt Jul 22, 2024
0f4651b
Delete hanging changelog entry
p-offtermatt Jul 24, 2024
e5f155d
Address comments
p-offtermatt Jul 24, 2024
b97ab26
Address more comments
p-offtermatt Jul 24, 2024
4bfc1df
Add migration for param
p-offtermatt Jul 24, 2024
8a67a8a
Fix allow inactive validators param test
p-offtermatt Jul 24, 2024
5ceaffc
Fix tests
p-offtermatt Jul 24, 2024
a859f7a
Merge branch 'main' into ph/inactive-vals-v50-2
p-offtermatt Jul 24, 2024
92904e9
Add LastProviderConsensusValidatorKey to fully defined keys
p-offtermatt Jul 24, 2024
9ab14ee
Fix key for validator set updates
p-offtermatt Jul 24, 2024
8024804
Add info about genesis/endblock ordering
p-offtermatt Jul 24, 2024
264b642
Add unit test for ProviderValidatorUpdates
p-offtermatt Jul 25, 2024
22bfde8
Add example to proto definition of max_rank
p-offtermatt Jul 25, 2024
42c05b2
Remove max rank
p-offtermatt Jul 26, 2024
ff2f074
Merge branch 'main' into ph/inactive-vals-v50-2
p-offtermatt Jul 26, 2024
60bf261
Remove references to max rank
p-offtermatt Jul 26, 2024
7fbb134
Start adding an extension to the simulator
p-offtermatt Jul 18, 2024
da4dd8e
Make invariant fail early when param is 0
p-offtermatt Jul 18, 2024
f4ce5b1
Reorder InitGenesis to put Crisis last
p-offtermatt Jul 26, 2024
75bb7a9
Remove canary
p-offtermatt Jul 26, 2024
af528c7
Swap equals for not equals
p-offtermatt Jul 26, 2024
74b4b94
Disable invariant check when max validators != max provider consensus…
p-offtermatt Jul 26, 2024
9b9a945
Make the simulator use a random seed
p-offtermatt Jul 26, 2024
a73ef5a
Remove TODO
p-offtermatt Jul 26, 2024
0726e63
Remove decoder
p-offtermatt Jul 26, 2024
837d111
Run go mod tidy
p-offtermatt Jul 29, 2024
0c2b427
Add migration in UPGRADING.md
p-offtermatt Jul 29, 2024
8c06477
Merge branch 'main' into ph/inactive-vals-v50-2
p-offtermatt Aug 1, 2024
4efaa98
Fix tests
p-offtermatt Aug 1, 2024
a35e39b
Put random seed generation into golang code
p-offtermatt Aug 2, 2024
4a01439
Rename simulation jobs
p-offtermatt Aug 2, 2024
fb6d09f
Update UPGRADING.md
p-offtermatt Aug 2, 2024
5cb6376
Update UPGRADING.md
p-offtermatt Aug 2, 2024
1860933
Update x/ccv/provider/keeper/genesis.go
p-offtermatt Aug 2, 2024
266e9da
Mention simulation tests in testing.md
p-offtermatt Aug 2, 2024
7c96789
Address some comments
p-offtermatt Aug 2, 2024
24823a6
Remake protos
p-offtermatt Aug 2, 2024
a7b1140
Panic when LastActiveBondedValidators fails
p-offtermatt Aug 2, 2024
aeb2e96
Address some comments
p-offtermatt Aug 2, 2024
2c70e3b
Address comments
p-offtermatt Aug 2, 2024
ed7e12d
Reorder tests
p-offtermatt Aug 2, 2024
484cb7d
Adjust stake_multiplier to stakeMultiplier
p-offtermatt Aug 2, 2024
930a482
Address comments
p-offtermatt Aug 5, 2024
20345bd
Add error logging
p-offtermatt Aug 5, 2024
46dbb4e
Fix reference to bank blocked addrs in simulation
p-offtermatt Aug 5, 2024
c3b36e6
Change hasToValidate to only take into account active validators
p-offtermatt Aug 5, 2024
bf35f2c
Update docs/docs/adrs/adr-017-allowing-inactive-validators.md
p-offtermatt Aug 5, 2024
f3b7995
Clarify: Slash happens on provider
p-offtermatt Aug 5, 2024
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Add minimum stake requirement to let consumer chains
determine requirements for validators that validate their chain. ([\#2035](https://github.com/cosmos/interchain-security/pull/2035))
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Add the `allow_inactive_vals` parameter for consumer chains to choose whether inactive validators can validate their chain ([\#2066](https://github.com/cosmos/interchain-security/pull/2066))
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Add minimum stake requirement to let consumer chains
determine requirements for validators that validate their chain. ([\#2035](https://github.com/cosmos/interchain-security/pull/2035))
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Add the `allow_inactive_vals` parameter for consumer chains to choose whether inactive validators can validate their chain ([\#2066](https://github.com/cosmos/interchain-security/pull/2066))
17 changes: 17 additions & 0 deletions .github/workflows/nightly-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,23 @@ jobs:
- name: E2E active set changes
run: go run ./tests/e2e/... --tc active-set-changes

inactive-provider-validators-on-consumer-test:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/setup-go@v5
with:
go-version: "1.22"
- uses: actions/checkout@v4
- name: Checkout LFS objects
run: git lfs checkout
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: "1.22" # The Go version to download (if necessary) and use.
- name: E2E inactive provider validators on consumer
run: go run ./tests/e2e/... --tc inactive-provider-validators-on-consumer

nightly-test-fail:
needs:
- happy-path-test
Expand Down
69 changes: 69 additions & 0 deletions .github/workflows/simulation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Simulation
on:
workflow_call:
pull_request:
merge_group:
push:
branches:
- main
- release/v*
- feat/*

permissions:
contents: read

concurrency:
group: ci-${{ github.ref }}-tests
cancel-in-progress: true

jobs:
simulation-full:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.22"
check-latest: true
cache: true
cache-dependency-path: go.sum
- uses: technote-space/[email protected]
id: git_diff
with:
PATTERNS: |
**/*.go
go.mod
go.sum
**/go.mod
**/go.sum
**/Makefile
Makefile
- name: full simulation test
if: env.GIT_DIFF
run: |
make sim-full
simulation-no-inactive:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.22"
check-latest: true
cache: true
cache-dependency-path: go.sum
- uses: technote-space/[email protected]
id: git_diff
with:
PATTERNS: |
**/*.go
go.mod
go.sum
**/go.mod
**/go.sum
**/Makefile
Makefile
- name: simulation test without inactive validators
if: env.GIT_DIFF
run: |
make sim-full-no-inactive-vals
13 changes: 13 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,19 @@ verify-models:
../run_invariants.sh


###############################################################################
### Simulation tests ###

# Run a full simulation test
sim-full:
p-offtermatt marked this conversation as resolved.
Show resolved Hide resolved
cd app/provider;\
go test -mod=readonly . -run=^TestFullAppSimulation$ -Enabled=true -NumBlocks=500 -BlockSize=200 -Commit=true -timeout 24h -v

# Run full simulation without any inactive validators
sim-full-no-inactive-vals:
cd app/provider;\
go test -mod=readonly . -run=^TestFullAppSimulation$ -Enabled=true -NumBlocks=500 -BlockSize=200 -Commit=true -timeout 24h -Params=no_inactive_vals_params.json -v


###############################################################################
### Linting ###
Expand Down
13 changes: 13 additions & 0 deletions TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ To run integration tests against your own consumer/provider implementations, use

[E2E tests](tests/e2e/) run true consumer and provider chain binaries within a docker container and are relevant to the highest level of functionality. E2E tests use queries/transactions invoked from CLI to drive and validate the code.

## Simulation Tests

[Simulation tests](app/provider/sim_test.go) are used to test the full application via the SDK's simulation framework. This framework generates random inputs and checks that certain user-defined invariants hold.
Notably, as-of-now simulation tests do not include any multi-chain testing, so can only test the provider chain on its own, without consumer chains.

## Compatibility Tests

To test compatibility between different provider and consumer versions the [E2E tests](tests/e2e/) were extended by compatibility tests. The test cases perform basic sanity tests against the selected provider and consumer versions. A selected combination of provider and consumer versions are tested on a nightly bases and can be run locally with the
Expand Down Expand Up @@ -57,6 +62,12 @@ make test-no-cache

# run E2E compatibility tests for selected provider and consumer versions
make test-e2e-compatibility-tests-latest

# run full simulation tests
make sim-full

#run simulation tests where providerModule.max_provider_consensus_validators=stakingModule.max_validators=100
make sim-full-no-inactive-vals
```

Alternatively you can run tests using `go test`:
Expand All @@ -83,6 +94,8 @@ go run ./tests/e2e/... --local-sdk-path "/Users/bob/Documents/cosmos-sdk/"
go test -fuzz=<regex-to-match-test-name>
# run verbose E2E tests
go run ./tests/e2e/... --local-sdk-path "/Users/bob/Documents/cosmos-sdk/" --verbose
# run simulation tests; should be run from the 0app/provider directory
go test -mod=readonly . -run=^TestFullAppSimulation$ -Enabled=true -NumBlocks=500 -BlockSize=200 -Commit=true -timeout 24h -v
```

### Testing with Gaia as the provider
Expand Down
27 changes: 27 additions & 0 deletions UPGRADING.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,32 @@
# Upgrading Replicated Security

## Unreleased

### Provider

Upgrading a provider from v5.1.x requires state migrations. The following migrators should be added to the upgrade handler of the provider chain:

```go
// InitializeMaxValidatorsForExistingConsumers initializes the max validators
// parameter for existing consumers to the MaxProviderConsensusValidators parameter.
// This is necessary to avoid those consumer chains having an excessive amount of validators.
func InitializeMaxValidatorsForExistingConsumers(ctx sdk.Context, providerKeeper providerkeeper.Keeper) {
insumity marked this conversation as resolved.
Show resolved Hide resolved
maxVals := providerKeeper.GetParams(ctx).MaxProviderConsensusValidators
for _, chainID := range providerKeeper.GetAllRegisteredConsumerChainIDs(ctx) {
providerKeeper.SetValidatorSetCap(ctx, chainID, uint32(maxVals))
}
}

// InitializeMaxProviderConsensusParam initializes the MaxProviderConsensusValidators parameter.
func InitializeMaxProviderConsensusParam(ctx sdk.Context, providerKeeper providerkeeper.Keeper) {
params := providerKeeper.GetParams(ctx)
if params.MaxProviderConsensusValidators == 0 {
params.MaxProviderConsensusValidators = 180
providerKeeper.SetParams(ctx, params)
}
}
```

## [v5.1.x](https://github.com/cosmos/interchain-security/releases/tag/v5.1.0)

### Provider
Expand Down
Loading
Loading