Skip to content

Commit

Permalink
Merge pull request #149 from 0xPolygon/jhilliard-uncessary-l1-dep
Browse files Browse the repository at this point in the history
Minor changes to better support external L1
  • Loading branch information
praetoriansentry authored Jul 29, 2024
2 parents 2f258ff + 26dedab commit e1c898c
Show file tree
Hide file tree
Showing 21 changed files with 1,102 additions and 511 deletions.
2 changes: 1 addition & 1 deletion .github/actions/monitor-cdk-verified-batches/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ inputs:
verified_batches_target:
description: The minimum number of batches to be verified
required: false
default: '30'
default: '10'
timeout:
description: The script timeout in seconds
required: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,15 @@ start_time=$(date +%s)
end_time=$((start_time + timeout))

rpc_url="$(kurtosis port print cdk-v1 $rpc_service http-rpc)"
pk="0x12d7de8621a77640c9241b2595ba78ce443d05e94090365ab3bb5e19df82c625"

while true; do
verified_batches="$(cast to-dec "$(cast rpc --rpc-url "$rpc_url" zkevm_verifiedBatchNumber | sed 's/"//g')")"
echo "[$(date '+%Y-%m-%d %H:%M:%S')] Verified Batches: $verified_batches"

# This is here to take up somce space within the batch in order to make sure the batches actually increase during the duration of the test
cast send --legacy --rpc-url "$rpc_url" --private-key "$pk" --gas-limit 643528 --create 0x600160015B810190630000000456

current_time=$(date +%s)
if (( current_time > end_time )); then
echo "[$(date '+%Y-%m-%d %H:%M:%S')] ❌ Exiting... Timeout reached!"
Expand All @@ -41,4 +46,4 @@ while true; do
fi

sleep 10
done
done
7 changes: 4 additions & 3 deletions cdk-erigon-sequencer-params.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ args:
data_availability_mode: cdk-validium

# Docker images and repositories used to spin up services.
zkevm_prover_image: hermeznetwork/zkevm-prover:v6.0.3-RC9
zkevm_prover_image: hermeznetwork/zkevm-prover:v6.0.3-RC18
# zkevm_prover_image: hermeznetwork/zkevm-prover:v4.0.19
zkevm_node_image: hermeznetwork/zkevm-node:v0.6.7
cdk_node_image: 0xpolygon/cdk-validium-node:0.6.7-cdk
Expand All @@ -62,10 +62,11 @@ args:
# zkevm_agglayer_image: 0xpolygon/agglayer:0.1.3
zkevm_agglayer_image: ghcr.io/agglayer/agglayer-rs:main
zkevm_bridge_service_image: hermeznetwork/zkevm-bridge-service:v0.4.2
cdk_erigon_node_image: hermeznetwork/cdk-erigon:v1.1.3
cdk_erigon_node_image: hermeznetwork/cdk-erigon:beta13-candidate3-5225235-amd64
# cdk_erigon_node_image: erigon:loop-wait
panoptichain_image: minhdvu/panoptichain
zkevm_bridge_ui_image: leovct/zkevm-bridge-ui:multi-network
zkevm_bridge_proxy_image: haproxy:2.9.7
zkevm_bridge_proxy_image: haproxy:2.9.9-bookworm
workload_image: leovct/workload:0.0.1
zkevm_sequence_sender_image: hermeznetwork/zkevm-sequence-sender:v0.2.0-RC5
toolbox_image: leovct/toolbox:0.0.1
Expand Down
7 changes: 4 additions & 3 deletions cdk_bridge_infra.star
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@ def run(plan, args):
)
zkevm_bridge_package.start_bridge_ui(plan, args, bridge_ui_config_artifact)

# Start the bridge UI reverse proxy.
proxy_config_artifact = create_reverse_proxy_config_artifact(plan, args)
zkevm_bridge_package.start_reverse_proxy(plan, args, proxy_config_artifact)
# Start the bridge UI reverse proxy. This is only relevant / needed if we have a fake l1
if args["deploy_l1"]:
proxy_config_artifact = create_reverse_proxy_config_artifact(plan, args)
zkevm_bridge_package.start_reverse_proxy(plan, args, proxy_config_artifact)


def create_agglayer_config_artifact(plan, args, contract_setup_addresses, db_configs):
Expand Down
10 changes: 4 additions & 6 deletions cdk_erigon.star
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ def run_rpc(plan, args):
zkevm_sequencer_service.ports["data-streamer"].number,
)

cdk_erigon_node_config_template = read_file(
src="./templates/cdk-erigon/config.yaml"
)
cdk_erigon_node_config_template = read_file(src="./templates/cdk-erigon/config.yml")
contract_setup_addresses = service_package.get_contract_setup_addresses(plan, args)
cdk_erigon_node_config_artifact = plan.render_templates(
name="cdk-erigon-node-config-artifact",
Expand All @@ -26,6 +24,7 @@ def run_rpc(plan, args):
data={
"zkevm_sequencer_url": zkevm_sequence_url,
"zkevm_datastreamer_url": zkevm_datastreamer_url,
"is_sequencer": False,
}
| args
| contract_setup_addresses,
Expand Down Expand Up @@ -67,9 +66,7 @@ def run_rpc(plan, args):


def run_sequencer(plan, args):
cdk_erigon_node_config_template = read_file(
src="./templates/cdk-erigon/config-sequencer.yaml"
)
cdk_erigon_node_config_template = read_file(src="./templates/cdk-erigon/config.yml")
contract_setup_addresses = service_package.get_contract_setup_addresses(plan, args)
cdk_erigon_node_config_artifact = plan.render_templates(
name="cdk-erigon-node-config-artifact-sequencer",
Expand All @@ -78,6 +75,7 @@ def run_sequencer(plan, args):
template=cdk_erigon_node_config_template,
data={
"zkevm_data_stream_port": args["zkevm_data_streamer_port"],
"is_sequencer": True,
}
| args
| contract_setup_addresses,
Expand Down
22 changes: 21 additions & 1 deletion deploy_zkevm_contracts.star
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,28 @@ ARTIFACTS = [


def run(plan, args):
artifact_paths = list(ARTIFACTS)
# If we are configured to use a previous deployment, we'll
# dynamically add artifacts for the genesis and combined outputs.
if (
"use_previously_deployed_contracts" in args
and args["use_previously_deployed_contracts"]
):
artifact_paths.append(
{
"name": "genesis.json",
"file": "./templates/contract-deploy/genesis.json",
}
)
artifact_paths.append(
{
"name": "combined.json",
"file": "./templates/contract-deploy/combined.json",
}
)

artifacts = []
for artifact_cfg in ARTIFACTS:
for artifact_cfg in artifact_paths:
template = read_file(src=artifact_cfg["file"])
artifact = plan.render_templates(
name=artifact_cfg["name"],
Expand Down
91 changes: 67 additions & 24 deletions docs/cdk-ops.org
Original file line number Diff line number Diff line change
@@ -1,44 +1,87 @@
* Connect Directly to Container Network

#+begin_src bash
export ETH_RPC_URL="$(kurtosis port print cdk-v1 el-1-geth-lighthouse rpc)"
docker run -it --net=container:f0ce09999e30 nicolaka/netshoot:latest /bin/bash
#+end_src

kurtosis files download cdk-v1 zkevm /tmp
pol_addr=$(cat /tmp/zkevm/combined.json | jq -r '.polTokenAddress')
rollup_addr=$(cat /tmp/zkevm/combined.json | jq -r '.rollupAddress')
* Chaos

cast call $pol_addr 'balanceOf(address)(uint256)' 0x5b06837A43bdC3dD9F114558DAf4B26ed49842Ed
#+begin_src bash
docker run --rm --name dsapp --network kt-cdk-v1 -it -v $PWD:/app ubuntu:latest /bin/bash

# do an approval for spend
cast send --private-key 0x183c492d0ba156041a7f31a1b188958a7a22eebadca741a7fe64436092dc3181 $pol_addr 'mint(address,uint256)' $rollup_addr 10000000000000000000000000
#inside container
apt update
apt install iproute2 curl
cd app
./dsapp client --server zkevm-node-sequencer-001:6900

# pumba
./.bin/github.com/alexei-led/pumba netem --duration 5m rate --rate 10bit dsapp
./.bin/github.com/alexei-led/pumba netem --duration 1m delay --time 100000 dsapp
./.bin/github.com/alexei-led/pumba pause --duration 1m dsapp
#+end_src

* Interruption

#+begin_src bash
export ETH_RPC_URL="$(kurtosis port print cdk-v1 zkevm-node-trusted-rpc-001 http-rpc)"
cast rpc zkevm_batchNumber
cast rpc zkevm_virtualBatchNumber
cast rpc zkevm_verifiedBatchNumber
#+end_src

Check DAC and Sequencing
#+begin_src bash
kurtosis files download cdk-v1 zkevm /tmp
cast call --rpc-url $(kurtosis port print cdk-v1 el-1-geth-lighthouse rpc) $(jq -r .rollupAddress /tmp/zkevm/combined.json) 'dataAvailabilityProtocol()(address)'
cast call --rpc-url $(kurtosis port print cdk-v1 el-1-geth-lighthouse rpc) $(jq -r .polygonDataCommitteeAddress /tmp/zkevm/combined.json) 'requiredAmountOfSignatures()(uint256)'
docker run --rm --name dsapp --network kt-cdk-v1 -it -v $PWD:/app ubuntu:latest /bin/bash
cd app
./dsapp relay --server zkevm-node-sequencer-001:6900

cat *.json | jq '.abi[] | select(.type != "receive")' | jq -s | polycli abi decode | sort -t: -k3 -u
docker run -it --net=container:f0ce09999e30 nicolaka/netshoot:latest /bin/bash
docker network inspect kt-cdk-v1

client_ip="172.16.0.19"
server_ip="172.16.0.15"

# Drop
sudo iptables -I DOCKER -s $client_ip -d $server_ip -j DROP
sudo iptables -I DOCKER -s $server_ip -d $client_ip -j DROP

# Restore
sudo iptables -D DOCKER -s $client_ip -d $server_ip -j DROP
sudo iptables -D DOCKER -s $server_ip -d $client_ip -j DROP

docker run -it --net=container:zkevm-prover-001--620987a8d7e44c60a3bc8a8742025635 nicolaka/netshoot:latest /bin/bash

sudo /usr/sbin/tcpkill -i br-edd588fc6880 host $client_ip and host $server_ip
#+end_src

* Slow Outbound from Sequencer

Confirm that we're on the correct fork
#+begin_src bash
export ETH_RPC_URL="$(kurtosis port print cdk-v1 el-1-geth-lighthouse rpc)"
cast call 0x2F50ef6b8e8Ee4E579B17619A92dE3E2ffbD8AD2 'rollupIDToRollupData(uint32)(address,uint64,address,uint64,bytes32,uint64,uint64,uint64,uint64,uint64,uint64,uint8)' 1
docker run -it --rm --name seqshoot --net=container:zkevm-node-sequencer-001--ede742f7c75e4d8d860c2a54756df797 nicolaka/netshoot:latest /bin/bash
./.bin/github.com/alexei-led/pumba netem --duration 1m --egress-port 6900 rate --rate 10bit seqshoot
#+end_src
* Chaos

* Determine interface

From inside the container we'll need to get the details of the link:

#+begin_src bash
apt install iproute2
ip link show eth0
#+end_src

#+begin_example
294: eth0@if295: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1440 qdisc noqueue state UP mode DEFAULT group default
link/ether 02:42:ac:10:00:11 brd ff:ff:ff:ff:ff:ff link-netnsid 0
#+end_example

In this case 294 is the ifindex for the interface within the
container. ~eth0@if295~ indicates that this interface is iflink.

From the host OS, I can run:

#+begin_src bash
ip link | grep ^295
#+end_src

#+begin_example
295: veth39145be@if294: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1440 qdisc noqueue master br-edd588fc6880 state UP mode DEFAULT group default
#+end_example

Now I have the interface name ~br-edd588fc6880~ and I can use that for
~tcpdump~, ~tcpkill~ and things like that

https://github.com/torvalds/linux/blob/55027e689933ba2e64f3d245fb1ff185b3e7fc81/Documentation/ABI/testing/sysfs-class-net#L188-L207

Loading

0 comments on commit e1c898c

Please sign in to comment.