Skip to content
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
53 changes: 51 additions & 2 deletions test-pp-op/2-deploy-op-contracts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand Down Expand Up @@ -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 $ROOT_DIR/test-pp-op/config-op/state.json | jq -r '.opChainDeployments[0].DisputeGameFactoryProxy')
echo "📋 DisputeGameFactory Address: $DISPUTE_GAME_FACTORY_ADDRESS"

# Set init bond using the script
bash $ROOT_DIR/test-pp-op/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}"
Expand Down
4 changes: 2 additions & 2 deletions test-pp-op/config-op/intent.fakemainnet.toml.bak
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ l2ContractsLocator = "file:///app/packages/contracts-bedrock/forge-artifacts"
eip1559Elasticity = 1
operatorFeeScalar = 0
operatorFeeConstant = 0
gasLimit = 30000000
gasLimit = 50000000
[chains.deployOverrides]
l2GenesisBlockGasLimit = "0x1C9C380"
l2GenesisBlockGasLimit = "0x2faf080"
l2GenesisBlockBaseFeePerGas = "0x5FC01C5"
l2BlockTime = 1
[chains.customGasToken]
Expand Down
18 changes: 9 additions & 9 deletions test-pp-op/config-op/intent.mainnet.toml.bak
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ l2ContractsLocator = "file:///app/packages/contracts-bedrock/forge-artifacts"

[[chains]]
id = "0x00000000000000000000000000000000000000000000000000000000000000C4"
baseFeeVaultRecipient = "0x98245d0adf4595c66f0a9db8e13c44cbff6be459"
l1FeeVaultRecipient = "0x98245d0adf4595c66f0a9db8e13c44cbff6be459"
sequencerFeeVaultRecipient = "0x98245d0adf4595c66f0a9db8e13c44cbff6be459"
baseFeeVaultRecipient = "0x610DE9141a2c51A9A9624278AA97fbE54b27c102"
l1FeeVaultRecipient = "0x610DE9141a2c51A9A9624278AA97fbE54b27c102"
sequencerFeeVaultRecipient = "0x610DE9141a2c51A9A9624278AA97fbE54b27c102"
eip1559DenominatorCanyon = 100000000
eip1559Denominator = 100000000
eip1559Elasticity = 1
operatorFeeScalar = 0
operatorFeeConstant = 0
gasLimit = 30000000
gasLimit = 50000000
[chains.deployOverrides]
l2GenesisBlockGasLimit = "0x1C9C380"
l2GenesisBlockGasLimit = "0x2faf080"
l2GenesisBlockBaseFeePerGas = "0x5FC01C5"
l2BlockTime = 1
sequencerWindowSize = 7200
Expand All @@ -28,9 +28,9 @@ l2ContractsLocator = "file:///app/packages/contracts-bedrock/forge-artifacts"
initialLiquidity = "0x0"
[chains.roles]
l1ProxyAdminOwner = "0x0000000000000000000000000000000000000000"
l2ProxyAdminOwner = "0x45985c85b6A2E4833824470F086556Bfd19f66f9"
l2ProxyAdminOwner = "0xF21637a6d8407aaE4bB0a051986261832dD91DDD"
systemConfigOwner = "0xAd9bCE315bF77C0Ade22097199953381C6Cc72eE"
unsafeBlockSigner = "0xC76b075B8B84eeB0402D7DC846Ce0759C1816Aab"
unsafeBlockSigner = "0x09dA216351B5E3df326220DaDA71cCCEEcD0D2f3"
batcher = "0xdfd6C636Dcb5a013c2431316c4A0762B84e70a5d"
proposer = "0xe43944421681170648e10007f73816e04f74394f"
challenger = "0x736e68af2cbf2ab0e46e4310fe5ae568b3642ff6"
proposer = "0xE43944421681170648E10007f73816e04F74394F"
challenger = "0x736E68Af2CbF2aB0E46E4310fE5Ae568b3642FF6"
3 changes: 3 additions & 0 deletions test-pp-op/local.env
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions test-pp-op/m1-deploy-and-upload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ echo "=============================================="
mkdir -p $UPLOAD_DIR
mv ${IMAGE_NAME}.tar.gz $UPLOAD_DIR
cp ./m2-migrate.sh $UPLOAD_DIR
cp ./m3-verify.sh $UPLOAD_DIR
tar -czvf $UPLOAD_DIR.tar.gz $UPLOAD_DIR
echo "✅ Upload file ${TAR_FILE} is created."

Expand Down
38 changes: 24 additions & 14 deletions test-pp-op/m2-migrate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,20 @@ done

# Prompt to delete ${BACKUP_DIR} contents
if [ -d $BACKUP_DIR ];then
echo ""
echo "============================================="
echo "Existing ${BACKUP_DIR}"
echo "============================================="
ls -la $BACKUP_DIR
echo ""
read -p "Do you want to delete the contents of ${BACKUP_DIR}? (y/n): " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo "${BACKUP_DIR} contents are DELETED..."
rm -rf ${BACKUP_DIR}/*
else
echo "${BACKUP_DIR} contents are NOT deleted..."
fi
echo ""
echo "============================================="
echo "Existing ${BACKUP_DIR}"
echo "============================================="
ls -la $BACKUP_DIR
echo ""
read -p "Do you want to delete the contents of ${BACKUP_DIR}? (y/n): " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo "${BACKUP_DIR} contents are DELETED..."
rm -rf ${BACKUP_DIR}/*
else
echo "${BACKUP_DIR} contents are NOT deleted..."
fi
fi

# Create and verify backup directory
Expand Down Expand Up @@ -374,6 +374,8 @@ execute_migration() {
cp .env ${BACKUP_DIR}/ || exit 1
cp merged.genesis.json ${BACKUP_DIR}/ || exit 1
cp -rf config-op ${BACKUP_DIR}/config-op || exit 1

[ -f migrate.log ] && cp migrate.log ${BACKUP_DIR}/
"; then
echo ""
echo "✅ Migration completed successfully inside container"
Expand Down Expand Up @@ -604,6 +606,14 @@ else
echo " Expected location: /app/test-pp-op/diff.genesis.json"
fi

echo ""
echo "=============================================="
echo "Step 9: Check for differences between mounted data and backup"
echo "=============================================="

diff -r $SOURCE_PATH $BACKUP_DIR/op-geth-seq # exit script on failure (set -e)
echo "✅ Contents of ${SOURCE_PATH} matches ${BACKUP_DIR}/op-geth-seq"

echo ""
echo "=============================================="
echo "✅ Migration process completed successfully!"
Expand Down
2 changes: 1 addition & 1 deletion test-pp-op/m3-verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ sleep 2

# Run verification
echo "Running verification..."
docker exec -it ${CONTAINER_NAME} geth verifyMigrate \
docker exec -w /app/test-pp-op -it ${CONTAINER_NAME} geth verifyMigrate \
--chaindata=/data/erigon-data/chaindata \
--datadir=${OP_GETH_DATA_DIR} \
--standalone-smt=true
Expand Down
152 changes: 152 additions & 0 deletions test-pp-op/scripts/set-init-bond.sh
Original file line number Diff line number Diff line change
@@ -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."