Skip to content

Commit db8500e

Browse files
authored
chore: minor contract fixes (#17984)
Addresses minor issues. - Adds check for chainid on the bloblib before allowing the test lookup - Removes unnecessary `RewardDistributor` storage on the rollup config (was not properly removed when the reward configuration was separated). - Return early in `RewardLib:_toShares` when result would be the same as in full execution - Removes unnecessary cast to bytes16 of value that is already bytes16
2 parents 750a8bd + 4d8c126 commit db8500e

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

l1-contracts/src/core/interfaces/IRollup.sol

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ struct RollupConfig {
8585
uint32 version;
8686
IERC20 feeAsset;
8787
IFeeJuicePortal feeAssetPortal;
88-
IRewardDistributor rewardDistributor;
8988
IVerifier epochProofVerifier;
9089
IInbox inbox;
9190
IOutbox outbox;

l1-contracts/src/core/libraries/rollup/BlobLib.sol

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ import {Vm} from "forge-std/Vm.sol";
2222
* The VM_ADDRESS (0x7109709ECfa91a80626fF3989D68f67F5b1DD12D) is a special address used to detect
2323
* when the contract is running in a Foundry test environment. This address is derived from
2424
* keccak256("hevm cheat code") and corresponds to Foundry's VM contract that provides testing utilities.
25-
* When VM_ADDRESS.code.length > 0, it indicates we're in a test environment, allowing the library to:
25+
* When block.chainid == 31337 && VM_ADDRESS.code.length > 0, it indicates we're in a test environment,
26+
* allowing the library to:
2627
* - Use Foundry's getBlobBaseFee() cheatcode instead of block.blobbasefee
2728
* - Use Foundry's getBlobhashes() cheatcode instead of the blobhash() opcode
2829
* This enables comprehensive testing of blob functionality without requiring actual blob transactions.
@@ -47,7 +48,7 @@ library BlobLib {
4748
* @return uint256 - The blob base fee
4849
*/
4950
function getBlobBaseFee() internal view returns (uint256) {
50-
if (VM_ADDRESS.code.length > 0) {
51+
if (block.chainid == 31_337 && VM_ADDRESS.code.length > 0) {
5152
return Vm(VM_ADDRESS).getBlobBaseFee();
5253
}
5354
return block.blobbasefee;
@@ -62,7 +63,7 @@ library BlobLib {
6263
* @return blobHash - The blob hash
6364
*/
6465
function getBlobHash(uint256 _index) internal view returns (bytes32 blobHash) {
65-
if (VM_ADDRESS.code.length > 0) {
66+
if (block.chainid == 31_337 && VM_ADDRESS.code.length > 0) {
6667
// We know that this one is ABHORRENT. But it should not exists, and only will
6768
// be hit in testing.
6869
bytes32[] memory blobHashes = Vm(VM_ADDRESS).getBlobhashes();

l1-contracts/src/core/messagebridge/Inbox.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ contract Inbox is IInbox {
114114

115115
bytes16 updatedRollingHash = bytes16(keccak256(abi.encodePacked(rollingHash, leaf)));
116116
state = InboxState({
117-
rollingHash: bytes16(updatedRollingHash),
117+
rollingHash: updatedRollingHash,
118118
totalMessagesInserted: totalMessagesInserted + 1,
119119
inProgress: inProgress
120120
});

l1-contracts/src/core/reward-boost/RewardBooster.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ contract RewardBooster is IBooster {
115115
}
116116

117117
function _toShares(uint256 _value) internal view returns (uint256) {
118-
if (_value > CONFIG_MAX_SCORE) {
118+
if (_value >= CONFIG_MAX_SCORE) {
119119
return CONFIG_K;
120120
}
121121
uint256 t = (CONFIG_MAX_SCORE - _value);

0 commit comments

Comments
 (0)