Skip to content

Commit 0e072fc

Browse files
committed
fix: sort order
1 parent 9089619 commit 0e072fc

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

yarn-project/sequencer-client/src/publisher/sequencer-publisher.test.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,19 @@ import { privateKeyToAccount } from 'viem/accounts';
3838

3939
import type { PublisherConfig, TxSenderConfig } from './config.js';
4040
import type { SequencerPublisherMetrics } from './sequencer-publisher-metrics.js';
41-
import { SequencerPublisher } from './sequencer-publisher.js';
41+
import { type Action, SequencerPublisher, compareActions } from './sequencer-publisher.js';
42+
43+
// Ensures proposal actions are sorted before slashing votes/signals
44+
45+
describe('compareActions sorting', () => {
46+
it('places propose before empire-slashing-signal and vote-offenses', () => {
47+
const actions: Action[] = ['empire-slashing-signal', 'propose', 'vote-offenses'];
48+
const sorted = [...actions].sort(compareActions);
49+
50+
expect(sorted.indexOf('propose')).toBeLessThan(sorted.indexOf('empire-slashing-signal'));
51+
expect(sorted.indexOf('propose')).toBeLessThan(sorted.indexOf('vote-offenses'));
52+
});
53+
});
4254

4355
const mockRollupAddress = EthAddress.random().toString();
4456
const mockGovernanceProposerAddress = EthAddress.random().toString();

yarn-project/sequencer-client/src/publisher/sequencer-publisher.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export enum SignalType {
6767
SLASHING,
6868
}
6969

70-
const Actions = [
70+
export const Actions = [
7171
'propose',
7272
'governance-signal',
7373
'empire-slashing-signal',
@@ -81,7 +81,7 @@ const Actions = [
8181
export type Action = (typeof Actions)[number];
8282

8383
// Sorting for actions such that invalidations go before proposals, and proposals go before votes
84-
const compareActions = (a: Action, b: Action) => Actions.indexOf(b) - Actions.indexOf(a);
84+
export const compareActions = (a: Action, b: Action) => Actions.indexOf(a) - Actions.indexOf(b);
8585

8686
export type InvalidateBlockRequest = {
8787
request: L1TxRequest;

0 commit comments

Comments
 (0)