Skip to content

Commit 8e56ed1

Browse files
authored
feat: setBatcherHash address overload (#18298)
* feat: setBatcherHash address overload * chore: semver
1 parent 31ecd4a commit 8e56ed1

File tree

5 files changed

+42
-4
lines changed

5 files changed

+42
-4
lines changed

packages/contracts-bedrock/interfaces/L1/ISystemConfig.sol

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ interface ISystemConfig is IProxyAdminOwnedBase {
8686
function renounceOwnership() external;
8787
function resourceConfig() external view returns (IResourceMetering.ResourceConfig memory);
8888
function scalar() external view returns (uint256);
89+
function setBatcherHash(address _batcher) external;
8990
function setBatcherHash(bytes32 _batcherHash) external;
9091
function setGasConfig(uint256 _overhead, uint256 _scalar) external;
9192
function setGasConfigEcotone(uint32 _basefeeScalar, uint32 _blobbasefeeScalar) external;

packages/contracts-bedrock/snapshots/abi/SystemConfig.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,19 @@
754754
"stateMutability": "view",
755755
"type": "function"
756756
},
757+
{
758+
"inputs": [
759+
{
760+
"internalType": "address",
761+
"name": "_batcher",
762+
"type": "address"
763+
}
764+
],
765+
"name": "setBatcherHash",
766+
"outputs": [],
767+
"stateMutability": "nonpayable",
768+
"type": "function"
769+
},
757770
{
758771
"inputs": [
759772
{

packages/contracts-bedrock/snapshots/semver-lock.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@
4848
"sourceCodeHash": "0xbf344c4369b8cb00ec7a3108f72795747f3bc59ab5b37ac18cf21e72e2979dbf"
4949
},
5050
"src/L1/SystemConfig.sol:SystemConfig": {
51-
"initCodeHash": "0x4a4d7e60fc65777a2faaf34c31d1fa310299b5e3384ac1c77ef42d9051a9b14d",
52-
"sourceCodeHash": "0xba941a73e213fdfbdf4ac0f8717e8f60036ca0bb421f9b08adcc1447f25cb477"
51+
"initCodeHash": "0x66a35556b51f537e8d0e11502a371fd58294719ae52fdee957dee26342307b60",
52+
"sourceCodeHash": "0x291e0d88c99defc3f0cdffd844e908471b28a47812ab7040fd17f15db67ece90"
5353
},
5454
"src/L2/BaseFeeVault.sol:BaseFeeVault": {
5555
"initCodeHash": "0x838bbd7f381e84e21887f72bd1da605bfc4588b3c39aed96cbce67c09335b3ee",

packages/contracts-bedrock/src/L1/SystemConfig.sol

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,9 @@ contract SystemConfig is ProxyAdminOwnedBase, OwnableUpgradeable, Reinitializabl
170170
error SystemConfig_InvalidFeatureState();
171171

172172
/// @notice Semantic version.
173-
/// @custom:semver 3.12.0
173+
/// @custom:semver 3.13.0
174174
function version() public pure virtual returns (string memory) {
175-
return "3.12.0";
175+
return "3.13.0";
176176
}
177177

178178
/// @notice Constructs the SystemConfig contract.
@@ -340,6 +340,12 @@ contract SystemConfig is ProxyAdminOwnedBase, OwnableUpgradeable, Reinitializabl
340340
emit ConfigUpdate(VERSION, UpdateType.UNSAFE_BLOCK_SIGNER, data);
341341
}
342342

343+
/// @notice Updates the batcher hash by formatting a provided batcher address.
344+
/// @param _batcher New batcher address.
345+
function setBatcherHash(address _batcher) external onlyOwner {
346+
_setBatcherHash(bytes32(uint256(uint160(_batcher))));
347+
}
348+
343349
/// @notice Updates the batcher hash. Can only be called by the owner.
344350
/// @param _batcherHash New batcher hash.
345351
function setBatcherHash(bytes32 _batcherHash) external onlyOwner {

packages/contracts-bedrock/test/L1/SystemConfig.t.sol

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,12 @@ contract SystemConfig_SetBatcherHash_Test is SystemConfig_TestInit {
327327
systemConfig.setBatcherHash(bytes32(hex""));
328328
}
329329

330+
/// @notice Tests that the address overload reverts if the caller is not the owner.
331+
function test_setBatcherHashFromAddress_notOwner_reverts(address batcher) external {
332+
vm.expectRevert("Ownable: caller is not the owner");
333+
systemConfig.setBatcherHash(batcher);
334+
}
335+
330336
/// @notice Tests that `setBatcherHash` updates the batcher hash successfully.
331337
function testFuzz_setBatcherHash_succeeds(bytes32 newBatcherHash) external {
332338
vm.expectEmit(address(systemConfig));
@@ -336,6 +342,18 @@ contract SystemConfig_SetBatcherHash_Test is SystemConfig_TestInit {
336342
systemConfig.setBatcherHash(newBatcherHash);
337343
assertEq(systemConfig.batcherHash(), newBatcherHash);
338344
}
345+
346+
/// @notice Tests that the address overload formats the hash correctly.
347+
function testFuzz_setBatcherHashFromAddress_succeeds(address newBatcher) external {
348+
bytes32 formatted = bytes32(uint256(uint160(newBatcher)));
349+
350+
vm.expectEmit(address(systemConfig));
351+
emit ConfigUpdate(0, ISystemConfig.UpdateType.BATCHER, abi.encode(formatted));
352+
353+
vm.prank(systemConfig.owner());
354+
systemConfig.setBatcherHash(newBatcher);
355+
assertEq(systemConfig.batcherHash(), formatted);
356+
}
339357
}
340358

341359
/// @title SystemConfig_SetGasConfig_Test

0 commit comments

Comments
 (0)