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
13d116ac
Unverified
Commit
13d116ac
authored
Oct 03, 2024
by
Maurelian
Committed by
GitHub
Oct 03, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: Delete scripts/fpac dir (#12286)
parent
1ab9775d
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
0 additions
and
288 deletions
+0
-288
.gitignore
packages/contracts-bedrock/scripts/fpac/.gitignore
+0
-2
Makefile
packages/contracts-bedrock/scripts/fpac/Makefile
+0
-31
README.md
packages/contracts-bedrock/scripts/fpac/README.md
+0
-21
SubmitLPP.sol
packages/contracts-bedrock/scripts/fpac/SubmitLPP.sol
+0
-61
lpp-estimation.sh
packages/contracts-bedrock/scripts/fpac/lpp-estimation.sh
+0
-44
FaultDisputeGameViz.s.sol
...tracts-bedrock/scripts/fpac/viz/FaultDisputeGameViz.s.sol
+0
-88
dag-viz.py
packages/contracts-bedrock/scripts/fpac/viz/dag-viz.py
+0
-28
visualize.sh
packages/contracts-bedrock/scripts/fpac/viz/visualize.sh
+0
-13
No files found.
packages/contracts-bedrock/scripts/fpac/.gitignore
deleted
100644 → 0
View file @
1ab9775d
prestate-artifacts/
prestate-artifacts.tar.gz
packages/contracts-bedrock/scripts/fpac/Makefile
deleted
100644 → 0
View file @
1ab9775d
# ENV
monorepo_root
:=
"../../../.."
deploy_config_path
:=
"../../deploy-config"
tmp
:=
$(
shell
mktemp
)
# Help menu
.PHONY
:
help
help
:
#
Show help for each of the Makefile recipes.
@
grep
-E
'^[a-zA-Z0-9 -]+:.*#'
Makefile |
sort
|
while
read
-r
l
;
do
printf
"
\0
33[1;32m
$$
(echo
$$
l | cut -f 1 -d':')
\0
33[00m:
$$
(echo
$$
l | cut -f 2- -d'#')
\n
"
;
done
.PHONY
:
cannon-prestate
cannon-prestate
:
#
Generate the cannon prestate
,
and tar the `op-program` + `cannon` binaries + prestate data used to generate it.
cd
$(monorepo_root)
&&
make reproducible-prestate
@
mkdir
-p
prestate-artifacts
@
cp
-r
$(monorepo_root)
/cannon/bin/
**
prestate-artifacts/
@
cp
-r
$(monorepo_root)
/op-program/bin/
**
prestate-artifacts/
tar
-czvf
prestate-artifacts.tar.gz prestate-artifacts
@
jq
".faultGameAbsolutePrestate =
$$
(cat prestate-artifacts/prestate-proof.json | jq .pre)"
"
$(deploy_config_path)
/
$(chain)
.json"
>
$(tmp)
&&
mv
$(tmp)
"
$(deploy_config_path)
/
$(chain)
.json"
@
echo
"-------------------------------------------------------------------------------------------------------------"
@
echo
"-> Archive of prestate artifacts available at prestate-artifacts.tar.gz"
@
echo
"-> Set the absolute prestate to
$$
(cat prestate-artifacts/prestate-proof.json | jq .pre) in the
$(chain)
deploy config."
@
rm
-rf
prestate-artifacts
.PHONY
:
deploy-fresh
deploy-fresh
:
cannon-prestate
#
Deploy a fresh version of the FPAC contracts. Pass `--broadcast` to send to the network.
forge script FPACOPS.s.sol
--sig
"deployFPAC(address,address,address)"
$
(
proxy-admin
)
$
(
final-system-owner
)
$
(
superchain-config-proxy
)
--chain
$(chain)
-vvv
$(args)
# TODO: Convert this whole file to a justfile
.PHONY
:
deploy-upgrade
deploy-upgrade
:
cannon-prestate
#
Deploy upgraded FP contracts. Pass `--broadcast` to send to the network.
forge script FPACOPS2.s.sol
--sig
"deployFPAC2(address,address,address,address,address)"
$
(
proxy-admin
)
$
(
final-system-owner
)
$
(
superchain-config-proxy
)
$
(
dispute-game-factory-proxy
)
$
(
anchor-state-registry-proxy
)
--chain
$(chain)
-vvv
$(args)
packages/contracts-bedrock/scripts/fpac/README.md
deleted
100644 → 0
View file @
1ab9775d
# `fpac-deploy`
Chain-ops scripts for the Fault Proof Alpha Chad contracts.
## Usage
### Generating the Cannon prestate and artifacts
_Description_
: Generates the cannon prestate, tars the relevant artifacts, and sets the absolute prestate field in the network's deploy config.
```
sh
make cannon-prestate
chain
=
<chain-name>
```
### Deploying a fresh system
_Description_
: Deploys a fully fresh FPAC system to the passed chain. All args after the
`args=`
are forwarded to
`forge script`
.
```
sh
make deploy-fresh
chain
=
<chain-name> proxy-admin
=
<chain-proxy-admin-addr> final-system-owner
=
<chain-safe-addr>
[
args
=
<forge-script-args>]
```
packages/contracts-bedrock/scripts/fpac/SubmitLPP.sol
deleted
100644 → 0
View file @
1ab9775d
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;
import { PreimageOracle } from "src/cannon/PreimageOracle.sol";
import { Script } from "forge-std/Script.sol";
import { StdAssertions } from "forge-std/StdAssertions.sol";
import "src/cannon/libraries/CannonTypes.sol";
contract SubmitLPP is Script, StdAssertions {
/// @notice Test UUID
uint256 private constant TEST_UUID = uint256(keccak256("TEST_UUID"));
/// @notice Number of bytes to submit to the preimage oracle.
uint256 private constant BYTES_TO_SUBMIT = 4_012_000;
/// @notice Chunk size to submit to the preimage oracle.
uint256 private constant CHUNK_SIZE = 500 * 136;
PreimageOracle private oracle;
function post(address _po) external {
// Bootstrap
oracle = PreimageOracle(_po);
// Allocate chunk - worst case w/ all bits set.
bytes memory chunk = new bytes(CHUNK_SIZE);
for (uint256 i; i < chunk.length; i++) {
chunk[i] = 0xFF;
}
// Mock state commitments. Worst case w/ all bits set.
bytes32[] memory mockStateCommitments = new bytes32[](CHUNK_SIZE / 136);
bytes32[] memory mockStateCommitmentsLast = new bytes32[](CHUNK_SIZE / 136 + 1);
for (uint256 i; i < mockStateCommitments.length; i++) {
mockStateCommitments[i] = bytes32(type(uint256).max);
mockStateCommitmentsLast[i] = bytes32(type(uint256).max);
}
// Assign last mock state commitment to all bits set.
mockStateCommitmentsLast[mockStateCommitmentsLast.length - 1] = bytes32(type(uint256).max);
vm.broadcast();
oracle.initLPP({ _uuid: TEST_UUID, _partOffset: 0, _claimedSize: uint32(BYTES_TO_SUBMIT) });
// Submit LPP in 500 * 136 byte chunks.
for (uint256 i = 0; i < BYTES_TO_SUBMIT; i += CHUNK_SIZE) {
bool finalize = i + CHUNK_SIZE >= BYTES_TO_SUBMIT;
vm.broadcast();
oracle.addLeavesLPP({
_uuid: TEST_UUID,
_inputStartBlock: i / 136,
_input: chunk,
_stateCommitments: finalize ? mockStateCommitmentsLast : mockStateCommitments,
_finalize: finalize
});
}
// Assert that all bytes were submitted.
LPPMetaData metaData = oracle.proposalMetadata(msg.sender, TEST_UUID);
assertEq(metaData.bytesProcessed(), BYTES_TO_SUBMIT);
assertEq(metaData.blocksProcessed(), (BYTES_TO_SUBMIT / 136) + 1);
}
}
packages/contracts-bedrock/scripts/fpac/lpp-estimation.sh
deleted
100755 → 0
View file @
1ab9775d
#!/bin/bash
# Default Anvil private key
PRIVATE_KEY
=
"0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
PUB_KEY
=
"
$(
cast wallet addr
$PRIVATE_KEY
)
"
# 40 gwei base fee
BASE_FEE
=
40000000000
# Anvil RPC
export
ETH_RPC_URL
=
"http://localhost:8545"
# Start anvil in the background
anvil
--base-fee
$BASE_FEE
&
# Capture the process ID
ANVIL_PID
=
$!
# Deploy the `PreimageOracle` contract to anvil.
PO_MIN_PROPOSAL_SIZE
=
10000
PO_CHALLENGE_PERIOD
=
120
PO_ADDR
=
$(
forge create PreimageOracle
--private-key
$PRIVATE_KEY
--rpc-url
$ETH_RPC_URL
--json
--constructor-args
"
${
PO_MIN_PROPOSAL_SIZE
}
"
"
${
PO_CHALLENGE_PERIOD
}
"
0 | jq
-r
'.deployedTo'
)
# Capture the balance of the submitter prior to submitting all leaves.
BALANCE_BEFORE
=
$(
cast balance
--rpc-url
http://localhost:8545
"
$PUB_KEY
"
)
BASE_FEE_BEFORE
=
$(
cast 2d
"
$(
cast rpc
'eth_gasPrice'
| jq
-r
)
"
)
# Run the `SubmitLPP` script to submit the LPP to the `PreimageOracle` contract.
forge script scripts/fpac/SubmitLPP.sol
\
--sig
"post(address)"
"
$PO_ADDR
"
\
--private-key
$PRIVATE_KEY
\
--rpc-url
$ETH_RPC_URL
\
--broadcast
BALANCE_AFTER
=
$(
cast balance
"
$PUB_KEY
"
)
BASE_FEE_AFTER
=
$(
cast 2d
"
$(
cast rpc
'eth_gasPrice'
| jq
-r
)
"
)
echo
"Base Fee Before:
$BASE_FEE_BEFORE
"
echo
"Base Fee After:
$BASE_FEE_AFTER
"
echo
"Balance before:
$BALANCE_BEFORE
"
echo
"Balance after:
$BALANCE_AFTER
"
echo
"Cost:
$(
cast from-wei
$((
BALANCE_BEFORE
-
BALANCE_AFTER
))
)
ETH"
# Kill anvil
kill
$ANVIL_PID
packages/contracts-bedrock/scripts/fpac/viz/FaultDisputeGameViz.s.sol
deleted
100644 → 0
View file @
1ab9775d
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.15;
// Testing
import { FaultDisputeGame_Init } from "test/dispute/FaultDisputeGame.t.sol";
// Scripts
import { Script } from "forge-std/Script.sol";
import { console2 as console } from "forge-std/console2.sol";
import { Process } from "scripts/libraries/Process.sol";
// Libraries
import "src/dispute/lib/Types.sol";
import "src/dispute/lib/Errors.sol";
// Interfaces
import { IFaultDisputeGame } from "src/dispute/interfaces/IFaultDisputeGame.sol";
/**
* @title FaultDisputeGameViz
* @dev To run this script, make sure to install the `dagviz` & `eth_abi` python packages.
*/
contract FaultDisputeGameViz is Script, FaultDisputeGame_Init {
/// @dev The root claim of the game.
Claim internal constant ROOT_CLAIM = Claim.wrap(bytes32(uint256(1)));
/// @dev The absolute prestate of the trace.
Claim internal constant ABSOLUTE_PRESTATE = Claim.wrap(bytes32((uint256(3) << 248) | uint256(0)));
function setUp() public override {
super.setUp();
super.init({ rootClaim: ROOT_CLAIM, absolutePrestate: ABSOLUTE_PRESTATE, l2BlockNumber: 0x10 });
}
/**
* @dev Entry point
*/
function local() public {
// Construct the game by performing attacks, defenses, and steps.
// ...
buildGraph();
console.log("Saved graph to `./dispute_game.svg");
}
/**
* @dev Entry point
*/
function remote(address _addr) public {
gameProxy = IFaultDisputeGame(payable(_addr));
buildGraph();
console.log("Saved graph to `./dispute_game.svg");
}
/**
* @dev Uses the `dag-viz` python script to generate a visual model of the game state.
*/
function buildGraph() internal {
uint256 numClaims = uint256(vm.load(address(gameProxy), bytes32(uint256(1))));
IFaultDisputeGame.ClaimData[] memory gameData = new IFaultDisputeGame.ClaimData[](numClaims);
for (uint256 i = 0; i < numClaims; i++) {
(
uint32 parentIndex,
address countered,
address claimant,
uint128 bond,
Claim claim,
Position position,
Clock clock
) = gameProxy.claimData(i);
gameData[i] = IFaultDisputeGame.ClaimData({
parentIndex: parentIndex,
counteredBy: countered,
claimant: claimant,
bond: bond,
claim: claim,
position: position,
clock: clock
});
}
string[] memory commands = new string[](3);
commands[0] = "python3";
commands[1] = "scripts/dag-viz.py";
commands[2] = vm.toString(abi.encode(gameData));
Process.run(commands);
}
}
packages/contracts-bedrock/scripts/fpac/viz/dag-viz.py
deleted
100644 → 0
View file @
1ab9775d
import
sys
import
dagviz
import
networkx
as
nx
from
eth_abi
import
decode
# The parent of the root claim is uint32 max.
ROOT_PARENT
=
4294967295
# Get the abi-encoded input
b
=
sys
.
argv
[
1
]
.
removeprefix
(
'0x'
)
# Decode the input
t
=
decode
([
'(uint32,bool,bytes32,uint128,uint128)[]'
],
bytes
.
fromhex
(
b
))[
0
]
# Create the graph
G
=
nx
.
DiGraph
()
for
c
in
t
:
claim
=
c
[
2
]
.
hex
()
key
=
f
"Position: {bin(c[3])[2:]} | Claim: 0x{claim[:4]}..{claim[60:64]}"
G
.
add_node
(
key
)
if
int
(
c
[
0
])
!=
ROOT_PARENT
:
pclaim
=
t
[
c
[
0
]][
2
]
.
hex
()
G
.
add_edge
(
f
"Position: {bin(t[c[0]][3])[2:]} | Claim: 0x{pclaim[:4]}..{pclaim[60:64]}"
,
key
)
r
=
dagviz
.
render_svg
(
G
)
f
=
open
(
'dispute_game.svg'
,
'w'
)
f
.
write
(
r
)
f
.
close
()
packages/contracts-bedrock/scripts/fpac/viz/visualize.sh
deleted
100644 → 0
View file @
1ab9775d
#!/usr/bin/env bash
set
-euo
pipefail
RPC
=
"
${
1
:?Must
specify RPC address
}
"
FAULT_GAME_ADDRESS
=
"
${
2
:?Must
specify game address
}
"
DIR
=
"
$(
cd
"
$(
dirname
"
${
BASH_SOURCE
[0]
}
"
)
"
&&
pwd
)
"
DIR
=
"
${
DIR
%/*
}
"
cd
"
$DIR
"
forge script scripts/fpac/viz/FaultDisputeGameViz.s.sol
\
--sig
"remote(address)"
"
$FAULT_GAME_ADDRESS
"
\
--fork-url
"
$RPC
"
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