Skip to content
Open
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
29 changes: 29 additions & 0 deletions foundry.lock
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should explain what this file is in the PR description. Also, do we still need the gitmodules file with this, or should it be deleted?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"lib/base-contracts": {
"rev": "7cca28be0f94134f9de1c6f409779b57d5f269b7"
},
"lib/forge-std": {
"rev": "3b20d60d14b343ee4f908cb8079495c07f5e8981"
},
"lib/openzeppelin-contracts": {
"rev": "fd81a96f01cc42ef1c9a5399364968d0e07e9e90"
},
"lib/optimism": {
"branch": {
"name": "develop",
"rev": "a10fd5259a3af9a465955b035e16f516327d51d5"
}
},
"lib/safe-contracts": {
"rev": "186a21a74b327f17fc41217a927dea7064f74604"
},
"lib/solady": {
"rev": "513f581675374706dbe947284d6b12d19ce35a2a"
},
"lib/solmate": {
"rev": "e8f96f25d48fe702117ce76c79228ca4f20206cb"
},
"lib/superchain-registry": {
"rev": "58b8ea0b875dcab6e7132a2d388c5c098ee6fac3"
}
}
30 changes: 19 additions & 11 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,30 @@ fs_permissions = [{ access = "read-write", path = "./" }]
gas_limit = "18446744073709551615" # max allowable value, which is max uint64
ffi = true # Enable FFI for reading lib/superchain-registry files in scripts SignFromJson.s.sol, NestedSignFromJson.s.sol within tasks
no_match_coverage = 'src/template/boilerplate/|script/|src/JsonTxBuilderBase.sol|test'
# Temporarily disabled for Foundry v1.4.3 upgrade. Protection prevents address(this) usage in scripts to avoid accidental misuse.
# See https://github.com/foundry-rs/foundry/issues/10289. Will be removed in a future PR.
script_execution_protection = false
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also a good thing to explain or link to docs about for reviewers in the PR description

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done here 9b708fd

Comment thread
AmadiMichael marked this conversation as resolved.

remappings = [
'@openzeppelin/contracts-upgradeable/=lib/optimism/packages/contracts-bedrock/lib/openzeppelin-contracts-upgradeable/contracts/',
'@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts',
'@base-contracts/=lib/base-contracts/',
'@eth-optimism-bedrock/=lib/optimism/packages/contracts-bedrock/',
'@rari-capital/solmate/=lib/solmate',
'@eth-optimism-superchain-registry/=lib/superchain-registry/',
'@solady/=lib/optimism/packages/contracts-bedrock/lib/solady/src/',
'@lib-keccak/=lib/optimism/packages/contracts-bedrock/lib/lib-keccak/contracts/lib/',
'ds-test/=lib/optimism/packages/contracts-bedrock/lib/forge-std/lib/ds-test/src',
'forge-std/=lib/forge-std/src/'
"@openzeppelin/contracts-upgradeable/=lib/optimism/packages/contracts-bedrock/lib/openzeppelin-contracts-upgradeable/contracts/",
"@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
"@base-contracts/=lib/base-contracts/",
"@eth-optimism-bedrock/=lib/optimism/packages/contracts-bedrock/",
"@rari-capital/solmate/=lib/solmate/",
"@eth-optimism-superchain-registry/=lib/superchain-registry/",
"@solady/=lib/optimism/packages/contracts-bedrock/lib/solady/src/",
"@lib-keccak/=lib/optimism/packages/contracts-bedrock/lib/lib-keccak/contracts/lib/",
"ds-test/=lib/optimism/packages/contracts-bedrock/lib/forge-std/lib/ds-test/src/",
"forge-std/=lib/forge-std/src/",
"solady/=lib/optimism/packages/contracts-bedrock/lib/solady/src/",
"safe-contracts/=lib/optimism/packages/contracts-bedrock/lib/safe-contracts/contracts/"
]

[lint]
exclude_lints = ["unused-import", "unsafe-cheatcode", "unsafe-typecast", "asm-keccak256", "unaliased-plain-import", "mixed-case-variable", "pascal-case-struct", "mixed-case-function", "screaming-snake-case-const", "unwrapped-modifier-logic", "named-struct-fields"]

[profile.ci]
deny_warnings = true
deny = "warnings"

[profile.ci.rpc_endpoints]
mainnet = "https://ci-mainnet-l1-archive.optimism.io"
Expand Down
6 changes: 3 additions & 3 deletions mise.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ fzf = "0.65.0"
# The git ref here should be on the `stable` branch.
# WARNING: DO NOT CHANGE FORGE/CAST/ANVIL VERSIONS UNLESS ABSOLUTELY NECESSARY!
# The forge release below includes a fix for: https://github.com/foundry-rs/foundry/issues/10302
forge = "v1.1.0" # https://github.com/foundry-rs/foundry/releases/tag/v1.1.0
cast = "v1.1.0"
anvil = "v1.1.0"
forge = "v1.4.3" # https://github.com/foundry-rs/foundry/releases/tag/v1.4.3
cast = "v1.4.3"
anvil = "v1.4.3"

[alias]
forge = "ubi:foundry-rs/foundry[exe=forge]"
Expand Down
12 changes: 8 additions & 4 deletions src/SuperchainAddressRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ contract SuperchainAddressRegistry is StdChains {
constructor(string memory configPath) {
require(
block.chainid == getChain("mainnet").chainId || block.chainid == getChain("sepolia").chainId
|| block.chainid == getChain("optimism_sepolia").chainId || block.chainid == getChain("optimism").chainId,
|| block.chainid == getChain("optimism_sepolia").chainId
|| block.chainid == getChain("optimism").chainId,
string.concat("SuperchainAddressRegistry: Unsupported task chain ID ", vm.toString(block.chainid))
);

Expand Down Expand Up @@ -203,9 +204,12 @@ contract SuperchainAddressRegistry is StdChains {
}

/// @notice Saves an address to the registry.
function saveAddress(string memory identifier, ChainInfo memory chain, address addr, string[] memory allowOverwrite)
public
{
function saveAddress(
string memory identifier,
ChainInfo memory chain,
address addr,
string[] memory allowOverwrite
) public {
require(addr != address(0), string.concat("SuperchainAddressRegistry: zero address for ", identifier));
require(bytes(identifier).length > 0, "SuperchainAddressRegistry: empty key");
// If we have overwrites, then we should check if we are allowed to overwrite the current address.
Expand Down
3 changes: 1 addition & 2 deletions src/interfaces/IFeeVault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ interface IFeeVault {
L2
}

function initialize(address _recipient, uint256 _minWithdrawalAmount, WithdrawalNetwork _withdrawalNetwork)
external;
function initialize(address _recipient, uint256 _minWithdrawalAmount, WithdrawalNetwork _withdrawalNetwork) external;

function RECIPIENT() external view returns (address);
function MIN_WITHDRAWAL_AMOUNT() external view returns (uint256);
Expand Down
25 changes: 9 additions & 16 deletions src/libraries/AccountAccessParser.sol
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,8 @@ library AccountAccessParser {
bytes32 _txHash
) internal view noGasMetering {
console.log("");
string memory line = unicode"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━";
string memory line =
unicode"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━";
console.log(string("TASK TRANSFERS").cyan().bold());
console.log(line.cyan().bold());
if (_transfers.length == 0) {
Expand Down Expand Up @@ -411,8 +412,7 @@ library AccountAccessParser {
}

function printCopyHelper(string memory _text) internal view noGasMetering {
string memory line = unicode"━━━━━";
// forgefmt: disable-start
string memory line = unicode"━━━━━"; // forgefmt: disable-start
string memory helper = string.concat(line, " Attention: Copy content ", _text, " this line into the VALIDATION.md file. ", line);
// forgefmt: disable-end
console.log(helper.yellow().bold());
Expand Down Expand Up @@ -487,12 +487,10 @@ library AccountAccessParser {
);
require(access.kind != VmSafe.AccountAccessKind.Create, "ETH transfer with Create is not yet supported");
if (access.kind == VmSafe.AccountAccessKind.Call) {
return DecodedTransfer({
from: access.accessor,
to: access.account,
value: access.value,
tokenAddress: ETHER
});
return
DecodedTransfer({
from: access.accessor, to: access.account, value: access.value, tokenAddress: ETHER
});
} else {
require(access.kind == VmSafe.AccountAccessKind.DelegateCall, "Expected kind to be DelegateCall.");
console.log(
Expand Down Expand Up @@ -531,11 +529,7 @@ library AccountAccessParser {
}

/// @notice Given an address, returns the contract name and L2 chain ID for the contract.
function getContractInfo(address _address)
internal
view
returns (uint256 l2ChainId_, string memory contractName_)
{
function getContractInfo(address _address) internal view returns (uint256 l2ChainId_, string memory contractName_) {
string memory addrsPath = "/lib/superchain-registry/superchain/extra/addresses/addresses.json";
string memory path = string.concat(vm.projectRoot(), addrsPath);
return findContractByAddress(path, _address);
Expand Down Expand Up @@ -796,8 +790,7 @@ library AccountAccessParser {
for (uint256 j = 0; j < layouts.length; j++) {
DecodedSlot memory decoded = decodeSlot(layouts[j], _oldValue, _newValue);
if (!decoded.oldValue.eq(decoded.newValue)) {
string memory kind = string.concat("(`", decoded.kind, "`)");
// forgefmt: disable-next-line
string memory kind = string.concat("(`", decoded.kind, "`)"); // forgefmt: disable-next-line
detail = string.concat(detail, "", kind, " ", layouts[j]._label, " `", decoded.oldValue, "` &rarr; `", decoded.newValue, "`, ");
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/libraries/DecimalNormalization.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ library DecimalNormalization {

validateAmountComponents(components, tokenDecimals);

uint256 finalAmount = components.integer * (10 ** uint256(tokenDecimals))
+ components.decimal * (10 ** uint256(tokenDecimals - components.decimalPlaces));
uint256 finalAmount = components.integer * (10 ** uint256(tokenDecimals)) + components.decimal
* (10 ** uint256(tokenDecimals - components.decimalPlaces));

return finalAmount;
}
Expand Down
27 changes: 14 additions & 13 deletions src/libraries/GnosisSafeHashes.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity ^0.8.15;

import {LibString} from "@solady/utils/LibString.sol";
import {JSONParserLib} from "@solady/utils/JSONParserLib.sol";
import {GnosisSafe} from "lib/safe-contracts/contracts/GnosisSafe.sol";
import {GnosisSafe} from "safe-contracts/GnosisSafe.sol";
import {IMulticall3} from "forge-std/interfaces/IMulticall3.sol";
import {VmSafe} from "forge-std/Vm.sol";
import {IGnosisSafe, Enum} from "@base-contracts/script/universal/IGnosisSafe.sol";
Expand Down Expand Up @@ -236,18 +236,19 @@ library GnosisSafeHashes {
uint256 _originalNonce,
address _multicallAddress
) internal view returns (bytes memory encodedTxData) {
encodedTxData = IGnosisSafe(_safe).encodeTransactionData({
to: _multicallAddress,
value: _value,
data: _data,
operation: Enum.Operation.DelegateCall,
safeTxGas: 0,
baseGas: 0,
gasPrice: 0,
gasToken: address(0),
refundReceiver: address(0),
_nonce: _originalNonce
});
encodedTxData = IGnosisSafe(_safe)
.encodeTransactionData({
to: _multicallAddress,
value: _value,
data: _data,
operation: Enum.Operation.DelegateCall,
safeTxGas: 0,
baseGas: 0,
gasPrice: 0,
gasToken: address(0),
refundReceiver: address(0),
_nonce: _originalNonce
});
require(encodedTxData.length == 66, "GnosisSafeHashes: encodedTxData length is not 66 bytes.");
}

Expand Down
6 changes: 4 additions & 2 deletions src/libraries/MultisigTaskPrinter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,16 @@ library MultisigTaskPrinter {
function printTitle(string memory title) internal pure {
console.log("");
console.log(vm.toUppercase(title).cyan().bold());
string memory line = unicode"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━";
string memory line =
unicode"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━";
console.log(line.cyan().bold());
}

/// @notice Prints the welcome message and conditionally the developer attention preamble.
function printWelcomeMessage() internal view {
console.log("");
string memory line = unicode"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━";
string memory line =
unicode"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━";
console.log(line.cyan().bold());
console.log(" WELCOME TO SUPERCHAIN-OPS");
console.log(line.cyan().bold());
Expand Down
24 changes: 10 additions & 14 deletions src/libraries/RevShareCommon.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@ library RevShareCommon {
/// @param _salt Salt for CREATE2 deployment
/// @param _initCode Contract creation code (creationCode + constructor args)
function depositCreate2(address _portal, uint64 _gasLimit, bytes32 _salt, bytes memory _initCode) internal {
IOptimismPortal2(payable(_portal)).depositTransaction({
_to: CREATE2_DEPLOYER,
_value: 0,
_gasLimit: _gasLimit,
_isCreation: false,
_data: abi.encodeCall(ICreate2Deployer.deploy, (0, _salt, _initCode))
});
IOptimismPortal2(payable(_portal))
.depositTransaction({
_to: CREATE2_DEPLOYER,
_value: 0,
_gasLimit: _gasLimit,
_isCreation: false,
_data: abi.encodeCall(ICreate2Deployer.deploy, (0, _salt, _initCode))
});
}

/// @notice Calls a contract on L2 by depositing a transaction to the OptimismPortal2
Expand All @@ -46,13 +47,8 @@ library RevShareCommon {
/// @param _gasLimit Gas limit for the L2 transaction
/// @param _data Calldata for the L2 transaction
function depositCall(address _portal, address _target, uint64 _gasLimit, bytes memory _data) internal {
IOptimismPortal2(payable(_portal)).depositTransaction({
_to: _target,
_value: 0,
_gasLimit: _gasLimit,
_isCreation: false,
_data: _data
});
IOptimismPortal2(payable(_portal))
.depositTransaction({_to: _target, _value: 0, _gasLimit: _gasLimit, _isCreation: false, _data: _data});
}

/// @notice Generates a salt for CREATE2 deployments
Expand Down
2 changes: 1 addition & 1 deletion src/libraries/Utils.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;

import {VmSafe} from "lib/forge-std/src/Vm.sol";
import {VmSafe} from "forge-std/Vm.sol";
import {SafeData, TaskPayload} from "src/libraries/MultisigTypes.sol";
import {LibString} from "@solady/utils/LibString.sol";
import {IGnosisSafe} from "@base-contracts/script/universal/IGnosisSafe.sol";
Expand Down
25 changes: 13 additions & 12 deletions src/script/ComputeSafeOwnerSwapHash.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,19 @@ contract ComputeSafeOwnerSwapHash is Script {
(address prevOwner,) = findPreviousOwner(owners, _oldOwner);

uint256 nonce = IGnosisSafe(_safe).nonce();
txData_ = IGnosisSafe(_safe).encodeTransactionData({
to: _safe,
value: 0,
data: abi.encodeCall(IGnosisSafe(_safe).swapOwner, (prevOwner, _oldOwner, _newOwner)),
operation: Enum.Operation.Call,
safeTxGas: 0,
baseGas: 0,
gasPrice: 0,
gasToken: address(0),
refundReceiver: address(0),
_nonce: nonce
});
txData_ = IGnosisSafe(_safe)
.encodeTransactionData({
to: _safe,
value: 0,
data: abi.encodeCall(IGnosisSafe(_safe).swapOwner, (prevOwner, _oldOwner, _newOwner)),
operation: Enum.Operation.Call,
safeTxGas: 0,
baseGas: 0,
gasPrice: 0,
gasToken: address(0),
refundReceiver: address(0),
_nonce: nonce
});

txHash_ = keccak256(txData_);
}
Expand Down
Loading