File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed
yarn-project/sequencer-client/src/publisher Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -38,7 +38,19 @@ import { privateKeyToAccount } from 'viem/accounts';
3838
3939import type { PublisherConfig , TxSenderConfig } from './config.js' ;
4040import 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
4355const mockRollupAddress = EthAddress . random ( ) . toString ( ) ;
4456const mockGovernanceProposerAddress = EthAddress . random ( ) . toString ( ) ;
Original file line number Diff line number Diff 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 = [
8181export 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
8686export type InvalidateBlockRequest = {
8787 request : L1TxRequest ;
You can’t perform that action at this time.
0 commit comments