Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,19 @@ import { privateKeyToAccount } from 'viem/accounts';

import type { PublisherConfig, TxSenderConfig } from './config.js';
import type { SequencerPublisherMetrics } from './sequencer-publisher-metrics.js';
import { SequencerPublisher } from './sequencer-publisher.js';
import { type Action, SequencerPublisher, compareActions } from './sequencer-publisher.js';

// Ensures proposal actions are sorted before slashing votes/signals

describe('compareActions sorting', () => {
it('places propose before empire-slashing-signal and vote-offenses', () => {
const actions: Action[] = ['empire-slashing-signal', 'propose', 'vote-offenses'];
const sorted = [...actions].sort(compareActions);

expect(sorted.indexOf('propose')).toBeLessThan(sorted.indexOf('empire-slashing-signal'));
expect(sorted.indexOf('propose')).toBeLessThan(sorted.indexOf('vote-offenses'));
});
});

const mockRollupAddress = EthAddress.random().toString();
const mockGovernanceProposerAddress = EthAddress.random().toString();
Expand Down Expand Up @@ -275,6 +287,10 @@ describe('SequencerPublisher', () => {

expect(forwardSpy).toHaveBeenCalledWith(
[
{
to: mockRollupAddress,
data: encodeFunctionData({ abi: RollupAbi, functionName: 'propose', args }),
},
{
to: mockGovernanceProposerAddress,
data: encodeFunctionData({
Expand All @@ -283,10 +299,6 @@ describe('SequencerPublisher', () => {
args: [govPayload.toString(), voteSig.toViemSignature()],
}),
},
{
to: mockRollupAddress,
data: encodeFunctionData({ abi: RollupAbi, functionName: 'propose', args }),
},
],
l1TxUtils,
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export enum SignalType {
SLASHING,
}

const Actions = [
export const Actions = [
'propose',
'governance-signal',
'empire-slashing-signal',
Expand All @@ -81,7 +81,7 @@ const Actions = [
export type Action = (typeof Actions)[number];

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

export type InvalidateBlockRequest = {
request: L1TxRequest;
Expand Down
Loading