Skip to content

Commit

Permalink
disable consumer initiated slashing + fix slash acks bug (#692)
Browse files Browse the repository at this point in the history
* disable consumer initiating slashing; also jailing for double-signing on the consumers

* fix diff testing

* fix TestHandleSlashPacket

* fix relay tests

* set jailUntil again

* rm TestSlashUndelegation

* rm unused func

* change e2e test to check downtime

* comments

* split out TestRelayAndApplySlashPacket

* final fix in slashing.go

* fix TestHandleSlashPacket

* expectJailing bool

* fix throttle e2e tests

* doc diff test

* fix diff-test slashing

* upstream new traces

* update integration tests with new consumer initiated slash behaviour (#705)

* Update tests/difference/core/model/src/model.ts

* Update tests/difference/core/model/src/model.ts

* rm comment

* fix bug in diff-test model

* Fix slash acks bug (#708)

* refactor Slash processing on provider and consumer

* add unittest for slash acks correctness

* update using review comments

* fix and tests

* relay test

* smol

---------

Co-authored-by: Matija Salopek <[email protected]>
Co-authored-by: MSalopek <[email protected]>

* fix comment strings in integration tests

---------

Co-authored-by: mpoke <[email protected]>
Co-authored-by: Shawn Marshall-Spitzbart <[email protected]>
Co-authored-by: MSalopek <[email protected]>
Co-authored-by: Matija Salopek <[email protected]>
Co-authored-by: Jehan <[email protected]>
  • Loading branch information
6 people authored Feb 6, 2023
1 parent 3c394c5 commit 00fd295
Show file tree
Hide file tree
Showing 13 changed files with 548 additions and 807 deletions.
2 changes: 1 addition & 1 deletion tests/difference/core/driver/traces.json

Large diffs are not rendered by default.

32 changes: 14 additions & 18 deletions tests/difference/core/model/src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,13 @@ class CCVProvider {
};

onReceive = (data: PacketData) => {

// Drop slash packets for double-sign infraction
if ('isDowntime' in data && ! data.isDowntime) {
this.m.events.push(Event.RECEIVE_DOUBLE_SIGN_SLASH_REQUEST);
return;
}

/*
TODO: tidy up before merging to main
This is some quick prototyping to get the tests passing
Expand Down Expand Up @@ -458,36 +465,25 @@ class CCVProvider {
};

onReceiveSlash = (data: Slash) => {
let infractionHeight = undefined;

if (data.vscID === 0) {
infractionHeight = this.initialHeight;
} else {
infractionHeight = this.vscIDtoH[data.vscID];
}

// Check validator status
if (this.m.staking.status[data.val] === Status.UNBONDED) {
this.m.events.push(Event.RECEIVE_SLASH_REQUEST_UNBONDED);
return;
}

if (data.isDowntime) {
this.m.events.push(Event.RECEIVE_DOWNTIME_SLASH_REQUEST);
} else {
this.m.events.push(Event.RECEIVE_DOUBLE_SIGN_SLASH_REQUEST);
}
this.m.events.push(Event.RECEIVE_DOWNTIME_SLASH_REQUEST);


if (this.tombstoned[data.val]) {
return;
}

this.m.staking.slash(data.val, infractionHeight);
// jail validator
this.m.staking.jailUntil(data.val, this.m.t[P] + JAIL_SECONDS);
if (data.isDowntime) {
this.downtimeSlashAcks.push(data.val);
} else {
this.tombstoned[data.val] = true;
}
// update slash acks
this.downtimeSlashAcks.push(data.val);

};

afterUnbondingInitiated = (opID: number) => {
Expand Down
35 changes: 0 additions & 35 deletions tests/e2e/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -611,38 +611,3 @@ func (s *CCVTestSuite) setupValidatorPowers() {
}
s.Require().Equal(int64(4000), stakingKeeper.GetLastTotalPower(s.providerCtx()).Int64())
}

// getHeightOfVSCPacketRecv returns the height of when the consumer received a VSCPacket.
// If expectedMaturityTimesLen > 0, then it's expected to find expectedMaturityTimesLen
// maturity times (i.e., VSCPakcets not yet matured). The vscID of the VSCPacket is retrieved
// from the maturity time with maturityTimesIndex.
func (s *CCVTestSuite) getHeightOfVSCPacketRecv(
bundle icstestingutils.ConsumerBundle,
expectedMaturityTimesLen int,
maturityTimesIndex int,
msgAndArgs ...interface{},
) (height uint64) {
maturityTimes := bundle.GetKeeper().GetAllPacketMaturityTimes(bundle.GetCtx())
if expectedMaturityTimesLen > 0 {
s.Require().Len(
maturityTimes,
expectedMaturityTimesLen,
fmt.Sprintf("unexpected number of maturity times; %s", msgAndArgs...),
)
}
vscID := maturityTimes[maturityTimesIndex].VscId
hToVSCids := bundle.GetKeeper().GetAllHeightToValsetUpdateIDs(bundle.GetCtx())
found := false
for _, hToVSCid := range hToVSCids {
if hToVSCid.ValsetUpdateId == vscID {
height = hToVSCid.Height
found = true
break
}
}
s.Require().True(
found,
fmt.Sprintf("cannot find height mapped to vscID; %s", msgAndArgs...),
)
return
}
Loading

0 comments on commit 00fd295

Please sign in to comment.