Skip to content

Commit 8bd8f20

Browse files
authored
fix: action sort order (#16680)
2 parents 9089619 + 3eb3292 commit 8bd8f20

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

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

Lines changed: 17 additions & 5 deletions
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();
@@ -275,6 +287,10 @@ describe('SequencerPublisher', () => {
275287

276288
expect(forwardSpy).toHaveBeenCalledWith(
277289
[
290+
{
291+
to: mockRollupAddress,
292+
data: encodeFunctionData({ abi: RollupAbi, functionName: 'propose', args }),
293+
},
278294
{
279295
to: mockGovernanceProposerAddress,
280296
data: encodeFunctionData({
@@ -283,10 +299,6 @@ describe('SequencerPublisher', () => {
283299
args: [govPayload.toString(), voteSig.toViemSignature()],
284300
}),
285301
},
286-
{
287-
to: mockRollupAddress,
288-
data: encodeFunctionData({ abi: RollupAbi, functionName: 'propose', args }),
289-
},
290302
],
291303
l1TxUtils,
292304
{

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)