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
164 changes: 164 additions & 0 deletions .mise-tasks/dev-check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
#!/usr/bin/env bash

#MISE description="Developers' local tests"
#MISE alias="dc"

set -e
# Inherit ERR trap in functions/subshells and catch pipeline failures
set -E -o pipefail
SECONDS=0

error_handler() {
local rc=$?
local cmd=${BASH_COMMAND:-unknown}
local where
where=$(caller 0 2>/dev/null || true)
halt "Command failed (exit $rc): ${cmd} | at: ${where}"
}

trap 'error_handler' ERR

# Graceful halt helper: print error, show total time, stop script without closing terminal
halt() {
echo "Error: $*" >&2
echo "Execution time: ${SECONDS} seconds"
# remove ERR trap to avoid double messaging
trap - ERR
# If sourced use return, else exit with success code (0) to not signal failure
return 0 2>/dev/null || exit 0
}

# Environment verify
echo "==========Checking environment..."
# mise install

if [ -z "${MISE_SHELL:-}" ]; then
if [ -n "${ZSH_VERSION:-}" ]; then
eval "$(mise activate zsh)"
elif [ -n "${BASH_VERSION:-}" ]; then
eval "$(mise activate bash)"
fi
fi

echo "Current branch: $(git rev-parse --abbrev-ref HEAD)" >&2
if [ -n "$(git status --porcelain)" ]; then
echo "WARN: Working tree not clean. Commit/stash changes first." >&2
git status --porcelain
exit 1
fi

echo "==========Checking environment done"

# Updating dependencies in contracts lib
pushd packages/contracts-bedrock > /dev/null
forge install

# contracts-bedrock-build
just clean && just forge-build --deny-warnings --skip test

# contracts-bedrock-checks
for cmd in \
check-kontrol-summaries-unchanged \
semgrep-test-validity-check \
semgrep \
semver-lock-no-build \
semver-diff-check-no-build \
validate-deploy-configs \
lint \
snapshots-check-no-build \
interfaces-check-no-build \
reinitializer-check-no-build \
size-check \
unused-imports-check-no-build \
validate-spacers-no-build \
opcm-upgrade-checks-no-build; do
git reset --hard
git clean -df
echo "==========Running just $cmd..."
just $cmd
echo "==========just $cmd done"
git status --porcelain
[ -z "$(git status --porcelain)" ] || exit 1
done

popd > /dev/null

# diff-fetcher-forge-artifacts
echo "==========Running diff-fetcher-forge-artifacts..."
git reset --hard
git clean -df
pushd op-fetcher > /dev/null
just build-contracts
popd > /dev/null
diff -qr "packages/contracts-bedrock/forge-artifacts/FetchChainInfo.s.sol" \
"op-fetcher/pkg/fetcher/fetch/forge-artifacts/FetchChainInfo.s.sol"

if [ $? -ne 0 ]; then
echo "ERROR: The checked-in forge artifacts for FetchChainInfo.s.sol do not match the ci build."
echo "Please run 'cd op-fetcher && just build-contracts' and commit the changes."
exit 1
fi

echo "==========diff-fetcher-forge-artifacts check done"

# diff-asterisc-bytecode
echo "==========Running diff-asterisc-bytecode..."
git reset --hard
git clean -df

pushd packages/contracts-bedrock > /dev/null

# Clone asterisc @ the pinned version to fetch remote `RISCV.sol`
ASTERISC_REV="v$(yq '.tools.asterisc' ../../mise.toml)"
REMOTE_ASTERISC_PATH="./src/vendor/asterisc/RISCV_Remote.sol"

git -c advice.detachedHead=false clone https://github.com/ethereum-optimism/asterisc \
-b "$ASTERISC_REV" \
./asterisc

cp ./asterisc/rvsol/src/RISCV.sol "$REMOTE_ASTERISC_PATH"

# Replace import paths
sed -i -e 's/@optimism\///' "$REMOTE_ASTERISC_PATH"
# Replace legacy interface paths
sed -i -e 's/src\/cannon\/interfaces\//interfaces\/cannon\//g' "$REMOTE_ASTERISC_PATH"
sed -i -e 's/src\/dispute\/interfaces\//interfaces\/dispute\//g' "$REMOTE_ASTERISC_PATH"
# Replace contract name
sed -i -e 's/contract RISCV/contract RISCV_Remote/' "$REMOTE_ASTERISC_PATH"

# Install deps
forge install

# Diff bytecode, with both contracts compiled in the local environment.
REMOTE_ASTERISC_CODE="$(forge inspect RISCV_Remote bytecode | tr -d '\n')"
LOCAL_ASTERISC_CODE="$(forge inspect RISCV bytecode | tr -d '\n')"

if [ "$REMOTE_ASTERISC_CODE" != "$LOCAL_ASTERISC_CODE" ]; then
echo "Asterisc bytecode mismatch. Local version does not match remote. Diff:"
diff <(echo "$REMOTE_ASTERISC_CODE") <(echo "$LOCAL_ASTERISC_CODE")
popd > /dev/null
exit 1
fi
rm -rf ./asterisc
popd > /dev/null
echo "==========diff-asterisc-bytecode check done"

git reset --hard
git clean -df

# semgrep-scan-local
echo "==========Running semgrep-scan-local..."
semgrep scan --timeout=100 --config .semgrep/rules/ --error .
echo "==========semgrep-scan-local done"

# semgrep-test
echo "==========Running semgrep-test..."
semgrep scan --test --config .semgrep/rules/ .semgrep/tests/
echo "==========semgrep-test done"

# go-lint
echo "==========Running go-lint (make lint-go)..."
make lint-go
echo "==========go-lint done"

echo "Execution time: $((SECONDS / 60)) minute(s) and $((SECONDS % 60)) second(s)"
2 changes: 2 additions & 0 deletions op-chain-ops/interopgen/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,8 @@ func GenesisL2(l2Host *script.Host, cfg *L2Config, deployment *L2Deployment, mul
DeployCrossL2Inbox: multichainDepSet,
EnableGovernance: cfg.EnableGovernance,
FundDevAccounts: cfg.FundDevAccounts,
DeploySoulGasToken: false,
IsSoulBackedByNative: false,
}); err != nil {
return fmt.Errorf("failed L2 genesis: %w", err)
}
Expand Down
5 changes: 5 additions & 0 deletions packages/contracts-bedrock/interfaces/L1/IOptimismPortal2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,16 @@ interface IOptimismPortal2 is IProxyAdminOwnedBase {
error OptimismPortal_ProofNotOldEnough();
error OptimismPortal_Unproven();
error OptimismPortal_InvalidLockboxState();
error OptimismPortal_Unauthorized();
error OptimismPortal_NativeDepositForbidden();
error OutOfGas();
error UnexpectedList();
error UnexpectedString();

event Initialized(uint8 version);
event NativeDepositEnabled();
event NativeDepositDisabled();
event MinterSet(address indexed minter);
event TransactionDeposited(address indexed from, address indexed to, uint256 indexed version, bytes opaqueData);
event WithdrawalFinalized(bytes32 indexed withdrawalHash, bool success);
event WithdrawalProven(bytes32 indexed withdrawalHash, address indexed from, address indexed to);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
pragma solidity ^0.8.0;

interface IL2ToL1MessagePasser {
event NativeDepositEnabled();
event NativeDepositDisabled();
error L2ToL1MessagePasser_NativeDepositDisabled();

event MessagePassed(
uint256 indexed nonce,
address indexed sender,
Expand Down
10 changes: 9 additions & 1 deletion packages/contracts-bedrock/scripts/deploy/ChainAssertions.sol
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,15 @@ library ChainAssertions {
require(config.scalar() >> 248 == 1, "CHECK-SCFG-70");
// Depends on start block being set to 0 in `initialize`
require(config.startBlock() == block.number, "CHECK-SCFG-140");
require(config.batchInbox() == (_doi.batchInbox() == address(0) ? _doi.opcm().chainIdToBatchInboxAddress(_doi.l2ChainId()) : _doi.batchInbox()), "CHECK-SCFG-150");
require(
config.batchInbox()
== (
_doi.batchInbox() == address(0)
? _doi.opcm().chainIdToBatchInboxAddress(_doi.l2ChainId())
: _doi.batchInbox()
),
"CHECK-SCFG-150"
);
// Check _addresses
require(config.l1CrossDomainMessenger() == _contracts.L1CrossDomainMessenger, "CHECK-SCFG-160");
require(config.l1ERC721Bridge() == _contracts.L1ERC721Bridge, "CHECK-SCFG-170");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,7 @@ contract UpgradeAnchorStateRegistry is Script {
_startingAnchorRoot
);
vm.stopBroadcast();
checkOutput(
IAnchorStateRegistry(_anchorStateRegistryProxy),
GameType.wrap(_type),
_startingAnchorRoot
);
checkOutput(IAnchorStateRegistry(_anchorStateRegistryProxy), GameType.wrap(_type), _startingAnchorRoot);
}

function upgradeAnchorStateRegistryImpl(
Expand All @@ -73,7 +69,9 @@ contract UpgradeAnchorStateRegistry is Script {
address anchorStateRegistryImpl = DeployUtils.create1({
_name: "AnchorStateRegistry",
_args: DeployUtils.encodeConstructor(
abi.encodeCall(IAnchorStateRegistry.__constructor__, (_anchorStateRegistryProxy.disputeGameFinalityDelaySeconds()))
abi.encodeCall(
IAnchorStateRegistry.__constructor__, (_anchorStateRegistryProxy.disputeGameFinalityDelaySeconds())
)
)
});

Expand Down Expand Up @@ -106,7 +104,9 @@ contract UpgradeAnchorStateRegistry is Script {
virtual
returns (bytes memory)
{
return abi.encodeCall(IAnchorStateRegistry.initialize, (_systemConfig, _disputeGameFactory, _startingAnchorRoot, _type));
return abi.encodeCall(
IAnchorStateRegistry.initialize, (_systemConfig, _disputeGameFactory, _startingAnchorRoot, _type)
);
}

/// @notice Makes an external call to the target to initialize the proxy with the specified data.
Expand Down Expand Up @@ -135,8 +135,14 @@ contract UpgradeAnchorStateRegistry is Script {
view
{
(Hash root, uint256 l2BlockNumber) = IAnchorStateRegistry(_anchorStateRegistryProxy).anchors(_type);
require(Hash.unwrap(root) == Hash.unwrap(_startingAnchorRoot.root), "UpgradeAnchorStateRegistryOutput: root mismatch");
require(l2BlockNumber == _startingAnchorRoot.l2SequenceNumber, "UpgradeAnchorStateRegistryOutput: l2BlockNumber mismatch");
require(
Hash.unwrap(root) == Hash.unwrap(_startingAnchorRoot.root),
"UpgradeAnchorStateRegistryOutput: root mismatch"
);
require(
l2BlockNumber == _startingAnchorRoot.l2SequenceNumber,
"UpgradeAnchorStateRegistryOutput: l2BlockNumber mismatch"
);
}

function bytes32ToHex(bytes32 _data) internal pure returns (string memory) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ import { Script } from "forge-std/Script.sol";
// Scripts
import { DeployUtils } from "scripts/libraries/DeployUtils.sol";

// Contracts
import { StorageSetter } from "src/universal/StorageSetter.sol";

// Interfaces
import { IProxyAdmin } from "interfaces/universal/IProxyAdmin.sol";
import { IStorageSetter } from "interfaces/universal/IStorageSetter.sol";
Expand Down
30 changes: 30 additions & 0 deletions packages/contracts-bedrock/snapshots/abi/L2ToL1MessagePasser.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,19 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bool",
"name": "_disable",
"type": "bool"
}
],
"name": "setNativeDeposit",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "version",
Expand Down Expand Up @@ -140,6 +153,18 @@
"name": "MessagePassed",
"type": "event"
},
{
"anonymous": false,
"inputs": [],
"name": "NativeDepositDisabled",
"type": "event"
},
{
"anonymous": false,
"inputs": [],
"name": "NativeDepositEnabled",
"type": "event"
},
{
"anonymous": false,
"inputs": [
Expand All @@ -152,5 +177,10 @@
],
"name": "WithdrawerBalanceBurnt",
"type": "event"
},
{
"inputs": [],
"name": "L2ToL1MessagePasser_NativeDepositDisabled",
"type": "error"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,11 @@
"internalType": "Duration",
"name": "disputeMaxClockDuration",
"type": "uint64"
},
{
"internalType": "address",
"name": "batchInbox",
"type": "address"
}
],
"internalType": "struct OPContractsManager.DeployInput",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,11 @@
"internalType": "Duration",
"name": "disputeMaxClockDuration",
"type": "uint64"
},
{
"internalType": "address",
"name": "batchInbox",
"type": "address"
}
],
"internalType": "struct OPContractsManager.DeployInput",
Expand Down
Loading