diff --git a/test-pp-op/2-deploy-op-contracts.sh b/test-pp-op/2-deploy-op-contracts.sh index a9bd6038bc2e3..c37bdde90bce2 100755 --- a/test-pp-op/2-deploy-op-contracts.sh +++ b/test-pp-op/2-deploy-op-contracts.sh @@ -74,7 +74,7 @@ deploy_transactor() { echo "DOCKER_NETWORK: $DOCKER_NETWORK" echo "L1_RPC_URL_IN_DOCKER: $L1_RPC_URL_IN_DOCKER" echo "DEPLOYER_PRIVATE_KEY: ${DEPLOYER_PRIVATE_KEY:0:10}..." - echo "ADMIN_OWNER_ADDRESS: $ADMIN_OWNER_ADDRESS" + echo "DEPLOYER_ADDRESS: $DEPLOYER_ADDRESS" echo "OP_CONTRACTS_IMAGE_TAG: $OP_CONTRACTS_IMAGE_TAG" # Build docker run command with conditional network flag @@ -98,7 +98,7 @@ deploy_transactor() { --rpc-url $L1_RPC_URL_IN_DOCKER \ --private-key $DEPLOYER_PRIVATE_KEY \ src/periphery/Transactor.sol:Transactor.0.8.30 \ - --constructor-args $ADMIN_OWNER_ADDRESS" + --constructor-args $DEPLOYER_ADDRESS" echo "🔧 Executing Docker command..." echo "Command: docker run ${DOCKER_ARGS[*]} $FORGE_CMD" @@ -365,6 +365,55 @@ deploy_custom_gas_token() { fi echo "" + # Set init bond for game type 1 + set_init_bond + + # Transfer Transactor ownership + echo "🔧 Transferring Transactor ownership..." + echo "" + + # Check current Transactor owner + CURRENT_TRANSACTOR_OWNER=$(cast call "$TRANSACTOR_ADDRESS" "owner()(address)" --rpc-url "$L1_RPC_URL") + echo "📋 Current Transactor owner: $CURRENT_TRANSACTOR_OWNER" + echo "📋 Target owner: $ADMIN_OWNER_ADDRESS" + + if [ "$CURRENT_TRANSACTOR_OWNER" != "$ADMIN_OWNER_ADDRESS" ]; then + echo "🔄 Transferring Transactor ownership to $ADMIN_OWNER_ADDRESS..." + + cast send "$TRANSACTOR_ADDRESS" \ + "setOwner(address)" \ + "$ADMIN_OWNER_ADDRESS" \ + --rpc-url "$L1_RPC_URL" \ + --private-key "$DEPLOYER_PRIVATE_KEY" + + # Verify transfer + NEW_TRANSACTOR_OWNER=$(cast call "$TRANSACTOR_ADDRESS" "owner()(address)" --rpc-url "$L1_RPC_URL") + echo "✅ Transactor ownership transferred to: $NEW_TRANSACTOR_OWNER" + else + echo "✅ Transactor already owned by $ADMIN_OWNER_ADDRESS" + fi + echo "" + +} + +set_init_bond() { + echo "🔧 Setting init bond for game type 1..." + echo "" + + # Get DisputeGameFactory address from state.json + DISPUTE_GAME_FACTORY_ADDRESS=$(cat ./config-op/state.json | jq -r '.opChainDeployments[0].DisputeGameFactoryProxy') + echo "📋 DisputeGameFactory Address: $DISPUTE_GAME_FACTORY_ADDRESS" + + # Set init bond using the script + bash ./scripts/set-init-bond.sh \ + --game-type 1 \ + --init-bond $INITIAL_BOND \ + --transactor $TRANSACTOR_ADDRESS \ + --dispute-game-factory $DISPUTE_GAME_FACTORY_ADDRESS \ + --private-key $DEPLOYER_PRIVATE_KEY \ + --rpc-url $L1_RPC_URL + + echo "" } echo "CGT_ENABLED: ${CGT_ENABLED}" diff --git a/test-pp-op/local.env b/test-pp-op/local.env index e49725db66b62..38e5dc5d1a020 100644 --- a/test-pp-op/local.env +++ b/test-pp-op/local.env @@ -97,6 +97,9 @@ PROXY_ADMIN=0x88c87adaf76a638cd81286b23b5830a7d6ffb80d # Upgrade l2 ger contract TIME_LOCK_DELAY=70 +# Set initial bond +INITIAL_BOND=10000000000 + # First game only for update anchor root TEMP_MAX_CLOCK_DURATION=40 TEMP_CLOCK_EXTENSION=5 diff --git a/test-pp-op/scripts/set-init-bond.sh b/test-pp-op/scripts/set-init-bond.sh new file mode 100755 index 0000000000000..cac10d0149acf --- /dev/null +++ b/test-pp-op/scripts/set-init-bond.sh @@ -0,0 +1,152 @@ +#!/bin/bash + +set -e + +# Function to display usage +usage() { + echo "Usage: $0 [OPTIONS]" + echo "Options:" + echo " --game-type TYPE Game type (uint32) (required)" + echo " --init-bond WEI Initial bond amount in wei (required)" + echo " --transactor ADDRESS Transactor contract address (required)" + echo " --dispute-game-factory ADDRESS DisputeGameFactory contract address (required)" + echo " --private-key KEY Private key for transaction (required)" + echo " --rpc-url URL RPC URL (required)" + echo " --help Show this help message" + echo "" + echo "Example:" + echo " $0 --game-type 1 --init-bond 1000000000000000000 --transactor 0x456... --dispute-game-factory 0xabc... --private-key 0xdef... --rpc-url https://..." + exit 1 +} + +# Parse command line arguments +while [[ $# -gt 0 ]]; do + case $1 in + --game-type) + GAME_TYPE="$2" + shift 2 + ;; + --init-bond) + INIT_BOND="$2" + shift 2 + ;; + --transactor) + TRANSACTOR_ADDRESS="$2" + shift 2 + ;; + --dispute-game-factory) + DISPUTE_GAME_FACTORY="$2" + shift 2 + ;; + --private-key) + PRIVATE_KEY="$2" + shift 2 + ;; + --rpc-url) + RPC_URL="$2" + shift 2 + ;; + --help) + usage + ;; + *) + echo "Unknown option: $1" + usage + ;; + esac +done + +# Validate required parameters +if [[ -z "$GAME_TYPE" || -z "$INIT_BOND" || -z "$TRANSACTOR_ADDRESS" || -z "$DISPUTE_GAME_FACTORY" || -z "$PRIVATE_KEY" || -z "$RPC_URL" ]]; then + echo "Error: Missing required parameters" + echo "" + usage +fi + +echo "=== Setting Init Bond via Transactor ===" +echo "Game Type: $GAME_TYPE" +echo "Init Bond: $INIT_BOND wei" +echo "Dispute Game Factory: $DISPUTE_GAME_FACTORY" +echo "Transactor Address: $TRANSACTOR_ADDRESS" +echo "RPC URL: $RPC_URL" +echo "" + +# Get sender address from private key +SENDER_ADDRESS=$(cast wallet address --private-key $PRIVATE_KEY) +echo "Sender Address: $SENDER_ADDRESS" +echo "" + +# Check if game type exists +echo "Checking if game type exists..." +GAME_IMPL=$(cast call --rpc-url $RPC_URL $DISPUTE_GAME_FACTORY "gameImpls(uint32)(address)" $GAME_TYPE) +echo "Game Type $GAME_TYPE Implementation: $GAME_IMPL" + +if [ "$GAME_IMPL" == "0x0000000000000000000000000000000000000000" ]; then + echo "Error: Game type $GAME_TYPE does not exist. Cannot set init bond." + exit 1 +fi + +# Get current init bond for comparison +echo "Retrieving current init bond..." +CURRENT_INIT_BOND_RAW=$(cast call --rpc-url $RPC_URL $DISPUTE_GAME_FACTORY "initBonds(uint32)(uint256)" $GAME_TYPE) +CURRENT_INIT_BOND=$(echo $CURRENT_INIT_BOND_RAW | sed 's/\[.*\]//' | xargs) +echo "Current Init Bond: $CURRENT_INIT_BOND wei" + +if [ "$CURRENT_INIT_BOND" == "$INIT_BOND" ]; then + echo "Warning: New init bond is the same as current init bond. No change needed." + exit 0 +fi + +echo "Creating setInitBond calldata..." +echo "Game Type: $GAME_TYPE" +echo "New Init Bond: $INIT_BOND wei" + +# Create calldata for setInitBond function +SETINITBOND_CALLDATA=$(cast calldata "setInitBond(uint32,uint256)" $GAME_TYPE $INIT_BOND) + +echo "SetInitBond calldata: $SETINITBOND_CALLDATA" +echo "" + +# Create calldata for Transactor's DELEGATECALL function +echo "Creating Transactor CALL calldata..." +TRANSACTOR_CALLDATA=$(cast calldata "CALL(address,bytes,uint256)" $DISPUTE_GAME_FACTORY $SETINITBOND_CALLDATA 0) + +echo "Transactor calldata: $TRANSACTOR_CALLDATA" +echo "" + +# Execute the transaction through Transactor +echo "Executing transaction via Transactor..." +echo "Target: $TRANSACTOR_ADDRESS" +echo "From: $SENDER_ADDRESS" + +cast send \ + --rpc-url $RPC_URL \ + --private-key $PRIVATE_KEY \ + --from $SENDER_ADDRESS \ + $TRANSACTOR_ADDRESS \ + $TRANSACTOR_CALLDATA \ + --json |jq + +echo "" +echo "Transaction sent! Check the transaction hash above for confirmation." +echo "" + +# Verify the init bond was updated +echo "Verifying init bond was updated..." +NEW_INIT_BOND=$(cast call --rpc-url $RPC_URL $DISPUTE_GAME_FACTORY "initBonds(uint32)(uint256)" $GAME_TYPE) + +# Extract the numeric value from the response (remove scientific notation and trim spaces) +NEW_INIT_BOND_NUMERIC=$(echo $NEW_INIT_BOND | sed 's/\[.*\]//' | xargs) + +if [ "$NEW_INIT_BOND_NUMERIC" == "$INIT_BOND" ]; then + echo "✅ Success! Init bond updated successfully." + echo "Previous Init Bond: $CURRENT_INIT_BOND wei" + echo "Game Type $GAME_TYPE Init Bond updated to: $NEW_INIT_BOND_NUMERIC wei" +else + echo "❌ Warning: Init bond was not updated as expected." + echo "Expected: $INIT_BOND wei" + echo "Actual: $NEW_INIT_BOND_NUMERIC wei" +fi + +echo "" +echo "Script completed."