Skip to content

Commit 6a7d736

Browse files
committed
chore(host-contracts): remove unused events and custom errors
1 parent 0c4bcf7 commit 6a7d736

File tree

3 files changed

+32
-48
lines changed

3 files changed

+32
-48
lines changed

host-contracts/contracts/InputVerifier.sol

Lines changed: 19 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,6 @@ import {ACLChecks} from "./shared/ACLChecks.sol";
1919
* @dev The contract uses EIP712UpgradeableCrossChain for cryptographic operations.
2020
*/
2121
contract InputVerifier is UUPSUpgradeableEmptyProxy, Ownable2StepUpgradeable, EIP712UpgradeableCrossChain, ACLChecks {
22-
/// @notice Emitted when a signer is added.
23-
/// @param signer The address of the signer that was added.
24-
event SignerAdded(address indexed signer);
25-
26-
/// @notice Emitted when a signer is removed.
27-
/// @param signer The address of the signer that was removed.
28-
event SignerRemoved(address indexed signer);
29-
3022
/// @notice Returned if the deserializing of the input proof fails.
3123
error DeserializingInputProofFail();
3224

@@ -45,18 +37,6 @@ contract InputVerifier is UUPSUpgradeableEmptyProxy, Ownable2StepUpgradeable, EI
4537
/// @notice Returned if the handle version is not the correct one.
4638
error InvalidHandleVersion();
4739

48-
/// @notice Returned if signer is null.
49-
error SignerNull();
50-
51-
/// @notice Returned if signer is already registered.
52-
error AlreadySigner();
53-
54-
/// @notice Returned if no signer is already registered.
55-
error AtLeastOneSignerIsRequired();
56-
57-
/// @notice Returned if not a registered signer.
58-
error NotASigner();
59-
6040
/// @notice Returned in case signerRecovered is an invalid signer.
6141
error InvalidSigner(address signerRecovered);
6242

@@ -165,8 +145,8 @@ contract InputVerifier is UUPSUpgradeableEmptyProxy, Ownable2StepUpgradeable, EI
165145
* @notice Initializes the contract.
166146
* @param verifyingContractSource InputVerification contract address from Gateway chain.
167147
* @param chainIDSource chainID of Gateway chain.
168-
* @param initialContextId Initial active context ID.
169-
* @param initialContextSigners Initial list of signers for the active context ID.
148+
* @param initialCoprocessorContextId Initial active coprocessor context ID.
149+
* @param initialCoprocessorSigners Initial list of signers for the active coprocessor context.
170150
*/
171151
/// @custom:oz-upgrades-validate-as-initializer
172152
function initializeFromEmptyProxy(
@@ -195,7 +175,9 @@ contract InputVerifier is UUPSUpgradeableEmptyProxy, Ownable2StepUpgradeable, EI
195175
}
196176

197177
/**
198-
* @notice Re-initializes the contract from V3.
178+
* @notice Re-initializes the contract from V1.
179+
* @param initialCoprocessorContextId Initial active coprocessor context ID.
180+
* @param initialCoprocessorSigners Initial list of signers for the active coprocessor context.
199181
*/
200182
/// @custom:oz-upgrades-unsafe-allow missing-initializer-call
201183
/// @custom:oz-upgrades-validate-as-initializer
@@ -271,16 +253,16 @@ contract InputVerifier is UUPSUpgradeableEmptyProxy, Ownable2StepUpgradeable, EI
271253
/// @dev bundleCiphertext is compressedPackedCT+ZKPOK
272254
/// inputHandle is keccak256(keccak256(bundleCiphertext)+index)[0:20] + index[21] + chainId[22:29] + type[30] + version[31]
273255
/// and inputProof is numHandles + numSigners + coprocessorContextId + handles + coprocessorSignatures (1 + 1 + 1 + 32*numHandles + 65*numSigners + extraData bytes)
274-
275-
// uint256 inputProofLen = inputProof.length;
276-
if (inputProof.length == 0) revert EmptyInputProof();
256+
if (inputProof.length == 0) {
257+
revert EmptyInputProof();
258+
}
277259
uint256 numHandles = uint256(uint8(inputProof[0]));
278260
uint256 numSigners = uint256(uint8(inputProof[1]));
279261

280262
// Extract the coprocessor context ID from inputProof.
281263
uint256 coprocessorContextId;
282264
assembly {
283-
coprocessorContextId := mload(add(inputProof, 0x22)) // 0x20 offset for array prefix + 2 bytes header
265+
coprocessorContextId := mload(add(inputProof, 0x22)) // 0x20 offset for array prefix + 2 bytes for numHandles and numSigners
284266
}
285267

286268
/// @dev This checks in particular that the list is non-empty.
@@ -289,20 +271,22 @@ contract InputVerifier is UUPSUpgradeableEmptyProxy, Ownable2StepUpgradeable, EI
289271
/// @dev The extraData is the rest of the inputProof bytes after:
290272
/// + numHandles (1 byte)
291273
/// + numSigners (1 byte)
292-
/// + coprocesorContextId (32 bytes)
274+
/// + coprocessorContextId (32 bytes)
293275
/// + handles (32 bytes each)
294276
/// + coprocessorSignatures (65 bytes each)
295277
uint256 extraDataOffset = 34 + 32 * numHandles + 65 * numSigners;
296278

297279
/// @dev Check that the inputProof is long enough to contain at least the numHandles + numSigners + handles + coprocessorSignatures
298-
if (inputProof.length < extraDataOffset) revert DeserializingInputProofFail();
280+
if (inputProof.length < extraDataOffset) {
281+
revert DeserializingInputProofFail();
282+
}
299283

300284
/// @dev Deserialize handle and check that they are from the correct version.
301285
bytes32[] memory listHandles = new bytes32[](numHandles);
302286
for (uint256 i = 0; i < numHandles; i++) {
303287
bytes32 element;
304288
assembly {
305-
// 32 (array length) + 2 (numSigners and numHandles) + 32 (coprocessorContextId) + 32*i
289+
// 32 bytes (array length) + 2 bytes (numSigners and numHandles) + 32 bytes (coprocessorContextId) + 32 bytes * i
306290
element := mload(add(inputProof, add(66, mul(i, 32))))
307291
}
308292
/// @dev Check that all handles are from the correct version.
@@ -364,9 +348,9 @@ contract InputVerifier is UUPSUpgradeableEmptyProxy, Ownable2StepUpgradeable, EI
364348
}
365349

366350
/**
367-
* @notice Get the threshold for signature.
351+
* @notice Get the threshold for required signatures.
368352
* @param coprocessorContextId The coprocessor context ID of the signer addresses to get the threshold from.
369-
* @return threshold Threshold for signature verification.
353+
* @return threshold Threshold for number of signatures verification.
370354
*/
371355
function getThreshold(uint256 coprocessorContextId) public view virtual returns (uint256) {
372356
address[] memory coprocessorSigners = getCoprocessorSigners(coprocessorContextId);
@@ -400,15 +384,15 @@ contract InputVerifier is UUPSUpgradeableEmptyProxy, Ownable2StepUpgradeable, EI
400384
function isCoprocessorContextActiveOrSuspended(uint256 coprocessorContextId) public view virtual returns (bool) {
401385
InputVerifierStorage storage $ = _getInputVerifierStorage();
402386
if (
403-
$.coprocessorContextStates[coprocessorContextId] == CoprocessorContextState.Suspended ||
404-
$.coprocessorContextStates[coprocessorContextId] == CoprocessorContextState.Active
387+
$.coprocessorContextStates[coprocessorContextId] == CoprocessorContextState.Active ||
388+
$.coprocessorContextStates[coprocessorContextId] == CoprocessorContextState.Suspended
405389
) {
406390
return true;
407391
}
408392
revert InvalidContextId(coprocessorContextId);
409393
}
410394

411-
function addNewContextAndSuspendOldOne(
395+
function addNewContextAndSuspendCurrentOne(
412396
uint256 newContextId,
413397
address[] calldata newContextSigners
414398
) public virtual onlyACLOwner {

host-contracts/test/inputVerifier/InputVerifier.t.sol

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ contract InputVerifierTest is Test {
514514
vm.prank(owner);
515515
uint256 newContextId = initialCoprocessorContextId + 1;
516516
address[] memory newContextSigners = new address[](0);
517-
inputVerifier.addNewContextAndSuspendOldOne(newContextId, newContextSigners);
517+
inputVerifier.addNewContextAndSuspendCurrentOne(newContextId, newContextSigners);
518518
}
519519

520520
/**
@@ -952,7 +952,7 @@ contract InputVerifierTest is Test {
952952
vm.prank(randomAccount);
953953
uint256 newContextId = initialCoprocessorContextId + 1;
954954
address[] memory newContextSigners = new address[](0);
955-
inputVerifier.addNewContextAndSuspendOldOne(newContextId, newContextSigners);
955+
inputVerifier.addNewContextAndSuspendCurrentOne(newContextId, newContextSigners);
956956
}
957957

958958
/**
@@ -975,7 +975,7 @@ contract InputVerifierTest is Test {
975975
vm.prank(owner);
976976
address[] memory newContextSigners = new address[](1);
977977
newContextSigners[0] = signer0;
978-
inputVerifier.addNewContextAndSuspendOldOne(initialCoprocessorContextId, newContextSigners);
978+
inputVerifier.addNewContextAndSuspendCurrentOne(initialCoprocessorContextId, newContextSigners);
979979
}
980980

981981
/**
@@ -990,7 +990,7 @@ contract InputVerifierTest is Test {
990990
newContextSigners[1] = signer1;
991991
newContextSigners[2] = signer2;
992992
newContextSigners[3] = signer3;
993-
inputVerifier.addNewContextAndSuspendOldOne(newContextId, newContextSigners);
993+
inputVerifier.addNewContextAndSuspendCurrentOne(newContextId, newContextSigners);
994994

995995
address[] memory signers = inputVerifier.getCoprocessorSigners(newContextId);
996996
assertEq(signers.length, 4);
@@ -1012,7 +1012,7 @@ contract InputVerifierTest is Test {
10121012

10131013
// Add a new context which should suspend the initial one.
10141014
vm.prank(owner);
1015-
inputVerifier.addNewContextAndSuspendOldOne(newContextId, newContextSigners);
1015+
inputVerifier.addNewContextAndSuspendCurrentOne(newContextId, newContextSigners);
10161016

10171017
// Mark the suspended context as deactivated.
10181018
vm.prank(owner);

host-contracts/test/inputVerifier/inputVerifier.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,21 +60,21 @@ describe('InputVerifier', function () {
6060
describe('Coprocessor context', function () {
6161
it('Should revert because the sender is not the host owner', async function () {
6262
const fakeOwner = signers.alice;
63-
await expect(inputVerifier.connect(fakeOwner).addNewContextAndSuspendOldOne(2, []))
63+
await expect(inputVerifier.connect(fakeOwner).addNewContextAndSuspendCurrentOne(2, []))
6464
.to.be.revertedWithCustomError(inputVerifier, 'NotHostOwner')
6565
.withArgs(fakeOwner);
6666
});
6767

6868
it('Should revert because the context ID is null', async function () {
6969
const nullContextId = 0;
7070
await expect(
71-
inputVerifier.connect(deployer).addNewContextAndSuspendOldOne(nullContextId, []),
71+
inputVerifier.connect(deployer).addNewContextAndSuspendCurrentOne(nullContextId, []),
7272
).to.be.revertedWithCustomError(inputVerifier, 'InvalidNullContextId');
7373
});
7474

7575
it('Should revert because the context signers is empty', async function () {
7676
const contextId = 2;
77-
await expect(inputVerifier.connect(deployer).addNewContextAndSuspendOldOne(contextId, []))
77+
await expect(inputVerifier.connect(deployer).addNewContextAndSuspendCurrentOne(contextId, []))
7878
.to.be.revertedWithCustomError(inputVerifier, 'EmptyCoprocessorSignerAddresses')
7979
.withArgs(contextId);
8080
});
@@ -83,7 +83,7 @@ describe('InputVerifier', function () {
8383
const alreadyUsedContextId = 1;
8484
const newContextSigners = [signers.alice.address, signers.bob.address];
8585
await expect(
86-
inputVerifier.connect(deployer).addNewContextAndSuspendOldOne(alreadyUsedContextId, newContextSigners),
86+
inputVerifier.connect(deployer).addNewContextAndSuspendCurrentOne(alreadyUsedContextId, newContextSigners),
8787
)
8888
.to.be.revertedWithCustomError(inputVerifier, 'ContextAlreadyInitialized')
8989
.withArgs(alreadyUsedContextId);
@@ -93,8 +93,8 @@ describe('InputVerifier', function () {
9393
const previousContextId = 1;
9494
const newContextId = 2;
9595
const newContextSigners = [signers.alice.address, signers.bob.address];
96-
await expect(inputVerifier.connect(deployer).addNewContextAndSuspendOldOne(newContextId, newContextSigners)).to.be
97-
.fulfilled;
96+
await expect(inputVerifier.connect(deployer).addNewContextAndSuspendCurrentOne(newContextId, newContextSigners))
97+
.to.be.fulfilled;
9898

9999
// New context signers should contain the new signers.
100100
const contextSigners = await inputVerifier.getCoprocessorSigners(newContextId);
@@ -118,7 +118,7 @@ describe('InputVerifier', function () {
118118
const previousContextId = 1;
119119
const newContextId = 2;
120120
const newContextSigners = [signers.alice.address, signers.bob.address];
121-
await inputVerifier.connect(deployer).addNewContextAndSuspendOldOne(newContextId, newContextSigners);
121+
await inputVerifier.connect(deployer).addNewContextAndSuspendCurrentOne(newContextId, newContextSigners);
122122

123123
// Previous context should be marked as suspended.
124124
expect(await inputVerifier.isCoprocessorContextActiveOrSuspended(previousContextId)).to.be.equal(true);
@@ -189,7 +189,7 @@ describe('InputVerifier', function () {
189189
// Add new context with 2 signers, so threshold becomes 2.
190190
const newContextId = 2;
191191
const newContextSigners = [signers.alice.address, signers.bob.address];
192-
await inputVerifier.connect(deployer).addNewContextAndSuspendOldOne(newContextId, newContextSigners);
192+
await inputVerifier.connect(deployer).addNewContextAndSuspendCurrentOne(newContextId, newContextSigners);
193193

194194
const testInputAddress = await testInput.getAddress();
195195

0 commit comments

Comments
 (0)