Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
8bb2ea5a
Unverified
Commit
8bb2ea5a
authored
Aug 28, 2023
by
Adrian Sutton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-challenger: Extract more flexible script to create a new game
parent
57bf998b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
36 deletions
+45
-36
init_game.sh
op-challenger/scripts/alphabet/init_game.sh
+1
-36
create_game.sh
op-challenger/scripts/create_game.sh
+44
-0
No files found.
op-challenger/scripts/alphabet/init_game.sh
View file @
8bb2ea5a
...
...
@@ -59,43 +59,8 @@ do
sleep
2
done
# Fetch the latest block number
L2_BLOCK_NUMBER
=
$(
cast call
$L2_OUTPUT_ORACLE_PROXY
"latestBlockNumber()"
)
echo
"Using the latest L2OO block number:
$L2_BLOCK_NUMBER
"
# We will use the l2 block number of 1 for the dispute game.
# We need to check that the block oracle contains the corresponding l1 block number.
echo
"Checkpointing the block oracle..."
L1_CHECKPOINT
=
$(
cast send
--private-key
$DEVNET_SPONSOR
$BLOCK_ORACLE_PROXY
"checkpoint()"
--json
| jq
-r
.blockNumber | cast to-dec
)
((
L1_CHECKPOINT
=
L1_CHECKPOINT-1
))
echo
"L1 Checkpoint:
$L1_CHECKPOINT
"
INDEX
=
$(
cast call
$L2_OUTPUT_ORACLE_PROXY
"getL2OutputIndexAfter(uint256)"
$L2_BLOCK_NUMBER
| cast to-dec
)
((
PRIOR_INDEX
=
INDEX-1
))
echo
"Getting the l2 output at index
$PRIOR_INDEX
"
cast call
$L2_OUTPUT_ORACLE_PROXY
"getL2Output(uint256)"
$PRIOR_INDEX
echo
"Getting the l2 output at index
$INDEX
"
cast call
$L2_OUTPUT_ORACLE_PROXY
"getL2Output(uint256)"
$INDEX
# (Alphabet) Fault game type = 255
GAME_TYPE
=
255
# Root claim commits to the entire trace.
# Alphabet game claim construction: keccak256(abi.encode(trace_index, trace[trace_index]))
ROOT_CLAIM
=
$(
cast keccak
$(
cast abi-encode
"f(uint256,uint256)"
15 122
))
# Fault dispute game extra data is calculated as follows.
# abi.encode(uint256(l2_block_number), uint256(l1 checkpoint))
EXTRA_DATA
=
$(
cast abi-encode
"f(uint256,uint256)"
$L2_BLOCK_NUMBER
$L1_CHECKPOINT
)
echo
"Initializing the game"
FAULT_GAME_ADDRESS
=
$(
cast call
--private-key
$MALLORY_KEY
$DISPUTE_GAME_PROXY
"create(uint8,bytes32,bytes)"
$GAME_TYPE
$ROOT_CLAIM
$EXTRA_DATA
)
echo
"Creating game at address
$FAULT_GAME_ADDRESS
"
cast send
--private-key
$MALLORY_KEY
$DISPUTE_GAME_PROXY
"create(uint8,bytes32,bytes)"
$GAME_TYPE
$ROOT_CLAIM
$EXTRA_DATA
FORMATTED_ADDRESS
=
$(
cast parse-bytes32-address
$FAULT_GAME_ADDRESS
)
echo
"Formatted Address:
$FORMATTED_ADDRESS
"
echo
$FORMATTED_ADDRESS
>
$CHALLENGER_DIR
/.fault-game-address
GAME_TYPE
=
255
${
SOURCE_DIR
}
/../create_game.sh http://localhost:8545
"
${
DISPUTE_GAME_PROXY
}
"
"
${
ROOT_CLAIM
}
"
--private-key
"
${
DEVNET_SPONSOR
}
"
op-challenger/scripts/create_game.sh
0 → 100755
View file @
8bb2ea5a
#!/usr/bin/env bash
set
-euo
pipefail
SOURCE_DIR
=
$(
cd
$(
dirname
"
${
BASH_SOURCE
[0]
}
"
)
&&
pwd
)
CHALLENGER_DIR
=
$(
echo
${
SOURCE_DIR
%/*
}
)
MONOREPO_DIR
=
$(
echo
${
CHALLENGER_DIR
%/*
}
)
# ./create_game.sh <rpc-addr> <dispute-game-factory-addr> <cast signing args>
RPC
=
${
1
:?Must
specify RPC address
}
FACTORY_ADDR
=
${
2
:?Must
specify factory address
}
ROOT_CLAIM
=
${
3
:?Must
specify root claim
}
SIGNER_ARGS
=
"
${
@
:4
}
"
# Default to Cannon Fault game type
GAME_TYPE
=
${
GAME_TYPE
:-
0
}
# Get the fault dispute game implementation addr
GAME_IMPL_ADDR
=
$(
cast call
--rpc-url
"
${
RPC
}
"
"
${
FACTORY_ADDR
}
"
'gameImpls(uint8) returns(address)'
0
)
echo
"Fault dispute game impl:
${
GAME_IMPL_ADDR
}
"
L2OO_ADDR
=
$(
cast call
--rpc-url
"
${
RPC
}
"
"
${
GAME_IMPL_ADDR
}
"
'L2_OUTPUT_ORACLE() returns(address)'
)
echo
"L2OO:
${
L2OO_ADDR
}
"
BLOCK_ORACLE_ADDR
=
$(
cast call
--rpc-url
"
${
RPC
}
"
"
${
GAME_IMPL_ADDR
}
"
'BLOCK_ORACLE() returns(address)'
)
echo
"Block Oracle:
${
BLOCK_ORACLE_ADDR
}
"
L2_BLOCK_NUM
=
$(
cast call
--rpc-url
"
${
RPC
}
"
"
${
L2OO_ADDR
}
"
'latestBlockNumber() public view returns (uint256)'
)
echo
"L2 Block Number:
${
L2_BLOCK_NUM
}
"
echo
"Checkpointing the block oracle..."
L1_CHECKPOINT
=
$(
cast send
--rpc-url
"
${
RPC
}
"
${
SIGNER_ARGS
}
"
${
BLOCK_ORACLE_ADDR
}
"
"checkpoint()"
--json
| jq
-r
.blockNumber | cast to-dec
)
((
L1_CHECKPOINT
=
L1_CHECKPOINT-1
))
echo
"L1 Checkpoint:
$L1_CHECKPOINT
"
# Fault dispute game extra data is calculated as follows.
# abi.encode(uint256(l2_block_number), uint256(l1 checkpoint))
EXTRA_DATA
=
$(
cast abi-encode
"f(uint256,uint256)"
"
${
L2_BLOCK_NUM
}
"
"
${
L1_CHECKPOINT
}
"
)
echo
"Initializing the game"
FAULT_GAME_DATA
=
$(
cast send
--rpc-url
"
${
RPC
}
"
${
SIGNER_ARGS
}
"
${
FACTORY_ADDR
}
"
"create(uint8,bytes32,bytes) returns(address)"
"
${
GAME_TYPE
}
"
"
${
ROOT_CLAIM
}
"
"
${
EXTRA_DATA
}
"
--json
)
FAULT_GAME_ADDRESS
=
$(
echo
"
${
FAULT_GAME_DATA
}
"
| jq
-r
'.logs[0].topics[1]'
| cast parse-bytes32-address
)
echo
"Fault game address:
${
FAULT_GAME_ADDRESS
}
"
echo
"
${
FAULT_GAME_ADDRESS
}
"
>
$CHALLENGER_DIR
/.fault-game-address
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment