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!: Customizable Slashing and Jailing #2403

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

stana-miric
Copy link
Collaborator

@stana-miric stana-miric commented Nov 15, 2024

Closes #2383

This PR introduces the ability for each consumer chain to set custom infraction parameters for slashing and jailing (double signing and downtime). The MsgCreateConsumer and MsgUpdateConsumer messages have been extended to support this functionality.

MsgCreateConsumer:
If infraction parameters are not provided in the message, the values will default to those from the provider and will be stored per consumer chain id.

MsgUpdateConsumer:
Pre-launch phase: Parameters are updated immediately.
Post-launch phase: Parameters are added to a queue, and the update will take effect after the unbonding period expires.

Queue Logic:
If parameters for the consumer already exist in the queue:
If the new parameters match the current infraction param for that consumer, the existing queued entry is removed to cancel the update. If the new parameters differ, the existing queued entry is replaced with the new parameters.
If parameters do not exist in the queue and the new parameters differ from the current ones, a new entry is added to schedule the update.

The unbonding period expiration is checked in the BeginBlocker, leveraging the existing time queue infrastructure.
When a consumer chain is removed, related queue records will also be deleted, but the infraction parameters will remain( following the same logic applied for power parameters). Additionally, a migration script has been implemented to set default infraction parameters for all currently active consumer chains.

@stana-miric stana-miric self-assigned this Nov 15, 2024
@github-actions github-actions bot added C:x/provider Assigned automatically by the PR labeler C:x/types Assigned automatically by the PR labeler labels Nov 15, 2024
x/ccv/provider/module.go Dismissed Show dismissed Hide dismissed
@stana-miric stana-miric force-pushed the smiric/custom-slashing-and-jailing branch from c848f9d to 9fa5ec3 Compare November 15, 2024 17:31
@github-actions github-actions bot added the C:Testing Assigned automatically by the PR labeler label Nov 22, 2024
@stana-miric stana-miric force-pushed the smiric/custom-slashing-and-jailing branch from 76e01b7 to 544331e Compare November 26, 2024 12:42
@github-actions github-actions bot added the C:Docs Assigned automatically by the PR labeler label Nov 26, 2024
@stana-miric stana-miric marked this pull request as ready for review November 26, 2024 14:35
@stana-miric stana-miric requested a review from a team as a code owner November 26, 2024 14:35
Copy link
Contributor

@mpoke mpoke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Partial review. See comments below.

docs/docs/features/slashing.md Outdated Show resolved Hide resolved
docs/docs/features/slashing.md Show resolved Hide resolved
proto/interchain_security/ccv/provider/v1/provider.proto Outdated Show resolved Hide resolved
x/ccv/provider/migrations/v9/migrations.go Outdated Show resolved Hide resolved
Copy link
Contributor

@mpoke mpoke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve the general logic. Great work @stana-miric. See my comments below.

Please add also interchain tests to ensure that updating the infraction params works.

x/ccv/provider/keeper/msg_server.go Outdated Show resolved Hide resolved
x/ccv/provider/keeper/relay.go Outdated Show resolved Hide resolved
@stana-miric
Copy link
Collaborator Author

Approve the general logic. Great work @stana-miric. See my comments below.

Please add also interchain tests to ensure that updating the infraction params works.

Cannot add interchain tests at this point cuz its another module and I can import the right version of ics in ics interchain test only after this pr is merged. I've added test that tests: adding infraction parameters through MsgCreateConsumer and MsgUpdateConsumer, also added tests that test queuing and overriding existing queued item as well as cancelling update, and tests that confirms that when jailing and lashing is called for misbehavior on consumer chain that parameters for that specific consumer is used.
I was thisnking to test this with interchain with the consumer suite that we're currently working on and will use those custon infraction parameters for consume chains.

@mpoke
Copy link
Contributor

mpoke commented Nov 27, 2024

Approve the general logic. Great work @stana-miric. See my comments below.
Please add also interchain tests to ensure that updating the infraction params works.

Cannot add interchain tests at this point cuz its another module and I can import the right version of ics in ics interchain test only after this pr is merged.

Sounds good.

I've added test that tests: adding infraction parameters through MsgCreateConsumer and MsgUpdateConsumer, also added tests that test queuing and overriding existing queued item as well as cancelling update, and tests that confirms that when jailing and lashing is called for misbehavior on consumer chain that parameters for that specific consumer is used.

Great

I was thisnking to test this with interchain with the consumer suite that we're currently working on and will use those custon infraction parameters for consume chains.

Not sure we need to consumer side. That needed in general to test infractions (downtime and double signing). This feature just enables consumer chain owners to change the params. So the e2e test for it should just involve the provider API -- create consumer and update consumer. For example, can we use interchain tests to verify that an update will take the unbonding period? without waiting for 3 weeks :)

Copy link
Contributor

@mpoke mpoke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work @stana-miric

@stana-miric
Copy link
Collaborator Author

Approve the general logic. Great work @stana-miric. See my comments below.
Please add also interchain tests to ensure that updating the infraction params works.

Cannot add interchain tests at this point cuz its another module and I can import the right version of ics in ics interchain test only after this pr is merged.

Sounds good.

I've added test that tests: adding infraction parameters through MsgCreateConsumer and MsgUpdateConsumer, also added tests that test queuing and overriding existing queued item as well as cancelling update, and tests that confirms that when jailing and lashing is called for misbehavior on consumer chain that parameters for that specific consumer is used.

Great

I was thisnking to test this with interchain with the consumer suite that we're currently working on and will use those custon infraction parameters for consume chains.

Not sure we need to consumer side. That needed in general to test infractions (downtime and double signing). This feature just enables consumer chain owners to change the params. So the e2e test for it should just involve the provider API -- create consumer and update consumer. For example, can we use interchain tests to verify that an update will take the unbonding period? without waiting for 3 weeks :)

Interchain tests are now implemented here. Once this pr is merged, pr with tests can be updated(ics version in go.mod, and image version) and reviewed

Copy link
Contributor

@MSalopek MSalopek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

I still need to do an deep dive into the tests. The logic actually seems straightforward - any time a slash/jail operation needs to take place we first consult the consumer parameters and apply them instead of using the sdk defaults.


## Unreleased

### Provider
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add some context here? Just a couple sentences would go a long way.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed a068fcb

@@ -257,6 +257,16 @@ where create_consumer.json has the following structure:
"allow_inactive_vals": false,
"prioritylist": ["cosmosvalcons..."]
},
"infraction_parameters": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: fix spacing.

Copy link
Collaborator Author

@stana-miric stana-miric Dec 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed a068fcb

@@ -363,6 +363,9 @@ message MsgCreateConsumer {

// allowlisted reward denoms of the consumer
AllowlistedRewardDenoms allowlisted_reward_denoms = 6;

// infraction parameters for slashing and jailing
InfractionParameters infraction_parameters = 7;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this optional when the Tx is submitted via CLI/RPC?

It seems very annoying to think about such details during MsgCreateConsumer.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, its optional. if its not set, default values(same as the provider values) will be set.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C:Docs Assigned automatically by the PR labeler C:Testing Assigned automatically by the PR labeler C:x/provider Assigned automatically by the PR labeler C:x/types Assigned automatically by the PR labeler
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature]: Customizable Slashing and Jailing
3 participants