Skip to content

Commit bccf9a1

Browse files
author
Daniel
committed
reb
1 parent 608ec5b commit bccf9a1

File tree

5 files changed

+35
-5
lines changed

5 files changed

+35
-5
lines changed

tests/difference/core/driver/setup.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,13 @@ func (b *Builder) build() {
678678

679679
b.setSlashParams()
680680

681+
// TODO: tidy up before merging into main
682+
prams := b.providerKeeper().GetParams(b.ctx(P))
683+
prams.SlashMeterReplenishFraction = "1.0"
684+
prams.SlashMeterReplenishPeriod = time.Second * 1
685+
b.providerKeeper().SetParams(b.ctx(P), prams)
686+
b.providerKeeper().InitializeSlashMeter(b.ctx(P))
687+
681688
// Set light client params to match model
682689
tmConfig := ibctesting.NewTendermintConfig()
683690
tmConfig.UnbondingPeriod = b.initState.UnbondingP

tests/difference/core/driver/traces.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

tests/difference/core/model/src/common.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ type ModelInitState = {
181181
downtimeSlashAcks: number[];
182182
tombstoned: boolean[];
183183
matureUnbondingOps: number[];
184+
queue: (Slash | VscMatured)[];
184185
};
185186
};
186187

tests/difference/core/model/src/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ const MODEL_INIT_STATE: ModelInitState = {
5656
downtimeSlashAcks: [],
5757
tombstoned: [false, false, false, false],
5858
matureUnbondingOps: [],
59+
queue: [],
5960
},
6061
staking: {
6162
delegation: [4000, 3000, 2000, 1000],

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

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,8 @@ class CCVProvider {
374374
tombstoned: boolean[];
375375
// unbonding operations to be completed in EndBlock
376376
matureUnbondingOps: number[];
377+
// queue
378+
queue: (Slash | VscMatured)[];
377379

378380
constructor(model: Model, { ccvP }: ModelInitState) {
379381
this.m = model;
@@ -382,6 +384,7 @@ class CCVProvider {
382384

383385
endBlockCIS = () => {
384386
this.vscIDtoH[this.vscID] = this.m.h[P] + 1;
387+
this.processPackets();
385388
};
386389

387390
endBlockVSU = () => {
@@ -420,14 +423,32 @@ class CCVProvider {
420423
};
421424

422425
onReceive = (data: PacketData) => {
423-
// It's sufficient to use isDowntime field as differentiator
424-
if ('isDowntime' in data) {
425-
this.onReceiveSlash(data);
426+
/*
427+
TODO: tidy up before merging to main
428+
This is some quick prototyping to get the tests passing
429+
We have 1 consumer chain so the slash queue is the global queue
430+
if the queue is empty we can just process the packet.
431+
*/
432+
if (this.queue.length == 0 && !('isDowntime' in data)) {
433+
// Skip the queue
434+
this.onReceiveVSCMatured(data as VscMatured);
426435
} else {
427-
this.onReceiveVSCMatured(data);
436+
this.queue.push(data);
428437
}
429438
};
430439

440+
processPackets = () => {
441+
this.queue.forEach((data) => {
442+
// It's sufficient to use isDowntime field as differentiator
443+
if ('isDowntime' in data) {
444+
this.onReceiveSlash(data);
445+
} else {
446+
this.onReceiveVSCMatured(data);
447+
}
448+
});
449+
this.queue = [];
450+
};
451+
431452
onReceiveVSCMatured = (data: VscMatured) => {
432453
if (this.vscIDtoOpIDs.has(data.vscID)) {
433454
this.vscIDtoOpIDs.get(data.vscID)!.forEach((opID: number) => {

0 commit comments

Comments
 (0)