Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: unify solady #412

Merged
merged 1 commit into from
Feb 27, 2025
Merged
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
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
[submodule "contracts/lib/openzeppelin-contracts-upgradeable"]
path = contracts/lib/openzeppelin-contracts-upgradeable
url = https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable
[submodule "contracts/lib/solady-v0.0.281"]
path = contracts/lib/solady-v0.0.281
url = https://github.com/vectorized/solady
[submodule "contracts/lib/lib-keccak"]
path = contracts/lib/lib-keccak
url = https://github.com/ethereum-optimism/lib-keccak
1 change: 0 additions & 1 deletion contracts/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ remappings = [
"@optimism/=lib/optimism/packages/contracts-bedrock/",
"@forge-std/=lib/forge-std/src/",
"@solady/=lib/solady/src",
"@solady-v0.0.281/=lib/solady-v0.0.281/src",
# Note: Use zobront/sp1-contracts as the current version for SP1 contracts is not compatible with the hard
# version for 0.8.15 on some Optimism contracts.
"@sp1-contracts/=lib/sp1-contracts/contracts/",
Expand Down
1 change: 0 additions & 1 deletion contracts/lib/solady-v0.0.281
Submodule solady-v0.0.281 deleted from d355d1
34 changes: 26 additions & 8 deletions contracts/src/validity/OPSuccinctDisputeGame.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@
pragma solidity ^0.8.15;

import {OPSuccinctL2OutputOracle} from "./OPSuccinctL2OutputOracle.sol";
import {CWIA} from "@solady-v0.0.281/utils/legacy/CWIA.sol";
import {LibBytes} from "@solady-v0.0.281/utils/LibBytes.sol";
import {Clone} from "@solady/utils/Clone.sol";
import {ISemver} from "interfaces/universal/ISemver.sol";
import {IDisputeGame} from "interfaces/dispute/IDisputeGame.sol";
import {Claim, GameStatus, GameType, GameTypes, Hash, Timestamp} from "@optimism/src/dispute/lib/Types.sol";
import {GameNotInProgress, OutOfOrderResolution} from "@optimism/src/dispute/lib/Errors.sol";

contract OPSuccinctDisputeGame is ISemver, CWIA, IDisputeGame {
using LibBytes for bytes;

contract OPSuccinctDisputeGame is ISemver, Clone, IDisputeGame {
////////////////////////////////////////////////////////////////
// Events //
////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -97,10 +94,31 @@ contract OPSuccinctDisputeGame is ISemver, CWIA, IDisputeGame {

/// @notice Getter for the extra data.
/// @dev `clones-with-immutable-args` argument #4
/// @return Any extra data supplied to the dispute game contract by the creator.
function extraData() public pure returns (bytes memory) {
/// @return extraData_ Any extra data supplied to the dispute game contract by the creator.
function extraData() public pure returns (bytes memory extraData_) {
// The extra data starts at the second word within the cwia calldata
return _getArgBytes().slice(0x54);
uint256 offset = _getImmutableArgsOffset();
/// @solidity memory-safe-assembly
assembly {
// Calculate the starting position (offset + 0x54)
let startPos := add(offset, 0x54)
// Calculate length (total calldata size minus the starting position)
let length := sub(calldatasize(), startPos)

// Allocate memory for the result
extraData_ := mload(0x40)
// Store the length
mstore(extraData_, length)
// Copy the calldata starting from offset+0x54
calldatacopy(add(extraData_, 0x20), startPos, length)

// Zeroize the slot after the bytes
let endPos := add(add(extraData_, 0x20), length)
mstore(endPos, 0)

// Update the free memory pointer
mstore(0x40, add(endPos, 0x20))
}
}

/// @notice If all necessary information has been gathered, this function should mark the game
Expand Down
4 changes: 2 additions & 2 deletions contracts/test/validity/OPSuccinctDisputeGame.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import {Utils} from "../helpers/Utils.sol";
import {OPSuccinctL2OutputOracle} from "../../src/validity/OPSuccinctL2OutputOracle.sol";
import {OPSuccinctDisputeGame} from "../../src/validity/OPSuccinctDisputeGame.sol";
import {IDisputeGame} from "interfaces/dispute/IDisputeGame.sol";
import {LibCWIA} from "@solady-v0.0.281/utils/legacy/LibCWIA.sol";
import {LibClone} from "@solady/utils/LibClone.sol";

contract OPSuccinctL2OutputOracleTest is Test, Utils {
using LibCWIA for address;
using LibClone for address;

// Example proof data for the BoB testnet. Tx: https://sepolia.etherscan.io/tx/0x35df99dce5db3d7644a005bd582af2d66533b56fdb01970f248d96e8053fc0ba
uint256 checkpointedL1BlockNum = 7438547;
Expand Down
4 changes: 2 additions & 2 deletions contracts/test/validity/OPSuccinctDisputeGameFactory.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {Utils} from "../helpers/Utils.sol";

// Libraries
import {IDisputeGame} from "interfaces/dispute/IDisputeGame.sol";
import {LibCWIA} from "@solady-v0.0.281/utils/legacy/LibCWIA.sol";
import {LibClone} from "@solady/utils/LibClone.sol";

import {GameType, Claim} from "src/dispute/lib/Types.sol";

Expand All @@ -18,7 +18,7 @@ import {OPSuccinctDisputeGame} from "../../src/validity/OPSuccinctDisputeGame.so
import {DisputeGameFactory} from "src/dispute/DisputeGameFactory.sol";

contract OPSuccinctDisputeGameFactoryTest is Test, Utils {
using LibCWIA for address;
using LibClone for address;

// Example proof data for the BoB testnet. Tx: https://sepolia.etherscan.io/tx/0x35df99dce5db3d7644a005bd582af2d66533b56fdb01970f248d96e8053fc0ba
uint256 checkpointedL1BlockNum = 7438547;
Expand Down
Loading