Skip to content

Commit 93976d6

Browse files
committed
fix: error prefix
1 parent 95c296f commit 93976d6

File tree

9 files changed

+45
-56
lines changed

9 files changed

+45
-56
lines changed

l1-contracts/src/governance/libraries/Errors.sol

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,19 @@ library Errors {
5151
error Governance__ProposalLib__ZeroYeaVotesNeeded();
5252
error Governance__ProposalLib__MoreYeaVoteThanExistNeeded();
5353

54-
error GovernanceProposer__FailedToSubmitRoundWinner(IPayload payload);
55-
error GovernanceProposer__InstanceHaveNoCode(address instance);
56-
error GovernanceProposer__InsufficientSignals(uint256 signalsCast, uint256 signalsNeeded);
57-
error GovernanceProposer__InvalidQuorumAndRoundSize(uint256 quorumSize, uint256 roundSize);
58-
error GovernanceProposer__QuorumCannotBeLargerThanRoundSize(uint256 quorumSize, uint256 roundSize);
59-
error GovernanceProposer__InvalidLifetimeAndExecutionDelay(uint256 lifetimeInRounds, uint256 executionDelayInRounds);
60-
error GovernanceProposer__OnlyProposerCanSignal(address caller, address proposer);
61-
error GovernanceProposer__PayloadAlreadySubmitted(uint256 roundNumber);
62-
error GovernanceProposer__PayloadCannotBeAddressZero();
54+
error EmpireBase__FailedToSubmitRoundWinner(IPayload payload);
55+
error EmpireBase__InstanceHaveNoCode(address instance);
56+
error EmpireBase__InsufficientSignals(uint256 signalsCast, uint256 signalsNeeded);
57+
error EmpireBase__InvalidQuorumAndRoundSize(uint256 quorumSize, uint256 roundSize);
58+
error EmpireBase__QuorumCannotBeLargerThanRoundSize(uint256 quorumSize, uint256 roundSize);
59+
error EmpireBase__InvalidLifetimeAndExecutionDelay(uint256 lifetimeInRounds, uint256 executionDelayInRounds);
60+
error EmpireBase__OnlyProposerCanSignal(address caller, address proposer);
61+
error EmpireBase__PayloadAlreadySubmitted(uint256 roundNumber);
62+
error EmpireBase__PayloadCannotBeAddressZero();
63+
error EmpireBase__RoundTooOld(uint256 roundNumber, uint256 currentRoundNumber);
64+
error EmpireBase__RoundTooNew(uint256 roundNumber, uint256 currentRoundNumber);
65+
error EmpireBase__SignalAlreadyCastForSlot(Slot slot);
6366
error GovernanceProposer__PayloadHaveNoCode(IPayload payload);
64-
error GovernanceProposer__RoundTooOld(uint256 roundNumber, uint256 currentRoundNumber);
65-
error GovernanceProposer__RoundTooNew(uint256 roundNumber, uint256 currentRoundNumber);
66-
error GovernanceProposer__SignalAlreadyCastForSlot(Slot slot);
6767
error GovernanceProposer__GSEPayloadInvalid();
6868

6969
error CoinIssuer__InsufficientMintAvailable(uint256 available, uint256 needed); // 0xa1cc8799

l1-contracts/src/governance/proposer/EmpireBase.sol

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,12 @@ abstract contract EmpireBase is EIP712, IEmpire {
130130
LIFETIME_IN_ROUNDS = _lifetimeInRounds;
131131
EXECUTION_DELAY_IN_ROUNDS = _executionDelayInRounds;
132132

133-
require(QUORUM_SIZE > ROUND_SIZE / 2, Errors.GovernanceProposer__InvalidQuorumAndRoundSize(QUORUM_SIZE, ROUND_SIZE));
134-
require(
135-
QUORUM_SIZE <= ROUND_SIZE, Errors.GovernanceProposer__QuorumCannotBeLargerThanRoundSize(QUORUM_SIZE, ROUND_SIZE)
136-
);
133+
require(QUORUM_SIZE > ROUND_SIZE / 2, Errors.EmpireBase__InvalidQuorumAndRoundSize(QUORUM_SIZE, ROUND_SIZE));
134+
require(QUORUM_SIZE <= ROUND_SIZE, Errors.EmpireBase__QuorumCannotBeLargerThanRoundSize(QUORUM_SIZE, ROUND_SIZE));
137135

138136
require(
139137
LIFETIME_IN_ROUNDS > EXECUTION_DELAY_IN_ROUNDS,
140-
Errors.GovernanceProposer__InvalidLifetimeAndExecutionDelay(LIFETIME_IN_ROUNDS, EXECUTION_DELAY_IN_ROUNDS)
138+
Errors.EmpireBase__InvalidLifetimeAndExecutionDelay(LIFETIME_IN_ROUNDS, EXECUTION_DELAY_IN_ROUNDS)
141139
);
142140
}
143141

@@ -178,7 +176,7 @@ abstract contract EmpireBase is EIP712, IEmpire {
178176
function submitRoundWinner(uint256 _roundNumber) external override(IEmpire) returns (bool) {
179177
// Need to ensure that the round is not active.
180178
address instance = getInstance();
181-
require(instance.code.length > 0, Errors.GovernanceProposer__InstanceHaveNoCode(instance));
179+
require(instance.code.length > 0, Errors.EmpireBase__InstanceHaveNoCode(instance));
182180

183181
IEmperor selection = IEmperor(instance);
184182
Slot currentSlot = selection.getCurrentSlot();
@@ -187,33 +185,30 @@ abstract contract EmpireBase is EIP712, IEmpire {
187185

188186
require(
189187
currentRound > _roundNumber + EXECUTION_DELAY_IN_ROUNDS,
190-
Errors.GovernanceProposer__RoundTooNew(_roundNumber, currentRound)
188+
Errors.EmpireBase__RoundTooNew(_roundNumber, currentRound)
191189
);
192190

193191
require(
194-
currentRound <= _roundNumber + LIFETIME_IN_ROUNDS,
195-
Errors.GovernanceProposer__RoundTooOld(_roundNumber, currentRound)
192+
currentRound <= _roundNumber + LIFETIME_IN_ROUNDS, Errors.EmpireBase__RoundTooOld(_roundNumber, currentRound)
196193
);
197194

198195
CompressedRoundAccounting storage round = rounds[instance][_roundNumber];
199-
require(!round.executed, Errors.GovernanceProposer__PayloadAlreadySubmitted(_roundNumber));
196+
require(!round.executed, Errors.EmpireBase__PayloadAlreadySubmitted(_roundNumber));
200197

201198
// If the payload with the most signals is address(0) there are nothing to execute and it is a no-op.
202199
// This will be the case if no signals have been cast during a round, or if people have simple signalled
203200
// for nothing to happen (the same as not signalling).
204-
require(
205-
round.payloadWithMostSignals != IPayload(address(0)), Errors.GovernanceProposer__PayloadCannotBeAddressZero()
206-
);
201+
require(round.payloadWithMostSignals != IPayload(address(0)), Errors.EmpireBase__PayloadCannotBeAddressZero());
207202
uint256 signalsCast = round.signalCount[round.payloadWithMostSignals];
208-
require(signalsCast >= QUORUM_SIZE, Errors.GovernanceProposer__InsufficientSignals(signalsCast, QUORUM_SIZE));
203+
require(signalsCast >= QUORUM_SIZE, Errors.EmpireBase__InsufficientSignals(signalsCast, QUORUM_SIZE));
209204

210205
round.executed = true;
211206

212207
emit PayloadSubmitted(round.payloadWithMostSignals, _roundNumber);
213208

214209
require(
215210
_handleRoundWinner(round.payloadWithMostSignals),
216-
Errors.GovernanceProposer__FailedToSubmitRoundWinner(round.payloadWithMostSignals)
211+
Errors.EmpireBase__FailedToSubmitRoundWinner(round.payloadWithMostSignals)
217212
);
218213
return true;
219214
}
@@ -277,7 +272,7 @@ abstract contract EmpireBase is EIP712, IEmpire {
277272

278273
function _internalSignal(IPayload _payload, Signature memory _sig) internal returns (bool) {
279274
address instance = getInstance();
280-
require(instance.code.length > 0, Errors.GovernanceProposer__InstanceHaveNoCode(instance));
275+
require(instance.code.length > 0, Errors.EmpireBase__InstanceHaveNoCode(instance));
281276

282277
IEmperor selection = IEmperor(instance);
283278
Slot currentSlot = selection.getCurrentSlot();
@@ -287,20 +282,18 @@ abstract contract EmpireBase is EIP712, IEmpire {
287282
CompressedRoundAccounting storage round = rounds[instance][roundNumber];
288283

289284
// Ensure that time have progressed since the last slot. If not, the current proposer might send multiple signals
290-
require(
291-
currentSlot > round.lastSignalSlot.decompress(), Errors.GovernanceProposer__SignalAlreadyCastForSlot(currentSlot)
292-
);
285+
require(currentSlot > round.lastSignalSlot.decompress(), Errors.EmpireBase__SignalAlreadyCastForSlot(currentSlot));
293286
round.lastSignalSlot = currentSlot.compress();
294287

295288
address signaler = selection.getCurrentProposer();
296289

297290
if (_sig.isEmpty()) {
298-
require(msg.sender == signaler, Errors.GovernanceProposer__OnlyProposerCanSignal(msg.sender, signaler));
291+
require(msg.sender == signaler, Errors.EmpireBase__OnlyProposerCanSignal(msg.sender, signaler));
299292
} else {
300293
bytes32 digest = getSignalSignatureDigest(_payload, currentSlot);
301294

302295
// _sig.verify will throw if invalid, it is more my sanity that I am doing this for.
303-
require(_sig.verify(signaler, digest), Errors.GovernanceProposer__OnlyProposerCanSignal(msg.sender, signaler));
296+
require(_sig.verify(signaler, digest), Errors.EmpireBase__OnlyProposerCanSignal(msg.sender, signaler));
304297
}
305298

306299
round.signalCount[_payload] += 1;

l1-contracts/test/governance/governance-proposer/constructor.t.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ contract ConstructorTest is Test {
2626

2727
uint256 n = bound(_n, 0, _m / 2);
2828

29-
vm.expectRevert(abi.encodeWithSelector(Errors.GovernanceProposer__InvalidQuorumAndRoundSize.selector, n, _m));
29+
vm.expectRevert(abi.encodeWithSelector(Errors.EmpireBase__InvalidQuorumAndRoundSize.selector, n, _m));
3030
new GovernanceProposer(REGISTRY, GSE, n, _m);
3131
}
3232

@@ -35,7 +35,7 @@ contract ConstructorTest is Test {
3535
uint256 m = bound(_m, 0, type(uint256).max - 1);
3636
uint256 n = bound(_n, m + 1, type(uint256).max);
3737

38-
vm.expectRevert(abi.encodeWithSelector(Errors.GovernanceProposer__QuorumCannotBeLargerThanRoundSize.selector, n, m));
38+
vm.expectRevert(abi.encodeWithSelector(Errors.EmpireBase__QuorumCannotBeLargerThanRoundSize.selector, n, m));
3939
new GovernanceProposer(REGISTRY, GSE, n, m);
4040
}
4141

l1-contracts/test/governance/governance-proposer/scenario/tmnt150.t.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ contract TestTmnt150 is GovernanceProposerBase {
7575

7676
assertEq(governanceProposer.signalCount(address(rollup1), round, proposal), 0, "invalid number of votes");
7777

78-
vm.expectRevert(abi.encodeWithSelector(Errors.GovernanceProposer__SignalAlreadyCastForSlot.selector, 1));
78+
vm.expectRevert(abi.encodeWithSelector(Errors.EmpireBase__SignalAlreadyCastForSlot.selector, 1));
7979

8080
rollup1.commenceAttack();
8181

l1-contracts/test/governance/governance-proposer/signal.t.sol

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ contract SignalTest is GovernanceProposerBase {
3636
registry.addRollup(IRollup(f));
3737
vm.etch(f, "");
3838

39-
vm.expectRevert(abi.encodeWithSelector(Errors.GovernanceProposer__InstanceHaveNoCode.selector, address(f)));
39+
vm.expectRevert(abi.encodeWithSelector(Errors.EmpireBase__InstanceHaveNoCode.selector, address(f)));
4040
governanceProposer.signal(proposal);
4141
}
4242

@@ -60,7 +60,7 @@ contract SignalTest is GovernanceProposerBase {
6060
vm.prank(proposer);
6161
governanceProposer.signal(proposal);
6262

63-
vm.expectRevert(abi.encodeWithSelector(Errors.GovernanceProposer__SignalAlreadyCastForSlot.selector, currentSlot));
63+
vm.expectRevert(abi.encodeWithSelector(Errors.EmpireBase__SignalAlreadyCastForSlot.selector, currentSlot));
6464
governanceProposer.signal(proposal);
6565
}
6666

@@ -86,9 +86,7 @@ contract SignalTest is GovernanceProposerBase {
8686
// it revert
8787
vm.assume(_proposer != proposer);
8888
vm.prank(_proposer);
89-
vm.expectRevert(
90-
abi.encodeWithSelector(Errors.GovernanceProposer__OnlyProposerCanSignal.selector, _proposer, proposer)
91-
);
89+
vm.expectRevert(abi.encodeWithSelector(Errors.EmpireBase__OnlyProposerCanSignal.selector, _proposer, proposer));
9290
governanceProposer.signal(proposal);
9391
}
9492

l1-contracts/test/governance/governance-proposer/submitRoundWinner.t.sol

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ contract ExecuteProposalTest is GovernanceProposerBase {
2727
registry.addRollup(IRollup(f));
2828
vm.etch(f, "");
2929

30-
vm.expectRevert(abi.encodeWithSelector(Errors.GovernanceProposer__InstanceHaveNoCode.selector, address(f)));
30+
vm.expectRevert(abi.encodeWithSelector(Errors.EmpireBase__InstanceHaveNoCode.selector, address(f)));
3131
governanceProposer.submitRoundWinner(_roundNumber);
3232
}
3333

@@ -43,7 +43,7 @@ contract ExecuteProposalTest is GovernanceProposerBase {
4343

4444
function test_WhenRoundNotInPast() external givenCanonicalInstanceHoldCode {
4545
// it revert
46-
vm.expectRevert(abi.encodeWithSelector(Errors.GovernanceProposer__RoundTooNew.selector, 0, 0));
46+
vm.expectRevert(abi.encodeWithSelector(Errors.EmpireBase__RoundTooNew.selector, 0, 0));
4747
governanceProposer.submitRoundWinner(0);
4848
}
4949

@@ -65,9 +65,7 @@ contract ExecuteProposalTest is GovernanceProposerBase {
6565

6666
vm.expectRevert(
6767
abi.encodeWithSelector(
68-
Errors.GovernanceProposer__RoundTooOld.selector,
69-
0,
70-
governanceProposer.computeRound(validatorSelection.getCurrentSlot())
68+
Errors.EmpireBase__RoundTooOld.selector, 0, governanceProposer.computeRound(validatorSelection.getCurrentSlot())
7169
)
7270
);
7371
governanceProposer.submitRoundWinner(0);
@@ -104,7 +102,7 @@ contract ExecuteProposalTest is GovernanceProposerBase {
104102
governanceProposer.submitRoundWinner(1);
105103
}
106104

107-
vm.expectRevert(abi.encodeWithSelector(Errors.GovernanceProposer__PayloadAlreadySubmitted.selector, 1));
105+
vm.expectRevert(abi.encodeWithSelector(Errors.EmpireBase__PayloadAlreadySubmitted.selector, 1));
108106
governanceProposer.submitRoundWinner(1);
109107
}
110108

@@ -134,7 +132,7 @@ contract ExecuteProposalTest is GovernanceProposerBase {
134132

135133
vm.warp(time);
136134

137-
vm.expectRevert(abi.encodeWithSelector(Errors.GovernanceProposer__PayloadCannotBeAddressZero.selector));
135+
vm.expectRevert(abi.encodeWithSelector(Errors.EmpireBase__PayloadCannotBeAddressZero.selector));
138136
governanceProposer.submitRoundWinner(0);
139137
}
140138

@@ -164,7 +162,7 @@ contract ExecuteProposalTest is GovernanceProposerBase {
164162
)
165163
)
166164
);
167-
vm.expectRevert(abi.encodeWithSelector(Errors.GovernanceProposer__InsufficientSignals.selector, 1, votesNeeded));
165+
vm.expectRevert(abi.encodeWithSelector(Errors.EmpireBase__InsufficientSignals.selector, 1, votesNeeded));
168166
governanceProposer.submitRoundWinner(1);
169167
}
170168

@@ -211,7 +209,7 @@ contract ExecuteProposalTest is GovernanceProposerBase {
211209
assertEq(address(r.payloadWithMostSignals), address(proposal));
212210

213211
// As time is perceived differently, round 1 is currently in the future
214-
vm.expectRevert(abi.encodeWithSelector(Errors.GovernanceProposer__RoundTooNew.selector, 1, 0));
212+
vm.expectRevert(abi.encodeWithSelector(Errors.EmpireBase__RoundTooNew.selector, 1, 0));
215213
governanceProposer.submitRoundWinner(1);
216214

217215
// Jump 2 rounds, since we are currently in round 0
@@ -222,7 +220,7 @@ contract ExecuteProposalTest is GovernanceProposerBase {
222220
)
223221
)
224222
);
225-
vm.expectRevert(abi.encodeWithSelector(Errors.GovernanceProposer__PayloadCannotBeAddressZero.selector));
223+
vm.expectRevert(abi.encodeWithSelector(Errors.EmpireBase__PayloadCannotBeAddressZero.selector));
226224
governanceProposer.submitRoundWinner(1);
227225
}
228226

l1-contracts/test/governance/governance-proposer/voteWithsig.t.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ contract SignalWithSigTest is GovernanceProposerBase {
5050
registry.addRollup(IRollup(f));
5151
vm.etch(f, "");
5252

53-
vm.expectRevert(abi.encodeWithSelector(Errors.GovernanceProposer__InstanceHaveNoCode.selector, address(f)));
53+
vm.expectRevert(abi.encodeWithSelector(Errors.EmpireBase__InstanceHaveNoCode.selector, address(f)));
5454
governanceProposer.signalWithSig(proposal, signature);
5555
}
5656

@@ -76,7 +76,7 @@ contract SignalWithSigTest is GovernanceProposerBase {
7676
assertEq(Slot.unwrap(currentSlot), 1);
7777
governanceProposer.signalWithSig(proposal, signature);
7878

79-
vm.expectRevert(abi.encodeWithSelector(Errors.GovernanceProposer__SignalAlreadyCastForSlot.selector, currentSlot));
79+
vm.expectRevert(abi.encodeWithSelector(Errors.EmpireBase__SignalAlreadyCastForSlot.selector, currentSlot));
8080
governanceProposer.signalWithSig(proposal, signature);
8181
}
8282

l1-contracts/test/governance/scenario/slashing/EmpireSlashing.t.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ contract SlashingTest is TestBase {
147147

148148
vm.expectRevert(
149149
abi.encodeWithSelector(
150-
Errors.GovernanceProposer__RoundTooNew.selector, firstSlashingRound, slashingProposer.getCurrentRound()
150+
Errors.EmpireBase__RoundTooNew.selector, firstSlashingRound, slashingProposer.getCurrentRound()
151151
)
152152
);
153153
slashingProposer.submitRoundWinner(firstSlashingRound);

yarn-project/ethereum/src/config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ export function validateConfig(config: Omit<L1ContractsConfig, keyof L1TxUtilsCo
457457
}
458458

459459
// EmpireBase constructor validations for governance/slashing proposers
460-
// From: require(QUORUM_SIZE > ROUND_SIZE / 2, Errors.GovernanceProposer__InvalidQuorumAndRoundSize(QUORUM_SIZE, ROUND_SIZE));
460+
// From: require(QUORUM_SIZE > ROUND_SIZE / 2, Errors.EmpireBase__InvalidQuorumAndRoundSize(QUORUM_SIZE, ROUND_SIZE));
461461
const { governanceProposerQuorum, governanceProposerRoundSize } = config;
462462
if (
463463
governanceProposerQuorum !== undefined &&
@@ -468,7 +468,7 @@ export function validateConfig(config: Omit<L1ContractsConfig, keyof L1TxUtilsCo
468468
);
469469
}
470470

471-
// From: require(QUORUM_SIZE <= ROUND_SIZE, Errors.GovernanceProposer__QuorumCannotBeLargerThanRoundSize(QUORUM_SIZE, ROUND_SIZE));
471+
// From: require(QUORUM_SIZE <= ROUND_SIZE, Errors.EmpireBase__QuorumCannotBeLargerThanRoundSize(QUORUM_SIZE, ROUND_SIZE));
472472
if (governanceProposerQuorum !== undefined && governanceProposerQuorum > governanceProposerRoundSize) {
473473
errors.push(
474474
`governanceProposerQuorum (${governanceProposerQuorum}) cannot be larger than governanceProposerRoundSize (${governanceProposerRoundSize})`,

0 commit comments

Comments
 (0)