Skip to content

Commit 052658f

Browse files
authored
fix: keep track of bad proposers (#16006)
Fix #16001
1 parent 7203810 commit 052658f

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

yarn-project/validator-client/src/validator.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ describe('ValidatorClient', () => {
300300
// We "remember" that we want to slash this person, up to the max penalty...
301301
await expect(
302302
validatorClient.shouldSlash({
303-
validator: proposer,
303+
validator: EthAddress.fromString(proposer.toString()), // create a copy of the EthAddress
304304
amount: config.slashInvalidBlockMaxPenalty,
305305
offense: Offense.INVALID_BLOCK,
306306
}),
@@ -309,7 +309,7 @@ describe('ValidatorClient', () => {
309309
// ...but no more than that
310310
await expect(
311311
validatorClient.shouldSlash({
312-
validator: proposer,
312+
validator: EthAddress.fromString(proposer.toString()),
313313
amount: config.slashInvalidBlockMaxPenalty + 1n,
314314
offense: Offense.INVALID_BLOCK,
315315
}),

yarn-project/validator-client/src/validator.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
8787

8888
private blockProposalValidator: BlockProposalValidator;
8989

90-
private proposersOfInvalidBlocks: Set<EthAddress> = new Set();
90+
private proposersOfInvalidBlocks: Set<string> = new Set();
9191

9292
protected constructor(
9393
private blockBuilder: IFullNodeBlockBuilder,
@@ -459,7 +459,7 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
459459
this.proposersOfInvalidBlocks.delete(this.proposersOfInvalidBlocks.values().next().value!);
460460
}
461461

462-
this.proposersOfInvalidBlocks.add(proposer);
462+
this.proposersOfInvalidBlocks.add(proposer.toString());
463463

464464
this.emit(WANT_TO_SLASH_EVENT, [
465465
{
@@ -485,7 +485,8 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
485485
public shouldSlash(args: WantToSlashArgs): Promise<boolean> {
486486
// note we don't check the offence here: we know this person is bad and we're willing to slash up to the max penalty.
487487
return Promise.resolve(
488-
args.amount <= this.config.slashInvalidBlockMaxPenalty && this.proposersOfInvalidBlocks.has(args.validator),
488+
args.amount <= this.config.slashInvalidBlockMaxPenalty &&
489+
this.proposersOfInvalidBlocks.has(args.validator.toString()),
489490
);
490491
}
491492

0 commit comments

Comments
 (0)