From cf27b239a3b2102666c0b575714b643e105c9f85 Mon Sep 17 00:00:00 2001 From: John Hilliard Date: Wed, 27 Nov 2024 15:21:04 -0500 Subject: [PATCH 01/38] feat: adding support for vkey config --- .github/tests/attach-second-cdk.yml | 8 +++++++- .github/tests/fork12-pessimistic.yml | 12 ++++++++---- input_parser.star | 4 ++++ templates/cdk-erigon/config.yml | 2 +- .../contract-deploy/create_rollup_parameters.json | 3 ++- 5 files changed, 22 insertions(+), 7 deletions(-) diff --git a/.github/tests/attach-second-cdk.yml b/.github/tests/attach-second-cdk.yml index 5f067180..90d9a756 100644 --- a/.github/tests/attach-second-cdk.yml +++ b/.github/tests/attach-second-cdk.yml @@ -7,7 +7,7 @@ args: deployment_suffix: "-002" zkevm_rollup_chain_id: 20202 zkevm_rollup_id: 2 - + # The following accounts have been generated using the following command: # polycli wallet inspect --mnemonic 'bless share truly shadow primary sun relief border van gallery stairs edit reflect gentle athlete main device smile response rescue mirror floor say people' --addresses 9 | tee keys.txt | jq -r '.Addresses[] | [.ETHAddress, .HexPrivateKey] | @tsv' | awk 'BEGIN{split("sequencer,aggregator,claimtxmanager,timelock,admin,loadtest,agglayer,dac,proofsigner",roles,",")} {print "zkevm_l2_" roles[NR] "_address: \"" $1 "\""; print "zkevm_l2_" roles[NR] "_private_key: \"0x" $2 "\"\n"}' # Note that admin and agglayer accounts have been removed since we're using the default accounts. @@ -25,3 +25,9 @@ args: zkevm_l2_dac_private_key: "0x992c9ab11d5eab6b6c2634b8bb0b85f3d8d1acf25024dc99c359cb2afd9b40a7" zkevm_l2_proofsigner_address: "0xf1a661D7b601Ec46a040f57193cC99aB8c4132FA" zkevm_l2_proofsigner_private_key: "0xc7fe3a006d75ba9326d9792523385abb49057c66aee0b8b4248821a89713f975" + + + cdk_erigon_node_image: hermeznetwork/cdk-erigon:v2.60.0 + cdk_node_image: ghcr.io/0xpolygon/cdk:0.5.0-beta5 + zkevm_contracts_image: leovct/zkevm-contracts:v9.0.0-rc.3-pp-fork.12 + additional_services: [] diff --git a/.github/tests/fork12-pessimistic.yml b/.github/tests/fork12-pessimistic.yml index 7a0a3152..5406ade0 100644 --- a/.github/tests/fork12-pessimistic.yml +++ b/.github/tests/fork12-pessimistic.yml @@ -1,13 +1,17 @@ args: - agglayer_image: ghcr.io/agglayer/agglayer:0.2.0-rc.11 - cdk_erigon_node_image: hermeznetwork/cdk-erigon:v2.60.0-beta8 + agglayer_image: ghcr.io/agglayer/agglayer:0.2.0-rc.17 + cdk_node_image: ghcr.io/0xpolygon/cdk:0.5.0-beta5 + cdk_erigon_node_image: hermeznetwork/cdk-erigon:v2.60.0 zkevm_bridge_proxy_image: haproxy:3.0-bookworm zkevm_bridge_service_image: hermeznetwork/zkevm-bridge-service:v0.6.0-RC2 zkevm_bridge_ui_image: leovct/zkevm-bridge-ui:multi-network - zkevm_contracts_image: nulyjkdhthz/zkevm-contracts:v9.0.0-rc.3-pp-fork.12 + zkevm_contracts_image: leovct/zkevm-contracts:v9.0.0-rc.3-pp-fork.12 additional_services: [] consensus_contract_type: pessimistic sequencer_type: erigon erigon_strict_mode: false - #agglayer_prover_sp1_key: + zkevm_use_gas_token_contract: false + #agglayer_prover_sp1_key: + zkevm_use_real_verifier: true enable_normalcy: true + verifier_program_vkey: 0x00e2a9cbc4eb87500598aa0c0953e9bee97097677c438cd71afd6c5ce35d2688 diff --git a/input_parser.star b/input_parser.star index 080c49c4..35979ce1 100644 --- a/input_parser.star +++ b/input_parser.star @@ -235,6 +235,10 @@ DEFAULT_ROLLUP_ARGS = { # Change to true to deploy a real verifier which will require a real prover. # Note: This will require a lot of memory to run! "zkevm_use_real_verifier": False, + # If we're using pessimistic consensus and a real verifier, we'll + # need to know which vkey to use. This value is tightly coupled to + # the agglayer version that's being used + "verifier_program_vkey": "0x0000000000000000000000000000000000000000000000000000000000000000", # This flag will enable a stateless executor to verify the execution of the batches. # Set to true to run erigon as the sequencer. "erigon_strict_mode": True, diff --git a/templates/cdk-erigon/config.yml b/templates/cdk-erigon/config.yml index cc2adeb5..38588d08 100644 --- a/templates/cdk-erigon/config.yml +++ b/templates/cdk-erigon/config.yml @@ -267,7 +267,7 @@ zkevm.data-stream-inactivity-check-interval: 5m # A shorter time increases block creation frequency but may lead to higher network load. # Consider network capacity and desired transaction confirmation speed when adjusting. # Default: 6s -zkevm.sequencer-block-seal-time: 6s +zkevm.sequencer-block-seal-time: 1s # The batch seal time. # Determine how frequently the sequencer groups blocks into a batch and seals it. diff --git a/templates/contract-deploy/create_rollup_parameters.json b/templates/contract-deploy/create_rollup_parameters.json index 6258c7c7..784197bc 100644 --- a/templates/contract-deploy/create_rollup_parameters.json +++ b/templates/contract-deploy/create_rollup_parameters.json @@ -14,5 +14,6 @@ "realVerifier": {{.zkevm_use_real_verifier}}, "trustedSequencer": "{{.zkevm_l2_sequencer_address}}", "trustedSequencerURL": "http://{{.sequencer_name}}{{.deployment_suffix}}:{{.zkevm_rpc_http_port}}", - "trustedAggregator":"{{.zkevm_l2_aggregator_address}}" + "trustedAggregator":"{{.zkevm_l2_aggregator_address}}", + "programVKey": "{{.verifier_program_vkey}}" } From 060f6a9edc1bf5b0127a24c13662d660b4a2f5a3 Mon Sep 17 00:00:00 2001 From: John Hilliard Date: Wed, 27 Nov 2024 15:22:06 -0500 Subject: [PATCH 02/38] docs: adding some guidance for testing --- multi-pp-test.sh | 376 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 376 insertions(+) create mode 100755 multi-pp-test.sh diff --git a/multi-pp-test.sh b/multi-pp-test.sh new file mode 100755 index 00000000..46ce5b38 --- /dev/null +++ b/multi-pp-test.sh @@ -0,0 +1,376 @@ +#!/bin/bash +echo "dont run this!" +exit 1; + +# To run this stuff you'll want to run most of these commands from within the kurtosis-cdk repo root. + +# Start up the networks (the secret file here is the same as the normal file but with an SP1 key) +kurtosis run --enclave pp --args-file .github/tests/fork12-pessimistic-secret.yml . +kurtosis run --enclave pp --args-file .github/tests/attach-second-cdk.yml . + +# Grab the combined.json files for future ref +kurtosis service exec pp contracts-001 "cat /opt/zkevm/combined-001.json" | tail -n +2 | jq '.' > combined-001.json +kurtosis service exec pp contracts-002 "cat /opt/zkevm/combined-002.json" | tail -n +2 | jq '.' > combined-002.json + +# Let's confirm the real verifier was deployed for the first rollup. At this point, I'm just going +cast code --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $(cat combined-001.json | jq -r '.verifierAddress') +cast code --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $(cat combined-002.json | jq -r '.verifierAddress') + +# Check that the hash of the verifier is actually the sp1 verifier. It should be f33fc6bc90b5ea5e0272a7ab87d701bdd05ecd78b8111ca4f450eeff1e6df26a +kurtosis service exec pp contracts-001 'cat /opt/zkevm-contracts/artifacts/contracts/verifiers/SP1Verifier.sol/SP1Verifier.json' | tail -n +2 | jq -r '.deployedBytecode' | sha256sum +cast code --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $(cat combined-001.json | jq -r '.verifierAddress') | sha256sum + +# At this point, the agglayer config needs to be manually updated for rollup2. This will add a second entry to the agglayer config +# TODO in the future we might as well make this values by default... +kurtosis service exec pp agglayer "sed -i 's/\[proof\-signers\]/2 = \"http:\/\/cdk-erigon-rpc-002:8123\"\n\[proof-signers\]/i' /etc/zkevm/agglayer-config.toml" +kurtosis service stop pp agglayer +kurtosis service start pp agglayer + +# At this point we should be able to confirm that things look right for both chains. In particular in rollup 2 we'd want to make sure batches are being verified +polycli monitor --rpc-url $(kurtosis port print pp cdk-erigon-rpc-001 rpc) +polycli monitor --rpc-url $(kurtosis port print pp cdk-erigon-rpc-002 rpc) + +# let's create a clean EOA for receiving bridges so that we can see +# things show up. This is a good way to make sure we don't mess things +# up by trying to exit more than we've deposited +cast wallet new +# Successfully created new keypair. +# Address: 0xdfC0482a44ff9A6e56ba8A37Fe5d07d3328431BC +# Private key: 0x5fa61eff44166582c8d6302c1eeeac4165057ed9d53d7786b85d6c65512ebfc3 +target_address=0xdfC0482a44ff9A6e56ba8A37Fe5d07d3328431BC +target_private_key=0x5fa61eff44166582c8d6302c1eeeac4165057ed9d53d7786b85d6c65512ebfc3 + +# Let's setup some variables for future use +private_key="0x12d7de8621a77640c9241b2595ba78ce443d05e94090365ab3bb5e19df82c625" +eth_address=$(cast wallet address --private-key $private_key) +l1_rpc_url=http://$(kurtosis port print pp el-1-geth-lighthouse rpc) +l2_pp_url=$(kurtosis port print pp cdk-erigon-rpc-001 rpc) +l2_fep_url=$(kurtosis port print pp cdk-erigon-rpc-002 rpc) +bridge_address=$(cat combined-001.json | jq -r .polygonZkEVMBridgeAddress) +pol_address=$(cat combined-001.json | jq -r .polTokenAddress) + +# Now let's make sure we have balance everywhere +cast balance --ether --rpc-url $l1_rpc_url $eth_address +cast balance --ether --rpc-url $l2_pp_url $eth_address +cast balance --ether --rpc-url $l2_fep_url $eth_address + +# Let's fund the claim tx manager for both rollups. These address come from the chain configurations (so either input_parser or the args file) +cast send --legacy --value 10ether --rpc-url $l2_pp_url --private-key $private_key 0x5f5dB0D4D58310F53713eF4Df80ba6717868A9f8 +cast send --legacy --value 10ether --rpc-url $l2_fep_url --private-key $private_key 0x93F63c24735f45Cd0266E87353071B64dd86bc05 + +# Let's mint some POL for bridge testing +cast send \ + --rpc-url $l1_rpc_url \ + --private-key $private_key \ + $pol_address \ + 'mint(address,uint256)' \ + $eth_address 10000000000000000000000 + +# We also need to approve +cast send \ + --rpc-url $l1_rpc_url \ + --private-key $private_key \ + $pol_address \ + 'approve(address,uint256)' \ + $bridge_address 10000000000000000000000 + + +# Let's go to madison county + +# R0, R1, Native, Force +cast send \ + --legacy \ + --rpc-url $l1_rpc_url \ + --value 100000000000000000000 \ + --private-key $private_key \ + $bridge_address \ + "bridgeAsset(uint32,address,uint256,address,bool,bytes)" \ + 1 $target_address 100000000000000000000 $(cast az) true 0x + +# R0, R2, Native, Force +cast send \ + --legacy \ + --rpc-url $l1_rpc_url \ + --value 100000000000000000000 \ + --private-key $private_key \ + $bridge_address \ + "bridgeAsset(uint32,address,uint256,address,bool,bytes)" \ + 2 $target_address 100000000000000000000 $(cast az) true 0x + +# R0, R1, Native, No Force +cast send \ + --legacy \ + --rpc-url $l1_rpc_url \ + --value 1000000000000000000 \ + --private-key $private_key \ + $bridge_address \ + "bridgeAsset(uint32,address,uint256,address,bool,bytes)" \ + 1 $target_address 1000000000000000000 $(cast az) false 0x + +# R0, R2, Native, No Force +cast send \ + --legacy \ + --rpc-url $l1_rpc_url \ + --value 1000000000000000000 \ + --private-key $private_key \ + $bridge_address \ + "bridgeAsset(uint32,address,uint256,address,bool,bytes)" \ + 2 $target_address 1000000000000000000 $(cast az) false 0x + + +# R0, R1, POL, Force +cast send \ + --legacy \ + --rpc-url $l1_rpc_url \ + --private-key $private_key \ + $bridge_address \ + "bridgeAsset(uint32,address,uint256,address,bool,bytes)" \ + 1 $target_address 1000000000000000000 $pol_address true 0x + +# R0, R2, POL, Force +cast send \ + --legacy \ + --rpc-url $l1_rpc_url \ + --private-key $private_key \ + $bridge_address \ + "bridgeAsset(uint32,address,uint256,address,bool,bytes)" \ + 2 $target_address 1000000000000000000 $pol_address true 0x + +# We'll need to wait a little bit... + +# Let's see if our balances have grown (both should be non-zero) +cast balance --ether --rpc-url $l2_pp_url $target_address +cast balance --ether --rpc-url $l2_fep_url $target_address + +# Let's check our L2 token balance (both should be non-zero) +token_hash=$(cast keccak $(cast abi-encode --packed 'f(uint32,address)' 0 $pol_address)) +l2_pol_address=$(cast call --rpc-url $l2_pp_url $bridge_address 'tokenInfoToWrappedToken(bytes32)(address)' $token_hash) +cast call --rpc-url $l2_pp_url $l2_pol_address 'balanceOf(address)(uint256)' $target_address +cast call --rpc-url $l2_fep_url $l2_pol_address 'balanceOf(address)(uint256)' $target_address + +# We should be in a good position now to try some bridge exits!! +# PP Exits +# R1, R0, Native, No Force +cast send \ + --legacy \ + --rpc-url $l2_pp_url \ + --value 100000000000000003 \ + --private-key $target_private_key \ + $bridge_address \ + "bridgeAsset(uint32,address,uint256,address,bool,bytes)" \ + 0 $target_address 100000000000000003 $(cast az) false 0x + +# R1, R2, Native, No Force +cast send \ + --legacy \ + --rpc-url $l2_pp_url \ + --value 100000000000000004 \ + --private-key $target_private_key \ + $bridge_address \ + "bridgeAsset(uint32,address,uint256,address,bool,bytes)" \ + 2 $target_address 100000000000000004 $(cast az) false 0x + +# R1, R0, POL, No Force +cast send \ + --legacy \ + --rpc-url $l2_pp_url \ + --private-key $target_private_key \ + $bridge_address \ + "bridgeAsset(uint32,address,uint256,address,bool,bytes)" \ + 0 $target_address 100000000000000005 $l2_pol_address false 0x + +# R1, R2, POL, No Force +cast send \ + --legacy \ + --rpc-url $l2_pp_url \ + --private-key $target_private_key \ + $bridge_address \ + "bridgeAsset(uint32,address,uint256,address,bool,bytes)" \ + 2 $target_address 100000000000000006 $l2_pol_address false 0x + +# R1, R0, Native, Force +cast send \ + --legacy \ + --rpc-url $l2_pp_url \ + --value 100000000000000001 \ + --private-key $target_private_key \ + $bridge_address \ + "bridgeAsset(uint32,address,uint256,address,bool,bytes)" \ + 0 $target_address 100000000000000001 $(cast az) true 0x + +# R1, R2, Native, Force +cast send \ + --legacy \ + --rpc-url $l2_pp_url \ + --value 100000000000000002 \ + --private-key $target_private_key \ + $bridge_address \ + "bridgeAsset(uint32,address,uint256,address,bool,bytes)" \ + 2 $target_address 100000000000000002 $(cast az) true 0x + +# FEP Exists +# R2, R0, Native, No Force +cast send \ + --legacy \ + --rpc-url $l2_fep_url \ + --value 100000000000000007 \ + --private-key $target_private_key \ + $bridge_address \ + "bridgeAsset(uint32,address,uint256,address,bool,bytes)" \ + 0 $target_address 100000000000000007 $(cast az) false 0x + +# R2, R1, Native, No Force +cast send \ + --legacy \ + --rpc-url $l2_fep_url \ + --value 100000000000000008 \ + --private-key $target_private_key \ + $bridge_address \ + "bridgeAsset(uint32,address,uint256,address,bool,bytes)" \ + 1 $target_address 100000000000000008 $(cast az) false 0x + +# R2, R0, POL, No Force +cast send \ + --legacy \ + --rpc-url $l2_fep_url \ + --private-key $target_private_key \ + $bridge_address \ + "bridgeAsset(uint32,address,uint256,address,bool,bytes)" \ + 0 $target_address 100000000000000009 $l2_pol_address false 0x + +# R2, R1, POL, No Force +cast send \ + --legacy \ + --rpc-url $l2_fep_url \ + --private-key $target_private_key \ + $bridge_address \ + "bridgeAsset(uint32,address,uint256,address,bool,bytes)" \ + 1 $target_address 100000000000000010 $l2_pol_address false 0x + +# R2, R0, Native, Force +cast send \ + --legacy \ + --rpc-url $l2_fep_url \ + --value 100000000000000011 \ + --private-key $target_private_key \ + $bridge_address \ + "bridgeAsset(uint32,address,uint256,address,bool,bytes)" \ + 0 $target_address 100000000000000011 $(cast az) true 0x + +# R2, R1, Native, Force +cast send \ + --legacy \ + --rpc-url $l2_fep_url \ + --value 100000000000000012 \ + --private-key $target_private_key \ + $bridge_address \ + "bridgeAsset(uint32,address,uint256,address,bool,bytes)" \ + 1 $target_address 100000000000000012 $(cast az) true 0x + + +# Do some criss-crossing +for i in {1..20}; do + # R1, R0, Native, Force + cast send \ + --legacy \ + --rpc-url $l2_pp_url \ + --value 100000000000000001 \ + --private-key $target_private_key \ + $bridge_address \ + "bridgeAsset(uint32,address,uint256,address,bool,bytes)" \ + 0 $target_address 100000000000000001 $(cast az) true 0x + + # R2, R0, Native, Force + cast send \ + --legacy \ + --rpc-url $l2_fep_url \ + --value 100000000000000011 \ + --private-key $target_private_key \ + $bridge_address \ + "bridgeAsset(uint32,address,uint256,address,bool,bytes)" \ + 0 $target_address 100000000000000011 $(cast az) true 0x +done + + +# Do a bridge message +# R0, R1, Message, Force +cast send \ + --legacy \ + --rpc-url $l1_rpc_url \ + --value 1 \ + --private-key $private_key \ + $bridge_address \ + "bridgeMessage(uint32,address,bool,bytes)" \ + 1 "0xFFFF000000000000000000000000000000000001" "true" "0x1234" + +# R0, R2, Message, Force +cast send \ + --legacy \ + --rpc-url $l1_rpc_url \ + --value 1 \ + --private-key $private_key \ + $bridge_address \ + "bridgeMessage(uint32,address,bool,bytes)" \ + 2 "0xFFFF000000000000000000000000000000000001" "true" "0x1234" + +# R0, R9999, Message, Force +cast send \ + --legacy \ + --rpc-url $l1_rpc_url \ + --value 1 \ + --private-key $private_key \ + $bridge_address \ + "bridgeMessage(uint32,address,bool,bytes)" \ + 9999 "0xFFFF000000000000000000000000000000000001" "true" "0x1234" + + +for i in {2..16}; do + call_size=$(bc <<< "2^$i") + # R0, R1, Message, Force + cast send \ + --legacy \ + --rpc-url $l1_rpc_url \ + --value 1 \ + --private-key $private_key \ + $bridge_address \ + "bridgeMessage(uint32,address,bool,bytes)" \ + 1 "0xFFFF000000000000000000000000000000000001" "true" "0x$(cat /dev/random | xxd -p | tr -d "\n" | head -c $call_size)" + + # R0, R2, Message, Force + cast send \ + --legacy \ + --rpc-url $l1_rpc_url \ + --value 1 \ + --private-key $private_key \ + $bridge_address \ + "bridgeMessage(uint32,address,bool,bytes)" \ + 2 "0xFFFF000000000000000000000000000000000001" "true" "0x$(cat /dev/random | xxd -p | tr -d "\n" | head -c $call_size)" +done + + +for i in {2..16}; do + call_size=$(bc <<< "2^$i") + # R1, R0, Message, Force + cast send \ + --legacy \ + --rpc-url $l2_pp_url \ + --value 1 \ + --private-key $target_private_key \ + $bridge_address \ + "bridgeMessage(uint32,address,bool,bytes)" \ + 0 "0xFFFF000000000000000000000000000000000001" "true" "0x$(cat /dev/random | xxd -p | tr -d "\n" | head -c $call_size)" + # R1, R2, Message, Force + cast send \ + --legacy \ + --rpc-url $l2_pp_url \ + --value 1 \ + --private-key $target_private_key \ + $bridge_address \ + "bridgeMessage(uint32,address,bool,bytes)" \ + 2 "0xFFFF000000000000000000000000000000000001" "true" "0x$(cat /dev/random | xxd -p | tr -d "\n" | head -c $call_size)" +done + +# At this point, I've encountered the error +# [agglayer] {"timestamp":"2024-11-27T20:18:52.021621Z","level":"WARN","fields":{"message":"Error during certification process of 0x24319d4ef5dda589b80498917cea4a66fd91494993fb391bfe5a02ddda84e674: native execution failed: MissingTokenBalanceProof(TokenInfo { origin_network: NetworkId(0), origin_token_address: 0x0000000000000000000000000000000000000000 })","hash":"0x24319d4ef5dda589b80498917cea4a66fd91494993fb391bfe5a02ddda84e674"},"target":"agglayer_certificate_orchestrator::network_task"} +# [agglayer] {"timestamp":"2024-11-27T20:18:59.020532Z","level":"WARN","fields":{"message":"Certificate 0x24319d4ef5dda589b80498917cea4a66fd91494993fb391bfe5a02ddda84e674 is in error: (native) proof generation error: Missing token balance proof. TokenInfo: TokenInfo { origin_network: NetworkId(0), origin_token_address: 0x0000000000000000000000000000000000000000 }","hash":"0x24319d4ef5dda589b80498917cea4a66fd91494993fb391bfe5a02ddda84e674"},"target":"agglayer_certificate_orchestrator::network_task"} + From d5c0b6199e97543933d11c9df473803a680b65ce Mon Sep 17 00:00:00 2001 From: John Hilliard Date: Mon, 2 Dec 2024 16:32:36 -0500 Subject: [PATCH 03/38] chore: version bump --- .github/tests/fork12-pessimistic.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/tests/fork12-pessimistic.yml b/.github/tests/fork12-pessimistic.yml index b2cd23bf..ddb47997 100644 --- a/.github/tests/fork12-pessimistic.yml +++ b/.github/tests/fork12-pessimistic.yml @@ -1,6 +1,6 @@ args: - agglayer_image: ghcr.io/agglayer/agglayer:0.2.0-rc.17 - cdk_node_image: ghcr.io/0xpolygon/cdk:0.5.0-beta5 + agglayer_image: ghcr.io/agglayer/agglayer:0.2.0-rc.18 + cdk_node_image: ghcr.io/0xpolygon/cdk:0.5.0-beta6 cdk_erigon_node_image: hermeznetwork/cdk-erigon:v2.60.0 zkevm_bridge_service_image: hermeznetwork/zkevm-bridge-service:v0.6.0-RC2 zkevm_bridge_ui_image: leovct/zkevm-bridge-ui:multi-network @@ -13,4 +13,4 @@ args: #agglayer_prover_sp1_key: zkevm_use_real_verifier: true enable_normalcy: true - verifier_program_vkey: 0x00e2a9cbc4eb87500598aa0c0953e9bee97097677c438cd71afd6c5ce35d2688 + verifier_program_vkey: 0x00e2a9cbc4eb87500598aa0c0953e9bee97097677c438cd71afd6c5 From bf90e63c909685dc46635c3a0b3bc77fc116d96e Mon Sep 17 00:00:00 2001 From: John Hilliard Date: Mon, 2 Dec 2024 16:34:02 -0500 Subject: [PATCH 04/38] fix: vkey --- .github/tests/fork12-pessimistic.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/tests/fork12-pessimistic.yml b/.github/tests/fork12-pessimistic.yml index ddb47997..598c2fc1 100644 --- a/.github/tests/fork12-pessimistic.yml +++ b/.github/tests/fork12-pessimistic.yml @@ -13,4 +13,4 @@ args: #agglayer_prover_sp1_key: zkevm_use_real_verifier: true enable_normalcy: true - verifier_program_vkey: 0x00e2a9cbc4eb87500598aa0c0953e9bee97097677c438cd71afd6c5 + verifier_program_vkey: 0x00617f688d0a520d3cdda077a80a3437e1997f630595d404117adfcb0ad56785 From 432a372940e8be44b50f2cac5c3a57f345cf98de Mon Sep 17 00:00:00 2001 From: John Hilliard Date: Mon, 2 Dec 2024 23:17:39 -0500 Subject: [PATCH 05/38] feat: latest changes for testing --- .github/tests/attach-second-cdk.yml | 4 +- multi-pp-test.sh | 154 ++++++++++++++++++++++++++++ 2 files changed, 156 insertions(+), 2 deletions(-) diff --git a/.github/tests/attach-second-cdk.yml b/.github/tests/attach-second-cdk.yml index 90d9a756..3e92d3ec 100644 --- a/.github/tests/attach-second-cdk.yml +++ b/.github/tests/attach-second-cdk.yml @@ -28,6 +28,6 @@ args: cdk_erigon_node_image: hermeznetwork/cdk-erigon:v2.60.0 - cdk_node_image: ghcr.io/0xpolygon/cdk:0.5.0-beta5 - zkevm_contracts_image: leovct/zkevm-contracts:v9.0.0-rc.3-pp-fork.12 + cdk_node_image: ghcr.io/0xpolygon/cdk:0.5.0-beta6 + zkevm_contracts_image: leovct/zkevm-contracts:v9.0.0-rc.3-pp-fork.12-patch.1 additional_services: [] diff --git a/multi-pp-test.sh b/multi-pp-test.sh index 46ce5b38..f4cfc770 100755 --- a/multi-pp-test.sh +++ b/multi-pp-test.sh @@ -374,3 +374,157 @@ done # [agglayer] {"timestamp":"2024-11-27T20:18:52.021621Z","level":"WARN","fields":{"message":"Error during certification process of 0x24319d4ef5dda589b80498917cea4a66fd91494993fb391bfe5a02ddda84e674: native execution failed: MissingTokenBalanceProof(TokenInfo { origin_network: NetworkId(0), origin_token_address: 0x0000000000000000000000000000000000000000 })","hash":"0x24319d4ef5dda589b80498917cea4a66fd91494993fb391bfe5a02ddda84e674"},"target":"agglayer_certificate_orchestrator::network_task"} # [agglayer] {"timestamp":"2024-11-27T20:18:59.020532Z","level":"WARN","fields":{"message":"Certificate 0x24319d4ef5dda589b80498917cea4a66fd91494993fb391bfe5a02ddda84e674 is in error: (native) proof generation error: Missing token balance proof. TokenInfo: TokenInfo { origin_network: NetworkId(0), origin_token_address: 0x0000000000000000000000000000000000000000 }","hash":"0x24319d4ef5dda589b80498917cea4a66fd91494993fb391bfe5a02ddda84e674"},"target":"agglayer_certificate_orchestrator::network_task"} + + + + + + +appleseed_address="0x56c069fd987CEA5A8e03E1c1AEB8089000f13bB6" + +cast send --legacy --rpc-url $l1_rpc_url --value 100000000000000000000 --private-key $private_key $appleseed_address +# R0, R1, Native, Force +cast send \ + --legacy \ + --rpc-url $l1_rpc_url \ + --value 100000000000000000000 \ + --private-key $private_key \ + $bridge_address \ + "bridgeAsset(uint32,address,uint256,address,bool,bytes)" \ + 1 $appleseed_address 100000000000000000000 $(cast az) true 0x + +# R0, R2, Native, Force +cast send \ + --legacy \ + --rpc-url $l1_rpc_url \ + --value 100000000000000000000 \ + --private-key $private_key \ + $bridge_address \ + "bridgeAsset(uint32,address,uint256,address,bool,bytes)" \ + 2 $appleseed_address 100000000000000000000 $(cast az) true 0x + +function distribute() { + + local mnemonic_index="$1" + local rpc_url="$2" + local lxly_bridge_addr="$3" + local cur_net="$4" + + local dest_net + + local seed_mnemonic="gallery option core excess loyal sing subject hold collect reason entry alpha" + + local mnemonic_index_1=$((2 * mnemonic_index + 1)) + local mnemonic_index_2=$((2 * mnemonic_index + 2)) + + local eth_address=$(cast wallet address --mnemonic "$seed_mnemonic" --mnemonic-index $mnemonic_index) + local eth_address_1=$(cast wallet address --mnemonic "$seed_mnemonic" --mnemonic-index $mnemonic_index_1) + local eth_address_2=$(cast wallet address --mnemonic "$seed_mnemonic" --mnemonic-index $mnemonic_index_2) + + local balance + local min_balance_check + local lxly_bridge_addr + + while true; do + balance=$(cast balance --rpc-url $rpc_url $eth_address) + min_balance_check=$(bc <<< "$balance > 1000000000") # should probably have at least 1gwei? + if [[ $min_balance_check -eq 1 ]]; then + break + fi + sleep 10 + done + + # do some work + # do some work + # do some work + + if [[ $cur_net -eq 0 ]]; then + if [[ $(($RANDOM % 2)) -eq 0 ]]; then + dest_net=1 + else + dest_net=2 + fi + elif [[ $cur_net -eq 1 ]]; then + if [[ $(($RANDOM % 2)) -eq 0 ]]; then + dest_net=0 + else + dest_net=2 + fi + else + if [[ $(($RANDOM % 2)) -eq 0 ]]; then + dest_net=0 + else + dest_net=1 + fi + fi + + local is_forced=true + if [[ $(($RANDOM % 2)) -eq 0 ]]; then + is_forced=false + fi + + local bridge_data="0x" + if [[ $(($RANDOM % 2)) -eq 0 ]]; then + bridge_data="0x$(cat /dev/random | xxd -p | tr -d "\n" | head -c $((RANDOM & ~1)))" + fi + + + if [[ $(($RANDOM % 2)) -eq 0 ]]; then + set -x + cast send \ + --legacy \ + --rpc-url "$rpc_url" \ + --value "$mnemonic_index" \ + --gas-limit 1000000 \ + --mnemonic "$seed_mnemonic" --mnemonic-index "$mnemonic_index" \ + "$lxly_bridge_addr" \ + "bridgeMessage(uint32,address,bool,bytes)" \ + "$dest_net" "0x56c069fd987CEA5A8e03E1c1AEB8089000f13bB6" "$is_forced" "$bridge_data" + set +x + else + set -x + cast send \ + --legacy \ + --rpc-url "$rpc_url" \ + --value "$mnemonic_index" \ + --gas-limit 1000000 \ + --mnemonic "$seed_mnemonic" --mnemonic-index "$mnemonic_index" \ + "$lxly_bridge_addr" \ + "bridgeAsset(uint32,address,uint256,address,bool,bytes)" \ + "$dest_net" "0x56c069fd987CEA5A8e03E1c1AEB8089000f13bB6" "$mnemonic_index" "$(cast az)" "$is_forced" "$bridge_data" + set +x + fi + + # finished + # finished + # finished + + balance=$(cast balance --rpc-url $rpc_url $eth_address) + + local gas_price="$(cast gas-price --rpc-url $rpc_url)" + gas_price=$(bc <<< "$gas_price * 3 / 2") # push the gas price up for faster mining + + local leave_behind=271828 + local dist_value=$(bc <<< "($balance - $leave_behind - (2 * 21000 * $gas_price)) / 2") + local has_enough=$(bc <<< "$dist_value > (1000000000*21000)") # let's assume we want at least enough for a tx at 1gwei + if [[ $has_enough -eq 0 ]]; then + echo "The address $eth_address does not have enough funds. Current balance is $balance and distribute value would be $dist_value" >&2 + exit 1 + fi + + echo "sending $dist_value from $eth_address:$mnemonic_index to $eth_address_1:$mnemonic_index_1 and $eth_address_2:$mnemonic_index_2" + echo "current balance: $balance" + + cast send --timeout 900 --legacy --mnemonic "$seed_mnemonic" --mnemonic-index "$mnemonic_index" --rpc-url "$rpc_url" --gas-price $gas_price --value $dist_value $eth_address_1 > /dev/null + cast send --timeout 900 --legacy --mnemonic "$seed_mnemonic" --mnemonic-index "$mnemonic_index" --rpc-url "$rpc_url" --gas-price $gas_price --value $dist_value $eth_address_2 > /dev/null +} + +export -f distribute + +seq 0 32768 | parallel -j32 distribute {} $l1_rpc_url $bridge_address 0 &> r0-bridge-logs.log & +seq 0 32768 | parallel -j32 distribute {} $l2_pp_url $bridge_address 1 &> r1-bridge-logs.log & +seq 0 32768 | parallel -j32 distribute {} $l2_fep_url $bridge_address 2 &> r2-bridge-logs.log & + +# Check why cdk-node is running hot +sudo /usr/sbin/profile-bpfcc --stack-storage-size 32000 -f -F 199 -p 3770750 100 > cdk-node-folded.out +~/code/FlameGraph/flamegraph.pl --title="CDK Node Profile" cdk-node-folded.out > cdk-node.2.svg From 14ff92c7a72662c7c425ed0b7fe354e574b09abe Mon Sep 17 00:00:00 2001 From: John Hilliard Date: Tue, 3 Dec 2024 19:18:34 -0500 Subject: [PATCH 06/38] feat: version difference and configs --- .github/tests/fork12-pessimistic.yml | 2 +- multi-pp-test.sh | 7 ++++--- templates/bridge-infra/agglayer-config.toml | 1 + templates/trusted-node/cdk-node-config.toml | 2 ++ 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/tests/fork12-pessimistic.yml b/.github/tests/fork12-pessimistic.yml index 598c2fc1..0d38de2f 100644 --- a/.github/tests/fork12-pessimistic.yml +++ b/.github/tests/fork12-pessimistic.yml @@ -1,6 +1,6 @@ args: agglayer_image: ghcr.io/agglayer/agglayer:0.2.0-rc.18 - cdk_node_image: ghcr.io/0xpolygon/cdk:0.5.0-beta6 + cdk_node_image: ghcr.io/0xpolygon/cdk:0.5.0-beta7 cdk_erigon_node_image: hermeznetwork/cdk-erigon:v2.60.0 zkevm_bridge_service_image: hermeznetwork/zkevm-bridge-service:v0.6.0-RC2 zkevm_bridge_ui_image: leovct/zkevm-bridge-ui:multi-network diff --git a/multi-pp-test.sh b/multi-pp-test.sh index f4cfc770..da5792c8 100755 --- a/multi-pp-test.sh +++ b/multi-pp-test.sh @@ -2,6 +2,7 @@ echo "dont run this!" exit 1; +# # Multi Chain PP Test # To run this stuff you'll want to run most of these commands from within the kurtosis-cdk repo root. # Start up the networks (the secret file here is the same as the normal file but with an SP1 key) @@ -55,8 +56,8 @@ cast balance --ether --rpc-url $l2_pp_url $eth_address cast balance --ether --rpc-url $l2_fep_url $eth_address # Let's fund the claim tx manager for both rollups. These address come from the chain configurations (so either input_parser or the args file) -cast send --legacy --value 10ether --rpc-url $l2_pp_url --private-key $private_key 0x5f5dB0D4D58310F53713eF4Df80ba6717868A9f8 -cast send --legacy --value 10ether --rpc-url $l2_fep_url --private-key $private_key 0x93F63c24735f45Cd0266E87353071B64dd86bc05 +cast send --legacy --value 100ether --rpc-url $l2_pp_url --private-key $private_key 0x5f5dB0D4D58310F53713eF4Df80ba6717868A9f8 +cast send --legacy --value 100ether --rpc-url $l2_fep_url --private-key $private_key 0x93F63c24735f45Cd0266E87353071B64dd86bc05 # Let's mint some POL for bridge testing cast send \ @@ -522,7 +523,7 @@ function distribute() { export -f distribute seq 0 32768 | parallel -j32 distribute {} $l1_rpc_url $bridge_address 0 &> r0-bridge-logs.log & -seq 0 32768 | parallel -j32 distribute {} $l2_pp_url $bridge_address 1 &> r1-bridge-logs.log & +seq 0 32768 | parallel -j32 distribute {} $l2_pp_url $bridge_address 1 &> r1-bridge-logs.log & seq 0 32768 | parallel -j32 distribute {} $l2_fep_url $bridge_address 2 &> r2-bridge-logs.log & # Check why cdk-node is running hot diff --git a/templates/bridge-infra/agglayer-config.toml b/templates/bridge-infra/agglayer-config.toml index 5f686c54..575cdf27 100644 --- a/templates/bridge-infra/agglayer-config.toml +++ b/templates/bridge-infra/agglayer-config.toml @@ -11,6 +11,7 @@ prover-entrypoint = "{{.agglayer_prover_entrypoint}}" port = {{.agglayer_port}} host = "0.0.0.0" request-timeout = 180 +max-request-body-size = 104857600 [outbound.rpc.settle] max-retries = 3 diff --git a/templates/trusted-node/cdk-node-config.toml b/templates/trusted-node/cdk-node-config.toml index 2559c48b..fa92453f 100644 --- a/templates/trusted-node/cdk-node-config.toml +++ b/templates/trusted-node/cdk-node-config.toml @@ -57,6 +57,8 @@ Outputs = ["stderr"] [AggSender] CertificateSendInterval = "1m" CheckSettledInterval = "5s" +MaxCertSize = 102760448 +SaveCertificatesToFilesPath="/tmp" [L1InfoTreeSync] # The initial block number from which to start syncing. From 142266887dd6a2744e7a486e861b0e94542cf2d0 Mon Sep 17 00:00:00 2001 From: John Hilliard Date: Tue, 3 Dec 2024 23:39:01 -0500 Subject: [PATCH 07/38] chore: version bump --- .github/tests/fork12-pessimistic.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/tests/fork12-pessimistic.yml b/.github/tests/fork12-pessimistic.yml index 0d38de2f..33a30ddd 100644 --- a/.github/tests/fork12-pessimistic.yml +++ b/.github/tests/fork12-pessimistic.yml @@ -1,5 +1,5 @@ args: - agglayer_image: ghcr.io/agglayer/agglayer:0.2.0-rc.18 + agglayer_image: ghcr.io/agglayer/agglayer:0.2.0-rc.19 cdk_node_image: ghcr.io/0xpolygon/cdk:0.5.0-beta7 cdk_erigon_node_image: hermeznetwork/cdk-erigon:v2.60.0 zkevm_bridge_service_image: hermeznetwork/zkevm-bridge-service:v0.6.0-RC2 From 682aef7bccdbd623a994bd1e29c2ff7d07600990 Mon Sep 17 00:00:00 2001 From: John Hilliard Date: Thu, 5 Dec 2024 13:57:12 -0500 Subject: [PATCH 08/38] chore: bridge version bump --- input_parser.star | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/input_parser.star b/input_parser.star index 20c74925..a1500d50 100644 --- a/input_parser.star +++ b/input_parser.star @@ -34,7 +34,7 @@ DEFAULT_IMAGES = { "cdk_node_image": "ghcr.io/0xpolygon/cdk:0.4.0", # https://github.com/0xpolygon/cdk/pkgs/container/cdk "cdk_validium_node_image": "0xpolygon/cdk-validium-node:0.7.0-cdk", # https://hub.docker.com/r/0xpolygon/cdk-validium-node/tags "zkevm_bridge_proxy_image": "haproxy:3.1-bookworm", # https://hub.docker.com/_/haproxy/tags - "zkevm_bridge_service_image": "hermeznetwork/zkevm-bridge-service:v0.6.0-RC2", # https://hub.docker.com/r/hermeznetwork/zkevm-bridge-service/tags + "zkevm_bridge_service_image": "hermeznetwork/zkevm-bridge-service:v0.6.0-RC3", # https://hub.docker.com/r/hermeznetwork/zkevm-bridge-service/tags "zkevm_bridge_ui_image": "leovct/zkevm-bridge-ui:multi-network", # https://hub.docker.com/r/leovct/zkevm-bridge-ui/tags "zkevm_contracts_image": "leovct/zkevm-contracts:v8.0.0-fork.12-patch.1", # https://hub.docker.com/repository/docker/leovct/zkevm-contracts/tags "zkevm_da_image": "0xpolygon/cdk-data-availability:0.0.11", # https://hub.docker.com/r/0xpolygon/cdk-data-availability/tags From a54f136cb8d1a5a4db2c6e715c82a383d52285c9 Mon Sep 17 00:00:00 2001 From: John Hilliard Date: Thu, 5 Dec 2024 15:13:58 -0500 Subject: [PATCH 09/38] chore: minore config changes --- templates/bridge-infra/agglayer-config.toml | 9 +++++++++ templates/bridge-infra/agglayer-prover-config.toml | 7 +++++++ templates/cdk-erigon/config.yml | 9 +++++++-- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/templates/bridge-infra/agglayer-config.toml b/templates/bridge-infra/agglayer-config.toml index 575cdf27..37b88812 100644 --- a/templates/bridge-infra/agglayer-config.toml +++ b/templates/bridge-infra/agglayer-config.toml @@ -11,8 +11,17 @@ prover-entrypoint = "{{.agglayer_prover_entrypoint}}" port = {{.agglayer_port}} host = "0.0.0.0" request-timeout = 180 +# size is define in bytes e.g. 100 * 1024 * 1024 +# same for `max_response_body_size` +# default value is equal to 10MB max-request-body-size = 104857600 +[prover.grpc] +# size is define in bytes e.g. 100 * 1024 * 1024 +# same for `max-encoding-message-size` +# default value is equal to 4MB +max-decoding-message-size = 104857600 + [outbound.rpc.settle] max-retries = 3 retry-interval = 7 diff --git a/templates/bridge-infra/agglayer-prover-config.toml b/templates/bridge-infra/agglayer-prover-config.toml index 9b95de65..d54bf695 100644 --- a/templates/bridge-infra/agglayer-prover-config.toml +++ b/templates/bridge-infra/agglayer-prover-config.toml @@ -21,3 +21,10 @@ proving-timeout = 900 [network-prover] enabled = {{.is_network_prover_enabled}} proving-timeout = 900 + +[grpc] +# size is define in bytes e.g. 100 * 1024 * 1024 +# same for `max-encoding-message-size` +# default value is equal to 4MB +max-decoding-message-size = 104857600 + diff --git a/templates/cdk-erigon/config.yml b/templates/cdk-erigon/config.yml index 38588d08..81a9ad3a 100644 --- a/templates/cdk-erigon/config.yml +++ b/templates/cdk-erigon/config.yml @@ -267,14 +267,19 @@ zkevm.data-stream-inactivity-check-interval: 5m # A shorter time increases block creation frequency but may lead to higher network load. # Consider network capacity and desired transaction confirmation speed when adjusting. # Default: 6s -zkevm.sequencer-block-seal-time: 1s +zkevm.sequencer-block-seal-time: 3s # The batch seal time. # Determine how frequently the sequencer groups blocks into a batch and seals it. # Longer times allow more blocks (and more txs) per batch, potentially improving efficiency, # but may increase overall transaction confirmation time. # Default: 12s -zkevm.sequencer-batch-seal-time: 12s +zkevm.sequencer-batch-seal-time: 15s + +# Seal the batch immediately when detecting a counter overflow +# This setting can be helpful to close batches faster while testing with a single account. +# Default: false +zkevm.seal-batch-immediately-on-overflow: true # Specify the maximum duration allowed for batch verification, including retry attempts. # This effectively limits how long the sequencer can operate without an executor. From c5058b845bd33e88e0aab04bb657f04ac17fccdd Mon Sep 17 00:00:00 2001 From: John Hilliard Date: Thu, 5 Dec 2024 15:14:12 -0500 Subject: [PATCH 10/38] docs: updating --- multi-pp-test.sh | 371 ++++++++++++----------------------------------- 1 file changed, 94 insertions(+), 277 deletions(-) diff --git a/multi-pp-test.sh b/multi-pp-test.sh index da5792c8..c134e03d 100755 --- a/multi-pp-test.sh +++ b/multi-pp-test.sh @@ -75,69 +75,40 @@ cast send \ 'approve(address,uint256)' \ $bridge_address 10000000000000000000000 +cast call --rpc-url $l1_rpc_url $bridge_address 'WETHToken()' # Let's go to madison county - -# R0, R1, Native, Force -cast send \ - --legacy \ - --rpc-url $l1_rpc_url \ - --value 100000000000000000000 \ - --private-key $private_key \ - $bridge_address \ - "bridgeAsset(uint32,address,uint256,address,bool,bytes)" \ - 1 $target_address 100000000000000000000 $(cast az) true 0x - -# R0, R2, Native, Force -cast send \ - --legacy \ - --rpc-url $l1_rpc_url \ - --value 100000000000000000000 \ - --private-key $private_key \ - $bridge_address \ - "bridgeAsset(uint32,address,uint256,address,bool,bytes)" \ - 2 $target_address 100000000000000000000 $(cast az) true 0x - -# R0, R1, Native, No Force -cast send \ - --legacy \ - --rpc-url $l1_rpc_url \ - --value 1000000000000000000 \ - --private-key $private_key \ - $bridge_address \ - "bridgeAsset(uint32,address,uint256,address,bool,bytes)" \ - 1 $target_address 1000000000000000000 $(cast az) false 0x - -# R0, R2, Native, No Force -cast send \ - --legacy \ - --rpc-url $l1_rpc_url \ - --value 1000000000000000000 \ - --private-key $private_key \ - $bridge_address \ - "bridgeAsset(uint32,address,uint256,address,bool,bytes)" \ - 2 $target_address 1000000000000000000 $(cast az) false 0x - - -# R0, R1, POL, Force -cast send \ - --legacy \ - --rpc-url $l1_rpc_url \ - --private-key $private_key \ - $bridge_address \ - "bridgeAsset(uint32,address,uint256,address,bool,bytes)" \ - 1 $target_address 1000000000000000000 $pol_address true 0x - -# R0, R2, POL, Force -cast send \ - --legacy \ - --rpc-url $l1_rpc_url \ - --private-key $private_key \ - $bridge_address \ - "bridgeAsset(uint32,address,uint256,address,bool,bytes)" \ - 2 $target_address 1000000000000000000 $pol_address true 0x - -# We'll need to wait a little bit... +for token_addr in $(cast az) $pol_address ; do + for destination_network in 1 2 ; do + for ger_update in "false" "true" ; do + value="0" + permit_data="0x" + if [[ $token_addr == $(cast az) ]]; then + value="100000000000000000000" + permit_data="0x$(cat /dev/random | xxd -p | tr -d "\n" | head -c $((RANDOM & ~1)))" + fi + polycli ulxly bridge asset \ + --private-key $private_key \ + --value $value \ + --bridge-address $bridge_address \ + --destination-network $destination_network \ + --destination-address $target_address \ + --force-update-root $ger_update \ + --call-data $permit_data \ + --rpc-url $l1_rpc_url \ + --token-address $token_addr + polycli ulxly bridge message \ + --private-key $private_key \ + --value $value \ + --bridge-address $bridge_address \ + --destination-network $destination_network \ + --destination-address $target_address \ + --force-update-root $ger_update \ + --call-data $permit_data \ + --rpc-url $l1_rpc_url + done + done +done # Let's see if our balances have grown (both should be non-zero) cast balance --ether --rpc-url $l2_pp_url $target_address @@ -149,227 +120,71 @@ l2_pol_address=$(cast call --rpc-url $l2_pp_url $bridge_address 'tokenInfoToWra cast call --rpc-url $l2_pp_url $l2_pol_address 'balanceOf(address)(uint256)' $target_address cast call --rpc-url $l2_fep_url $l2_pol_address 'balanceOf(address)(uint256)' $target_address -# We should be in a good position now to try some bridge exits!! -# PP Exits -# R1, R0, Native, No Force -cast send \ - --legacy \ - --rpc-url $l2_pp_url \ - --value 100000000000000003 \ - --private-key $target_private_key \ - $bridge_address \ - "bridgeAsset(uint32,address,uint256,address,bool,bytes)" \ - 0 $target_address 100000000000000003 $(cast az) false 0x - -# R1, R2, Native, No Force -cast send \ - --legacy \ - --rpc-url $l2_pp_url \ - --value 100000000000000004 \ - --private-key $target_private_key \ - $bridge_address \ - "bridgeAsset(uint32,address,uint256,address,bool,bytes)" \ - 2 $target_address 100000000000000004 $(cast az) false 0x - -# R1, R0, POL, No Force -cast send \ - --legacy \ - --rpc-url $l2_pp_url \ - --private-key $target_private_key \ - $bridge_address \ - "bridgeAsset(uint32,address,uint256,address,bool,bytes)" \ - 0 $target_address 100000000000000005 $l2_pol_address false 0x - -# R1, R2, POL, No Force -cast send \ - --legacy \ - --rpc-url $l2_pp_url \ - --private-key $target_private_key \ - $bridge_address \ - "bridgeAsset(uint32,address,uint256,address,bool,bytes)" \ - 2 $target_address 100000000000000006 $l2_pol_address false 0x - -# R1, R0, Native, Force -cast send \ - --legacy \ - --rpc-url $l2_pp_url \ - --value 100000000000000001 \ - --private-key $target_private_key \ - $bridge_address \ - "bridgeAsset(uint32,address,uint256,address,bool,bytes)" \ - 0 $target_address 100000000000000001 $(cast az) true 0x - -# R1, R2, Native, Force -cast send \ - --legacy \ - --rpc-url $l2_pp_url \ - --value 100000000000000002 \ - --private-key $target_private_key \ - $bridge_address \ - "bridgeAsset(uint32,address,uint256,address,bool,bytes)" \ - 2 $target_address 100000000000000002 $(cast az) true 0x - -# FEP Exists -# R2, R0, Native, No Force -cast send \ - --legacy \ - --rpc-url $l2_fep_url \ - --value 100000000000000007 \ - --private-key $target_private_key \ - $bridge_address \ - "bridgeAsset(uint32,address,uint256,address,bool,bytes)" \ - 0 $target_address 100000000000000007 $(cast az) false 0x - -# R2, R1, Native, No Force -cast send \ - --legacy \ - --rpc-url $l2_fep_url \ - --value 100000000000000008 \ - --private-key $target_private_key \ - $bridge_address \ - "bridgeAsset(uint32,address,uint256,address,bool,bytes)" \ - 1 $target_address 100000000000000008 $(cast az) false 0x - -# R2, R0, POL, No Force -cast send \ - --legacy \ - --rpc-url $l2_fep_url \ - --private-key $target_private_key \ - $bridge_address \ - "bridgeAsset(uint32,address,uint256,address,bool,bytes)" \ - 0 $target_address 100000000000000009 $l2_pol_address false 0x - -# R2, R1, POL, No Force -cast send \ - --legacy \ - --rpc-url $l2_fep_url \ - --private-key $target_private_key \ - $bridge_address \ - "bridgeAsset(uint32,address,uint256,address,bool,bytes)" \ - 1 $target_address 100000000000000010 $l2_pol_address false 0x - -# R2, R0, Native, Force -cast send \ - --legacy \ - --rpc-url $l2_fep_url \ - --value 100000000000000011 \ - --private-key $target_private_key \ - $bridge_address \ - "bridgeAsset(uint32,address,uint256,address,bool,bytes)" \ - 0 $target_address 100000000000000011 $(cast az) true 0x - -# R2, R1, Native, Force -cast send \ - --legacy \ - --rpc-url $l2_fep_url \ - --value 100000000000000012 \ - --private-key $target_private_key \ - $bridge_address \ - "bridgeAsset(uint32,address,uint256,address,bool,bytes)" \ - 1 $target_address 100000000000000012 $(cast az) true 0x - - -# Do some criss-crossing -for i in {1..20}; do - # R1, R0, Native, Force - cast send \ - --legacy \ - --rpc-url $l2_pp_url \ - --value 100000000000000001 \ - --private-key $target_private_key \ - $bridge_address \ - "bridgeAsset(uint32,address,uint256,address,bool,bytes)" \ - 0 $target_address 100000000000000001 $(cast az) true 0x - - # R2, R0, Native, Force - cast send \ - --legacy \ - --rpc-url $l2_fep_url \ - --value 100000000000000011 \ - --private-key $target_private_key \ - $bridge_address \ - "bridgeAsset(uint32,address,uint256,address,bool,bytes)" \ - 0 $target_address 100000000000000011 $(cast az) true 0x +for token_addr in $(cast az) $l2_pol_address ; do + for destination_network in 0 2 ; do + for ger_update in "false" "true" ; do + value="0" + permit_data="0x" + if [[ $token_addr == $(cast az) ]]; then + value="100000000000000000" + permit_data="0x$(cat /dev/random | xxd -p | tr -d "\n" | head -c $((RANDOM & ~1)))" + fi + polycli ulxly bridge asset \ + --private-key $target_private_key \ + --value $value \ + --bridge-address $bridge_address \ + --destination-network $destination_network \ + --destination-address $target_address \ + --force-update-root $ger_update \ + --call-data $permit_data \ + --rpc-url $l2_pp_url \ + --token-address $token_addr + polycli ulxly bridge message \ + --private-key $target_private_key \ + --value $value \ + --bridge-address $bridge_address \ + --destination-network $destination_network \ + --destination-address $target_address \ + --force-update-root $ger_update \ + --call-data $permit_data \ + --rpc-url $l2_pp_url + done + done done - -# Do a bridge message -# R0, R1, Message, Force -cast send \ - --legacy \ - --rpc-url $l1_rpc_url \ - --value 1 \ - --private-key $private_key \ - $bridge_address \ - "bridgeMessage(uint32,address,bool,bytes)" \ - 1 "0xFFFF000000000000000000000000000000000001" "true" "0x1234" - -# R0, R2, Message, Force -cast send \ - --legacy \ - --rpc-url $l1_rpc_url \ - --value 1 \ - --private-key $private_key \ - $bridge_address \ - "bridgeMessage(uint32,address,bool,bytes)" \ - 2 "0xFFFF000000000000000000000000000000000001" "true" "0x1234" - -# R0, R9999, Message, Force -cast send \ - --legacy \ - --rpc-url $l1_rpc_url \ - --value 1 \ - --private-key $private_key \ - $bridge_address \ - "bridgeMessage(uint32,address,bool,bytes)" \ - 9999 "0xFFFF000000000000000000000000000000000001" "true" "0x1234" - - -for i in {2..16}; do - call_size=$(bc <<< "2^$i") - # R0, R1, Message, Force - cast send \ - --legacy \ - --rpc-url $l1_rpc_url \ - --value 1 \ - --private-key $private_key \ - $bridge_address \ - "bridgeMessage(uint32,address,bool,bytes)" \ - 1 "0xFFFF000000000000000000000000000000000001" "true" "0x$(cat /dev/random | xxd -p | tr -d "\n" | head -c $call_size)" - - # R0, R2, Message, Force - cast send \ - --legacy \ - --rpc-url $l1_rpc_url \ - --value 1 \ - --private-key $private_key \ - $bridge_address \ - "bridgeMessage(uint32,address,bool,bytes)" \ - 2 "0xFFFF000000000000000000000000000000000001" "true" "0x$(cat /dev/random | xxd -p | tr -d "\n" | head -c $call_size)" +for token_addr in $(cast az) $l2_pol_address ; do + for destination_network in 0 1 ; do + for ger_update in "false" "true" ; do + value="0" + permit_data="0x" + if [[ $token_addr == $(cast az) ]]; then + value="100000000000000000" + permit_data="0x$(cat /dev/random | xxd -p | tr -d "\n" | head -c $((RANDOM & ~1)))" + fi + polycli ulxly bridge asset \ + --private-key $target_private_key \ + --value $value \ + --bridge-address $bridge_address \ + --destination-network $destination_network \ + --destination-address $target_address \ + --force-update-root $ger_update \ + --call-data $permit_data \ + --rpc-url $l2_fep_url \ + --token-address $token_addr + polycli ulxly bridge message \ + --private-key $target_private_key \ + --value $value \ + --bridge-address $bridge_address \ + --destination-network $destination_network \ + --destination-address $target_address \ + --force-update-root $ger_update \ + --call-data $permit_data \ + --rpc-url $l2_fep_url + done + done done -for i in {2..16}; do - call_size=$(bc <<< "2^$i") - # R1, R0, Message, Force - cast send \ - --legacy \ - --rpc-url $l2_pp_url \ - --value 1 \ - --private-key $target_private_key \ - $bridge_address \ - "bridgeMessage(uint32,address,bool,bytes)" \ - 0 "0xFFFF000000000000000000000000000000000001" "true" "0x$(cat /dev/random | xxd -p | tr -d "\n" | head -c $call_size)" - # R1, R2, Message, Force - cast send \ - --legacy \ - --rpc-url $l2_pp_url \ - --value 1 \ - --private-key $target_private_key \ - $bridge_address \ - "bridgeMessage(uint32,address,bool,bytes)" \ - 2 "0xFFFF000000000000000000000000000000000001" "true" "0x$(cat /dev/random | xxd -p | tr -d "\n" | head -c $call_size)" -done # At this point, I've encountered the error # [agglayer] {"timestamp":"2024-11-27T20:18:52.021621Z","level":"WARN","fields":{"message":"Error during certification process of 0x24319d4ef5dda589b80498917cea4a66fd91494993fb391bfe5a02ddda84e674: native execution failed: MissingTokenBalanceProof(TokenInfo { origin_network: NetworkId(0), origin_token_address: 0x0000000000000000000000000000000000000000 })","hash":"0x24319d4ef5dda589b80498917cea4a66fd91494993fb391bfe5a02ddda84e674"},"target":"agglayer_certificate_orchestrator::network_task"} @@ -529,3 +344,5 @@ seq 0 32768 | parallel -j32 distribute {} $l2_fep_url $bridge_address 2 &> r2-br # Check why cdk-node is running hot sudo /usr/sbin/profile-bpfcc --stack-storage-size 32000 -f -F 199 -p 3770750 100 > cdk-node-folded.out ~/code/FlameGraph/flamegraph.pl --title="CDK Node Profile" cdk-node-folded.out > cdk-node.2.svg + +# TODO We still need to run some tests specifically with a gas token network. perhaps this test suite shoudl be updated so there is a third PP network that uses a gas token From 349a515128f2dfc9b549c8e66954e6e18fce4c5e Mon Sep 17 00:00:00 2001 From: John Hilliard Date: Thu, 5 Dec 2024 17:01:17 -0500 Subject: [PATCH 11/38] chore: version bump and adding reference rate limit --- input_parser.star | 2 +- templates/bridge-infra/agglayer-config.toml | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/input_parser.star b/input_parser.star index a1500d50..b316a626 100644 --- a/input_parser.star +++ b/input_parser.star @@ -29,7 +29,7 @@ DEFAULT_DEPLOYMENT_STAGES = { } DEFAULT_IMAGES = { - "agglayer_image": "ghcr.io/agglayer/agglayer:0.2.0-rc.17", # https://github.com/agglayer/agglayer/tags + "agglayer_image": "ghcr.io/agglayer/agglayer:0.2.0-rc.19", # https://github.com/agglayer/agglayer/tags "cdk_erigon_node_image": "hermeznetwork/cdk-erigon:v2.60.0", # https://hub.docker.com/r/hermeznetwork/cdk-erigon/tags "cdk_node_image": "ghcr.io/0xpolygon/cdk:0.4.0", # https://github.com/0xpolygon/cdk/pkgs/container/cdk "cdk_validium_node_image": "0xpolygon/cdk-validium-node:0.7.0-cdk", # https://hub.docker.com/r/0xpolygon/cdk-validium-node/tags diff --git a/templates/bridge-infra/agglayer-config.toml b/templates/bridge-infra/agglayer-config.toml index 37b88812..d1fa7b45 100644 --- a/templates/bridge-infra/agglayer-config.toml +++ b/templates/bridge-infra/agglayer-config.toml @@ -54,8 +54,13 @@ rpc-timeout = 45 [telemetry] prometheus-addr = "0.0.0.0:{{.prometheus_port}}" +# https://github.com/orgs/agglayer/discussions/213 + [rate-limiting] send-tx = "unlimited" +# [rate-limiting.send-tx] +# max-per-interval = 1 +# time-interval = "15m" [rate-limiting.network] From 9ddebd3a22c4f0798e7b6820a95c7636e80ffbcb Mon Sep 17 00:00:00 2001 From: John Hilliard Date: Thu, 5 Dec 2024 19:48:32 -0500 Subject: [PATCH 12/38] chore: wip docs --- .github/tests/attach-second-cdk.yml | 14 +- multi-pp-test.sh | 481 +++++++++++++--------------- 2 files changed, 233 insertions(+), 262 deletions(-) diff --git a/.github/tests/attach-second-cdk.yml b/.github/tests/attach-second-cdk.yml index 3e92d3ec..ce8aa030 100644 --- a/.github/tests/attach-second-cdk.yml +++ b/.github/tests/attach-second-cdk.yml @@ -27,7 +27,19 @@ args: zkevm_l2_proofsigner_private_key: "0xc7fe3a006d75ba9326d9792523385abb49057c66aee0b8b4248821a89713f975" + agglayer_image: ghcr.io/agglayer/agglayer:0.2.0-rc.19 + cdk_node_image: ghcr.io/0xpolygon/cdk:0.5.0-beta7 cdk_erigon_node_image: hermeznetwork/cdk-erigon:v2.60.0 - cdk_node_image: ghcr.io/0xpolygon/cdk:0.5.0-beta6 + zkevm_bridge_service_image: hermeznetwork/zkevm-bridge-service:v0.6.0-RC3 + zkevm_bridge_ui_image: leovct/zkevm-bridge-ui:multi-network zkevm_contracts_image: leovct/zkevm-contracts:v9.0.0-rc.3-pp-fork.12-patch.1 additional_services: [] + consensus_contract_type: pessimistic + sequencer_type: erigon + erigon_strict_mode: false + gas_token_enabled: true + agglayer_prover_sp1_key: "0x7a2baab6e39878897307784a76f9711e783d54e6221d23f1cd4f3baf7d044f6c" + zkevm_use_real_verifier: true + enable_normalcy: true + verifier_program_vkey: 0x00617f688d0a520d3cdda077a80a3437e1997f630595d404117adfcb0ad56785 + diff --git a/multi-pp-test.sh b/multi-pp-test.sh index c134e03d..b585f468 100755 --- a/multi-pp-test.sh +++ b/multi-pp-test.sh @@ -3,63 +3,83 @@ echo "dont run this!" exit 1; # # Multi Chain PP Test -# To run this stuff you'll want to run most of these commands from within the kurtosis-cdk repo root. - -# Start up the networks (the secret file here is the same as the normal file but with an SP1 key) +# +# ## Infra Setup +# +# This is an example of a system where there are two PP chains +# attached to the rollup manager. One chain uses a gas token and the +# other does not. Between those two chains we're going to attempt a +# bunch of bridge scenarios. +# +# To run this stuff you'll want to run most of these commands from +# within the kurtosis-cdk repo root. +# +# First we're going to do a Kurtosis run to spin up both of the +# networks. The secret file here is the same as the normal file but +# with an SP1 key kurtosis run --enclave pp --args-file .github/tests/fork12-pessimistic-secret.yml . kurtosis run --enclave pp --args-file .github/tests/attach-second-cdk.yml . -# Grab the combined.json files for future ref +# In order to proceed, we'll need to grab the combined files from both +# chains. We'll specifically want the create rollup parameters file +# from the second chain because we need to know the gas token address. kurtosis service exec pp contracts-001 "cat /opt/zkevm/combined-001.json" | tail -n +2 | jq '.' > combined-001.json kurtosis service exec pp contracts-002 "cat /opt/zkevm/combined-002.json" | tail -n +2 | jq '.' > combined-002.json +kurtosis service exec pp contracts-002 "cat /opt/zkevm-contracts/deployment/v2/create_rollup_parameters.json" | tail -n +2 | jq -r '.gasTokenAddress' > gas-token-address.json -# Let's confirm the real verifier was deployed for the first rollup. At this point, I'm just going +# This diagnosis isn't critical, but it's nice to confirm that we are +# using a real verifier. cast code --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $(cat combined-001.json | jq -r '.verifierAddress') cast code --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $(cat combined-002.json | jq -r '.verifierAddress') # Check that the hash of the verifier is actually the sp1 verifier. It should be f33fc6bc90b5ea5e0272a7ab87d701bdd05ecd78b8111ca4f450eeff1e6df26a kurtosis service exec pp contracts-001 'cat /opt/zkevm-contracts/artifacts/contracts/verifiers/SP1Verifier.sol/SP1Verifier.json' | tail -n +2 | jq -r '.deployedBytecode' | sha256sum cast code --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $(cat combined-001.json | jq -r '.verifierAddress') | sha256sum +cast code --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $(cat combined-002.json | jq -r '.verifierAddress') | sha256sum -# At this point, the agglayer config needs to be manually updated for rollup2. This will add a second entry to the agglayer config -# TODO in the future we might as well make this values by default... +# At this point, the agglayer config needs to be manually updated for +# rollup2. This will add a second entry to the agglayer config. kurtosis service exec pp agglayer "sed -i 's/\[proof\-signers\]/2 = \"http:\/\/cdk-erigon-rpc-002:8123\"\n\[proof-signers\]/i' /etc/zkevm/agglayer-config.toml" kurtosis service stop pp agglayer kurtosis service start pp agglayer -# At this point we should be able to confirm that things look right for both chains. In particular in rollup 2 we'd want to make sure batches are being verified +# At this point we should be able to confirm that things look right for both chains. polycli monitor --rpc-url $(kurtosis port print pp cdk-erigon-rpc-001 rpc) polycli monitor --rpc-url $(kurtosis port print pp cdk-erigon-rpc-002 rpc) -# let's create a clean EOA for receiving bridges so that we can see +# Let's create a clean EOA for receiving bridges so that we can see # things show up. This is a good way to make sure we don't mess things # up by trying to exit more than we've deposited cast wallet new -# Successfully created new keypair. -# Address: 0xdfC0482a44ff9A6e56ba8A37Fe5d07d3328431BC -# Private key: 0x5fa61eff44166582c8d6302c1eeeac4165057ed9d53d7786b85d6c65512ebfc3 -target_address=0xdfC0482a44ff9A6e56ba8A37Fe5d07d3328431BC -target_private_key=0x5fa61eff44166582c8d6302c1eeeac4165057ed9d53d7786b85d6c65512ebfc3 +target_address=0xbecE3a31343c6019CDE0D5a4dF2AF8Df17ebcB0f +target_private_key=0x51caa196504216b1730280feb63ddd8c5ae194d13e57e58d559f1f1dc3eda7c9 # Let's setup some variables for future use private_key="0x12d7de8621a77640c9241b2595ba78ce443d05e94090365ab3bb5e19df82c625" eth_address=$(cast wallet address --private-key $private_key) l1_rpc_url=http://$(kurtosis port print pp el-1-geth-lighthouse rpc) -l2_pp_url=$(kurtosis port print pp cdk-erigon-rpc-001 rpc) -l2_fep_url=$(kurtosis port print pp cdk-erigon-rpc-002 rpc) +l2_pp1_url=$(kurtosis port print pp cdk-erigon-rpc-001 rpc) +l2_pp2_url=$(kurtosis port print pp cdk-erigon-rpc-002 rpc) bridge_address=$(cat combined-001.json | jq -r .polygonZkEVMBridgeAddress) pol_address=$(cat combined-001.json | jq -r .polTokenAddress) +gas_token_address=$( 1000000000") # should probably have at least 1gwei? - if [[ $min_balance_check -eq 1 ]]; then - break - fi - sleep 10 - done - # do some work - # do some work - # do some work - - if [[ $cur_net -eq 0 ]]; then - if [[ $(($RANDOM % 2)) -eq 0 ]]; then - dest_net=1 - else - dest_net=2 - fi - elif [[ $cur_net -eq 1 ]]; then - if [[ $(($RANDOM % 2)) -eq 0 ]]; then - dest_net=0 - else - dest_net=2 - fi - else - if [[ $(($RANDOM % 2)) -eq 0 ]]; then - dest_net=0 - else - dest_net=1 - fi - fi - - local is_forced=true - if [[ $(($RANDOM % 2)) -eq 0 ]]; then - is_forced=false - fi - - local bridge_data="0x" - if [[ $(($RANDOM % 2)) -eq 0 ]]; then - bridge_data="0x$(cat /dev/random | xxd -p | tr -d "\n" | head -c $((RANDOM & ~1)))" - fi - - - if [[ $(($RANDOM % 2)) -eq 0 ]]; then - set -x - cast send \ - --legacy \ - --rpc-url "$rpc_url" \ - --value "$mnemonic_index" \ - --gas-limit 1000000 \ - --mnemonic "$seed_mnemonic" --mnemonic-index "$mnemonic_index" \ - "$lxly_bridge_addr" \ - "bridgeMessage(uint32,address,bool,bytes)" \ - "$dest_net" "0x56c069fd987CEA5A8e03E1c1AEB8089000f13bB6" "$is_forced" "$bridge_data" - set +x - else - set -x - cast send \ - --legacy \ - --rpc-url "$rpc_url" \ - --value "$mnemonic_index" \ - --gas-limit 1000000 \ - --mnemonic "$seed_mnemonic" --mnemonic-index "$mnemonic_index" \ - "$lxly_bridge_addr" \ - "bridgeAsset(uint32,address,uint256,address,bool,bytes)" \ - "$dest_net" "0x56c069fd987CEA5A8e03E1c1AEB8089000f13bB6" "$mnemonic_index" "$(cast az)" "$is_forced" "$bridge_data" - set +x - fi - - # finished - # finished - # finished - - balance=$(cast balance --rpc-url $rpc_url $eth_address) - - local gas_price="$(cast gas-price --rpc-url $rpc_url)" - gas_price=$(bc <<< "$gas_price * 3 / 2") # push the gas price up for faster mining - - local leave_behind=271828 - local dist_value=$(bc <<< "($balance - $leave_behind - (2 * 21000 * $gas_price)) / 2") - local has_enough=$(bc <<< "$dist_value > (1000000000*21000)") # let's assume we want at least enough for a tx at 1gwei - if [[ $has_enough -eq 0 ]]; then - echo "The address $eth_address does not have enough funds. Current balance is $balance and distribute value would be $dist_value" >&2 - exit 1 - fi - - echo "sending $dist_value from $eth_address:$mnemonic_index to $eth_address_1:$mnemonic_index_1 and $eth_address_2:$mnemonic_index_2" - echo "current balance: $balance" - - cast send --timeout 900 --legacy --mnemonic "$seed_mnemonic" --mnemonic-index "$mnemonic_index" --rpc-url "$rpc_url" --gas-price $gas_price --value $dist_value $eth_address_1 > /dev/null - cast send --timeout 900 --legacy --mnemonic "$seed_mnemonic" --mnemonic-index "$mnemonic_index" --rpc-url "$rpc_url" --gas-price $gas_price --value $dist_value $eth_address_2 > /dev/null -} - -export -f distribute - -seq 0 32768 | parallel -j32 distribute {} $l1_rpc_url $bridge_address 0 &> r0-bridge-logs.log & -seq 0 32768 | parallel -j32 distribute {} $l2_pp_url $bridge_address 1 &> r1-bridge-logs.log & -seq 0 32768 | parallel -j32 distribute {} $l2_fep_url $bridge_address 2 &> r2-bridge-logs.log & - -# Check why cdk-node is running hot -sudo /usr/sbin/profile-bpfcc --stack-storage-size 32000 -f -F 199 -p 3770750 100 > cdk-node-folded.out -~/code/FlameGraph/flamegraph.pl --title="CDK Node Profile" cdk-node-folded.out > cdk-node.2.svg - -# TODO We still need to run some tests specifically with a gas token network. perhaps this test suite shoudl be updated so there is a third PP network that uses a gas token From d44d726f6c22d63644e2b7f0ba6e417371e51a7a Mon Sep 17 00:00:00 2001 From: John Hilliard Date: Thu, 5 Dec 2024 20:04:32 -0500 Subject: [PATCH 13/38] doc: litdown --- multi-pp-test.sh.md | 390 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 390 insertions(+) create mode 100644 multi-pp-test.sh.md diff --git a/multi-pp-test.sh.md b/multi-pp-test.sh.md new file mode 100644 index 00000000..90014b93 --- /dev/null +++ b/multi-pp-test.sh.md @@ -0,0 +1,390 @@ + +```sh +#!/bin/bash +echo "dont run this!" +exit 1; +``` + +# Multi Chain PP Test + +## Infra Setup + +This is an example of a system where there are two PP chains +attached to the rollup manager. One chain uses a gas token and the +other does not. Between those two chains we're going to attempt a +bunch of bridge scenarios. + +To run this stuff you'll want to run most of these commands from +within the kurtosis-cdk repo root. + +First we're going to do a Kurtosis run to spin up both of the +networks. The secret file here is the same as the normal file but +with an SP1 key + +```sh +kurtosis run --enclave pp --args-file .github/tests/fork12-pessimistic-secret.yml . +kurtosis run --enclave pp --args-file .github/tests/attach-second-cdk.yml . +``` + +In order to proceed, we'll need to grab the combined files from both +chains. We'll specifically want the create rollup parameters file +from the second chain because we need to know the gas token address. + +```sh +kurtosis service exec pp contracts-001 "cat /opt/zkevm/combined-001.json" | tail -n +2 | jq '.' > combined-001.json +kurtosis service exec pp contracts-002 "cat /opt/zkevm/combined-002.json" | tail -n +2 | jq '.' > combined-002.json +kurtosis service exec pp contracts-002 "cat /opt/zkevm-contracts/deployment/v2/create_rollup_parameters.json" | tail -n +2 | jq -r '.gasTokenAddress' > gas-token-address.json +``` + +This diagnosis isn't critical, but it's nice to confirm that we are +using a real verifier. + +```sh +cast code --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $(cat combined-001.json | jq -r '.verifierAddress') +cast code --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $(cat combined-002.json | jq -r '.verifierAddress') +``` + +Check that the hash of the verifier is actually the sp1 verifier. It should be f33fc6bc90b5ea5e0272a7ab87d701bdd05ecd78b8111ca4f450eeff1e6df26a + +```sh +kurtosis service exec pp contracts-001 'cat /opt/zkevm-contracts/artifacts/contracts/verifiers/SP1Verifier.sol/SP1Verifier.json' | tail -n +2 | jq -r '.deployedBytecode' | sha256sum +cast code --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $(cat combined-001.json | jq -r '.verifierAddress') | sha256sum +cast code --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $(cat combined-002.json | jq -r '.verifierAddress') | sha256sum +``` + +At this point, the agglayer config needs to be manually updated for +rollup2. This will add a second entry to the agglayer config. + +```sh +kurtosis service exec pp agglayer "sed -i 's/\[proof\-signers\]/2 = \"http:\/\/cdk-erigon-rpc-002:8123\"\n\[proof-signers\]/i' /etc/zkevm/agglayer-config.toml" +kurtosis service stop pp agglayer +kurtosis service start pp agglayer +``` + +At this point we should be able to confirm that things look right for both chains. + +```sh +polycli monitor --rpc-url $(kurtosis port print pp cdk-erigon-rpc-001 rpc) +polycli monitor --rpc-url $(kurtosis port print pp cdk-erigon-rpc-002 rpc) +``` + +Let's create a clean EOA for receiving bridges so that we can see +things show up. This is a good way to make sure we don't mess things +up by trying to exit more than we've deposited + +```sh +cast wallet new +target_address=0xbecE3a31343c6019CDE0D5a4dF2AF8Df17ebcB0f +target_private_key=0x51caa196504216b1730280feb63ddd8c5ae194d13e57e58d559f1f1dc3eda7c9 +``` + +Let's setup some variables for future use + +```sh +private_key="0x12d7de8621a77640c9241b2595ba78ce443d05e94090365ab3bb5e19df82c625" +eth_address=$(cast wallet address --private-key $private_key) +l1_rpc_url=http://$(kurtosis port print pp el-1-geth-lighthouse rpc) +l2_pp1_url=$(kurtosis port print pp cdk-erigon-rpc-001 rpc) +l2_pp2_url=$(kurtosis port print pp cdk-erigon-rpc-002 rpc) +bridge_address=$(cat combined-001.json | jq -r .polygonZkEVMBridgeAddress) +pol_address=$(cat combined-001.json | jq -r .polTokenAddress) +gas_token_address=$( Date: Fri, 6 Dec 2024 18:50:54 -0500 Subject: [PATCH 14/38] docs: latest tests --- .github/tests/attach-second-cdk.yml | 9 ++------- .github/tests/fork12-pessimistic.yml | 12 +++++------- input_parser.star | 2 +- multi-pp-test.sh | 27 +++++++++++++++++++++++++-- multi-pp-test.sh.md | 24 +++++++++++++++++++++++- 5 files changed, 56 insertions(+), 18 deletions(-) diff --git a/.github/tests/attach-second-cdk.yml b/.github/tests/attach-second-cdk.yml index ce8aa030..99a860c7 100644 --- a/.github/tests/attach-second-cdk.yml +++ b/.github/tests/attach-second-cdk.yml @@ -3,7 +3,6 @@ deployment_stages: deploy_agglayer: false args: - verbosity: debug deployment_suffix: "-002" zkevm_rollup_chain_id: 20202 zkevm_rollup_id: 2 @@ -27,19 +26,15 @@ args: zkevm_l2_proofsigner_private_key: "0xc7fe3a006d75ba9326d9792523385abb49057c66aee0b8b4248821a89713f975" - agglayer_image: ghcr.io/agglayer/agglayer:0.2.0-rc.19 - cdk_node_image: ghcr.io/0xpolygon/cdk:0.5.0-beta7 + cdk_node_image: ghcr.io/0xpolygon/cdk:0.5.0-beta8 cdk_erigon_node_image: hermeznetwork/cdk-erigon:v2.60.0 - zkevm_bridge_service_image: hermeznetwork/zkevm-bridge-service:v0.6.0-RC3 - zkevm_bridge_ui_image: leovct/zkevm-bridge-ui:multi-network zkevm_contracts_image: leovct/zkevm-contracts:v9.0.0-rc.3-pp-fork.12-patch.1 additional_services: [] consensus_contract_type: pessimistic sequencer_type: erigon erigon_strict_mode: false gas_token_enabled: true - agglayer_prover_sp1_key: "0x7a2baab6e39878897307784a76f9711e783d54e6221d23f1cd4f3baf7d044f6c" zkevm_use_real_verifier: true enable_normalcy: true - verifier_program_vkey: 0x00617f688d0a520d3cdda077a80a3437e1997f630595d404117adfcb0ad56785 + verifier_program_vkey: 0x00766aa16a6efe4ac05c0fe21d4b50f9631dbd1a2663a982da861427085ea2ea diff --git a/.github/tests/fork12-pessimistic.yml b/.github/tests/fork12-pessimistic.yml index 1176f5b6..15b92550 100644 --- a/.github/tests/fork12-pessimistic.yml +++ b/.github/tests/fork12-pessimistic.yml @@ -1,16 +1,14 @@ args: - agglayer_image: ghcr.io/agglayer/agglayer:0.2.0-rc.19 - cdk_node_image: ghcr.io/0xpolygon/cdk:0.5.0-beta7 + cdk_node_image: ghcr.io/0xpolygon/cdk:0.5.0-beta8 cdk_erigon_node_image: hermeznetwork/cdk-erigon:v2.60.0 - zkevm_bridge_service_image: hermeznetwork/zkevm-bridge-service:v0.6.0-RC3 - zkevm_bridge_ui_image: leovct/zkevm-bridge-ui:multi-network zkevm_contracts_image: leovct/zkevm-contracts:v9.0.0-rc.3-pp-fork.12-patch.1 additional_services: [] consensus_contract_type: pessimistic sequencer_type: erigon erigon_strict_mode: false - zkevm_use_gas_token_contract: false - #agglayer_prover_sp1_key: + gas_token_enabled: false zkevm_use_real_verifier: true enable_normalcy: true - verifier_program_vkey: 0x00617f688d0a520d3cdda077a80a3437e1997f630595d404117adfcb0ad56785 + verifier_program_vkey: 0x00766aa16a6efe4ac05c0fe21d4b50f9631dbd1a2663a982da861427085ea2ea + agglayer_prover_sp1_key: "" + diff --git a/input_parser.star b/input_parser.star index b316a626..45b96eef 100644 --- a/input_parser.star +++ b/input_parser.star @@ -29,7 +29,7 @@ DEFAULT_DEPLOYMENT_STAGES = { } DEFAULT_IMAGES = { - "agglayer_image": "ghcr.io/agglayer/agglayer:0.2.0-rc.19", # https://github.com/agglayer/agglayer/tags + "agglayer_image": "ghcr.io/agglayer/agglayer:0.2.0-rc.20", # https://github.com/agglayer/agglayer/tags "cdk_erigon_node_image": "hermeznetwork/cdk-erigon:v2.60.0", # https://hub.docker.com/r/hermeznetwork/cdk-erigon/tags "cdk_node_image": "ghcr.io/0xpolygon/cdk:0.4.0", # https://github.com/0xpolygon/cdk/pkgs/container/cdk "cdk_validium_node_image": "0xpolygon/cdk-validium-node:0.7.0-cdk", # https://hub.docker.com/r/0xpolygon/cdk-validium-node/tags diff --git a/multi-pp-test.sh b/multi-pp-test.sh index b585f468..de611894 100755 --- a/multi-pp-test.sh +++ b/multi-pp-test.sh @@ -18,7 +18,8 @@ exit 1; # networks. The secret file here is the same as the normal file but # with an SP1 key kurtosis run --enclave pp --args-file .github/tests/fork12-pessimistic-secret.yml . -kurtosis run --enclave pp --args-file .github/tests/attach-second-cdk.yml . +kurtosis run --enclave pp --args-file .github/tests/attach-second-cdk.yml . # TODO investigate issue with first block startup + # In order to proceed, we'll need to grab the combined files from both # chains. We'll specifically want the create rollup parameters file @@ -27,6 +28,29 @@ kurtosis service exec pp contracts-001 "cat /opt/zkevm/combined-001.json" | tai kurtosis service exec pp contracts-002 "cat /opt/zkevm/combined-002.json" | tail -n +2 | jq '.' > combined-002.json kurtosis service exec pp contracts-002 "cat /opt/zkevm-contracts/deployment/v2/create_rollup_parameters.json" | tail -n +2 | jq -r '.gasTokenAddress' > gas-token-address.json + + +cast logs --from-block 0 --to-block 1 --rpc-url https://rpc.cdk12.dev.polygon --address 0x1348947e282138d8f377b467F7D9c2EB0F335d1f 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498 + + +curl http://127.0.0.1:33725 \ +--json '{ + "id": 1, + "jsonrpc": "2.0", + "method": "eth_call", + "params": [ + { + "chainId": "0x1ce", + "data": "0xbab161bf", + "from": "0x0000000000000000000000000000000000000000", + "input": "0xbab161bf", + "to": "0xd8886e9D827218a02B8C04323b5550f2F36BC8d5" + }, + "latest" + ] +}' + + # This diagnosis isn't critical, but it's nice to confirm that we are # using a real verifier. cast code --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $(cat combined-001.json | jq -r '.verifierAddress') @@ -200,7 +224,6 @@ curl -s $l2_pp2b_url/bridges/$target_address | jq '.deposits[] | select(.ready_f cast balance --ether --rpc-url $l2_pp1_url $target_address cast balance --ether --rpc-url $l2_pp2_url $target_address - # Let's check our L2 Pol token balance (both should be non-zero) token_hash=$(cast keccak $(cast abi-encode --packed 'f(uint32,address)' 0 $pol_address)) l2_pol_address=$(cast call --rpc-url $l2_pp1_url $bridge_address 'tokenInfoToWrappedToken(bytes32)(address)' $token_hash) diff --git a/multi-pp-test.sh.md b/multi-pp-test.sh.md index 90014b93..2c9b1be3 100644 --- a/multi-pp-test.sh.md +++ b/multi-pp-test.sh.md @@ -23,7 +23,7 @@ with an SP1 key ```sh kurtosis run --enclave pp --args-file .github/tests/fork12-pessimistic-secret.yml . -kurtosis run --enclave pp --args-file .github/tests/attach-second-cdk.yml . +kurtosis run --enclave pp --args-file .github/tests/attach-second-cdk.yml . # TODO investigate issue with first block startup ``` In order to proceed, we'll need to grab the combined files from both @@ -34,6 +34,28 @@ from the second chain because we need to know the gas token address. kurtosis service exec pp contracts-001 "cat /opt/zkevm/combined-001.json" | tail -n +2 | jq '.' > combined-001.json kurtosis service exec pp contracts-002 "cat /opt/zkevm/combined-002.json" | tail -n +2 | jq '.' > combined-002.json kurtosis service exec pp contracts-002 "cat /opt/zkevm-contracts/deployment/v2/create_rollup_parameters.json" | tail -n +2 | jq -r '.gasTokenAddress' > gas-token-address.json + + + +cast logs --from-block 0 --to-block 1 --rpc-url https://rpc.cdk12.dev.polygon --address 0x1348947e282138d8f377b467F7D9c2EB0F335d1f 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498 + + +curl http://127.0.0.1:33725 \ +--json '{ + "id": 1, + "jsonrpc": "2.0", + "method": "eth_call", + "params": [ + { + "chainId": "0x1ce", + "data": "0xbab161bf", + "from": "0x0000000000000000000000000000000000000000", + "input": "0xbab161bf", + "to": "0xd8886e9D827218a02B8C04323b5550f2F36BC8d5" + }, + "latest" + ] +}' ``` This diagnosis isn't critical, but it's nice to confirm that we are From 7360cd128812ae21bb29d0c81cb89c5bd7626845 Mon Sep 17 00:00:00 2001 From: John Hilliard Date: Wed, 11 Dec 2024 19:07:07 -0500 Subject: [PATCH 15/38] wip: testing notes --- .github/tests/attach-second-cdk.yml | 4 +- .github/tests/fork12-pessimistic.yml | 4 +- input_parser.star | 3 +- multi-pp-test.sh | 288 ++++++++++++++++++++---- multi-pp-test.sh.md | 313 +++++++++++++++++++++++---- 5 files changed, 532 insertions(+), 80 deletions(-) diff --git a/.github/tests/attach-second-cdk.yml b/.github/tests/attach-second-cdk.yml index 99a860c7..517af041 100644 --- a/.github/tests/attach-second-cdk.yml +++ b/.github/tests/attach-second-cdk.yml @@ -26,7 +26,7 @@ args: zkevm_l2_proofsigner_private_key: "0xc7fe3a006d75ba9326d9792523385abb49057c66aee0b8b4248821a89713f975" - cdk_node_image: ghcr.io/0xpolygon/cdk:0.5.0-beta8 + cdk_node_image: ghcr.io/0xpolygon/cdk:0.5.0-beta10 cdk_erigon_node_image: hermeznetwork/cdk-erigon:v2.60.0 zkevm_contracts_image: leovct/zkevm-contracts:v9.0.0-rc.3-pp-fork.12-patch.1 additional_services: [] @@ -36,5 +36,5 @@ args: gas_token_enabled: true zkevm_use_real_verifier: true enable_normalcy: true - verifier_program_vkey: 0x00766aa16a6efe4ac05c0fe21d4b50f9631dbd1a2663a982da861427085ea2ea + verifier_program_vkey: 0x00b4769114e641ec0d62858e7063b73ce02f8ba1a360dd678bc5aa5b2bd4410c diff --git a/.github/tests/fork12-pessimistic.yml b/.github/tests/fork12-pessimistic.yml index 15b92550..091b6c8c 100644 --- a/.github/tests/fork12-pessimistic.yml +++ b/.github/tests/fork12-pessimistic.yml @@ -1,5 +1,5 @@ args: - cdk_node_image: ghcr.io/0xpolygon/cdk:0.5.0-beta8 + cdk_node_image: ghcr.io/0xpolygon/cdk:0.5.0-beta10 cdk_erigon_node_image: hermeznetwork/cdk-erigon:v2.60.0 zkevm_contracts_image: leovct/zkevm-contracts:v9.0.0-rc.3-pp-fork.12-patch.1 additional_services: [] @@ -9,6 +9,6 @@ args: gas_token_enabled: false zkevm_use_real_verifier: true enable_normalcy: true - verifier_program_vkey: 0x00766aa16a6efe4ac05c0fe21d4b50f9631dbd1a2663a982da861427085ea2ea + verifier_program_vkey: 0x00b4769114e641ec0d62858e7063b73ce02f8ba1a360dd678bc5aa5b2bd4410c agglayer_prover_sp1_key: "" diff --git a/input_parser.star b/input_parser.star index 45b96eef..e02fd221 100644 --- a/input_parser.star +++ b/input_parser.star @@ -29,7 +29,8 @@ DEFAULT_DEPLOYMENT_STAGES = { } DEFAULT_IMAGES = { - "agglayer_image": "ghcr.io/agglayer/agglayer:0.2.0-rc.20", # https://github.com/agglayer/agglayer/tags + # "agglayer_image": "ghcr.io/agglayer/agglayer:0.2.0-rc.20", # https://github.com/agglayer/agglayer/tags + "agglayer_image": "agglayer:adding-sigterm-signal-hook", # https://github.com/agglayer/agglayer/tags "cdk_erigon_node_image": "hermeznetwork/cdk-erigon:v2.60.0", # https://hub.docker.com/r/hermeznetwork/cdk-erigon/tags "cdk_node_image": "ghcr.io/0xpolygon/cdk:0.4.0", # https://github.com/0xpolygon/cdk/pkgs/container/cdk "cdk_validium_node_image": "0xpolygon/cdk-validium-node:0.7.0-cdk", # https://hub.docker.com/r/0xpolygon/cdk-validium-node/tags diff --git a/multi-pp-test.sh b/multi-pp-test.sh index de611894..38c846e5 100755 --- a/multi-pp-test.sh +++ b/multi-pp-test.sh @@ -18,8 +18,14 @@ exit 1; # networks. The secret file here is the same as the normal file but # with an SP1 key kurtosis run --enclave pp --args-file .github/tests/fork12-pessimistic-secret.yml . -kurtosis run --enclave pp --args-file .github/tests/attach-second-cdk.yml . # TODO investigate issue with first block startup +kurtosis run --enclave pp --args-file .github/tests/attach-second-cdk.yml . +# At this point we should be able to confirm that things look right +# for both chains. Recently, it seems like the fork id isn't initially +# detected by erigon which is causing the chain not to start up right +# away. +polycli monitor --rpc-url $(kurtosis port print pp cdk-erigon-rpc-001 rpc) +polycli monitor --rpc-url $(kurtosis port print pp cdk-erigon-rpc-002 rpc) # In order to proceed, we'll need to grab the combined files from both # chains. We'll specifically want the create rollup parameters file @@ -28,29 +34,6 @@ kurtosis service exec pp contracts-001 "cat /opt/zkevm/combined-001.json" | tai kurtosis service exec pp contracts-002 "cat /opt/zkevm/combined-002.json" | tail -n +2 | jq '.' > combined-002.json kurtosis service exec pp contracts-002 "cat /opt/zkevm-contracts/deployment/v2/create_rollup_parameters.json" | tail -n +2 | jq -r '.gasTokenAddress' > gas-token-address.json - - -cast logs --from-block 0 --to-block 1 --rpc-url https://rpc.cdk12.dev.polygon --address 0x1348947e282138d8f377b467F7D9c2EB0F335d1f 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498 - - -curl http://127.0.0.1:33725 \ ---json '{ - "id": 1, - "jsonrpc": "2.0", - "method": "eth_call", - "params": [ - { - "chainId": "0x1ce", - "data": "0xbab161bf", - "from": "0x0000000000000000000000000000000000000000", - "input": "0xbab161bf", - "to": "0xd8886e9D827218a02B8C04323b5550f2F36BC8d5" - }, - "latest" - ] -}' - - # This diagnosis isn't critical, but it's nice to confirm that we are # using a real verifier. cast code --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $(cat combined-001.json | jq -r '.verifierAddress') @@ -61,16 +44,18 @@ kurtosis service exec pp contracts-001 'cat /opt/zkevm-contracts/artifacts/contr cast code --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $(cat combined-001.json | jq -r '.verifierAddress') | sha256sum cast code --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $(cat combined-002.json | jq -r '.verifierAddress') | sha256sum +# It's also worth while probably to confirm that the vkey matches! +kurtosis service exec pp agglayer agglayer vkey +cast call --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $(cat combined-001.json | jq -r '.polygonRollupManagerAddress') 'rollupTypeMap(uint32)(address,address,uint64,uint8,bool,bytes32,bytes32)' 1 + # At this point, the agglayer config needs to be manually updated for -# rollup2. This will add a second entry to the agglayer config. +# rollup2. This will add a second entry to the agglayer config. If the +# second chain is also pessimistic, this isn't strictly necessary, but +# there's no harm in it. kurtosis service exec pp agglayer "sed -i 's/\[proof\-signers\]/2 = \"http:\/\/cdk-erigon-rpc-002:8123\"\n\[proof-signers\]/i' /etc/zkevm/agglayer-config.toml" kurtosis service stop pp agglayer kurtosis service start pp agglayer -# At this point we should be able to confirm that things look right for both chains. -polycli monitor --rpc-url $(kurtosis port print pp cdk-erigon-rpc-001 rpc) -polycli monitor --rpc-url $(kurtosis port print pp cdk-erigon-rpc-002 rpc) - # Let's create a clean EOA for receiving bridges so that we can see # things show up. This is a good way to make sure we don't mess things # up by trying to exit more than we've deposited @@ -103,6 +88,10 @@ cast balance --ether --rpc-url $l2_pp2_url $eth_address cast send --legacy --value 100ether --rpc-url $l2_pp1_url --private-key $private_key 0x5f5dB0D4D58310F53713eF4Df80ba6717868A9f8 cast send --legacy --value 100ether --rpc-url $l2_pp2_url --private-key $private_key 0x93F63c24735f45Cd0266E87353071B64dd86bc05 +# We should also fund the target address on L1 so that we can use this +# key for L1 bridge transfers +cast send --value 100ether --rpc-url $l1_rpc_url --private-key $private_key $target_address + # Let's mint some POL token for testing purpsoes cast send \ --rpc-url $l1_rpc_url \ @@ -133,12 +122,12 @@ cast send \ 'approve(address,uint256)' \ $bridge_address 10000000000000000000000 -# At this point, I just want to confirm my understanding of the WETH -# Token. My sense is that only the L2 bridge for a network that has a -# gas token should have a WETH Token -cast call --rpc-url $l1_rpc_url $bridge_address 'WETHToken()' -cast call --rpc-url $l2_pp1_url $bridge_address 'WETHToken()' -cast call --rpc-url $l2_pp2_url $bridge_address 'WETHToken()' +# We're also going to mint POL and Gas Token from the target account for additional test scenarios +cast send --rpc-url $l1_rpc_url --private-key $target_private_key $pol_address 'mint(address,uint256)' $target_address 10000000000000000000000 +cast send --rpc-url $l1_rpc_url --private-key $target_private_key $pol_address 'approve(address,uint256)' $bridge_address 10000000000000000000000 + +cast send --rpc-url $l1_rpc_url --private-key $target_private_key $gas_token_address 'mint(address,uint256)' $target_address 10000000000000000000000 +cast send --rpc-url $l1_rpc_url --private-key $target_private_key $gas_token_address 'approve(address,uint256)' $bridge_address 10000000000000000000000 # We're going to do a little matrix of L1 to L2 bridges here. The idea # is to mix bridges across a few scenarios @@ -180,7 +169,8 @@ for token_addr in $(cast az) $pol_address $gas_token_address ; do done # At this point, we should be able to see our bridges in the bridge -# service for both chains +# service for both chains. Recently, with this setup there has been an +# issue with network id detection in the bridge service curl -s $l2_pp1b_url/bridges/$target_address | jq '.' curl -s $l2_pp2b_url/bridges/$target_address | jq '.' @@ -324,7 +314,231 @@ polycli ulxly bridge asset \ --force-update-root=true \ --rpc-url $l2_pp2_url - +# Now we should try to claim these transactions again on Layer one and PP1 curl -s $l2_pp2b_url/bridges/$target_address | jq '.deposits[] | select(.ready_for_claim) | select(.claim_tx_hash == "")' +deposit_cnt=0 +polycli ulxly claim asset \ + --bridge-address $bridge_address \ + --bridge-service-url $l2_pp2b_url \ + --rpc-url $l1_rpc_url \ + --deposit-count $deposit_cnt \ + --deposit-network 2 \ + --destination-address $target_address \ + --private-key $private_key + +deposit_cnt=1 +polycli ulxly claim asset \ + --bridge-address $bridge_address \ + --bridge-service-url $l2_pp2b_url \ + --rpc-url $l2_pp1_url \ + --deposit-count $deposit_cnt \ + --deposit-network 2 \ + --destination-address $target_address \ + --private-key $private_key + +cast call --rpc-url $l1_rpc_url $bridge_address 'depositCount() external view returns (uint256)' + + +deposit_cnt=2 +polycli ulxly claim asset \ + --bridge-address $bridge_address \ + --bridge-service-url $l2_pp2b_url \ + --rpc-url $l1_rpc_url \ + --deposit-count $deposit_cnt \ + --deposit-network 2 \ + --destination-address $target_address \ + --private-key $private_key + + +# ## Pict Based Test Scenarios +# I'm using a command like this to generate the test cases. +pict lxly.pict /f:json | jq -c '.[] | from_entries' | jq -s > ~/code/kurtosis-cdk/test-scenarios.json + +# I want to setup the deterministic deployer for some consistent l2 addresses +cast send --legacy --value 0.1ether --rpc-url $l1_rpc_url --private-key $private_key 0x3fab184622dc19b6109349b94811493bf2a45362 +cast send --legacy --value 0.1ether --rpc-url $l2_pp1_url --private-key $private_key 0x3fab184622dc19b6109349b94811493bf2a45362 +cast send --legacy --value 0.1ether --rpc-url $l2_pp2_url --private-key $private_key 0x3fab184622dc19b6109349b94811493bf2a45362 + +deterministic_deployer_tx=0xf8a58085174876e800830186a08080b853604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf31ba02222222222222222222222222222222222222222222222222222222222222222a02222222222222222222222222222222222222222222222222222222222222222 +deterministic_deployer_addr=0x4e59b44847b379578588920ca78fbf26c0b4956c + +cast publish --rpc-url $l1_rpc_url $deterministic_deployer_tx +cast publish --rpc-url $l2_pp1_url $deterministic_deployer_tx +cast publish --rpc-url $l2_pp2_url $deterministic_deployer_tx + + +salt=0x6a6f686e2068696c6c696172642077617320686572650a000000000000000000 +erc_20_bytecode=60806040526040516200143a3803806200143a833981016040819052620000269162000201565b8383600362000036838262000322565b50600462000045828262000322565b5050506200005a82826200007160201b60201c565b505081516020909201919091206006555062000416565b6001600160a01b038216620000cc5760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015260640160405180910390fd5b8060026000828254620000e09190620003ee565b90915550506001600160a01b038216600081815260208181526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b505050565b634e487b7160e01b600052604160045260246000fd5b600082601f8301126200016457600080fd5b81516001600160401b03808211156200018157620001816200013c565b604051601f8301601f19908116603f01168101908282118183101715620001ac57620001ac6200013c565b81604052838152602092508683858801011115620001c957600080fd5b600091505b83821015620001ed5785820183015181830184015290820190620001ce565b600093810190920192909252949350505050565b600080600080608085870312156200021857600080fd5b84516001600160401b03808211156200023057600080fd5b6200023e8883890162000152565b955060208701519150808211156200025557600080fd5b50620002648782880162000152565b604087015190945090506001600160a01b03811681146200028457600080fd5b6060959095015193969295505050565b600181811c90821680620002a957607f821691505b602082108103620002ca57634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200013757600081815260208120601f850160051c81016020861015620002f95750805b601f850160051c820191505b818110156200031a5782815560010162000305565b505050505050565b81516001600160401b038111156200033e576200033e6200013c565b62000356816200034f845462000294565b84620002d0565b602080601f8311600181146200038e5760008415620003755750858301515b600019600386901b1c1916600185901b1785556200031a565b600085815260208120601f198616915b82811015620003bf578886015182559484019460019091019084016200039e565b5085821015620003de5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b808201808211156200041057634e487b7160e01b600052601160045260246000fd5b92915050565b61101480620004266000396000f3fe608060405234801561001057600080fd5b506004361061014d5760003560e01c806340c10f19116100c35780639e4e73181161007c5780639e4e73181461033c578063a457c2d714610363578063a9059cbb14610376578063c473af3314610389578063d505accf146103b0578063dd62ed3e146103c357600080fd5b806340c10f19146102b257806342966c68146102c557806356189cb4146102d857806370a08231146102eb5780637ecebe001461031457806395d89b411461033457600080fd5b806323b872dd1161011557806323b872dd146101c357806330adf81f146101d6578063313ce567146101fd5780633408e4701461020c5780633644e51514610212578063395093511461029f57600080fd5b806304622c2e1461015257806306fdde031461016e578063095ea7b31461018357806318160ddd146101a6578063222f5be0146101ae575b600080fd5b61015b60065481565b6040519081526020015b60405180910390f35b6101766103d6565b6040516101659190610db1565b610196610191366004610e1b565b610468565b6040519015158152602001610165565b60025461015b565b6101c16101bc366004610e45565b610482565b005b6101966101d1366004610e45565b610492565b61015b7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b60405160128152602001610165565b4661015b565b61015b6006546000907f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f907fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc646604080516020810195909552840192909252606083015260808201523060a082015260c00160405160208183030381529060405280519060200120905090565b6101966102ad366004610e1b565b6104b6565b6101c16102c0366004610e1b565b6104d8565b6101c16102d3366004610e81565b6104e6565b6101c16102e6366004610e45565b6104f3565b61015b6102f9366004610e9a565b6001600160a01b031660009081526020819052604090205490565b61015b610322366004610e9a565b60056020526000908152604090205481565b6101766104fe565b61015b7fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc681565b610196610371366004610e1b565b61050d565b610196610384366004610e1b565b61058d565b61015b7f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f81565b6101c16103be366004610ebc565b61059b565b61015b6103d1366004610f2f565b6106ae565b6060600380546103e590610f62565b80601f016020809104026020016040519081016040528092919081815260200182805461041190610f62565b801561045e5780601f106104335761010080835404028352916020019161045e565b820191906000526020600020905b81548152906001019060200180831161044157829003601f168201915b5050505050905090565b6000336104768185856106d9565b60019150505b92915050565b61048d8383836107fd565b505050565b6000336104a08582856109a3565b6104ab8585856107fd565b506001949350505050565b6000336104768185856104c983836106ae565b6104d39190610fb2565b6106d9565b6104e28282610a17565b5050565b6104f03382610ad6565b50565b61048d8383836106d9565b6060600480546103e590610f62565b6000338161051b82866106ae565b9050838110156105805760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b60648201526084015b60405180910390fd5b6104ab82868684036106d9565b6000336104768185856107fd565b428410156105eb5760405162461bcd60e51b815260206004820152601960248201527f48455a3a3a7065726d69743a20415554485f45585049524544000000000000006044820152606401610577565b6001600160a01b038716600090815260056020526040812080547f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9918a918a918a91908661063883610fc5565b909155506040805160208101969096526001600160a01b0394851690860152929091166060840152608083015260a082015260c0810186905260e0016040516020818303038152906040528051906020012090506106998882868686610c08565b6106a48888886106d9565b5050505050505050565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6001600160a01b03831661073b5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610577565b6001600160a01b03821661079c5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610577565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b0383166108615760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610577565b6001600160a01b0382166108c35760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610577565b6001600160a01b0383166000908152602081905260409020548181101561093b5760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610577565b6001600160a01b03848116600081815260208181526040808320878703905593871680835291849020805487019055925185815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35b50505050565b60006109af84846106ae565b9050600019811461099d5781811015610a0a5760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610577565b61099d84848484036106d9565b6001600160a01b038216610a6d5760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610577565b8060026000828254610a7f9190610fb2565b90915550506001600160a01b038216600081815260208181526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b6001600160a01b038216610b365760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b6064820152608401610577565b6001600160a01b03821660009081526020819052604090205481811015610baa5760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b6064820152608401610577565b6001600160a01b0383166000818152602081815260408083208686039055600280548790039055518581529192917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3505050565b600654604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f602080830191909152818301939093527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a0808301919091528251808303909101815260c082019092528151919092012061190160f01b60e083015260e282018190526101028201869052906000906101220160408051601f198184030181528282528051602091820120600080855291840180845281905260ff89169284019290925260608301879052608083018690529092509060019060a0016020604051602081039080840390855afa158015610d1b573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811615801590610d515750876001600160a01b0316816001600160a01b0316145b6106a45760405162461bcd60e51b815260206004820152602b60248201527f48455a3a3a5f76616c69646174655369676e6564446174613a20494e56414c4960448201526a445f5349474e415455524560a81b6064820152608401610577565b600060208083528351808285015260005b81811015610dde57858101830151858201604001528201610dc2565b506000604082860101526040601f19601f8301168501019250505092915050565b80356001600160a01b0381168114610e1657600080fd5b919050565b60008060408385031215610e2e57600080fd5b610e3783610dff565b946020939093013593505050565b600080600060608486031215610e5a57600080fd5b610e6384610dff565b9250610e7160208501610dff565b9150604084013590509250925092565b600060208284031215610e9357600080fd5b5035919050565b600060208284031215610eac57600080fd5b610eb582610dff565b9392505050565b600080600080600080600060e0888a031215610ed757600080fd5b610ee088610dff565b9650610eee60208901610dff565b95506040880135945060608801359350608088013560ff81168114610f1257600080fd5b9699959850939692959460a0840135945060c09093013592915050565b60008060408385031215610f4257600080fd5b610f4b83610dff565b9150610f5960208401610dff565b90509250929050565b600181811c90821680610f7657607f821691505b602082108103610f9657634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b8082018082111561047c5761047c610f9c565b600060018201610fd757610fd7610f9c565b506001019056fea26469706673582212207bede9966bc8e8634cc0c3dc076626579b27dff7bbcac0b645c87d4cf1812b9864736f6c63430008140033 +constructor_args=$(cast abi-encode 'f(string,string,address,uint256)' 'Bridge Test' 'BT' "$target_address" 100000000000000000000 | sed 's/0x//') + +cast send --legacy --rpc-url $l1_rpc_url --private-key $private_key $deterministic_deployer_addr $salt$erc_20_bytecode$constructor_args +cast send --legacy --rpc-url $l2_pp1_url --private-key $private_key $deterministic_deployer_addr $salt$erc_20_bytecode$constructor_args +cast send --legacy --rpc-url $l2_pp2_url --private-key $private_key $deterministic_deployer_addr $salt$erc_20_bytecode$constructor_args + +test_erc20_addr=$(cast create2 --salt $salt --init-code $erc_20_bytecode$constructor_args) + +cast send --legacy --rpc-url $l1_rpc_url --private-key $target_private_key $test_erc20_addr 'approve(address,uint256)' $bridge_address 100000000000000000000 +cast send --legacy --rpc-url $l2_pp1_url --private-key $target_private_key $test_erc20_addr 'approve(address,uint256)' $bridge_address 100000000000000000000 +cast send --legacy --rpc-url $l2_pp2_url --private-key $target_private_key $test_erc20_addr 'approve(address,uint256)' $bridge_address 100000000000000000000 + + +# One of the test cases that I've left out for now is a permit +# call. It'll take some work to get the signed permit data in place, +# but it seems doable. +# +# - https://eips.ethereum.org/EIPS/eip-2612 +# - https://eips.ethereum.org/EIPS/eip-712 +# +# permit_sig=$(cast wallet sign --private-key $target_private_key 0x$(< /dev/urandom xxd -p | tr -d "\n" | head -c 40)) +# permit_sig_r=${permit_sig:2:64} +# permit_sig_s=${permit_sig:66:64} +# permit_sig_v=${permit_sig:130:2} + +# The test cases are committed for convenience, we'll use that to +# dynamically to some testing +cat test-scenarios.json | jq -c '.[]' | while read scenario ; do + testBridgeType=$(echo $scenario | jq -r '.BridgeType') + testDepositChain=$(echo $scenario | jq -r '.DepositChain') + testDestinationChain=$(echo $scenario | jq -r '.DestinationChain') + testDestinationAddress=$(echo $scenario | jq -r '.DestinationAddress') + testToken=$(echo $scenario | jq -r '.Token') + testMetaData=$(echo $scenario | jq -r '.MetaData') + testForceUpdate=$(echo $scenario | jq -r '.ForceUpdate') + testAmount=$(echo $scenario | jq -r '.Amount') + + testCommand="polycli ulxly bridge" + + if [[ $testBridgeType == "Asset" ]]; then + testCommand="$testCommand asset" + elif [[ $testBridgeType == "Message" ]]; then + testCommand="$testCommand message" + else + testCommand="$testCommand weth" + fi + + if [[ $testDepositChain == "L1" ]]; then + testCommand="$testCommand --rpc-url $l1_rpc_url" + elif [[ $testDepositChain == "PP1" ]]; then + testCommand="$testCommand --rpc-url $l2_pp1_url" + else + testCommand="$testCommand --rpc-url $l2_pp2_url" + fi + + if [[ $testDestinationChain == "L1" ]]; then + testCommand="$testCommand --destination-network 0" + elif [[ $testDestinationChain == "PP1" ]]; then + testCommand="$testCommand --destination-network 1" + else + testCommand="$testCommand --destination-network 2" + fi + + if [[ $testDestinationAddress == "Contract" ]]; then + testCommand="$testCommand --destination-address $bridge_address" + elif [[ $testDestinationAddress == "Precompile" ]]; then + testCommand="$testCommand --destination-address 0x0000000000000000000000000000000000000004" + else + testCommand="$testCommand --destination-address $target_address" + fi + + if [[ $testToken == "POL" ]]; then + testCommand="$testCommand --token-address $pol_address" + elif [[ $testToken == "LocalERC20" ]]; then + testCommand="$testCommand --token-address $test_erc20_addr" + elif [[ $testToken == "WETH" ]]; then + testCommand="$testCommand --token-address $pp2_weth_address" + elif [[ $testToken == "Invalid" ]]; then + testCommand="$testCommand --token-address $(< /dev/urandom xxd -p | tr -d "\n" | head -c 40)" + else + testCommand="$testCommand --token-address 0x0000000000000000000000000000000000000000" + fi + + if [[ $testMetaData == "Random" ]]; then + testCommand="$testCommand --call-data $(date +%s | xxd -p)" + else + testCommand="$testCommand --call-data 0x" + fi + + if [[ $testForceUpdate == "True" ]]; then + testCommand="$testCommand --force-update-root=true" + else + testCommand="$testCommand --force-update-root=false" + fi + + if [[ $testAmount == "0" ]]; then + testCommand="$testCommand --value 0" + elif [[ $testAmount == "1" ]]; then + testCommand="$testCommand --value 1" + else + testCommand="$testCommand --value $(date +%s)" + fi + + testCommand="$testCommand --bridge-address $bridge_address" + testCommand="$testCommand --private-key $target_private_key" + + echo $scenario | jq -c '.' + echo $testCommand + $testCommand +done + + +curl -s $l2_pp2b_url/bridges/$target_address | jq -c '.deposits[] | select(.network_id == 2) | select(.dest_net == 1)' | while read deposit ; do + echo $deposit | jq -c '.' + leaf_type=$(echo $deposit | jq -r '.leaf_type') + if [[ $leaf_type == "0" ]]; then + polycli ulxly claim asset \ + --bridge-address $bridge_address \ + --bridge-service-url $l2_pp2b_url \ + --rpc-url $l2_pp1_url \ + --deposit-count $(echo $deposit | jq -r '.deposit_cnt') \ + --deposit-network 2 \ + --destination-address $(echo $deposit | jq -r '.dest_addr') \ + --private-key $private_key + + else + polycli ulxly claim message \ + --bridge-address $bridge_address \ + --bridge-service-url $l2_pp2b_url \ + --rpc-url $l2_pp1_url \ + --deposit-count $(echo $deposit | jq -r '.deposit_cnt') \ + --deposit-network 2 \ + --destination-address $(echo $deposit | jq -r '.dest_addr') \ + --private-key $private_key + fi +done + + + +constructor_args=$(cast abi-encode 'f(string,string,address,uint256)' 'Bridge Test' 'BT' "$target_address" $(cast max-uint) | sed 's/0x//') +cast send --legacy --rpc-url $l2_pp1_url --private-key $target_private_key $deterministic_deployer_addr 0x6a6f686e2068696c6c696172642077617320686572650a000000000000000002$erc_20_bytecode$constructor_args +cast send --legacy --rpc-url $l2_pp1_url --private-key $target_private_key 0x0B006480c0318197b33458DA1448b9CE07C76A2E 'approve(address,uint256)' $bridge_address $(cast max-uint) + +polycli ulxly bridge asset \ + --private-key $target_private_key \ + --value $(cast max-uint) \ + --bridge-address $bridge_address \ + --destination-network 2 \ + --destination-address $target_address \ + --call-data 0x \ + --rpc-url $l2_pp1_url \ + --token-address 0x0B006480c0318197b33458DA1448b9CE07C76A2E \ + --force-update-root=true + +# 5:44PM INF bridgeTxn: 0xfc34856a8a0009fdb3d3c1f431716557c60431d693e6526756588d27dfcf05a8 +# 5:44PM INF Deposit transaction successful txHash=0xfc34856a8a0009fdb3d3c1f431716557c60431d693e6526756588d27dfcf05a8 + + +curl -s $l2_pp1b_url/bridges/$target_address + +# ## State Capture Procedure +pushd $(mktemp -d) +mkdir agglayer-storage +docker cp agglayer--f3cc4c8d0bad44be9c0ea8eccedd0da1:/etc/zkevm/storage agglayer-storage/ +mkdir cdk-001 +docker cp cdk-node-001--bd52b030071a4c438cf82b6c281219e6:/tmp cdk-001/ +mkdir cdk-002 +docker cp cdk-node-002--3c9a92d0e1aa4259a795d7a60156188c:/tmp cdk-002/ +kurtosis enclave dump pp +popd +tar caf agglayer-details.tar.xz /tmp/tmp.VKezDefjS6 diff --git a/multi-pp-test.sh.md b/multi-pp-test.sh.md index 2c9b1be3..8df655e2 100644 --- a/multi-pp-test.sh.md +++ b/multi-pp-test.sh.md @@ -23,7 +23,17 @@ with an SP1 key ```sh kurtosis run --enclave pp --args-file .github/tests/fork12-pessimistic-secret.yml . -kurtosis run --enclave pp --args-file .github/tests/attach-second-cdk.yml . # TODO investigate issue with first block startup +kurtosis run --enclave pp --args-file .github/tests/attach-second-cdk.yml . +``` + +At this point we should be able to confirm that things look right +for both chains. Recently, it seems like the fork id isn't initially +detected by erigon which is causing the chain not to start up right +away. + +```sh +polycli monitor --rpc-url $(kurtosis port print pp cdk-erigon-rpc-001 rpc) +polycli monitor --rpc-url $(kurtosis port print pp cdk-erigon-rpc-002 rpc) ``` In order to proceed, we'll need to grab the combined files from both @@ -34,28 +44,6 @@ from the second chain because we need to know the gas token address. kurtosis service exec pp contracts-001 "cat /opt/zkevm/combined-001.json" | tail -n +2 | jq '.' > combined-001.json kurtosis service exec pp contracts-002 "cat /opt/zkevm/combined-002.json" | tail -n +2 | jq '.' > combined-002.json kurtosis service exec pp contracts-002 "cat /opt/zkevm-contracts/deployment/v2/create_rollup_parameters.json" | tail -n +2 | jq -r '.gasTokenAddress' > gas-token-address.json - - - -cast logs --from-block 0 --to-block 1 --rpc-url https://rpc.cdk12.dev.polygon --address 0x1348947e282138d8f377b467F7D9c2EB0F335d1f 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498 - - -curl http://127.0.0.1:33725 \ ---json '{ - "id": 1, - "jsonrpc": "2.0", - "method": "eth_call", - "params": [ - { - "chainId": "0x1ce", - "data": "0xbab161bf", - "from": "0x0000000000000000000000000000000000000000", - "input": "0xbab161bf", - "to": "0xd8886e9D827218a02B8C04323b5550f2F36BC8d5" - }, - "latest" - ] -}' ``` This diagnosis isn't critical, but it's nice to confirm that we are @@ -74,20 +62,22 @@ cast code --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $( cast code --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $(cat combined-002.json | jq -r '.verifierAddress') | sha256sum ``` -At this point, the agglayer config needs to be manually updated for -rollup2. This will add a second entry to the agglayer config. +It's also worth while probably to confirm that the vkey matches! ```sh -kurtosis service exec pp agglayer "sed -i 's/\[proof\-signers\]/2 = \"http:\/\/cdk-erigon-rpc-002:8123\"\n\[proof-signers\]/i' /etc/zkevm/agglayer-config.toml" -kurtosis service stop pp agglayer -kurtosis service start pp agglayer +kurtosis service exec pp agglayer agglayer vkey +cast call --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $(cat combined-001.json | jq -r '.polygonRollupManagerAddress') 'rollupTypeMap(uint32)(address,address,uint64,uint8,bool,bytes32,bytes32)' 1 ``` -At this point we should be able to confirm that things look right for both chains. +At this point, the agglayer config needs to be manually updated for +rollup2. This will add a second entry to the agglayer config. If the +second chain is also pessimistic, this isn't strictly necessary, but +there's no harm in it. ```sh -polycli monitor --rpc-url $(kurtosis port print pp cdk-erigon-rpc-001 rpc) -polycli monitor --rpc-url $(kurtosis port print pp cdk-erigon-rpc-002 rpc) +kurtosis service exec pp agglayer "sed -i 's/\[proof\-signers\]/2 = \"http:\/\/cdk-erigon-rpc-002:8123\"\n\[proof-signers\]/i' /etc/zkevm/agglayer-config.toml" +kurtosis service stop pp agglayer +kurtosis service start pp agglayer ``` Let's create a clean EOA for receiving bridges so that we can see @@ -134,6 +124,13 @@ cast send --legacy --value 100ether --rpc-url $l2_pp1_url --private-key $private cast send --legacy --value 100ether --rpc-url $l2_pp2_url --private-key $private_key 0x93F63c24735f45Cd0266E87353071B64dd86bc05 ``` +We should also fund the target address on L1 so that we can use this +key for L1 bridge transfers + +```sh +cast send --value 100ether --rpc-url $l1_rpc_url --private-key $private_key $target_address +``` + Let's mint some POL token for testing purpsoes ```sh @@ -173,14 +170,14 @@ cast send \ $bridge_address 10000000000000000000000 ``` -At this point, I just want to confirm my understanding of the WETH -Token. My sense is that only the L2 bridge for a network that has a -gas token should have a WETH Token +We're also going to mint POL and Gas Token from the target account for additional test scenarios ```sh -cast call --rpc-url $l1_rpc_url $bridge_address 'WETHToken()' -cast call --rpc-url $l2_pp1_url $bridge_address 'WETHToken()' -cast call --rpc-url $l2_pp2_url $bridge_address 'WETHToken()' +cast send --rpc-url $l1_rpc_url --private-key $target_private_key $pol_address 'mint(address,uint256)' $target_address 10000000000000000000000 +cast send --rpc-url $l1_rpc_url --private-key $target_private_key $pol_address 'approve(address,uint256)' $bridge_address 10000000000000000000000 + +cast send --rpc-url $l1_rpc_url --private-key $target_private_key $gas_token_address 'mint(address,uint256)' $target_address 10000000000000000000000 +cast send --rpc-url $l1_rpc_url --private-key $target_private_key $gas_token_address 'approve(address,uint256)' $bridge_address 10000000000000000000000 ``` We're going to do a little matrix of L1 to L2 bridges here. The idea @@ -226,7 +223,8 @@ done ``` At this point, we should be able to see our bridges in the bridge -service for both chains +service for both chains. Recently, with this setup there has been an +issue with network id detection in the bridge service ```sh curl -s $l2_pp1b_url/bridges/$target_address | jq '.' @@ -405,8 +403,247 @@ polycli ulxly bridge asset \ --destination-address $target_address \ --force-update-root=true \ --rpc-url $l2_pp2_url +``` +Now we should try to claim these transactions again on Layer one and PP1 +```sh curl -s $l2_pp2b_url/bridges/$target_address | jq '.deposits[] | select(.ready_for_claim) | select(.claim_tx_hash == "")' + +deposit_cnt=0 +polycli ulxly claim asset \ + --bridge-address $bridge_address \ + --bridge-service-url $l2_pp2b_url \ + --rpc-url $l1_rpc_url \ + --deposit-count $deposit_cnt \ + --deposit-network 2 \ + --destination-address $target_address \ + --private-key $private_key + +deposit_cnt=1 +polycli ulxly claim asset \ + --bridge-address $bridge_address \ + --bridge-service-url $l2_pp2b_url \ + --rpc-url $l2_pp1_url \ + --deposit-count $deposit_cnt \ + --deposit-network 2 \ + --destination-address $target_address \ + --private-key $private_key + +cast call --rpc-url $l1_rpc_url $bridge_address 'depositCount() external view returns (uint256)' + + +deposit_cnt=2 +polycli ulxly claim asset \ + --bridge-address $bridge_address \ + --bridge-service-url $l2_pp2b_url \ + --rpc-url $l1_rpc_url \ + --deposit-count $deposit_cnt \ + --deposit-network 2 \ + --destination-address $target_address \ + --private-key $private_key +``` + +## Pict Based Test Scenarios +I'm using a command like this to generate the test cases. + +```sh +pict lxly.pict /f:json | jq -c '.[] | from_entries' | jq -s > ~/code/kurtosis-cdk/test-scenarios.json +``` + +I want to setup the deterministic deployer for some consistent l2 addresses + +```sh +cast send --legacy --value 0.1ether --rpc-url $l1_rpc_url --private-key $private_key 0x3fab184622dc19b6109349b94811493bf2a45362 +cast send --legacy --value 0.1ether --rpc-url $l2_pp1_url --private-key $private_key 0x3fab184622dc19b6109349b94811493bf2a45362 +cast send --legacy --value 0.1ether --rpc-url $l2_pp2_url --private-key $private_key 0x3fab184622dc19b6109349b94811493bf2a45362 + +deterministic_deployer_tx=0xf8a58085174876e800830186a08080b853604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf31ba02222222222222222222222222222222222222222222222222222222222222222a02222222222222222222222222222222222222222222222222222222222222222 +deterministic_deployer_addr=0x4e59b44847b379578588920ca78fbf26c0b4956c + +cast publish --rpc-url $l1_rpc_url $deterministic_deployer_tx +cast publish --rpc-url $l2_pp1_url $deterministic_deployer_tx +cast publish --rpc-url $l2_pp2_url $deterministic_deployer_tx + + +salt=0x6a6f686e2068696c6c696172642077617320686572650a000000000000000000 +erc_20_bytecode=60806040526040516200143a3803806200143a833981016040819052620000269162000201565b8383600362000036838262000322565b50600462000045828262000322565b5050506200005a82826200007160201b60201c565b505081516020909201919091206006555062000416565b6001600160a01b038216620000cc5760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015260640160405180910390fd5b8060026000828254620000e09190620003ee565b90915550506001600160a01b038216600081815260208181526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b505050565b634e487b7160e01b600052604160045260246000fd5b600082601f8301126200016457600080fd5b81516001600160401b03808211156200018157620001816200013c565b604051601f8301601f19908116603f01168101908282118183101715620001ac57620001ac6200013c565b81604052838152602092508683858801011115620001c957600080fd5b600091505b83821015620001ed5785820183015181830184015290820190620001ce565b600093810190920192909252949350505050565b600080600080608085870312156200021857600080fd5b84516001600160401b03808211156200023057600080fd5b6200023e8883890162000152565b955060208701519150808211156200025557600080fd5b50620002648782880162000152565b604087015190945090506001600160a01b03811681146200028457600080fd5b6060959095015193969295505050565b600181811c90821680620002a957607f821691505b602082108103620002ca57634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200013757600081815260208120601f850160051c81016020861015620002f95750805b601f850160051c820191505b818110156200031a5782815560010162000305565b505050505050565b81516001600160401b038111156200033e576200033e6200013c565b62000356816200034f845462000294565b84620002d0565b602080601f8311600181146200038e5760008415620003755750858301515b600019600386901b1c1916600185901b1785556200031a565b600085815260208120601f198616915b82811015620003bf578886015182559484019460019091019084016200039e565b5085821015620003de5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b808201808211156200041057634e487b7160e01b600052601160045260246000fd5b92915050565b61101480620004266000396000f3fe608060405234801561001057600080fd5b506004361061014d5760003560e01c806340c10f19116100c35780639e4e73181161007c5780639e4e73181461033c578063a457c2d714610363578063a9059cbb14610376578063c473af3314610389578063d505accf146103b0578063dd62ed3e146103c357600080fd5b806340c10f19146102b257806342966c68146102c557806356189cb4146102d857806370a08231146102eb5780637ecebe001461031457806395d89b411461033457600080fd5b806323b872dd1161011557806323b872dd146101c357806330adf81f146101d6578063313ce567146101fd5780633408e4701461020c5780633644e51514610212578063395093511461029f57600080fd5b806304622c2e1461015257806306fdde031461016e578063095ea7b31461018357806318160ddd146101a6578063222f5be0146101ae575b600080fd5b61015b60065481565b6040519081526020015b60405180910390f35b6101766103d6565b6040516101659190610db1565b610196610191366004610e1b565b610468565b6040519015158152602001610165565b60025461015b565b6101c16101bc366004610e45565b610482565b005b6101966101d1366004610e45565b610492565b61015b7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b60405160128152602001610165565b4661015b565b61015b6006546000907f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f907fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc646604080516020810195909552840192909252606083015260808201523060a082015260c00160405160208183030381529060405280519060200120905090565b6101966102ad366004610e1b565b6104b6565b6101c16102c0366004610e1b565b6104d8565b6101c16102d3366004610e81565b6104e6565b6101c16102e6366004610e45565b6104f3565b61015b6102f9366004610e9a565b6001600160a01b031660009081526020819052604090205490565b61015b610322366004610e9a565b60056020526000908152604090205481565b6101766104fe565b61015b7fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc681565b610196610371366004610e1b565b61050d565b610196610384366004610e1b565b61058d565b61015b7f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f81565b6101c16103be366004610ebc565b61059b565b61015b6103d1366004610f2f565b6106ae565b6060600380546103e590610f62565b80601f016020809104026020016040519081016040528092919081815260200182805461041190610f62565b801561045e5780601f106104335761010080835404028352916020019161045e565b820191906000526020600020905b81548152906001019060200180831161044157829003601f168201915b5050505050905090565b6000336104768185856106d9565b60019150505b92915050565b61048d8383836107fd565b505050565b6000336104a08582856109a3565b6104ab8585856107fd565b506001949350505050565b6000336104768185856104c983836106ae565b6104d39190610fb2565b6106d9565b6104e28282610a17565b5050565b6104f03382610ad6565b50565b61048d8383836106d9565b6060600480546103e590610f62565b6000338161051b82866106ae565b9050838110156105805760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b60648201526084015b60405180910390fd5b6104ab82868684036106d9565b6000336104768185856107fd565b428410156105eb5760405162461bcd60e51b815260206004820152601960248201527f48455a3a3a7065726d69743a20415554485f45585049524544000000000000006044820152606401610577565b6001600160a01b038716600090815260056020526040812080547f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9918a918a918a91908661063883610fc5565b909155506040805160208101969096526001600160a01b0394851690860152929091166060840152608083015260a082015260c0810186905260e0016040516020818303038152906040528051906020012090506106998882868686610c08565b6106a48888886106d9565b5050505050505050565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6001600160a01b03831661073b5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610577565b6001600160a01b03821661079c5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610577565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b0383166108615760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610577565b6001600160a01b0382166108c35760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610577565b6001600160a01b0383166000908152602081905260409020548181101561093b5760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610577565b6001600160a01b03848116600081815260208181526040808320878703905593871680835291849020805487019055925185815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35b50505050565b60006109af84846106ae565b9050600019811461099d5781811015610a0a5760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610577565b61099d84848484036106d9565b6001600160a01b038216610a6d5760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610577565b8060026000828254610a7f9190610fb2565b90915550506001600160a01b038216600081815260208181526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b6001600160a01b038216610b365760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b6064820152608401610577565b6001600160a01b03821660009081526020819052604090205481811015610baa5760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b6064820152608401610577565b6001600160a01b0383166000818152602081815260408083208686039055600280548790039055518581529192917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3505050565b600654604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f602080830191909152818301939093527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a0808301919091528251808303909101815260c082019092528151919092012061190160f01b60e083015260e282018190526101028201869052906000906101220160408051601f198184030181528282528051602091820120600080855291840180845281905260ff89169284019290925260608301879052608083018690529092509060019060a0016020604051602081039080840390855afa158015610d1b573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811615801590610d515750876001600160a01b0316816001600160a01b0316145b6106a45760405162461bcd60e51b815260206004820152602b60248201527f48455a3a3a5f76616c69646174655369676e6564446174613a20494e56414c4960448201526a445f5349474e415455524560a81b6064820152608401610577565b600060208083528351808285015260005b81811015610dde57858101830151858201604001528201610dc2565b506000604082860101526040601f19601f8301168501019250505092915050565b80356001600160a01b0381168114610e1657600080fd5b919050565b60008060408385031215610e2e57600080fd5b610e3783610dff565b946020939093013593505050565b600080600060608486031215610e5a57600080fd5b610e6384610dff565b9250610e7160208501610dff565b9150604084013590509250925092565b600060208284031215610e9357600080fd5b5035919050565b600060208284031215610eac57600080fd5b610eb582610dff565b9392505050565b600080600080600080600060e0888a031215610ed757600080fd5b610ee088610dff565b9650610eee60208901610dff565b95506040880135945060608801359350608088013560ff81168114610f1257600080fd5b9699959850939692959460a0840135945060c09093013592915050565b60008060408385031215610f4257600080fd5b610f4b83610dff565b9150610f5960208401610dff565b90509250929050565b600181811c90821680610f7657607f821691505b602082108103610f9657634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b8082018082111561047c5761047c610f9c565b600060018201610fd757610fd7610f9c565b506001019056fea26469706673582212207bede9966bc8e8634cc0c3dc076626579b27dff7bbcac0b645c87d4cf1812b9864736f6c63430008140033 +constructor_args=$(cast abi-encode 'f(string,string,address,uint256)' 'Bridge Test' 'BT' "$target_address" 100000000000000000000 | sed 's/0x//') + +cast send --legacy --rpc-url $l1_rpc_url --private-key $private_key $deterministic_deployer_addr $salt$erc_20_bytecode$constructor_args +cast send --legacy --rpc-url $l2_pp1_url --private-key $private_key $deterministic_deployer_addr $salt$erc_20_bytecode$constructor_args +cast send --legacy --rpc-url $l2_pp2_url --private-key $private_key $deterministic_deployer_addr $salt$erc_20_bytecode$constructor_args + +test_erc20_addr=$(cast create2 --salt $salt --init-code $erc_20_bytecode$constructor_args) + +cast send --legacy --rpc-url $l1_rpc_url --private-key $target_private_key $test_erc20_addr 'approve(address,uint256)' $bridge_address 100000000000000000000 +cast send --legacy --rpc-url $l2_pp1_url --private-key $target_private_key $test_erc20_addr 'approve(address,uint256)' $bridge_address 100000000000000000000 +cast send --legacy --rpc-url $l2_pp2_url --private-key $target_private_key $test_erc20_addr 'approve(address,uint256)' $bridge_address 100000000000000000000 +``` + +One of the test cases that I've left out for now is a permit +call. It'll take some work to get the signed permit data in place, +but it seems doable. + +- https://eips.ethereum.org/EIPS/eip-2612 +- https://eips.ethereum.org/EIPS/eip-712 + +permit_sig=$(cast wallet sign --private-key $target_private_key 0x$(< /dev/urandom xxd -p | tr -d "\n" | head -c 40)) +permit_sig_r=${permit_sig:2:64} +permit_sig_s=${permit_sig:66:64} +permit_sig_v=${permit_sig:130:2} +The test cases are committed for convenience, we'll use that to +dynamically to some testing + +```sh +cat test-scenarios.json | jq -c '.[]' | while read scenario ; do + testBridgeType=$(echo $scenario | jq -r '.BridgeType') + testDepositChain=$(echo $scenario | jq -r '.DepositChain') + testDestinationChain=$(echo $scenario | jq -r '.DestinationChain') + testDestinationAddress=$(echo $scenario | jq -r '.DestinationAddress') + testToken=$(echo $scenario | jq -r '.Token') + testMetaData=$(echo $scenario | jq -r '.MetaData') + testForceUpdate=$(echo $scenario | jq -r '.ForceUpdate') + testAmount=$(echo $scenario | jq -r '.Amount') + + testCommand="polycli ulxly bridge" + + if [[ $testBridgeType == "Asset" ]]; then + testCommand="$testCommand asset" + elif [[ $testBridgeType == "Message" ]]; then + testCommand="$testCommand message" + else + testCommand="$testCommand weth" + fi + + if [[ $testDepositChain == "L1" ]]; then + testCommand="$testCommand --rpc-url $l1_rpc_url" + elif [[ $testDepositChain == "PP1" ]]; then + testCommand="$testCommand --rpc-url $l2_pp1_url" + else + testCommand="$testCommand --rpc-url $l2_pp2_url" + fi + + if [[ $testDestinationChain == "L1" ]]; then + testCommand="$testCommand --destination-network 0" + elif [[ $testDestinationChain == "PP1" ]]; then + testCommand="$testCommand --destination-network 1" + else + testCommand="$testCommand --destination-network 2" + fi + + if [[ $testDestinationAddress == "Contract" ]]; then + testCommand="$testCommand --destination-address $bridge_address" + elif [[ $testDestinationAddress == "Precompile" ]]; then + testCommand="$testCommand --destination-address 0x0000000000000000000000000000000000000004" + else + testCommand="$testCommand --destination-address $target_address" + fi + + if [[ $testToken == "POL" ]]; then + testCommand="$testCommand --token-address $pol_address" + elif [[ $testToken == "LocalERC20" ]]; then + testCommand="$testCommand --token-address $test_erc20_addr" + elif [[ $testToken == "WETH" ]]; then + testCommand="$testCommand --token-address $pp2_weth_address" + elif [[ $testToken == "Invalid" ]]; then + testCommand="$testCommand --token-address $(< /dev/urandom xxd -p | tr -d "\n" | head -c 40)" + else + testCommand="$testCommand --token-address 0x0000000000000000000000000000000000000000" + fi + + if [[ $testMetaData == "Random" ]]; then + testCommand="$testCommand --call-data $(date +%s | xxd -p)" + else + testCommand="$testCommand --call-data 0x" + fi + + if [[ $testForceUpdate == "True" ]]; then + testCommand="$testCommand --force-update-root=true" + else + testCommand="$testCommand --force-update-root=false" + fi + + if [[ $testAmount == "0" ]]; then + testCommand="$testCommand --value 0" + elif [[ $testAmount == "1" ]]; then + testCommand="$testCommand --value 1" + else + testCommand="$testCommand --value $(date +%s)" + fi + + testCommand="$testCommand --bridge-address $bridge_address" + testCommand="$testCommand --private-key $target_private_key" + + echo $scenario | jq -c '.' + echo $testCommand + $testCommand +done + + +curl -s $l2_pp2b_url/bridges/$target_address | jq -c '.deposits[] | select(.network_id == 2) | select(.dest_net == 1)' | while read deposit ; do + echo $deposit | jq -c '.' + leaf_type=$(echo $deposit | jq -r '.leaf_type') + if [[ $leaf_type == "0" ]]; then + polycli ulxly claim asset \ + --bridge-address $bridge_address \ + --bridge-service-url $l2_pp2b_url \ + --rpc-url $l2_pp1_url \ + --deposit-count $(echo $deposit | jq -r '.deposit_cnt') \ + --deposit-network 2 \ + --destination-address $(echo $deposit | jq -r '.dest_addr') \ + --private-key $private_key + + else + polycli ulxly claim message \ + --bridge-address $bridge_address \ + --bridge-service-url $l2_pp2b_url \ + --rpc-url $l2_pp1_url \ + --deposit-count $(echo $deposit | jq -r '.deposit_cnt') \ + --deposit-network 2 \ + --destination-address $(echo $deposit | jq -r '.dest_addr') \ + --private-key $private_key + fi +done + + + +constructor_args=$(cast abi-encode 'f(string,string,address,uint256)' 'Bridge Test' 'BT' "$target_address" $(cast max-uint) | sed 's/0x//') +cast send --legacy --rpc-url $l2_pp1_url --private-key $target_private_key $deterministic_deployer_addr 0x6a6f686e2068696c6c696172642077617320686572650a000000000000000002$erc_20_bytecode$constructor_args +cast send --legacy --rpc-url $l2_pp1_url --private-key $target_private_key 0x0B006480c0318197b33458DA1448b9CE07C76A2E 'approve(address,uint256)' $bridge_address $(cast max-uint) + +polycli ulxly bridge asset \ + --private-key $target_private_key \ + --value $(cast max-uint) \ + --bridge-address $bridge_address \ + --destination-network 2 \ + --destination-address $target_address \ + --call-data 0x \ + --rpc-url $l2_pp1_url \ + --token-address 0x0B006480c0318197b33458DA1448b9CE07C76A2E \ + --force-update-root=true +``` + +5:44PM INF bridgeTxn: 0xfc34856a8a0009fdb3d3c1f431716557c60431d693e6526756588d27dfcf05a8 +5:44PM INF Deposit transaction successful txHash=0xfc34856a8a0009fdb3d3c1f431716557c60431d693e6526756588d27dfcf05a8 + +```sh +curl -s $l2_pp1b_url/bridges/$target_address +``` + +## State Capture Procedure + +```sh +pushd $(mktemp -d) +mkdir agglayer-storage +docker cp agglayer--f3cc4c8d0bad44be9c0ea8eccedd0da1:/etc/zkevm/storage agglayer-storage/ +mkdir cdk-001 +docker cp cdk-node-001--bd52b030071a4c438cf82b6c281219e6:/tmp cdk-001/ +mkdir cdk-002 +docker cp cdk-node-002--3c9a92d0e1aa4259a795d7a60156188c:/tmp cdk-002/ +kurtosis enclave dump pp + +popd +tar caf agglayer-details.tar.xz /tmp/tmp.VKezDefjS6 ``` From 1dca419dfd69704cdcfb4f7fcd39bfed38209536 Mon Sep 17 00:00:00 2001 From: John Hilliard Date: Thu, 12 Dec 2024 11:47:41 -0500 Subject: [PATCH 16/38] docs: latest testing procedures --- .github/tests/attach-second-cdk.yml | 1 - .github/tests/fork12-pessimistic.yml | 1 - input_parser.star | 5 +- lxly.pict | 23 +++++ multi-pp-test.sh | 95 +++++++++++++----- multi-pp-test.sh.md | 98 +++++++++++++++---- .../contract-deploy/run-contract-setup.sh | 11 ++- 7 files changed, 185 insertions(+), 49 deletions(-) create mode 100644 lxly.pict diff --git a/.github/tests/attach-second-cdk.yml b/.github/tests/attach-second-cdk.yml index 517af041..e2fe5dab 100644 --- a/.github/tests/attach-second-cdk.yml +++ b/.github/tests/attach-second-cdk.yml @@ -36,5 +36,4 @@ args: gas_token_enabled: true zkevm_use_real_verifier: true enable_normalcy: true - verifier_program_vkey: 0x00b4769114e641ec0d62858e7063b73ce02f8ba1a360dd678bc5aa5b2bd4410c diff --git a/.github/tests/fork12-pessimistic.yml b/.github/tests/fork12-pessimistic.yml index 091b6c8c..31a35e0e 100644 --- a/.github/tests/fork12-pessimistic.yml +++ b/.github/tests/fork12-pessimistic.yml @@ -9,6 +9,5 @@ args: gas_token_enabled: false zkevm_use_real_verifier: true enable_normalcy: true - verifier_program_vkey: 0x00b4769114e641ec0d62858e7063b73ce02f8ba1a360dd678bc5aa5b2bd4410c agglayer_prover_sp1_key: "" diff --git a/input_parser.star b/input_parser.star index e02fd221..a4ac7751 100644 --- a/input_parser.star +++ b/input_parser.star @@ -29,8 +29,7 @@ DEFAULT_DEPLOYMENT_STAGES = { } DEFAULT_IMAGES = { - # "agglayer_image": "ghcr.io/agglayer/agglayer:0.2.0-rc.20", # https://github.com/agglayer/agglayer/tags - "agglayer_image": "agglayer:adding-sigterm-signal-hook", # https://github.com/agglayer/agglayer/tags + "agglayer_image": "ghcr.io/agglayer/agglayer:0.2.0-rc.21", # https://github.com/agglayer/agglayer/tags "cdk_erigon_node_image": "hermeznetwork/cdk-erigon:v2.60.0", # https://hub.docker.com/r/hermeznetwork/cdk-erigon/tags "cdk_node_image": "ghcr.io/0xpolygon/cdk:0.4.0", # https://github.com/0xpolygon/cdk/pkgs/container/cdk "cdk_validium_node_image": "0xpolygon/cdk-validium-node:0.7.0-cdk", # https://hub.docker.com/r/0xpolygon/cdk-validium-node/tags @@ -239,7 +238,7 @@ DEFAULT_ROLLUP_ARGS = { # If we're using pessimistic consensus and a real verifier, we'll # need to know which vkey to use. This value is tightly coupled to # the agglayer version that's being used - "verifier_program_vkey": "0x0000000000000000000000000000000000000000000000000000000000000000", + "verifier_program_vkey": "0x00e360ff2c18d456d6ee96c17f4e746216b475b62174bd2e9e8775ed99368ca3", # This flag will enable a stateless executor to verify the execution of the batches. # Set to true to run erigon as the sequencer. "erigon_strict_mode": True, diff --git a/lxly.pict b/lxly.pict new file mode 100644 index 00000000..0a0b9b5f --- /dev/null +++ b/lxly.pict @@ -0,0 +1,23 @@ +# pict lxly.pict /f:json | jq -c '.[] | from_entries' +DepositChain : L1, PP1 (2), PP2 (2) +DestinationChain : L1, PP1, PP2 +DestinationAddress : EOA, Contract, Precompile +BridgeType : Asset, Message, Weth +Token : NativeEther (5), LocalERC20 (5), POL (2), Invalid, WETH (2) +MetaData : 0x, Random +ForceUpdate : True (4), False +Amount : 0, 1, Random + +IF [DepositChain] = "L1" THEN [DestinationChain] <> "L1"; +IF [DepositChain] = "PP1" THEN [DestinationChain] <> "PP1"; +IF [DepositChain] = "PP2" THEN [DestinationChain] <> "PP2"; + +IF [BridgeType] = "Message" THEN [Token] = "NativeEther"; +IF [BridgeType] = "Weth" THEN [Token] = "WETH"; + +IF [Token] = "POL" THEN [DepositChain] = "L1"; +IF [Token] = "WETH" THEN [DepositChain] = "PP2"; +IF [Token] = "LocalERC20" OR [Token] = "WETH" OR [Token] = "POL" OR [Token] = "Invalid" THEN [MetaData] = "0x"; + + + diff --git a/multi-pp-test.sh b/multi-pp-test.sh index 38c846e5..b81aa4b5 100755 --- a/multi-pp-test.sh +++ b/multi-pp-test.sh @@ -45,9 +45,15 @@ cast code --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $( cast code --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $(cat combined-002.json | jq -r '.verifierAddress') | sha256sum # It's also worth while probably to confirm that the vkey matches! -kurtosis service exec pp agglayer agglayer vkey +kurtosis service exec pp agglayer "agglayer vkey" cast call --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $(cat combined-001.json | jq -r '.polygonRollupManagerAddress') 'rollupTypeMap(uint32)(address,address,uint64,uint8,bool,bytes32,bytes32)' 1 +# Let's make sure both rollups have the same vkey + +cast call --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $(cat combined-001.json | jq -r '.polygonRollupManagerAddress') 'rollupIDToRollupDataV2(uint32 rollupID)(address,uint64,address,uint64,bytes32,uint64,uint64,uint64,uint64,uint8,bytes32,bytes32)' 1 +cast call --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $(cat combined-001.json | jq -r '.polygonRollupManagerAddress') 'rollupIDToRollupDataV2(uint32 rollupID)(address,uint64,address,uint64,bytes32,uint64,uint64,uint64,uint64,uint8,bytes32,bytes32)' 2 + + # At this point, the agglayer config needs to be manually updated for # rollup2. This will add a second entry to the agglayer config. If the # second chain is also pessimistic, this isn't strictly necessary, but @@ -122,7 +128,10 @@ cast send \ 'approve(address,uint256)' \ $bridge_address 10000000000000000000000 -# We're also going to mint POL and Gas Token from the target account for additional test scenarios +# We're also going to mint POL and Gas Token from the target account +# for additional test scenarios. The logic here is that we don't want +# to send Ether to the target address on L2 because we might risk +# withdrawing more than we deposit cast send --rpc-url $l1_rpc_url --private-key $target_private_key $pol_address 'mint(address,uint256)' $target_address 10000000000000000000000 cast send --rpc-url $l1_rpc_url --private-key $target_private_key $pol_address 'approve(address,uint256)' $bridge_address 10000000000000000000000 @@ -340,26 +349,23 @@ polycli ulxly claim asset \ cast call --rpc-url $l1_rpc_url $bridge_address 'depositCount() external view returns (uint256)' -deposit_cnt=2 -polycli ulxly claim asset \ - --bridge-address $bridge_address \ - --bridge-service-url $l2_pp2b_url \ - --rpc-url $l1_rpc_url \ - --deposit-count $deposit_cnt \ - --deposit-network 2 \ - --destination-address $target_address \ - --private-key $private_key - - # ## Pict Based Test Scenarios -# I'm using a command like this to generate the test cases. -pict lxly.pict /f:json | jq -c '.[] | from_entries' | jq -s > ~/code/kurtosis-cdk/test-scenarios.json - -# I want to setup the deterministic deployer for some consistent l2 addresses +# +# The goal here is to have some methods for creating more robust +# testing combinations. In theory, we can probably brute force test +# every combination of parameters, but as the number of parameters +# grows, this might become too difficult. I'm using a command like +# this to generate the test cases. +pict lxly.pict /f:json | jq -c '.[] | from_entries' | jq -s > test-scenarios.json + +# For the sake of simplicity, I'm going to use the deterministic +# deployer so that I have the same ERC20 address on each chain. Here +# I'm adding some funds to the deterministict deployer address. cast send --legacy --value 0.1ether --rpc-url $l1_rpc_url --private-key $private_key 0x3fab184622dc19b6109349b94811493bf2a45362 cast send --legacy --value 0.1ether --rpc-url $l2_pp1_url --private-key $private_key 0x3fab184622dc19b6109349b94811493bf2a45362 cast send --legacy --value 0.1ether --rpc-url $l2_pp2_url --private-key $private_key 0x3fab184622dc19b6109349b94811493bf2a45362 +# The tx data and address are standard for the deterministict deployer deterministic_deployer_tx=0xf8a58085174876e800830186a08080b853604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf31ba02222222222222222222222222222222222222222222222222222222222222222a02222222222222222222222222222222222222222222222222222222222222222 deterministic_deployer_addr=0x4e59b44847b379578588920ca78fbf26c0b4956c @@ -506,12 +512,38 @@ curl -s $l2_pp2b_url/bridges/$target_address | jq -c '.deposits[] | select(.netw --private-key $private_key fi done +curl -s $l2_pp1b_url/bridges/$target_address | jq -c '.deposits[] | select(.network_id == 1) | select(.dest_net == 2)' | while read deposit ; do + echo $deposit | jq -c '.' + leaf_type=$(echo $deposit | jq -r '.leaf_type') + if [[ $leaf_type == "0" ]]; then + polycli ulxly claim asset \ + --bridge-address $bridge_address \ + --bridge-service-url $l2_pp1b_url \ + --rpc-url $l2_pp2_url \ + --deposit-count $(echo $deposit | jq -r '.deposit_cnt') \ + --deposit-network 1 \ + --destination-address $(echo $deposit | jq -r '.dest_addr') \ + --private-key $private_key + + else + polycli ulxly claim message \ + --bridge-address $bridge_address \ + --bridge-service-url $l2_pp1b_url \ + --rpc-url $l2_pp2_url \ + --deposit-count $(echo $deposit | jq -r '.deposit_cnt') \ + --deposit-network 1 \ + --destination-address $(echo $deposit | jq -r '.dest_addr') \ + --private-key $private_key + fi +done + + -constructor_args=$(cast abi-encode 'f(string,string,address,uint256)' 'Bridge Test' 'BT' "$target_address" $(cast max-uint) | sed 's/0x//') +constructor_args=$(cast abi-encode 'f(string,string,address,uint256)' 'Big Test' 'BT' "$target_address" $(cast max-uint) | sed 's/0x//') cast send --legacy --rpc-url $l2_pp1_url --private-key $target_private_key $deterministic_deployer_addr 0x6a6f686e2068696c6c696172642077617320686572650a000000000000000002$erc_20_bytecode$constructor_args -cast send --legacy --rpc-url $l2_pp1_url --private-key $target_private_key 0x0B006480c0318197b33458DA1448b9CE07C76A2E 'approve(address,uint256)' $bridge_address $(cast max-uint) +cast send --legacy --rpc-url $l2_pp1_url --private-key $target_private_key 0x8A5B34caF06Da682FDC4d08696417054fBaA5D6B 'approve(address,uint256)' $bridge_address $(cast max-uint) polycli ulxly bridge asset \ --private-key $target_private_key \ @@ -521,15 +553,34 @@ polycli ulxly bridge asset \ --destination-address $target_address \ --call-data 0x \ --rpc-url $l2_pp1_url \ - --token-address 0x0B006480c0318197b33458DA1448b9CE07C76A2E \ + --token-address 0x8A5B34caF06Da682FDC4d08696417054fBaA5D6B \ + --force-update-root=true + +# 9:45AM INF bridgeTxn: 0x2b23e48077674e683ddd0af6e753ec6e394bc5d880e819db3903899e2dffce71 +# 9:45AM INF Deposit transaction successful txHash=0x2b23e48077674e683ddd0af6e753ec6e394bc5d880e819db3903899e2dffce71 +token_hash=$(cast keccak $(cast abi-encode --packed 'f(uint32,address)' 1 0x8A5B34caF06Da682FDC4d08696417054fBaA5D6B)) +pp2_big_test_addr=$(cast call --rpc-url $l2_pp2_url $bridge_address 'tokenInfoToWrappedToken(bytes32)(address)' $token_hash) +cast call --rpc-url $l2_pp2_url $pp2_big_test_addr 'balanceOf(address)' $target_address + + +polycli ulxly bridge asset \ + --private-key $target_private_key \ + --value 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe \ + --bridge-address $bridge_address \ + --destination-network 1 \ + --destination-address $target_address \ + --rpc-url $l2_pp2_url \ + --token-address $pp2_big_test_addr \ --force-update-root=true -# 5:44PM INF bridgeTxn: 0xfc34856a8a0009fdb3d3c1f431716557c60431d693e6526756588d27dfcf05a8 -# 5:44PM INF Deposit transaction successful txHash=0xfc34856a8a0009fdb3d3c1f431716557c60431d693e6526756588d27dfcf05a8 curl -s $l2_pp1b_url/bridges/$target_address +# TODO add a test where there is more than uint256 funds +# TODO add some tests with reverting +# TODO add some tests where the bridge is called via a smart contract rather than directly + # ## State Capture Procedure pushd $(mktemp -d) mkdir agglayer-storage diff --git a/multi-pp-test.sh.md b/multi-pp-test.sh.md index 8df655e2..683606a0 100644 --- a/multi-pp-test.sh.md +++ b/multi-pp-test.sh.md @@ -65,10 +65,17 @@ cast code --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $( It's also worth while probably to confirm that the vkey matches! ```sh -kurtosis service exec pp agglayer agglayer vkey +kurtosis service exec pp agglayer "agglayer vkey" cast call --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $(cat combined-001.json | jq -r '.polygonRollupManagerAddress') 'rollupTypeMap(uint32)(address,address,uint64,uint8,bool,bytes32,bytes32)' 1 ``` +Let's make sure both rollups have the same vkey + +```sh +cast call --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $(cat combined-001.json | jq -r '.polygonRollupManagerAddress') 'rollupIDToRollupDataV2(uint32 rollupID)(address,uint64,address,uint64,bytes32,uint64,uint64,uint64,uint64,uint8,bytes32,bytes32)' 1 +cast call --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $(cat combined-001.json | jq -r '.polygonRollupManagerAddress') 'rollupIDToRollupDataV2(uint32 rollupID)(address,uint64,address,uint64,bytes32,uint64,uint64,uint64,uint64,uint8,bytes32,bytes32)' 2 +``` + At this point, the agglayer config needs to be manually updated for rollup2. This will add a second entry to the agglayer config. If the second chain is also pessimistic, this isn't strictly necessary, but @@ -170,7 +177,10 @@ cast send \ $bridge_address 10000000000000000000000 ``` -We're also going to mint POL and Gas Token from the target account for additional test scenarios +We're also going to mint POL and Gas Token from the target account +for additional test scenarios. The logic here is that we don't want +to send Ether to the target address on L2 because we might risk +withdrawing more than we deposit ```sh cast send --rpc-url $l1_rpc_url --private-key $target_private_key $pol_address 'mint(address,uint256)' $target_address 10000000000000000000000 @@ -431,33 +441,33 @@ polycli ulxly claim asset \ --private-key $private_key cast call --rpc-url $l1_rpc_url $bridge_address 'depositCount() external view returns (uint256)' - - -deposit_cnt=2 -polycli ulxly claim asset \ - --bridge-address $bridge_address \ - --bridge-service-url $l2_pp2b_url \ - --rpc-url $l1_rpc_url \ - --deposit-count $deposit_cnt \ - --deposit-network 2 \ - --destination-address $target_address \ - --private-key $private_key ``` ## Pict Based Test Scenarios -I'm using a command like this to generate the test cases. + +The goal here is to have some methods for creating more robust +testing combinations. In theory, we can probably brute force test +every combination of parameters, but as the number of parameters +grows, this might become too difficult. I'm using a command like +this to generate the test cases. ```sh -pict lxly.pict /f:json | jq -c '.[] | from_entries' | jq -s > ~/code/kurtosis-cdk/test-scenarios.json +pict lxly.pict /f:json | jq -c '.[] | from_entries' | jq -s > test-scenarios.json ``` -I want to setup the deterministic deployer for some consistent l2 addresses +For the sake of simplicity, I'm going to use the deterministic +deployer so that I have the same ERC20 address on each chain. Here +I'm adding some funds to the deterministict deployer address. ```sh cast send --legacy --value 0.1ether --rpc-url $l1_rpc_url --private-key $private_key 0x3fab184622dc19b6109349b94811493bf2a45362 cast send --legacy --value 0.1ether --rpc-url $l2_pp1_url --private-key $private_key 0x3fab184622dc19b6109349b94811493bf2a45362 cast send --legacy --value 0.1ether --rpc-url $l2_pp2_url --private-key $private_key 0x3fab184622dc19b6109349b94811493bf2a45362 +``` +The tx data and address are standard for the deterministict deployer + +```sh deterministic_deployer_tx=0xf8a58085174876e800830186a08080b853604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf31ba02222222222222222222222222222222222222222222222222222222222222222a02222222222222222222222222222222222222222222222222222222222222222 deterministic_deployer_addr=0x4e59b44847b379578588920ca78fbf26c0b4956c @@ -605,12 +615,38 @@ curl -s $l2_pp2b_url/bridges/$target_address | jq -c '.deposits[] | select(.netw --private-key $private_key fi done +curl -s $l2_pp1b_url/bridges/$target_address | jq -c '.deposits[] | select(.network_id == 1) | select(.dest_net == 2)' | while read deposit ; do + echo $deposit | jq -c '.' + leaf_type=$(echo $deposit | jq -r '.leaf_type') + if [[ $leaf_type == "0" ]]; then + polycli ulxly claim asset \ + --bridge-address $bridge_address \ + --bridge-service-url $l2_pp1b_url \ + --rpc-url $l2_pp2_url \ + --deposit-count $(echo $deposit | jq -r '.deposit_cnt') \ + --deposit-network 1 \ + --destination-address $(echo $deposit | jq -r '.dest_addr') \ + --private-key $private_key + + else + polycli ulxly claim message \ + --bridge-address $bridge_address \ + --bridge-service-url $l2_pp1b_url \ + --rpc-url $l2_pp2_url \ + --deposit-count $(echo $deposit | jq -r '.deposit_cnt') \ + --deposit-network 1 \ + --destination-address $(echo $deposit | jq -r '.dest_addr') \ + --private-key $private_key + fi +done + + -constructor_args=$(cast abi-encode 'f(string,string,address,uint256)' 'Bridge Test' 'BT' "$target_address" $(cast max-uint) | sed 's/0x//') +constructor_args=$(cast abi-encode 'f(string,string,address,uint256)' 'Big Test' 'BT' "$target_address" $(cast max-uint) | sed 's/0x//') cast send --legacy --rpc-url $l2_pp1_url --private-key $target_private_key $deterministic_deployer_addr 0x6a6f686e2068696c6c696172642077617320686572650a000000000000000002$erc_20_bytecode$constructor_args -cast send --legacy --rpc-url $l2_pp1_url --private-key $target_private_key 0x0B006480c0318197b33458DA1448b9CE07C76A2E 'approve(address,uint256)' $bridge_address $(cast max-uint) +cast send --legacy --rpc-url $l2_pp1_url --private-key $target_private_key 0x8A5B34caF06Da682FDC4d08696417054fBaA5D6B 'approve(address,uint256)' $bridge_address $(cast max-uint) polycli ulxly bridge asset \ --private-key $target_private_key \ @@ -620,17 +656,37 @@ polycli ulxly bridge asset \ --destination-address $target_address \ --call-data 0x \ --rpc-url $l2_pp1_url \ - --token-address 0x0B006480c0318197b33458DA1448b9CE07C76A2E \ + --token-address 0x8A5B34caF06Da682FDC4d08696417054fBaA5D6B \ --force-update-root=true ``` -5:44PM INF bridgeTxn: 0xfc34856a8a0009fdb3d3c1f431716557c60431d693e6526756588d27dfcf05a8 -5:44PM INF Deposit transaction successful txHash=0xfc34856a8a0009fdb3d3c1f431716557c60431d693e6526756588d27dfcf05a8 +9:45AM INF bridgeTxn: 0x2b23e48077674e683ddd0af6e753ec6e394bc5d880e819db3903899e2dffce71 +9:45AM INF Deposit transaction successful txHash=0x2b23e48077674e683ddd0af6e753ec6e394bc5d880e819db3903899e2dffce71 ```sh +token_hash=$(cast keccak $(cast abi-encode --packed 'f(uint32,address)' 1 0x8A5B34caF06Da682FDC4d08696417054fBaA5D6B)) +pp2_big_test_addr=$(cast call --rpc-url $l2_pp2_url $bridge_address 'tokenInfoToWrappedToken(bytes32)(address)' $token_hash) +cast call --rpc-url $l2_pp2_url $pp2_big_test_addr 'balanceOf(address)' $target_address + + +polycli ulxly bridge asset \ + --private-key $target_private_key \ + --value 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe \ + --bridge-address $bridge_address \ + --destination-network 1 \ + --destination-address $target_address \ + --rpc-url $l2_pp2_url \ + --token-address $pp2_big_test_addr \ + --force-update-root=true + + + curl -s $l2_pp1b_url/bridges/$target_address ``` +TODO add a test where there is more than uint256 funds +TODO add some tests with reverting +TODO add some tests where the bridge is called via a smart contract rather than directly ## State Capture Procedure ```sh diff --git a/templates/contract-deploy/run-contract-setup.sh b/templates/contract-deploy/run-contract-setup.sh index 63fdec69..a575d76c 100755 --- a/templates/contract-deploy/run-contract-setup.sh +++ b/templates/contract-deploy/run-contract-setup.sh @@ -315,9 +315,18 @@ cast send \ # finalized block l1_preset="{{.l1_preset}}" if [[ $l1_preset == "minimal" ]]; then - wait_for_finalized_block; + # This might not be required, but it seems like the downstream + # processes are more reliable if we wait for all of the deployments to + # finalize before moving on + current_block_number="$(cast block-number --rpc-url '{{.l1_rpc_url}}')" + finalized_block_number=0 + until [[ $finalized_block_number -gt $current_block_number ]]; do + sleep 5 + finalized_block_number="$(cast block-number --rpc-url '{{.l1_rpc_url}}' finalized)" + done fi # The contract setup is done! touch "/opt/zkevm/.init-complete{{.deployment_suffix}}.lock" + From ada28e07b3a06129b1e781baea7809f58964864b Mon Sep 17 00:00:00 2001 From: John Hilliard Date: Thu, 12 Dec 2024 18:34:20 -0500 Subject: [PATCH 17/38] feat: latest testing notes --- multi-pp-test.sh | 112 +++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 94 insertions(+), 18 deletions(-) diff --git a/multi-pp-test.sh b/multi-pp-test.sh index b81aa4b5..8728d2a1 100755 --- a/multi-pp-test.sh +++ b/multi-pp-test.sh @@ -49,7 +49,6 @@ kurtosis service exec pp agglayer "agglayer vkey" cast call --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $(cat combined-001.json | jq -r '.polygonRollupManagerAddress') 'rollupTypeMap(uint32)(address,address,uint64,uint8,bool,bytes32,bytes32)' 1 # Let's make sure both rollups have the same vkey - cast call --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $(cat combined-001.json | jq -r '.polygonRollupManagerAddress') 'rollupIDToRollupDataV2(uint32 rollupID)(address,uint64,address,uint64,bytes32,uint64,uint64,uint64,uint64,uint8,bytes32,bytes32)' 1 cast call --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $(cat combined-001.json | jq -r '.polygonRollupManagerAddress') 'rollupIDToRollupDataV2(uint32 rollupID)(address,uint64,address,uint64,bytes32,uint64,uint64,uint64,uint64,uint8,bytes32,bytes32)' 2 @@ -314,6 +313,7 @@ polycli ulxly bridge asset \ --destination-address $target_address \ --force-update-root=true \ --rpc-url $l2_pp2_url + polycli ulxly bridge asset \ --private-key $target_private_key \ --value $(date +%s) \ @@ -323,6 +323,16 @@ polycli ulxly bridge asset \ --force-update-root=true \ --rpc-url $l2_pp2_url +polycli ulxly bridge weth \ + --private-key $target_private_key \ + --value $(date +%s) \ + --bridge-address $bridge_address \ + --destination-network 1 \ + --destination-address $target_address \ + --force-update-root=true \ + --token-address $pp2_weth_address \ + --rpc-url $l2_pp2_url + # Now we should try to claim these transactions again on Layer one and PP1 curl -s $l2_pp2b_url/bridges/$target_address | jq '.deposits[] | select(.ready_for_claim) | select(.claim_tx_hash == "")' @@ -346,8 +356,17 @@ polycli ulxly claim asset \ --destination-address $target_address \ --private-key $private_key -cast call --rpc-url $l1_rpc_url $bridge_address 'depositCount() external view returns (uint256)' +deposit_cnt=2 +polycli ulxly claim message \ + --bridge-address $bridge_address \ + --bridge-service-url $l2_pp2b_url \ + --rpc-url $l2_pp1_url \ + --deposit-count $deposit_cnt \ + --deposit-network 2 \ + --destination-address $target_address \ + --private-key $private_key +cast call --rpc-url $l1_rpc_url $bridge_address 'depositCount() external view returns (uint256)' # ## Pict Based Test Scenarios # @@ -388,6 +407,23 @@ cast send --legacy --rpc-url $l1_rpc_url --private-key $target_private_key $test cast send --legacy --rpc-url $l2_pp1_url --private-key $target_private_key $test_erc20_addr 'approve(address,uint256)' $bridge_address 100000000000000000000 cast send --legacy --rpc-url $l2_pp2_url --private-key $target_private_key $test_erc20_addr 'approve(address,uint256)' $bridge_address 100000000000000000000 +# docker run -v $PWD/src:/contracts ethereum/solc:0.7.6 --bin /contracts/tokens/ERC20Buggy.sol +erc20_buggy_bytecode=608060405234801561001057600080fd5b506040516109013803806109018339818101604052606081101561003357600080fd5b810190808051604051939291908464010000000082111561005357600080fd5b90830190602082018581111561006857600080fd5b825164010000000081118282018810171561008257600080fd5b82525081516020918201929091019080838360005b838110156100af578181015183820152602001610097565b50505050905090810190601f1680156100dc5780820380516001836020036101000a031916815260200191505b50604052602001805160405193929190846401000000008211156100ff57600080fd5b90830190602082018581111561011457600080fd5b825164010000000081118282018810171561012e57600080fd5b82525081516020918201929091019080838360005b8381101561015b578181015183820152602001610143565b50505050905090810190601f1680156101885780820380516001836020036101000a031916815260200191505b5060405260209081015185519093506101a792506003918601906101d8565b5081516101bb9060049060208501906101d8565b506005805460ff191660ff92909216919091179055506102799050565b828054600181600116156101000203166002900490600052602060002090601f01602090048101928261020e5760008555610254565b82601f1061022757805160ff1916838001178555610254565b82800160010185558215610254579182015b82811115610254578251825591602001919060010190610239565b50610260929150610264565b5090565b5b808211156102605760008155600101610265565b610679806102886000396000f3fe608060405234801561001057600080fd5b50600436106100b45760003560e01c806370a082311161007157806370a082311461021257806395d89b41146102385780639dc29fac14610240578063a9059cbb1461026c578063b46310f614610298578063dd62ed3e146102c4576100b4565b806306fdde03146100b9578063095ea7b31461013657806318160ddd1461017657806323b872dd14610190578063313ce567146101c657806340c10f19146101e4575b600080fd5b6100c16102f2565b6040805160208082528351818301528351919283929083019185019080838360005b838110156100fb5781810151838201526020016100e3565b50505050905090810190601f1680156101285780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101626004803603604081101561014c57600080fd5b506001600160a01b038135169060200135610380565b604080519115158252519081900360200190f35b61017e6103e6565b60408051918252519081900360200190f35b610162600480360360608110156101a657600080fd5b506001600160a01b038135811691602081013590911690604001356103ec565b6101ce610466565b6040805160ff9092168252519081900360200190f35b610210600480360360408110156101fa57600080fd5b506001600160a01b03813516906020013561046f565b005b61017e6004803603602081101561022857600080fd5b50356001600160a01b031661047d565b6100c161048f565b6102106004803603604081101561025657600080fd5b506001600160a01b0381351690602001356104ea565b6101626004803603604081101561028257600080fd5b506001600160a01b0381351690602001356104f4565b610210600480360360408110156102ae57600080fd5b506001600160a01b03813516906020013561054f565b61017e600480360360408110156102da57600080fd5b506001600160a01b038135811691602001351661056b565b6003805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156103785780601f1061034d57610100808354040283529160200191610378565b820191906000526020600020905b81548152906001019060200180831161035b57829003601f168201915b505050505081565b3360008181526002602090815260408083206001600160a01b038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a350600192915050565b60005481565b6001600160a01b0380841660008181526002602090815260408083203384528252808320805487900390558383526001825280832080548790039055938616808352848320805487019055845186815294519294909392600080516020610624833981519152929181900390910190a35060019392505050565b60055460ff1681565b6104798282610588565b5050565b60016020526000908152604090205481565b6004805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156103785780601f1061034d57610100808354040283529160200191610378565b61047982826105d3565b336000818152600160209081526040808320805486900390556001600160a01b03861680845281842080548701905581518681529151939490939092600080516020610624833981519152928290030190a350600192915050565b6001600160a01b03909116600090815260016020526040902055565b600260209081526000928352604080842090915290825290205481565b6001600160a01b038216600081815260016020908152604080832080548601905582548501835580518581529051600080516020610624833981519152929181900390910190a35050565b6001600160a01b0382166000818152600160209081526040808320805486900390558254859003835580518581529051929392600080516020610624833981519152929181900390910190a3505056feddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa2646970667358221220364a383ccce0e270376267b8631412d1b7ddb1883c5379556b58cbefc1ca504564736f6c63430007060033 +constructor_args=$(cast abi-encode 'f(string,string,uint8)' 'Buggy ERC20' 'BUG' "18" | sed 's/0x//') + +cast send --legacy --rpc-url $l1_rpc_url --private-key $private_key $deterministic_deployer_addr $salt$erc20_buggy_bytecode$constructor_args +cast send --legacy --rpc-url $l2_pp1_url --private-key $private_key $deterministic_deployer_addr $salt$erc20_buggy_bytecode$constructor_args +cast send --legacy --rpc-url $l2_pp2_url --private-key $private_key $deterministic_deployer_addr $salt$erc20_buggy_bytecode$constructor_args + +test_erc20_buggy_addr=$(cast create2 --salt $salt --init-code $erc20_buggy_bytecode$constructor_args) + +cast send --legacy --rpc-url $l1_rpc_url --private-key $target_private_key $test_erc20_buggy_addr 'mint(address,uint256)' $target_address $(cast max-uint) +cast send --legacy --rpc-url $l2_pp1_url --private-key $target_private_key $test_erc20_buggy_addr 'mint(address,uint256)' $target_address $(cast max-uint) +cast send --legacy --rpc-url $l2_pp2_url --private-key $target_private_key $test_erc20_buggy_addr 'mint(address,uint256)' $target_address $(cast max-uint) + +cast send --legacy --rpc-url $l1_rpc_url --private-key $target_private_key $test_erc20_buggy_addr 'approve(address,uint256)' $bridge_address $(cast max-uint) +cast send --legacy --rpc-url $l2_pp1_url --private-key $target_private_key $test_erc20_buggy_addr 'approve(address,uint256)' $bridge_address $(cast max-uint) +cast send --legacy --rpc-url $l2_pp2_url --private-key $target_private_key $test_erc20_buggy_addr 'approve(address,uint256)' $bridge_address $(cast max-uint) # One of the test cases that I've left out for now is a permit # call. It'll take some work to get the signed permit data in place, @@ -537,32 +573,35 @@ curl -s $l2_pp1b_url/bridges/$target_address | jq -c '.deposits[] | select(.netw fi done - - - - -constructor_args=$(cast abi-encode 'f(string,string,address,uint256)' 'Big Test' 'BT' "$target_address" $(cast max-uint) | sed 's/0x//') -cast send --legacy --rpc-url $l2_pp1_url --private-key $target_private_key $deterministic_deployer_addr 0x6a6f686e2068696c6c696172642077617320686572650a000000000000000002$erc_20_bytecode$constructor_args -cast send --legacy --rpc-url $l2_pp1_url --private-key $target_private_key 0x8A5B34caF06Da682FDC4d08696417054fBaA5D6B 'approve(address,uint256)' $bridge_address $(cast max-uint) +# ## Buggy ERC 20 +# +# These are some simple tests to try bridging more than the uint max +# limit to understand how the balance tree might be impacted. We're +# going to run thie snippt below a few times which does the following. +# +# 1. Bridge the max amount possible from the target address. This +# assumes we've already minted some +# 2. Mint the max amount again for the target address. +# 3. Zero out the balance of the bridge +# +# Repeat that a few times just to make sure everything is okay. The +# commands below are for doing tests from PP1 to PP2 polycli ulxly bridge asset \ --private-key $target_private_key \ - --value $(cast max-uint) \ + --value 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe \ --bridge-address $bridge_address \ --destination-network 2 \ --destination-address $target_address \ - --call-data 0x \ --rpc-url $l2_pp1_url \ - --token-address 0x8A5B34caF06Da682FDC4d08696417054fBaA5D6B \ + --token-address $test_erc20_buggy_addr \ --force-update-root=true -# 9:45AM INF bridgeTxn: 0x2b23e48077674e683ddd0af6e753ec6e394bc5d880e819db3903899e2dffce71 -# 9:45AM INF Deposit transaction successful txHash=0x2b23e48077674e683ddd0af6e753ec6e394bc5d880e819db3903899e2dffce71 -token_hash=$(cast keccak $(cast abi-encode --packed 'f(uint32,address)' 1 0x8A5B34caF06Da682FDC4d08696417054fBaA5D6B)) -pp2_big_test_addr=$(cast call --rpc-url $l2_pp2_url $bridge_address 'tokenInfoToWrappedToken(bytes32)(address)' $token_hash) -cast call --rpc-url $l2_pp2_url $pp2_big_test_addr 'balanceOf(address)' $target_address +cast send --legacy --rpc-url $l2_pp1_url --private-key $target_private_key $test_erc20_buggy_addr 'mint(address,uint256)' $target_address $(cast max-uint) +cast send --legacy --rpc-url $l2_pp1_url --private-key $target_private_key $test_erc20_buggy_addr 'setBalanceOf(address,uint256)' $bridge_address 0 +# These commands do the same thing more or less but from PP2 to PP1 polycli ulxly bridge asset \ --private-key $target_private_key \ --value 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe \ @@ -570,16 +609,53 @@ polycli ulxly bridge asset \ --destination-network 1 \ --destination-address $target_address \ --rpc-url $l2_pp2_url \ - --token-address $pp2_big_test_addr \ + --token-address $test_erc20_buggy_addr \ --force-update-root=true +cast send --legacy --rpc-url $l2_pp2_url --private-key $target_private_key $test_erc20_buggy_addr 'mint(address,uint256)' $target_address $(cast max-uint) +cast send --legacy --rpc-url $l2_pp2_url --private-key $target_private_key $test_erc20_buggy_addr 'setBalanceOf(address,uint256)' $bridge_address 0 curl -s $l2_pp1b_url/bridges/$target_address +# ## Calling through a smart contract of some kind +# +# The idea here is to do some transactions through a proxy or some kind so + +lxly_proxy_bytecode=608060405234801561001057600080fd5b50604051610acb380380610acb83398101604081905261002f91610054565b600080546001600160a01b0319166001600160a01b0392909216919091179055610084565b60006020828403121561006657600080fd5b81516001600160a01b038116811461007d57600080fd5b9392505050565b610a38806100936000396000f3fe6080604052600436106100955760003560e01c8063b8b284d011610059578063b8b284d014610196578063ccaa2d11146101c9578063cd586579146101e9578063dd96eab7146101fc578063f5efcd79146101fc57610116565b80631c253d72146101965780631eb5f7aa146101b6578063240ff378146101b65780632c4422ca146101c95780635ea89907146101e957610116565b366101165760008054604051630481fe6f60e31b815263ffffffff34166004820152336024820152600160448201526080606482015260848101929092526001600160a01b03169063240ff3789060a401600060405180830381600087803b15801561010057600080fd5b505af1158015610114573d6000803e3d6000fd5b005b60008054604051630481fe6f60e31b815236916060916001600160a01b039091169063240ff37890610155903490339060019089908990600401610436565b600060405180830381600087803b15801561016f57600080fd5b505af1158015610183573d6000803e3d6000fd5b5050604080516020810190915260009052005b3480156101a257600080fd5b506101146101b136600461056f565b61021c565b6101146101c43660046105e8565b61028d565b3480156101d557600080fd5b506101146101e43660046106c5565b6102fb565b6101146101f7366004610799565b61037e565b34801561020857600080fd5b506101146102173660046106c5565b6103f2565b600054604051630b8b284d60e41b81526001600160a01b039091169063b8b284d0906102549088908890889088908890600401610867565b600060405180830381600087803b15801561026e57600080fd5b505af1158015610282573d6000803e3d6000fd5b505050505050505050565b600054604051630481fe6f60e31b81526001600160a01b039091169063240ff378906102c39087908790879087906004016108ad565b600060405180830381600087803b1580156102dd57600080fd5b505af11580156102f1573d6000803e3d6000fd5b5050505050505050565b60005460405163ccaa2d1160e01b81526001600160a01b039091169063ccaa2d119061033f908e908e908e908e908e908e908e908e908e908e908e9060040161091c565b600060405180830381600087803b15801561035957600080fd5b505af115801561036d573d6000803e3d6000fd5b505050505050505050505050505050565b60005460405163cd58657960e01b81526001600160a01b039091169063cd586579906103b8908990899089908990899089906004016109af565b600060405180830381600087803b1580156103d257600080fd5b505af11580156103e6573d6000803e3d6000fd5b50505050505050505050565b60005460405163f5efcd7960e01b81526001600160a01b039091169063f5efcd799061033f908e908e908e908e908e908e908e908e908e908e908e9060040161091c565b63ffffffff861681526001600160a01b038516602082015283151560408201526080606082018190528101829052818360a0830137600081830160a090810191909152601f909201601f19160101949350505050565b803563ffffffff811681146104a057600080fd5b919050565b80356001600160a01b03811681146104a057600080fd5b803580151581146104a057600080fd5b634e487b7160e01b600052604160045260246000fd5b600082601f8301126104f357600080fd5b813567ffffffffffffffff8082111561050e5761050e6104cc565b604051601f8301601f19908116603f01168101908282118183101715610536576105366104cc565b8160405283815286602085880101111561054f57600080fd5b836020870160208301376000602085830101528094505050505092915050565b600080600080600060a0868803121561058757600080fd5b6105908661048c565b945061059e602087016104a5565b9350604086013592506105b3606087016104bc565b9150608086013567ffffffffffffffff8111156105cf57600080fd5b6105db888289016104e2565b9150509295509295909350565b600080600080608085870312156105fe57600080fd5b6106078561048c565b9350610615602086016104a5565b9250610623604086016104bc565b9150606085013567ffffffffffffffff81111561063f57600080fd5b61064b878288016104e2565b91505092959194509250565b600082601f83011261066857600080fd5b60405161040080820182811067ffffffffffffffff8211171561068d5761068d6104cc565b604052830181858211156106a057600080fd5b845b828110156106ba5780358252602091820191016106a2565b509195945050505050565b60008060008060008060008060008060006109208c8e0312156106e757600080fd5b6106f18d8d610657565b9a506107018d6104008e01610657565b99506108008c013598506108208c013597506108408c013596506107286108608d0161048c565b95506107376108808d016104a5565b94506107466108a08d0161048c565b93506107556108c08d016104a5565b92506108e08c013591506109008c013567ffffffffffffffff81111561077a57600080fd5b6107868e828f016104e2565b9150509295989b509295989b9093969950565b60008060008060008060c087890312156107b257600080fd5b6107bb8761048c565b95506107c9602088016104a5565b9450604087013593506107de606088016104a5565b92506107ec608088016104bc565b915060a087013567ffffffffffffffff81111561080857600080fd5b61081489828a016104e2565b9150509295509295509295565b6000815180845260005b818110156108475760208185018101518683018201520161082b565b506000602082860101526020601f19601f83011685010191505092915050565b63ffffffff8616815260018060a01b0385166020820152836040820152821515606082015260a0608082015260006108a260a0830184610821565b979650505050505050565b63ffffffff851681526001600160a01b038416602082015282151560408201526080606082018190526000906108e590830184610821565b9695505050505050565b8060005b60208082106109025750610916565b8251855293840193909101906001016108f3565b50505050565b600061092061092b838f6108ef565b61093961040084018e6108ef565b61080083018c905261082083018b905261084083018a905263ffffffff8981166108608501526001600160a01b038981166108808601529088166108a085015286166108c08401526108e08301859052610900830181905261099d81840185610821565b9e9d5050505050505050505050505050565b63ffffffff871681526001600160a01b0386811660208301526040820186905284166060820152821515608082015260c060a082018190526000906109f690830184610821565b9897505050505050505056fea2646970667358221220b86e525972f2e2cc9d33328df79fceaa11e88478f9966dde327eeec360259b4964736f6c63430008140033 + +constructor_args=$(cast abi-encode 'f(address)' $bridge_address | sed 's/0x//') + +cast send --legacy --rpc-url $l1_rpc_url --private-key $private_key $deterministic_deployer_addr $salt$lxly_proxy_bytecode$constructor_args +cast send --legacy --rpc-url $l2_pp1_url --private-key $private_key $deterministic_deployer_addr $salt$lxly_proxy_bytecode$constructor_args +cast send --legacy --rpc-url $l2_pp2_url --private-key $private_key $deterministic_deployer_addr $salt$lxly_proxy_bytecode$constructor_args + +test_lxly_proxy_addr=$(cast create2 --salt $salt --init-code $lxly_proxy_bytecode$constructor_args) + +cast send --legacy --value 2 --rpc-url $l1_rpc_url --private-key $target_private_key $test_lxly_proxy_addr +cast send --legacy --value 3 --rpc-url $l2_pp1_url --private-key $target_private_key $test_lxly_proxy_addr +cast send --legacy --value 1 --rpc-url $l2_pp2_url --private-key $target_private_key $test_lxly_proxy_addr + +# In in my test environment I've deployed a contract specifically for +# testing. You might not have this. The idea is to call the bridge +# contract from a bunch of contexts and ensure that things more or +# less still work +tester_contract_address=0xfBE07a394847c26b1d998B6e44EE78A9C8191f13 + +address_tester_actions="001 002 003 004 011 012 013 014 021 022 023 024 031 032 033 034 041 042 043 044 101 201 301 401 501 601 701 801 901" + +for create_mode in 0 1 2; do + for action in $address_tester_actions ; do + cast send --legacy --value 1 --rpc-url $l1_rpc_url --private-key $target_private_key $tester_contract_address $(cast abi-encode 'f(uint32, address, uint256)' 0x"$create_mode$action" $test_lxly_proxy_addr 1) + cast send --legacy --value 2 --rpc-url $l2_pp1_url --private-key $target_private_key $tester_contract_address $(cast abi-encode 'f(uint32, address, uint256)' 0x"$create_mode$action" $test_lxly_proxy_addr 2) + cast send --legacy --value 1 --rpc-url $l2_pp2_url --private-key $target_private_key $tester_contract_address $(cast abi-encode 'f(uint32, address, uint256)' 0x"$create_mode$action" $test_lxly_proxy_addr 1) + done +done + # TODO add a test where there is more than uint256 funds # TODO add some tests with reverting # TODO add some tests where the bridge is called via a smart contract rather than directly +# TODO add a scneario that does a full sweep of the target account native token and the end to ensure all of the accounting looks good # ## State Capture Procedure pushd $(mktemp -d) From a4d18b209df59fe99d9fa10d92993d3fbb5199d8 Mon Sep 17 00:00:00 2001 From: John Hilliard Date: Thu, 12 Dec 2024 18:36:45 -0500 Subject: [PATCH 18/38] chore: moving docs --- .../multi-pp-testing/README.sh | 0 .../multi-pp-testing/README.sh.md | 118 +++++++++++++++--- lxly.pict => docs/multi-pp-testing/lxly.pict | 0 3 files changed, 103 insertions(+), 15 deletions(-) rename multi-pp-test.sh => docs/multi-pp-testing/README.sh (100%) rename multi-pp-test.sh.md => docs/multi-pp-testing/README.sh.md (70%) rename lxly.pict => docs/multi-pp-testing/lxly.pict (100%) diff --git a/multi-pp-test.sh b/docs/multi-pp-testing/README.sh similarity index 100% rename from multi-pp-test.sh rename to docs/multi-pp-testing/README.sh diff --git a/multi-pp-test.sh.md b/docs/multi-pp-testing/README.sh.md similarity index 70% rename from multi-pp-test.sh.md rename to docs/multi-pp-testing/README.sh.md index 683606a0..4cc3fcc3 100644 --- a/multi-pp-test.sh.md +++ b/docs/multi-pp-testing/README.sh.md @@ -405,6 +405,7 @@ polycli ulxly bridge asset \ --destination-address $target_address \ --force-update-root=true \ --rpc-url $l2_pp2_url + polycli ulxly bridge asset \ --private-key $target_private_key \ --value $(date +%s) \ @@ -413,6 +414,16 @@ polycli ulxly bridge asset \ --destination-address $target_address \ --force-update-root=true \ --rpc-url $l2_pp2_url + +polycli ulxly bridge weth \ + --private-key $target_private_key \ + --value $(date +%s) \ + --bridge-address $bridge_address \ + --destination-network 1 \ + --destination-address $target_address \ + --force-update-root=true \ + --token-address $pp2_weth_address \ + --rpc-url $l2_pp2_url ``` Now we should try to claim these transactions again on Layer one and PP1 @@ -440,6 +451,16 @@ polycli ulxly claim asset \ --destination-address $target_address \ --private-key $private_key +deposit_cnt=2 +polycli ulxly claim message \ + --bridge-address $bridge_address \ + --bridge-service-url $l2_pp2b_url \ + --rpc-url $l2_pp1_url \ + --deposit-count $deposit_cnt \ + --deposit-network 2 \ + --destination-address $target_address \ + --private-key $private_key + cast call --rpc-url $l1_rpc_url $bridge_address 'depositCount() external view returns (uint256)' ``` @@ -491,6 +512,27 @@ cast send --legacy --rpc-url $l2_pp1_url --private-key $target_private_key $test cast send --legacy --rpc-url $l2_pp2_url --private-key $target_private_key $test_erc20_addr 'approve(address,uint256)' $bridge_address 100000000000000000000 ``` +docker run -v $PWD/src:/contracts ethereum/solc:0.7.6 --bin /contracts/tokens/ERC20Buggy.sol + +```sh +erc20_buggy_bytecode=608060405234801561001057600080fd5b506040516109013803806109018339818101604052606081101561003357600080fd5b810190808051604051939291908464010000000082111561005357600080fd5b90830190602082018581111561006857600080fd5b825164010000000081118282018810171561008257600080fd5b82525081516020918201929091019080838360005b838110156100af578181015183820152602001610097565b50505050905090810190601f1680156100dc5780820380516001836020036101000a031916815260200191505b50604052602001805160405193929190846401000000008211156100ff57600080fd5b90830190602082018581111561011457600080fd5b825164010000000081118282018810171561012e57600080fd5b82525081516020918201929091019080838360005b8381101561015b578181015183820152602001610143565b50505050905090810190601f1680156101885780820380516001836020036101000a031916815260200191505b5060405260209081015185519093506101a792506003918601906101d8565b5081516101bb9060049060208501906101d8565b506005805460ff191660ff92909216919091179055506102799050565b828054600181600116156101000203166002900490600052602060002090601f01602090048101928261020e5760008555610254565b82601f1061022757805160ff1916838001178555610254565b82800160010185558215610254579182015b82811115610254578251825591602001919060010190610239565b50610260929150610264565b5090565b5b808211156102605760008155600101610265565b610679806102886000396000f3fe608060405234801561001057600080fd5b50600436106100b45760003560e01c806370a082311161007157806370a082311461021257806395d89b41146102385780639dc29fac14610240578063a9059cbb1461026c578063b46310f614610298578063dd62ed3e146102c4576100b4565b806306fdde03146100b9578063095ea7b31461013657806318160ddd1461017657806323b872dd14610190578063313ce567146101c657806340c10f19146101e4575b600080fd5b6100c16102f2565b6040805160208082528351818301528351919283929083019185019080838360005b838110156100fb5781810151838201526020016100e3565b50505050905090810190601f1680156101285780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101626004803603604081101561014c57600080fd5b506001600160a01b038135169060200135610380565b604080519115158252519081900360200190f35b61017e6103e6565b60408051918252519081900360200190f35b610162600480360360608110156101a657600080fd5b506001600160a01b038135811691602081013590911690604001356103ec565b6101ce610466565b6040805160ff9092168252519081900360200190f35b610210600480360360408110156101fa57600080fd5b506001600160a01b03813516906020013561046f565b005b61017e6004803603602081101561022857600080fd5b50356001600160a01b031661047d565b6100c161048f565b6102106004803603604081101561025657600080fd5b506001600160a01b0381351690602001356104ea565b6101626004803603604081101561028257600080fd5b506001600160a01b0381351690602001356104f4565b610210600480360360408110156102ae57600080fd5b506001600160a01b03813516906020013561054f565b61017e600480360360408110156102da57600080fd5b506001600160a01b038135811691602001351661056b565b6003805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156103785780601f1061034d57610100808354040283529160200191610378565b820191906000526020600020905b81548152906001019060200180831161035b57829003601f168201915b505050505081565b3360008181526002602090815260408083206001600160a01b038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a350600192915050565b60005481565b6001600160a01b0380841660008181526002602090815260408083203384528252808320805487900390558383526001825280832080548790039055938616808352848320805487019055845186815294519294909392600080516020610624833981519152929181900390910190a35060019392505050565b60055460ff1681565b6104798282610588565b5050565b60016020526000908152604090205481565b6004805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156103785780601f1061034d57610100808354040283529160200191610378565b61047982826105d3565b336000818152600160209081526040808320805486900390556001600160a01b03861680845281842080548701905581518681529151939490939092600080516020610624833981519152928290030190a350600192915050565b6001600160a01b03909116600090815260016020526040902055565b600260209081526000928352604080842090915290825290205481565b6001600160a01b038216600081815260016020908152604080832080548601905582548501835580518581529051600080516020610624833981519152929181900390910190a35050565b6001600160a01b0382166000818152600160209081526040808320805486900390558254859003835580518581529051929392600080516020610624833981519152929181900390910190a3505056feddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa2646970667358221220364a383ccce0e270376267b8631412d1b7ddb1883c5379556b58cbefc1ca504564736f6c63430007060033 +constructor_args=$(cast abi-encode 'f(string,string,uint8)' 'Buggy ERC20' 'BUG' "18" | sed 's/0x//') + +cast send --legacy --rpc-url $l1_rpc_url --private-key $private_key $deterministic_deployer_addr $salt$erc20_buggy_bytecode$constructor_args +cast send --legacy --rpc-url $l2_pp1_url --private-key $private_key $deterministic_deployer_addr $salt$erc20_buggy_bytecode$constructor_args +cast send --legacy --rpc-url $l2_pp2_url --private-key $private_key $deterministic_deployer_addr $salt$erc20_buggy_bytecode$constructor_args + +test_erc20_buggy_addr=$(cast create2 --salt $salt --init-code $erc20_buggy_bytecode$constructor_args) + +cast send --legacy --rpc-url $l1_rpc_url --private-key $target_private_key $test_erc20_buggy_addr 'mint(address,uint256)' $target_address $(cast max-uint) +cast send --legacy --rpc-url $l2_pp1_url --private-key $target_private_key $test_erc20_buggy_addr 'mint(address,uint256)' $target_address $(cast max-uint) +cast send --legacy --rpc-url $l2_pp2_url --private-key $target_private_key $test_erc20_buggy_addr 'mint(address,uint256)' $target_address $(cast max-uint) + +cast send --legacy --rpc-url $l1_rpc_url --private-key $target_private_key $test_erc20_buggy_addr 'approve(address,uint256)' $bridge_address $(cast max-uint) +cast send --legacy --rpc-url $l2_pp1_url --private-key $target_private_key $test_erc20_buggy_addr 'approve(address,uint256)' $bridge_address $(cast max-uint) +cast send --legacy --rpc-url $l2_pp2_url --private-key $target_private_key $test_erc20_buggy_addr 'approve(address,uint256)' $bridge_address $(cast max-uint) +``` + One of the test cases that I've left out for now is a permit call. It'll take some work to get the signed permit data in place, but it seems doable. @@ -639,36 +681,40 @@ curl -s $l2_pp1b_url/bridges/$target_address | jq -c '.deposits[] | select(.netw --private-key $private_key fi done +``` +## Buggy ERC 20 +These are some simple tests to try bridging more than the uint max +limit to understand how the balance tree might be impacted. We're +going to run thie snippt below a few times which does the following. +1. Bridge the max amount possible from the target address. This +assumes we've already minted some +2. Mint the max amount again for the target address. +3. Zero out the balance of the bridge +Repeat that a few times just to make sure everything is okay. The +commands below are for doing tests from PP1 to PP2 -constructor_args=$(cast abi-encode 'f(string,string,address,uint256)' 'Big Test' 'BT' "$target_address" $(cast max-uint) | sed 's/0x//') -cast send --legacy --rpc-url $l2_pp1_url --private-key $target_private_key $deterministic_deployer_addr 0x6a6f686e2068696c6c696172642077617320686572650a000000000000000002$erc_20_bytecode$constructor_args -cast send --legacy --rpc-url $l2_pp1_url --private-key $target_private_key 0x8A5B34caF06Da682FDC4d08696417054fBaA5D6B 'approve(address,uint256)' $bridge_address $(cast max-uint) - +```sh polycli ulxly bridge asset \ --private-key $target_private_key \ - --value $(cast max-uint) \ + --value 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe \ --bridge-address $bridge_address \ --destination-network 2 \ --destination-address $target_address \ - --call-data 0x \ --rpc-url $l2_pp1_url \ - --token-address 0x8A5B34caF06Da682FDC4d08696417054fBaA5D6B \ + --token-address $test_erc20_buggy_addr \ --force-update-root=true + +cast send --legacy --rpc-url $l2_pp1_url --private-key $target_private_key $test_erc20_buggy_addr 'mint(address,uint256)' $target_address $(cast max-uint) +cast send --legacy --rpc-url $l2_pp1_url --private-key $target_private_key $test_erc20_buggy_addr 'setBalanceOf(address,uint256)' $bridge_address 0 ``` -9:45AM INF bridgeTxn: 0x2b23e48077674e683ddd0af6e753ec6e394bc5d880e819db3903899e2dffce71 -9:45AM INF Deposit transaction successful txHash=0x2b23e48077674e683ddd0af6e753ec6e394bc5d880e819db3903899e2dffce71 +These commands do the same thing more or less but from PP2 to PP1 ```sh -token_hash=$(cast keccak $(cast abi-encode --packed 'f(uint32,address)' 1 0x8A5B34caF06Da682FDC4d08696417054fBaA5D6B)) -pp2_big_test_addr=$(cast call --rpc-url $l2_pp2_url $bridge_address 'tokenInfoToWrappedToken(bytes32)(address)' $token_hash) -cast call --rpc-url $l2_pp2_url $pp2_big_test_addr 'balanceOf(address)' $target_address - - polycli ulxly bridge asset \ --private-key $target_private_key \ --value 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe \ @@ -676,17 +722,59 @@ polycli ulxly bridge asset \ --destination-network 1 \ --destination-address $target_address \ --rpc-url $l2_pp2_url \ - --token-address $pp2_big_test_addr \ + --token-address $test_erc20_buggy_addr \ --force-update-root=true +cast send --legacy --rpc-url $l2_pp2_url --private-key $target_private_key $test_erc20_buggy_addr 'mint(address,uint256)' $target_address $(cast max-uint) +cast send --legacy --rpc-url $l2_pp2_url --private-key $target_private_key $test_erc20_buggy_addr 'setBalanceOf(address,uint256)' $bridge_address 0 curl -s $l2_pp1b_url/bridges/$target_address ``` +## Calling through a smart contract of some kind + +The idea here is to do some transactions through a proxy or some kind so + +```sh +lxly_proxy_bytecode=608060405234801561001057600080fd5b50604051610acb380380610acb83398101604081905261002f91610054565b600080546001600160a01b0319166001600160a01b0392909216919091179055610084565b60006020828403121561006657600080fd5b81516001600160a01b038116811461007d57600080fd5b9392505050565b610a38806100936000396000f3fe6080604052600436106100955760003560e01c8063b8b284d011610059578063b8b284d014610196578063ccaa2d11146101c9578063cd586579146101e9578063dd96eab7146101fc578063f5efcd79146101fc57610116565b80631c253d72146101965780631eb5f7aa146101b6578063240ff378146101b65780632c4422ca146101c95780635ea89907146101e957610116565b366101165760008054604051630481fe6f60e31b815263ffffffff34166004820152336024820152600160448201526080606482015260848101929092526001600160a01b03169063240ff3789060a401600060405180830381600087803b15801561010057600080fd5b505af1158015610114573d6000803e3d6000fd5b005b60008054604051630481fe6f60e31b815236916060916001600160a01b039091169063240ff37890610155903490339060019089908990600401610436565b600060405180830381600087803b15801561016f57600080fd5b505af1158015610183573d6000803e3d6000fd5b5050604080516020810190915260009052005b3480156101a257600080fd5b506101146101b136600461056f565b61021c565b6101146101c43660046105e8565b61028d565b3480156101d557600080fd5b506101146101e43660046106c5565b6102fb565b6101146101f7366004610799565b61037e565b34801561020857600080fd5b506101146102173660046106c5565b6103f2565b600054604051630b8b284d60e41b81526001600160a01b039091169063b8b284d0906102549088908890889088908890600401610867565b600060405180830381600087803b15801561026e57600080fd5b505af1158015610282573d6000803e3d6000fd5b505050505050505050565b600054604051630481fe6f60e31b81526001600160a01b039091169063240ff378906102c39087908790879087906004016108ad565b600060405180830381600087803b1580156102dd57600080fd5b505af11580156102f1573d6000803e3d6000fd5b5050505050505050565b60005460405163ccaa2d1160e01b81526001600160a01b039091169063ccaa2d119061033f908e908e908e908e908e908e908e908e908e908e908e9060040161091c565b600060405180830381600087803b15801561035957600080fd5b505af115801561036d573d6000803e3d6000fd5b505050505050505050505050505050565b60005460405163cd58657960e01b81526001600160a01b039091169063cd586579906103b8908990899089908990899089906004016109af565b600060405180830381600087803b1580156103d257600080fd5b505af11580156103e6573d6000803e3d6000fd5b50505050505050505050565b60005460405163f5efcd7960e01b81526001600160a01b039091169063f5efcd799061033f908e908e908e908e908e908e908e908e908e908e908e9060040161091c565b63ffffffff861681526001600160a01b038516602082015283151560408201526080606082018190528101829052818360a0830137600081830160a090810191909152601f909201601f19160101949350505050565b803563ffffffff811681146104a057600080fd5b919050565b80356001600160a01b03811681146104a057600080fd5b803580151581146104a057600080fd5b634e487b7160e01b600052604160045260246000fd5b600082601f8301126104f357600080fd5b813567ffffffffffffffff8082111561050e5761050e6104cc565b604051601f8301601f19908116603f01168101908282118183101715610536576105366104cc565b8160405283815286602085880101111561054f57600080fd5b836020870160208301376000602085830101528094505050505092915050565b600080600080600060a0868803121561058757600080fd5b6105908661048c565b945061059e602087016104a5565b9350604086013592506105b3606087016104bc565b9150608086013567ffffffffffffffff8111156105cf57600080fd5b6105db888289016104e2565b9150509295509295909350565b600080600080608085870312156105fe57600080fd5b6106078561048c565b9350610615602086016104a5565b9250610623604086016104bc565b9150606085013567ffffffffffffffff81111561063f57600080fd5b61064b878288016104e2565b91505092959194509250565b600082601f83011261066857600080fd5b60405161040080820182811067ffffffffffffffff8211171561068d5761068d6104cc565b604052830181858211156106a057600080fd5b845b828110156106ba5780358252602091820191016106a2565b509195945050505050565b60008060008060008060008060008060006109208c8e0312156106e757600080fd5b6106f18d8d610657565b9a506107018d6104008e01610657565b99506108008c013598506108208c013597506108408c013596506107286108608d0161048c565b95506107376108808d016104a5565b94506107466108a08d0161048c565b93506107556108c08d016104a5565b92506108e08c013591506109008c013567ffffffffffffffff81111561077a57600080fd5b6107868e828f016104e2565b9150509295989b509295989b9093969950565b60008060008060008060c087890312156107b257600080fd5b6107bb8761048c565b95506107c9602088016104a5565b9450604087013593506107de606088016104a5565b92506107ec608088016104bc565b915060a087013567ffffffffffffffff81111561080857600080fd5b61081489828a016104e2565b9150509295509295509295565b6000815180845260005b818110156108475760208185018101518683018201520161082b565b506000602082860101526020601f19601f83011685010191505092915050565b63ffffffff8616815260018060a01b0385166020820152836040820152821515606082015260a0608082015260006108a260a0830184610821565b979650505050505050565b63ffffffff851681526001600160a01b038416602082015282151560408201526080606082018190526000906108e590830184610821565b9695505050505050565b8060005b60208082106109025750610916565b8251855293840193909101906001016108f3565b50505050565b600061092061092b838f6108ef565b61093961040084018e6108ef565b61080083018c905261082083018b905261084083018a905263ffffffff8981166108608501526001600160a01b038981166108808601529088166108a085015286166108c08401526108e08301859052610900830181905261099d81840185610821565b9e9d5050505050505050505050505050565b63ffffffff871681526001600160a01b0386811660208301526040820186905284166060820152821515608082015260c060a082018190526000906109f690830184610821565b9897505050505050505056fea2646970667358221220b86e525972f2e2cc9d33328df79fceaa11e88478f9966dde327eeec360259b4964736f6c63430008140033 + +constructor_args=$(cast abi-encode 'f(address)' $bridge_address | sed 's/0x//') + +cast send --legacy --rpc-url $l1_rpc_url --private-key $private_key $deterministic_deployer_addr $salt$lxly_proxy_bytecode$constructor_args +cast send --legacy --rpc-url $l2_pp1_url --private-key $private_key $deterministic_deployer_addr $salt$lxly_proxy_bytecode$constructor_args +cast send --legacy --rpc-url $l2_pp2_url --private-key $private_key $deterministic_deployer_addr $salt$lxly_proxy_bytecode$constructor_args + +test_lxly_proxy_addr=$(cast create2 --salt $salt --init-code $lxly_proxy_bytecode$constructor_args) + +cast send --legacy --value 2 --rpc-url $l1_rpc_url --private-key $target_private_key $test_lxly_proxy_addr +cast send --legacy --value 3 --rpc-url $l2_pp1_url --private-key $target_private_key $test_lxly_proxy_addr +cast send --legacy --value 1 --rpc-url $l2_pp2_url --private-key $target_private_key $test_lxly_proxy_addr +``` + +In in my test environment I've deployed a contract specifically for +testing. You might not have this. The idea is to call the bridge +contract from a bunch of contexts and ensure that things more or +less still work + +```sh +tester_contract_address=0xfBE07a394847c26b1d998B6e44EE78A9C8191f13 + +address_tester_actions="001 002 003 004 011 012 013 014 021 022 023 024 031 032 033 034 041 042 043 044 101 201 301 401 501 601 701 801 901" + +for create_mode in 0 1 2; do + for action in $address_tester_actions ; do + cast send --legacy --value 1 --rpc-url $l1_rpc_url --private-key $target_private_key $tester_contract_address $(cast abi-encode 'f(uint32, address, uint256)' 0x"$create_mode$action" $test_lxly_proxy_addr 1) + cast send --legacy --value 2 --rpc-url $l2_pp1_url --private-key $target_private_key $tester_contract_address $(cast abi-encode 'f(uint32, address, uint256)' 0x"$create_mode$action" $test_lxly_proxy_addr 2) + cast send --legacy --value 1 --rpc-url $l2_pp2_url --private-key $target_private_key $tester_contract_address $(cast abi-encode 'f(uint32, address, uint256)' 0x"$create_mode$action" $test_lxly_proxy_addr 1) + done +done +``` + TODO add a test where there is more than uint256 funds TODO add some tests with reverting TODO add some tests where the bridge is called via a smart contract rather than directly +TODO add a scneario that does a full sweep of the target account native token and the end to ensure all of the accounting looks good ## State Capture Procedure ```sh diff --git a/lxly.pict b/docs/multi-pp-testing/lxly.pict similarity index 100% rename from lxly.pict rename to docs/multi-pp-testing/lxly.pict From 124027577984b69b35e8eed629e9ba0ec44c63f3 Mon Sep 17 00:00:00 2001 From: joanestebanr <129153821+joanestebanr@users.noreply.github.com> Date: Wed, 18 Dec 2024 13:00:41 +0100 Subject: [PATCH 19/38] feat: add RPC port to cdk-node --- input_parser.star | 1 + lib/cdk_node.star | 13 ++++++++++++- templates/trusted-node/cdk-node-config.toml | 2 ++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/input_parser.star b/input_parser.star index a4ac7751..744124e0 100644 --- a/input_parser.star +++ b/input_parser.star @@ -62,6 +62,7 @@ DEFAULT_PORTS = { "zkevm_pprof_port": 6060, "zkevm_rpc_http_port": 8123, "zkevm_rpc_ws_port": 8133, + "zkevm_cdk_node_port": 5576, } DEFAULT_STATIC_PORTS = { diff --git a/lib/cdk_node.star b/lib/cdk_node.star index 4b3cc803..622c22c7 100644 --- a/lib/cdk_node.star +++ b/lib/cdk_node.star @@ -39,7 +39,14 @@ def create_cdk_node_service_config( def get_cdk_node_ports(args): # We won't have an aggregator if we're in PP mode if args["consensus_contract_type"] == "pessimistic": - return (dict(), dict()) + ports = { + "rpc": PortSpec( + args["zkevm_cdk_node_port"], + application_protocol="http", + ), + } + public_ports = ports_package.get_public_ports(ports, "cdk_node_start_port", args) + return (ports, public_ports) # In the case where we have pre deployed contract, the cdk node # can go through a syncing process that takes a long time and @@ -58,6 +65,10 @@ def get_cdk_node_ports(args): application_protocol="grpc", wait=aggregator_wait, ), + "rpc": PortSpec( + args["zkevm_cdk_node_port"], + application_protocol="http", + ), } public_ports = ports_package.get_public_ports(ports, "cdk_node_start_port", args) diff --git a/templates/trusted-node/cdk-node-config.toml b/templates/trusted-node/cdk-node-config.toml index fa92453f..ea142a1a 100644 --- a/templates/trusted-node/cdk-node-config.toml +++ b/templates/trusted-node/cdk-node-config.toml @@ -53,6 +53,8 @@ Outputs = ["stderr"] Port = "{{.aggregator_db.port}}" EnableLog = false MaxConns = 200 +[RPC] + Port = {{.zkevm_cdk_node_port}} [AggSender] CertificateSendInterval = "1m" From dbcb1d78143bdf2e73be6da11a53f41cdfa5a2e0 Mon Sep 17 00:00:00 2001 From: John Hilliard Date: Wed, 18 Dec 2024 07:06:50 -0500 Subject: [PATCH 20/38] feat: wip docs --- docs/multi-pp-testing/README.sh | 208 ++++++++++++++-------- docs/multi-pp-testing/lxly.pict | 10 +- input_parser.star | 2 +- templates/bridge-infra/bridge-config.toml | 2 +- 4 files changed, 137 insertions(+), 85 deletions(-) diff --git a/docs/multi-pp-testing/README.sh b/docs/multi-pp-testing/README.sh index 8728d2a1..c65cd13a 100755 --- a/docs/multi-pp-testing/README.sh +++ b/docs/multi-pp-testing/README.sh @@ -49,8 +49,8 @@ kurtosis service exec pp agglayer "agglayer vkey" cast call --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $(cat combined-001.json | jq -r '.polygonRollupManagerAddress') 'rollupTypeMap(uint32)(address,address,uint64,uint8,bool,bytes32,bytes32)' 1 # Let's make sure both rollups have the same vkey -cast call --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $(cat combined-001.json | jq -r '.polygonRollupManagerAddress') 'rollupIDToRollupDataV2(uint32 rollupID)(address,uint64,address,uint64,bytes32,uint64,uint64,uint64,uint64,uint8,bytes32,bytes32)' 1 -cast call --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $(cat combined-001.json | jq -r '.polygonRollupManagerAddress') 'rollupIDToRollupDataV2(uint32 rollupID)(address,uint64,address,uint64,bytes32,uint64,uint64,uint64,uint64,uint8,bytes32,bytes32)' 2 +cast call --json --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $(cat combined-001.json | jq -r '.polygonRollupManagerAddress') 'rollupIDToRollupDataV2(uint32 rollupID)(address,uint64,address,uint64,bytes32,uint64,uint64,uint64,uint64,uint8,bytes32,bytes32)' 1 | jq '.[11]' +cast call --json --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $(cat combined-001.json | jq -r '.polygonRollupManagerAddress') 'rollupIDToRollupDataV2(uint32 rollupID)(address,uint64,address,uint64,bytes32,uint64,uint64,uint64,uint64,uint8,bytes32,bytes32)' 2 | jq '.[11]' # At this point, the agglayer config needs to be manually updated for @@ -190,28 +190,22 @@ curl -s $l2_pp1b_url/bridges/$target_address | jq '.deposits[] | select(.ready_f curl -s $l2_pp2b_url/bridges/$target_address | jq '.deposits[] | select(.ready_for_claim) | select(.claim_tx_hash == "")' # We should be able to take these commands and then try to claim each -# of the deposits. -curl -s $l2_pp1b_url/bridges/$target_address | jq -c '.deposits[] | select(.ready_for_claim) | select(.claim_tx_hash == "")' | while read deposit ; do - polycli ulxly claim message \ - --bridge-address $bridge_address \ - --bridge-service-url $l2_pp1b_url \ - --rpc-url $l2_pp1_url \ - --deposit-count $(echo $deposit | jq -r '.deposit_cnt') \ - --deposit-network $(echo $deposit | jq -r '.orig_net') \ - --destination-address $(echo $deposit | jq -r '.dest_addr') \ - --private-key $private_key -done - -curl -s $l2_pp2b_url/bridges/$target_address | jq -c '.deposits[] | select(.ready_for_claim) | select(.claim_tx_hash == "")' | while read deposit ; do - polycli ulxly claim message \ - --bridge-address $bridge_address \ - --bridge-service-url $l2_pp2b_url \ - --rpc-url $l2_pp2_url \ - --deposit-count $(echo $deposit | jq -r '.deposit_cnt') \ - --deposit-network $(echo $deposit | jq -r '.orig_net') \ - --destination-address $(echo $deposit | jq -r '.dest_addr') \ - --private-key $private_key -done +# of the deposits. This will print out some errors right now because +# it's going to try to claim some deposits that are already claimed +polycli ulxly claim-everything \ + --bridge-address $bridge_address \ + --bridge-service-map 1=$l2_pp1b_url \ + --bridge-service-map 2=$l2_pp2b_url \ + --rpc-url $l2_pp1_url \ + --destination-address $target_address \ + --private-key $private_key +polycli ulxly claim-everything \ + --bridge-address $bridge_address \ + --bridge-service-map 1=$l2_pp1b_url \ + --bridge-service-map 2=$l2_pp2b_url \ + --rpc-url $l2_pp2_url \ + --destination-address $target_address \ + --private-key $private_key # Hopefully at this point everything has been claimed on L2. These # calls should return empty. @@ -375,7 +369,7 @@ cast call --rpc-url $l1_rpc_url $bridge_address 'depositCount() external view re # every combination of parameters, but as the number of parameters # grows, this might become too difficult. I'm using a command like # this to generate the test cases. -pict lxly.pict /f:json | jq -c '.[] | from_entries' | jq -s > test-scenarios.json +pict docs/multi-pp-testing/lxly.pict /f:json | jq -c '.[] | from_entries' | jq -s > test-scenarios.json # For the sake of simplicity, I'm going to use the deterministic # deployer so that I have the same ERC20 address on each chain. Here @@ -407,7 +401,6 @@ cast send --legacy --rpc-url $l1_rpc_url --private-key $target_private_key $test cast send --legacy --rpc-url $l2_pp1_url --private-key $target_private_key $test_erc20_addr 'approve(address,uint256)' $bridge_address 100000000000000000000 cast send --legacy --rpc-url $l2_pp2_url --private-key $target_private_key $test_erc20_addr 'approve(address,uint256)' $bridge_address 100000000000000000000 -# docker run -v $PWD/src:/contracts ethereum/solc:0.7.6 --bin /contracts/tokens/ERC20Buggy.sol erc20_buggy_bytecode=608060405234801561001057600080fd5b506040516109013803806109018339818101604052606081101561003357600080fd5b810190808051604051939291908464010000000082111561005357600080fd5b90830190602082018581111561006857600080fd5b825164010000000081118282018810171561008257600080fd5b82525081516020918201929091019080838360005b838110156100af578181015183820152602001610097565b50505050905090810190601f1680156100dc5780820380516001836020036101000a031916815260200191505b50604052602001805160405193929190846401000000008211156100ff57600080fd5b90830190602082018581111561011457600080fd5b825164010000000081118282018810171561012e57600080fd5b82525081516020918201929091019080838360005b8381101561015b578181015183820152602001610143565b50505050905090810190601f1680156101885780820380516001836020036101000a031916815260200191505b5060405260209081015185519093506101a792506003918601906101d8565b5081516101bb9060049060208501906101d8565b506005805460ff191660ff92909216919091179055506102799050565b828054600181600116156101000203166002900490600052602060002090601f01602090048101928261020e5760008555610254565b82601f1061022757805160ff1916838001178555610254565b82800160010185558215610254579182015b82811115610254578251825591602001919060010190610239565b50610260929150610264565b5090565b5b808211156102605760008155600101610265565b610679806102886000396000f3fe608060405234801561001057600080fd5b50600436106100b45760003560e01c806370a082311161007157806370a082311461021257806395d89b41146102385780639dc29fac14610240578063a9059cbb1461026c578063b46310f614610298578063dd62ed3e146102c4576100b4565b806306fdde03146100b9578063095ea7b31461013657806318160ddd1461017657806323b872dd14610190578063313ce567146101c657806340c10f19146101e4575b600080fd5b6100c16102f2565b6040805160208082528351818301528351919283929083019185019080838360005b838110156100fb5781810151838201526020016100e3565b50505050905090810190601f1680156101285780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101626004803603604081101561014c57600080fd5b506001600160a01b038135169060200135610380565b604080519115158252519081900360200190f35b61017e6103e6565b60408051918252519081900360200190f35b610162600480360360608110156101a657600080fd5b506001600160a01b038135811691602081013590911690604001356103ec565b6101ce610466565b6040805160ff9092168252519081900360200190f35b610210600480360360408110156101fa57600080fd5b506001600160a01b03813516906020013561046f565b005b61017e6004803603602081101561022857600080fd5b50356001600160a01b031661047d565b6100c161048f565b6102106004803603604081101561025657600080fd5b506001600160a01b0381351690602001356104ea565b6101626004803603604081101561028257600080fd5b506001600160a01b0381351690602001356104f4565b610210600480360360408110156102ae57600080fd5b506001600160a01b03813516906020013561054f565b61017e600480360360408110156102da57600080fd5b506001600160a01b038135811691602001351661056b565b6003805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156103785780601f1061034d57610100808354040283529160200191610378565b820191906000526020600020905b81548152906001019060200180831161035b57829003601f168201915b505050505081565b3360008181526002602090815260408083206001600160a01b038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a350600192915050565b60005481565b6001600160a01b0380841660008181526002602090815260408083203384528252808320805487900390558383526001825280832080548790039055938616808352848320805487019055845186815294519294909392600080516020610624833981519152929181900390910190a35060019392505050565b60055460ff1681565b6104798282610588565b5050565b60016020526000908152604090205481565b6004805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156103785780601f1061034d57610100808354040283529160200191610378565b61047982826105d3565b336000818152600160209081526040808320805486900390556001600160a01b03861680845281842080548701905581518681529151939490939092600080516020610624833981519152928290030190a350600192915050565b6001600160a01b03909116600090815260016020526040902055565b600260209081526000928352604080842090915290825290205481565b6001600160a01b038216600081815260016020908152604080832080548601905582548501835580518581529051600080516020610624833981519152929181900390910190a35050565b6001600160a01b0382166000818152600160209081526040808320805486900390558254859003835580518581529051929392600080516020610624833981519152929181900390910190a3505056feddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa2646970667358221220364a383ccce0e270376267b8631412d1b7ddb1883c5379556b58cbefc1ca504564736f6c63430007060033 constructor_args=$(cast abi-encode 'f(string,string,uint8)' 'Buggy ERC20' 'BUG' "18" | sed 's/0x//') @@ -459,12 +452,16 @@ cat test-scenarios.json | jq -c '.[]' | while read scenario ; do testCommand="$testCommand weth" fi + temp_rpc_url="" if [[ $testDepositChain == "L1" ]]; then testCommand="$testCommand --rpc-url $l1_rpc_url" + temp_rpc_url="$l1_rpc_url" elif [[ $testDepositChain == "PP1" ]]; then testCommand="$testCommand --rpc-url $l2_pp1_url" + temp_rpc_url="$l2_pp1_url" else testCommand="$testCommand --rpc-url $l2_pp2_url" + temp_rpc_url="$l2_pp2_url" fi if [[ $testDestinationChain == "L1" ]]; then @@ -489,8 +486,8 @@ cat test-scenarios.json | jq -c '.[]' | while read scenario ; do testCommand="$testCommand --token-address $test_erc20_addr" elif [[ $testToken == "WETH" ]]; then testCommand="$testCommand --token-address $pp2_weth_address" - elif [[ $testToken == "Invalid" ]]; then - testCommand="$testCommand --token-address $(< /dev/urandom xxd -p | tr -d "\n" | head -c 40)" + elif [[ $testToken == "Buggy" ]]; then + testCommand="$testCommand --token-address $test_erc20_buggy_addr" else testCommand="$testCommand --token-address 0x0000000000000000000000000000000000000000" fi @@ -511,6 +508,10 @@ cat test-scenarios.json | jq -c '.[]' | while read scenario ; do testCommand="$testCommand --value 0" elif [[ $testAmount == "1" ]]; then testCommand="$testCommand --value 1" + elif [[ $testAmount == "Max" ]]; then + cast send --legacy --rpc-url $temp_rpc_url --private-key $target_private_key $test_erc20_buggy_addr 'mint(address,uint256)' $target_address $(cast max-uint) + cast send --legacy --rpc-url $temp_rpc_url --private-key $target_private_key $test_erc20_buggy_addr 'setBalanceOf(address,uint256)' $bridge_address 0 + testCommand="$testCommand --value $(cast max-uint)" else testCommand="$testCommand --value $(date +%s)" fi @@ -521,57 +522,40 @@ cat test-scenarios.json | jq -c '.[]' | while read scenario ; do echo $scenario | jq -c '.' echo $testCommand $testCommand + + # In this particular case, we should zero the bridge out after the deposit is made + if [[ $testAmount == "Max" ]]; then + cast send --legacy --rpc-url $temp_rpc_url --private-key $target_private_key $test_erc20_buggy_addr 'setBalanceOf(address,uint256)' $bridge_address 0 + fi done -curl -s $l2_pp2b_url/bridges/$target_address | jq -c '.deposits[] | select(.network_id == 2) | select(.dest_net == 1)' | while read deposit ; do - echo $deposit | jq -c '.' - leaf_type=$(echo $deposit | jq -r '.leaf_type') - if [[ $leaf_type == "0" ]]; then - polycli ulxly claim asset \ - --bridge-address $bridge_address \ - --bridge-service-url $l2_pp2b_url \ - --rpc-url $l2_pp1_url \ - --deposit-count $(echo $deposit | jq -r '.deposit_cnt') \ - --deposit-network 2 \ - --destination-address $(echo $deposit | jq -r '.dest_addr') \ - --private-key $private_key +polycli ulxly claim-everything \ + --bridge-address $bridge_address \ + --bridge-service-map 1=$l2_pp1b_url \ + --bridge-service-map 2=$l2_pp2b_url \ + --rpc-url $l2_pp1_url \ + --destination-address $target_address \ + --private-key $private_key \ + --bridge-limit 100 - else - polycli ulxly claim message \ - --bridge-address $bridge_address \ - --bridge-service-url $l2_pp2b_url \ - --rpc-url $l2_pp1_url \ - --deposit-count $(echo $deposit | jq -r '.deposit_cnt') \ - --deposit-network 2 \ - --destination-address $(echo $deposit | jq -r '.dest_addr') \ - --private-key $private_key - fi -done -curl -s $l2_pp1b_url/bridges/$target_address | jq -c '.deposits[] | select(.network_id == 1) | select(.dest_net == 2)' | while read deposit ; do - echo $deposit | jq -c '.' - leaf_type=$(echo $deposit | jq -r '.leaf_type') - if [[ $leaf_type == "0" ]]; then - polycli ulxly claim asset \ - --bridge-address $bridge_address \ - --bridge-service-url $l2_pp1b_url \ - --rpc-url $l2_pp2_url \ - --deposit-count $(echo $deposit | jq -r '.deposit_cnt') \ - --deposit-network 1 \ - --destination-address $(echo $deposit | jq -r '.dest_addr') \ - --private-key $private_key +polycli ulxly claim-everything \ + --bridge-address $bridge_address \ + --bridge-service-map 1=$l2_pp1b_url \ + --bridge-service-map 2=$l2_pp2b_url \ + --rpc-url $l2_pp2_url \ + --destination-address $target_address \ + --private-key $private_key \ + --bridge-limit 100 - else - polycli ulxly claim message \ - --bridge-address $bridge_address \ - --bridge-service-url $l2_pp1b_url \ - --rpc-url $l2_pp2_url \ - --deposit-count $(echo $deposit | jq -r '.deposit_cnt') \ - --deposit-network 1 \ - --destination-address $(echo $deposit | jq -r '.dest_addr') \ - --private-key $private_key - fi -done +polycli ulxly claim-everything \ + --bridge-address $bridge_address \ + --bridge-service-map 1=$l2_pp1b_url \ + --bridge-service-map 2=$l2_pp2b_url \ + --rpc-url $l1_rpc_url \ + --destination-address $target_address \ + --private-key $private_key \ + --bridge-limit 100 # ## Buggy ERC 20 # @@ -615,6 +599,19 @@ polycli ulxly bridge asset \ cast send --legacy --rpc-url $l2_pp2_url --private-key $target_private_key $test_erc20_buggy_addr 'mint(address,uint256)' $target_address $(cast max-uint) cast send --legacy --rpc-url $l2_pp2_url --private-key $target_private_key $test_erc20_buggy_addr 'setBalanceOf(address,uint256)' $bridge_address 0 +# Then do the same thing for PP2 to L1 +polycli ulxly bridge asset \ + --private-key $target_private_key \ + --value 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe \ + --bridge-address $bridge_address \ + --destination-network 0 \ + --destination-address $target_address \ + --rpc-url $l2_pp2_url \ + --token-address $test_erc20_buggy_addr \ + --force-update-root=true + +cast send --legacy --rpc-url $l2_pp2_url --private-key $target_private_key $test_erc20_buggy_addr 'mint(address,uint256)' $target_address $(cast max-uint) +cast send --legacy --rpc-url $l2_pp2_url --private-key $target_private_key $test_erc20_buggy_addr 'setBalanceOf(address,uint256)' $bridge_address 0 curl -s $l2_pp1b_url/bridges/$target_address @@ -640,15 +637,21 @@ cast send --legacy --value 1 --rpc-url $l2_pp2_url --private-key $target_private # testing. You might not have this. The idea is to call the bridge # contract from a bunch of contexts and ensure that things more or # less still work -tester_contract_address=0xfBE07a394847c26b1d998B6e44EE78A9C8191f13 +tester_contract_address=0xc54E34B55EF562FE82Ca858F70D1B73244e86388 -address_tester_actions="001 002 003 004 011 012 013 014 021 022 023 024 031 032 033 034 041 042 043 044 101 201 301 401 501 601 701 801 901" +# address_tester_actions="001 002 003 004 011 012 013 014 021 022 023 024 031 032 033 034 041 042 043 044 101 201 301 401 501 601 701 801 901" +address_tester_actions="001 011 021 031 041 101 201 301 401 501 601 701 801 901" for create_mode in 0 1 2; do for action in $address_tester_actions ; do - cast send --legacy --value 1 --rpc-url $l1_rpc_url --private-key $target_private_key $tester_contract_address $(cast abi-encode 'f(uint32, address, uint256)' 0x"$create_mode$action" $test_lxly_proxy_addr 1) - cast send --legacy --value 2 --rpc-url $l2_pp1_url --private-key $target_private_key $tester_contract_address $(cast abi-encode 'f(uint32, address, uint256)' 0x"$create_mode$action" $test_lxly_proxy_addr 2) - cast send --legacy --value 1 --rpc-url $l2_pp2_url --private-key $target_private_key $tester_contract_address $(cast abi-encode 'f(uint32, address, uint256)' 0x"$create_mode$action" $test_lxly_proxy_addr 1) + cast send --gas-limit 1000000 --legacy --value 1 --rpc-url $l1_rpc_url --private-key $target_private_key $tester_contract_address $(cast abi-encode 'f(uint32, address, uint256)' 0x"$create_mode$action" $test_lxly_proxy_addr 1) + cast send --gas-limit 1000000 --legacy --value 2 --rpc-url $l1_rpc_url --private-key $target_private_key $tester_contract_address $(cast abi-encode 'f(uint32, address, uint256)' 0x"$create_mode$action" $test_lxly_proxy_addr 2) + + cast send --gas-limit 1000000 --legacy --value 0 --rpc-url $l2_pp1_url --private-key $target_private_key $tester_contract_address $(cast abi-encode 'f(uint32, address, uint256)' 0x"$create_mode$action" $test_lxly_proxy_addr 0) + cast send --gas-limit 1000000 --legacy --value 2 --rpc-url $l2_pp1_url --private-key $target_private_key $tester_contract_address $(cast abi-encode 'f(uint32, address, uint256)' 0x"$create_mode$action" $test_lxly_proxy_addr 2) + + cast send --gas-limit 1000000 --legacy --value 0 --rpc-url $l2_pp2_url --private-key $target_private_key $tester_contract_address $(cast abi-encode 'f(uint32, address, uint256)' 0x"$create_mode$action" $test_lxly_proxy_addr 0) + cast send --gas-limit 1000000 --legacy --value 1 --rpc-url $l2_pp2_url --private-key $target_private_key $tester_contract_address $(cast abi-encode 'f(uint32, address, uint256)' 0x"$create_mode$action" $test_lxly_proxy_addr 1) done done @@ -657,6 +660,47 @@ done # TODO add some tests where the bridge is called via a smart contract rather than directly # TODO add a scneario that does a full sweep of the target account native token and the end to ensure all of the accounting looks good +cast send --legacy --gas-limit 1000000 --value 2 --rpc-url $l2_pp1_url --private-key $target_private_key $tester_contract_address $(cast abi-encode 'f(uint32, address, uint256)' 0x0201 $test_lxly_proxy_addr 2) + +polycli ulxly claim-everything \ + --bridge-address $bridge_address \ + --bridge-service-map 1=$l2_pp1b_url \ + --bridge-service-map 2=$l2_pp2b_url \ + --destination-address $target_address \ + --private-key $target_private_key \ + --rpc-url $l2_pp1_url \ + --bridge-limit 100 + +polycli ulxly claim-everything \ + --bridge-address $bridge_address \ + --bridge-service-map 1=$l2_pp1b_url \ + --bridge-service-map 2=$l2_pp2b_url \ + --destination-address $target_address \ + --private-key $target_private_key \ + --rpc-url $l2_pp2_url \ + --bridge-limit 100 + +polycli ulxly claim-everything \ + --bridge-address $bridge_address \ + --bridge-service-map 1=$l2_pp1b_url \ + --bridge-service-map 2=$l2_pp2b_url \ + --destination-address $target_address \ + --private-key $target_private_key \ + --rpc-url $l1_rpc_url \ + --bridge-limit 100 + +curl -s "$l2_pp1b_url/bridges/0xbecE3a31343c6019CDE0D5a4dF2AF8Df17ebcB0f?limit=150" | jq '.deposits[] | select(.deposit_cnt == 111)' +curl -s "$l2_pp1b_url/merkle-proof?deposit_cnt=111&net_id=0" | jq '.' +curl -s "$l2_pp1b_url/merkle-proof?deposit_cnt=111&net_id=1" | jq '.' +curl -s "$l2_pp1b_url/merkle-proof?deposit_cnt=111&net_id=2" | jq '.' + +curl -s "$l2_pp2b_url/bridges/0xbecE3a31343c6019CDE0D5a4dF2AF8Df17ebcB0f?limit=150" | jq '.deposits[] | select(.tx_hash == "0x932945c01362a5e121405b6bf38b14da8b6ddeee253732cdf362be74b455bea8")' +curl -s "$l2_pp2b_url/bridges/0xbecE3a31343c6019CDE0D5a4dF2AF8Df17ebcB0f?limit=150" | jq '.deposits[] | select(.deposit_cnt == 111)' +curl -s "$l2_pp2b_url/merkle-proof?deposit_cnt=111&net_id=0" | jq '.' +curl -s "$l2_pp2b_url/merkle-proof?deposit_cnt=111&net_id=1" | jq '.' +curl -s "$l2_pp2b_url/merkle-proof?deposit_cnt=111&net_id=2" | jq '.' + + # ## State Capture Procedure pushd $(mktemp -d) mkdir agglayer-storage @@ -669,3 +713,9 @@ kurtosis enclave dump pp popd tar caf agglayer-details.tar.xz /tmp/tmp.VKezDefjS6 + + +# drop table public.gorp_migrations; +# drop schema sync cascade; +# drop schema mt cascade; +# delete from sync.claim where index = '14' and rollup_index = 0 and network_id = 2; diff --git a/docs/multi-pp-testing/lxly.pict b/docs/multi-pp-testing/lxly.pict index 0a0b9b5f..1b6f831c 100644 --- a/docs/multi-pp-testing/lxly.pict +++ b/docs/multi-pp-testing/lxly.pict @@ -3,21 +3,23 @@ DepositChain : L1, PP1 (2), PP2 (2) DestinationChain : L1, PP1, PP2 DestinationAddress : EOA, Contract, Precompile BridgeType : Asset, Message, Weth -Token : NativeEther (5), LocalERC20 (5), POL (2), Invalid, WETH (2) +Token : NativeEther, LocalERC20, POL, Buggy, WETH MetaData : 0x, Random ForceUpdate : True (4), False -Amount : 0, 1, Random +Amount : 0, 1, Random, Max IF [DepositChain] = "L1" THEN [DestinationChain] <> "L1"; IF [DepositChain] = "PP1" THEN [DestinationChain] <> "PP1"; IF [DepositChain] = "PP2" THEN [DestinationChain] <> "PP2"; +IF [DepositChain] = "PP2" AND [BridgeType] = "Message" THEN [Amount] = "0"; IF [BridgeType] = "Message" THEN [Token] = "NativeEther"; IF [BridgeType] = "Weth" THEN [Token] = "WETH"; + IF [Token] = "POL" THEN [DepositChain] = "L1"; IF [Token] = "WETH" THEN [DepositChain] = "PP2"; -IF [Token] = "LocalERC20" OR [Token] = "WETH" OR [Token] = "POL" OR [Token] = "Invalid" THEN [MetaData] = "0x"; - +IF [Token] = "LocalERC20" OR [Token] = "WETH" OR [Token] = "POL" OR [Token] = "Buggy" THEN [MetaData] = "0x"; +IF [Amount] = "Max" THEN [Token] = "Buggy"; diff --git a/input_parser.star b/input_parser.star index a4ac7751..eca6bfdb 100644 --- a/input_parser.star +++ b/input_parser.star @@ -29,7 +29,7 @@ DEFAULT_DEPLOYMENT_STAGES = { } DEFAULT_IMAGES = { - "agglayer_image": "ghcr.io/agglayer/agglayer:0.2.0-rc.21", # https://github.com/agglayer/agglayer/tags + "agglayer_image": "ghcr.io/agglayer/agglayer:0.2.0-rc.22", # https://github.com/agglayer/agglayer/tags "cdk_erigon_node_image": "hermeznetwork/cdk-erigon:v2.60.0", # https://hub.docker.com/r/hermeznetwork/cdk-erigon/tags "cdk_node_image": "ghcr.io/0xpolygon/cdk:0.4.0", # https://github.com/0xpolygon/cdk/pkgs/container/cdk "cdk_validium_node_image": "0xpolygon/cdk-validium-node:0.7.0-cdk", # https://hub.docker.com/r/0xpolygon/cdk-validium-node/tags diff --git a/templates/bridge-infra/bridge-config.toml b/templates/bridge-infra/bridge-config.toml index d4ae1f1c..7acf1c02 100644 --- a/templates/bridge-infra/bridge-config.toml +++ b/templates/bridge-infra/bridge-config.toml @@ -28,7 +28,7 @@ Height = 32 GRPCPort = "{{.zkevm_bridge_grpc_port}}" HTTPPort = "{{.zkevm_bridge_rpc_port}}" DefaultPageLimit = 25 -MaxPageLimit = 100 +MaxPageLimit = 1000 BridgeVersion = "v1" # Read only [BridgeServer.DB] From 355de587c6012a93dd1ae2cd629652465306883f Mon Sep 17 00:00:00 2001 From: John Hilliard Date: Wed, 18 Dec 2024 07:48:48 -0500 Subject: [PATCH 21/38] fix: adding no wait for rpc port --- lib/cdk_node.star | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/cdk_node.star b/lib/cdk_node.star index 622c22c7..0d8b2660 100644 --- a/lib/cdk_node.star +++ b/lib/cdk_node.star @@ -43,9 +43,12 @@ def get_cdk_node_ports(args): "rpc": PortSpec( args["zkevm_cdk_node_port"], application_protocol="http", + wait=None, ), } - public_ports = ports_package.get_public_ports(ports, "cdk_node_start_port", args) + public_ports = ports_package.get_public_ports( + ports, "cdk_node_start_port", args + ) return (ports, public_ports) # In the case where we have pre deployed contract, the cdk node @@ -66,9 +69,10 @@ def get_cdk_node_ports(args): wait=aggregator_wait, ), "rpc": PortSpec( - args["zkevm_cdk_node_port"], - application_protocol="http", - ), + args["zkevm_cdk_node_port"], + application_protocol="http", + wait=None, + ), } public_ports = ports_package.get_public_ports(ports, "cdk_node_start_port", args) From d2ce23a0e83da43d31fe4524913f787428c22ee1 Mon Sep 17 00:00:00 2001 From: John Hilliard Date: Wed, 18 Dec 2024 08:20:47 -0500 Subject: [PATCH 22/38] lint: removing .sh extension --- .github/workflows/lint.yml | 2 +- docs/multi-pp-testing/{README.sh => README} | 0 docs/multi-pp-testing/{README.sh.md => README.md} | 0 3 files changed, 1 insertion(+), 1 deletion(-) rename docs/multi-pp-testing/{README.sh => README} (100%) rename docs/multi-pp-testing/{README.sh.md => README.md} (100%) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 8d37f164..9bd2d5f7 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -65,7 +65,7 @@ jobs: - name: Generate test combinations and cdk version matrix working-directory: .github/tests run: ./combine-ymls.sh - + - name: Check if test combinations and cdk version matrix are up to date run: | if [[ -n $(git status --porcelain) ]]; then diff --git a/docs/multi-pp-testing/README.sh b/docs/multi-pp-testing/README similarity index 100% rename from docs/multi-pp-testing/README.sh rename to docs/multi-pp-testing/README diff --git a/docs/multi-pp-testing/README.sh.md b/docs/multi-pp-testing/README.md similarity index 100% rename from docs/multi-pp-testing/README.sh.md rename to docs/multi-pp-testing/README.md From 539cb7255efa10561875c82616617519e846a2c9 Mon Sep 17 00:00:00 2001 From: John Hilliard Date: Wed, 18 Dec 2024 08:57:26 -0500 Subject: [PATCH 23/38] chore: deleteing unused function --- .github/tests/fork12-pessimistic.yml | 1 - templates/contract-deploy/run-contract-setup.sh | 14 -------------- 2 files changed, 15 deletions(-) diff --git a/.github/tests/fork12-pessimistic.yml b/.github/tests/fork12-pessimistic.yml index 31a35e0e..4c4e542f 100644 --- a/.github/tests/fork12-pessimistic.yml +++ b/.github/tests/fork12-pessimistic.yml @@ -1,5 +1,4 @@ args: - cdk_node_image: ghcr.io/0xpolygon/cdk:0.5.0-beta10 cdk_erigon_node_image: hermeznetwork/cdk-erigon:v2.60.0 zkevm_contracts_image: leovct/zkevm-contracts:v9.0.0-rc.3-pp-fork.12-patch.1 additional_services: [] diff --git a/templates/contract-deploy/run-contract-setup.sh b/templates/contract-deploy/run-contract-setup.sh index a575d76c..a4b05560 100755 --- a/templates/contract-deploy/run-contract-setup.sh +++ b/templates/contract-deploy/run-contract-setup.sh @@ -27,20 +27,6 @@ wait_for_rpc_to_be_available() { done } -wait_for_finalized_block() { - counter=0 - max_retries=100 - until cast block --rpc-url "{{.l1_rpc_url}}" finalized &> /dev/null; do - ((counter++)) - echo_ts "No finalized block yet... Retrying ($counter)..." - if [[ $counter -ge $max_retries ]]; then - echo_ts "Exceeded maximum retry attempts. Exiting." - exit 1 - fi - sleep 5 - done -} - fund_account_on_l1() { name="$1" address="$2" From f58acdc5d40625ab0dcb1c28da5204e14a7a2117 Mon Sep 17 00:00:00 2001 From: John Hilliard Date: Wed, 18 Dec 2024 09:47:54 -0500 Subject: [PATCH 24/38] fix: pegging pre-banana chains to agglayer rc20 --- .../tests/combinations/fork11-legacy-zkevm-stack-rollup.yml | 1 + .../tests/combinations/fork11-new-cdk-stack-cdk-validium.yml | 1 + .github/tests/combinations/fork11-new-cdk-stack-rollup.yml | 1 + .../combinations/fork9-legacy-zkevm-stack-cdk-validium.yml | 1 + .github/tests/combinations/fork9-legacy-zkevm-stack-rollup.yml | 1 + .../tests/combinations/fork9-new-cdk-stack-cdk-validium.yml | 1 + .github/tests/combinations/fork9-new-cdk-stack-rollup.yml | 1 + .github/tests/forks/fork11.yml | 3 +++ .github/tests/forks/fork9.yml | 3 +++ 9 files changed, 13 insertions(+) diff --git a/.github/tests/combinations/fork11-legacy-zkevm-stack-rollup.yml b/.github/tests/combinations/fork11-legacy-zkevm-stack-rollup.yml index 72515dcf..4b27b18b 100644 --- a/.github/tests/combinations/fork11-legacy-zkevm-stack-rollup.yml +++ b/.github/tests/combinations/fork11-legacy-zkevm-stack-rollup.yml @@ -9,6 +9,7 @@ args: additional_services: - tx_spammer deploy_l2_contracts: true + agglayer_image: ghcr.io/agglayer/agglayer:0.2.0-rc.20 consensus_contract_type: rollup sequencer_type: zkevm deployment_stages: diff --git a/.github/tests/combinations/fork11-new-cdk-stack-cdk-validium.yml b/.github/tests/combinations/fork11-new-cdk-stack-cdk-validium.yml index 622d6fa2..37cf55ca 100644 --- a/.github/tests/combinations/fork11-new-cdk-stack-cdk-validium.yml +++ b/.github/tests/combinations/fork11-new-cdk-stack-cdk-validium.yml @@ -9,5 +9,6 @@ args: additional_services: - tx_spammer deploy_l2_contracts: true + agglayer_image: ghcr.io/agglayer/agglayer:0.2.0-rc.20 consensus_contract_type: cdk-validium sequencer_type: erigon diff --git a/.github/tests/combinations/fork11-new-cdk-stack-rollup.yml b/.github/tests/combinations/fork11-new-cdk-stack-rollup.yml index 5af1190d..dec2ea5b 100644 --- a/.github/tests/combinations/fork11-new-cdk-stack-rollup.yml +++ b/.github/tests/combinations/fork11-new-cdk-stack-rollup.yml @@ -9,5 +9,6 @@ args: additional_services: - tx_spammer deploy_l2_contracts: true + agglayer_image: ghcr.io/agglayer/agglayer:0.2.0-rc.20 consensus_contract_type: rollup sequencer_type: erigon diff --git a/.github/tests/combinations/fork9-legacy-zkevm-stack-cdk-validium.yml b/.github/tests/combinations/fork9-legacy-zkevm-stack-cdk-validium.yml index c2fb5760..5384162c 100644 --- a/.github/tests/combinations/fork9-legacy-zkevm-stack-cdk-validium.yml +++ b/.github/tests/combinations/fork9-legacy-zkevm-stack-cdk-validium.yml @@ -11,6 +11,7 @@ args: - pless_zkevm_node - tx_spammer deploy_l2_contracts: true + agglayer_image: ghcr.io/agglayer/agglayer:0.2.0-rc.20 consensus_contract_type: cdk-validium sequencer_type: zkevm deployment_stages: diff --git a/.github/tests/combinations/fork9-legacy-zkevm-stack-rollup.yml b/.github/tests/combinations/fork9-legacy-zkevm-stack-rollup.yml index b071eaee..441de715 100644 --- a/.github/tests/combinations/fork9-legacy-zkevm-stack-rollup.yml +++ b/.github/tests/combinations/fork9-legacy-zkevm-stack-rollup.yml @@ -11,6 +11,7 @@ args: - pless_zkevm_node - tx_spammer deploy_l2_contracts: true + agglayer_image: ghcr.io/agglayer/agglayer:0.2.0-rc.20 consensus_contract_type: rollup sequencer_type: zkevm deployment_stages: diff --git a/.github/tests/combinations/fork9-new-cdk-stack-cdk-validium.yml b/.github/tests/combinations/fork9-new-cdk-stack-cdk-validium.yml index 5616ffd4..d77ae9b7 100644 --- a/.github/tests/combinations/fork9-new-cdk-stack-cdk-validium.yml +++ b/.github/tests/combinations/fork9-new-cdk-stack-cdk-validium.yml @@ -11,5 +11,6 @@ args: - pless_zkevm_node - tx_spammer deploy_l2_contracts: true + agglayer_image: ghcr.io/agglayer/agglayer:0.2.0-rc.20 consensus_contract_type: cdk-validium sequencer_type: erigon diff --git a/.github/tests/combinations/fork9-new-cdk-stack-rollup.yml b/.github/tests/combinations/fork9-new-cdk-stack-rollup.yml index de953d1a..3d121dca 100644 --- a/.github/tests/combinations/fork9-new-cdk-stack-rollup.yml +++ b/.github/tests/combinations/fork9-new-cdk-stack-rollup.yml @@ -11,5 +11,6 @@ args: - pless_zkevm_node - tx_spammer deploy_l2_contracts: true + agglayer_image: ghcr.io/agglayer/agglayer:0.2.0-rc.20 consensus_contract_type: rollup sequencer_type: erigon diff --git a/.github/tests/forks/fork11.yml b/.github/tests/forks/fork11.yml index ee57de6e..5eeb6714 100644 --- a/.github/tests/forks/fork11.yml +++ b/.github/tests/forks/fork11.yml @@ -23,3 +23,6 @@ args: - tx_spammer deploy_l2_contracts: true + + # https://github.com/agglayer/agglayer/tags + agglayer_image: ghcr.io/agglayer/agglayer:0.2.0-rc.20 diff --git a/.github/tests/forks/fork9.yml b/.github/tests/forks/fork9.yml index fbeee964..c683f039 100644 --- a/.github/tests/forks/fork9.yml +++ b/.github/tests/forks/fork9.yml @@ -27,3 +27,6 @@ args: - tx_spammer deploy_l2_contracts: true + + # https://github.com/agglayer/agglayer/tags + agglayer_image: ghcr.io/agglayer/agglayer:0.2.0-rc.20 From e78a4268ca8ba836cb1f40ba9cf74e34f0227ea3 Mon Sep 17 00:00:00 2001 From: John Hilliard Date: Thu, 19 Dec 2024 06:41:55 -0500 Subject: [PATCH 25/38] fix: downgrading to 19 for the older forks --- .github/tests/combinations/fork11-legacy-zkevm-stack-rollup.yml | 2 +- .../tests/combinations/fork11-new-cdk-stack-cdk-validium.yml | 2 +- .github/tests/combinations/fork11-new-cdk-stack-rollup.yml | 2 +- .../combinations/fork9-legacy-zkevm-stack-cdk-validium.yml | 2 +- .github/tests/combinations/fork9-legacy-zkevm-stack-rollup.yml | 2 +- .github/tests/combinations/fork9-new-cdk-stack-cdk-validium.yml | 2 +- .github/tests/combinations/fork9-new-cdk-stack-rollup.yml | 2 +- .github/tests/forks/fork11.yml | 2 +- .github/tests/forks/fork9.yml | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/tests/combinations/fork11-legacy-zkevm-stack-rollup.yml b/.github/tests/combinations/fork11-legacy-zkevm-stack-rollup.yml index 4b27b18b..8e2b824d 100644 --- a/.github/tests/combinations/fork11-legacy-zkevm-stack-rollup.yml +++ b/.github/tests/combinations/fork11-legacy-zkevm-stack-rollup.yml @@ -9,7 +9,7 @@ args: additional_services: - tx_spammer deploy_l2_contracts: true - agglayer_image: ghcr.io/agglayer/agglayer:0.2.0-rc.20 + agglayer_image: ghcr.io/agglayer/agglayer:0.2.0-rc.19 consensus_contract_type: rollup sequencer_type: zkevm deployment_stages: diff --git a/.github/tests/combinations/fork11-new-cdk-stack-cdk-validium.yml b/.github/tests/combinations/fork11-new-cdk-stack-cdk-validium.yml index 37cf55ca..3f2b08b2 100644 --- a/.github/tests/combinations/fork11-new-cdk-stack-cdk-validium.yml +++ b/.github/tests/combinations/fork11-new-cdk-stack-cdk-validium.yml @@ -9,6 +9,6 @@ args: additional_services: - tx_spammer deploy_l2_contracts: true - agglayer_image: ghcr.io/agglayer/agglayer:0.2.0-rc.20 + agglayer_image: ghcr.io/agglayer/agglayer:0.2.0-rc.19 consensus_contract_type: cdk-validium sequencer_type: erigon diff --git a/.github/tests/combinations/fork11-new-cdk-stack-rollup.yml b/.github/tests/combinations/fork11-new-cdk-stack-rollup.yml index dec2ea5b..67dfc6b1 100644 --- a/.github/tests/combinations/fork11-new-cdk-stack-rollup.yml +++ b/.github/tests/combinations/fork11-new-cdk-stack-rollup.yml @@ -9,6 +9,6 @@ args: additional_services: - tx_spammer deploy_l2_contracts: true - agglayer_image: ghcr.io/agglayer/agglayer:0.2.0-rc.20 + agglayer_image: ghcr.io/agglayer/agglayer:0.2.0-rc.19 consensus_contract_type: rollup sequencer_type: erigon diff --git a/.github/tests/combinations/fork9-legacy-zkevm-stack-cdk-validium.yml b/.github/tests/combinations/fork9-legacy-zkevm-stack-cdk-validium.yml index 5384162c..b725d0d4 100644 --- a/.github/tests/combinations/fork9-legacy-zkevm-stack-cdk-validium.yml +++ b/.github/tests/combinations/fork9-legacy-zkevm-stack-cdk-validium.yml @@ -11,7 +11,7 @@ args: - pless_zkevm_node - tx_spammer deploy_l2_contracts: true - agglayer_image: ghcr.io/agglayer/agglayer:0.2.0-rc.20 + agglayer_image: ghcr.io/agglayer/agglayer:0.2.0-rc.19 consensus_contract_type: cdk-validium sequencer_type: zkevm deployment_stages: diff --git a/.github/tests/combinations/fork9-legacy-zkevm-stack-rollup.yml b/.github/tests/combinations/fork9-legacy-zkevm-stack-rollup.yml index 441de715..c6129ff2 100644 --- a/.github/tests/combinations/fork9-legacy-zkevm-stack-rollup.yml +++ b/.github/tests/combinations/fork9-legacy-zkevm-stack-rollup.yml @@ -11,7 +11,7 @@ args: - pless_zkevm_node - tx_spammer deploy_l2_contracts: true - agglayer_image: ghcr.io/agglayer/agglayer:0.2.0-rc.20 + agglayer_image: ghcr.io/agglayer/agglayer:0.2.0-rc.19 consensus_contract_type: rollup sequencer_type: zkevm deployment_stages: diff --git a/.github/tests/combinations/fork9-new-cdk-stack-cdk-validium.yml b/.github/tests/combinations/fork9-new-cdk-stack-cdk-validium.yml index d77ae9b7..1cb92f19 100644 --- a/.github/tests/combinations/fork9-new-cdk-stack-cdk-validium.yml +++ b/.github/tests/combinations/fork9-new-cdk-stack-cdk-validium.yml @@ -11,6 +11,6 @@ args: - pless_zkevm_node - tx_spammer deploy_l2_contracts: true - agglayer_image: ghcr.io/agglayer/agglayer:0.2.0-rc.20 + agglayer_image: ghcr.io/agglayer/agglayer:0.2.0-rc.19 consensus_contract_type: cdk-validium sequencer_type: erigon diff --git a/.github/tests/combinations/fork9-new-cdk-stack-rollup.yml b/.github/tests/combinations/fork9-new-cdk-stack-rollup.yml index 3d121dca..243cd04b 100644 --- a/.github/tests/combinations/fork9-new-cdk-stack-rollup.yml +++ b/.github/tests/combinations/fork9-new-cdk-stack-rollup.yml @@ -11,6 +11,6 @@ args: - pless_zkevm_node - tx_spammer deploy_l2_contracts: true - agglayer_image: ghcr.io/agglayer/agglayer:0.2.0-rc.20 + agglayer_image: ghcr.io/agglayer/agglayer:0.2.0-rc.19 consensus_contract_type: rollup sequencer_type: erigon diff --git a/.github/tests/forks/fork11.yml b/.github/tests/forks/fork11.yml index 5eeb6714..5ffdb01a 100644 --- a/.github/tests/forks/fork11.yml +++ b/.github/tests/forks/fork11.yml @@ -25,4 +25,4 @@ args: deploy_l2_contracts: true # https://github.com/agglayer/agglayer/tags - agglayer_image: ghcr.io/agglayer/agglayer:0.2.0-rc.20 + agglayer_image: ghcr.io/agglayer/agglayer:0.2.0-rc.19 diff --git a/.github/tests/forks/fork9.yml b/.github/tests/forks/fork9.yml index c683f039..8a85bfc7 100644 --- a/.github/tests/forks/fork9.yml +++ b/.github/tests/forks/fork9.yml @@ -29,4 +29,4 @@ args: deploy_l2_contracts: true # https://github.com/agglayer/agglayer/tags - agglayer_image: ghcr.io/agglayer/agglayer:0.2.0-rc.20 + agglayer_image: ghcr.io/agglayer/agglayer:0.2.0-rc.19 From 539ab8e6dade631c90feefbb8984819ccca1d918 Mon Sep 17 00:00:00 2001 From: John Hilliard Date: Thu, 19 Dec 2024 06:55:32 -0500 Subject: [PATCH 26/38] feat: separating pessmistic config --- .../tests/attach-second-cdk-pessimistic.yml | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/tests/attach-second-cdk-pessimistic.yml diff --git a/.github/tests/attach-second-cdk-pessimistic.yml b/.github/tests/attach-second-cdk-pessimistic.yml new file mode 100644 index 00000000..e2fe5dab --- /dev/null +++ b/.github/tests/attach-second-cdk-pessimistic.yml @@ -0,0 +1,39 @@ +deployment_stages: + deploy_l1: false + deploy_agglayer: false + +args: + deployment_suffix: "-002" + zkevm_rollup_chain_id: 20202 + zkevm_rollup_id: 2 + + # The following accounts have been generated using the following command: + # polycli wallet inspect --mnemonic 'bless share truly shadow primary sun relief border van gallery stairs edit reflect gentle athlete main device smile response rescue mirror floor say people' --addresses 9 | tee keys.txt | jq -r '.Addresses[] | [.ETHAddress, .HexPrivateKey] | @tsv' | awk 'BEGIN{split("sequencer,aggregator,claimtxmanager,timelock,admin,loadtest,agglayer,dac,proofsigner",roles,",")} {print "zkevm_l2_" roles[NR] "_address: \"" $1 "\""; print "zkevm_l2_" roles[NR] "_private_key: \"0x" $2 "\"\n"}' + # Note that admin and agglayer accounts have been removed since we're using the default accounts. + zkevm_l2_sequencer_address: "0xA670342930242407b9984e467353044f8472055e" + zkevm_l2_sequencer_private_key: "0x902ed4ce26b536617a4f26da5e0cd0ef61b514a076b4bd766d6ab8b97efbb8c1" + zkevm_l2_aggregator_address: "0xfC419a9d9Fe0DfA4Cf9971AcD1Fbcd356DD768FD" + zkevm_l2_aggregator_private_key: "0xa70db9fb4b84a6ba18c03cd2266116dd110538d6c4c88e67ca35a29b910da25d" + zkevm_l2_claimtxmanager_address: "0x93F63c24735f45Cd0266E87353071B64dd86bc05" + zkevm_l2_claimtxmanager_private_key: "0x38718f22097afba13be48d818964326c9c5c48133f51e3c3bfd6faf05f813b34" + zkevm_l2_timelock_address: "0xDB22C6f61A82d6AA6d3607289fC93774AC09413a" + zkevm_l2_timelock_private_key: "0xae4a69010583a09709baa563fa66f9e6f2dacf9e9c84b89932406b9a0521b561" + zkevm_l2_loadtest_address: "0xD5278fC3Dc72A226d5C04c3d2C85fd397A46fA08" + zkevm_l2_loadtest_private_key: "0xef4db4f97684b8307adc332ed6c1bc82d66d160f08e7427d082d66a23889625e" + zkevm_l2_dac_address: "0xDa07AAD7226B136bc24157Dc4Ff5A813490E20D0" + zkevm_l2_dac_private_key: "0x992c9ab11d5eab6b6c2634b8bb0b85f3d8d1acf25024dc99c359cb2afd9b40a7" + zkevm_l2_proofsigner_address: "0xf1a661D7b601Ec46a040f57193cC99aB8c4132FA" + zkevm_l2_proofsigner_private_key: "0xc7fe3a006d75ba9326d9792523385abb49057c66aee0b8b4248821a89713f975" + + + cdk_node_image: ghcr.io/0xpolygon/cdk:0.5.0-beta10 + cdk_erigon_node_image: hermeznetwork/cdk-erigon:v2.60.0 + zkevm_contracts_image: leovct/zkevm-contracts:v9.0.0-rc.3-pp-fork.12-patch.1 + additional_services: [] + consensus_contract_type: pessimistic + sequencer_type: erigon + erigon_strict_mode: false + gas_token_enabled: true + zkevm_use_real_verifier: true + enable_normalcy: true + From d5ee23e9f550e33d4bb8f3be1d40aed3e9048ebf Mon Sep 17 00:00:00 2001 From: John Hilliard Date: Thu, 19 Dec 2024 06:56:58 -0500 Subject: [PATCH 27/38] revert: changes to the attachment file --- .github/tests/attach-second-cdk.yml | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/.github/tests/attach-second-cdk.yml b/.github/tests/attach-second-cdk.yml index e2fe5dab..5f067180 100644 --- a/.github/tests/attach-second-cdk.yml +++ b/.github/tests/attach-second-cdk.yml @@ -3,10 +3,11 @@ deployment_stages: deploy_agglayer: false args: + verbosity: debug deployment_suffix: "-002" zkevm_rollup_chain_id: 20202 zkevm_rollup_id: 2 - + # The following accounts have been generated using the following command: # polycli wallet inspect --mnemonic 'bless share truly shadow primary sun relief border van gallery stairs edit reflect gentle athlete main device smile response rescue mirror floor say people' --addresses 9 | tee keys.txt | jq -r '.Addresses[] | [.ETHAddress, .HexPrivateKey] | @tsv' | awk 'BEGIN{split("sequencer,aggregator,claimtxmanager,timelock,admin,loadtest,agglayer,dac,proofsigner",roles,",")} {print "zkevm_l2_" roles[NR] "_address: \"" $1 "\""; print "zkevm_l2_" roles[NR] "_private_key: \"0x" $2 "\"\n"}' # Note that admin and agglayer accounts have been removed since we're using the default accounts. @@ -24,16 +25,3 @@ args: zkevm_l2_dac_private_key: "0x992c9ab11d5eab6b6c2634b8bb0b85f3d8d1acf25024dc99c359cb2afd9b40a7" zkevm_l2_proofsigner_address: "0xf1a661D7b601Ec46a040f57193cC99aB8c4132FA" zkevm_l2_proofsigner_private_key: "0xc7fe3a006d75ba9326d9792523385abb49057c66aee0b8b4248821a89713f975" - - - cdk_node_image: ghcr.io/0xpolygon/cdk:0.5.0-beta10 - cdk_erigon_node_image: hermeznetwork/cdk-erigon:v2.60.0 - zkevm_contracts_image: leovct/zkevm-contracts:v9.0.0-rc.3-pp-fork.12-patch.1 - additional_services: [] - consensus_contract_type: pessimistic - sequencer_type: erigon - erigon_strict_mode: false - gas_token_enabled: true - zkevm_use_real_verifier: true - enable_normalcy: true - From b9f23ce51d321244e651ac862c03e0f9d3345ea9 Mon Sep 17 00:00:00 2001 From: John Hilliard Date: Thu, 19 Dec 2024 06:58:27 -0500 Subject: [PATCH 28/38] doc: updating attachment script name --- docs/multi-pp-testing/README | 2 +- docs/multi-pp-testing/README.md | 301 +++++++++++++++++++------------- 2 files changed, 178 insertions(+), 125 deletions(-) diff --git a/docs/multi-pp-testing/README b/docs/multi-pp-testing/README index c65cd13a..c171d6df 100755 --- a/docs/multi-pp-testing/README +++ b/docs/multi-pp-testing/README @@ -18,7 +18,7 @@ exit 1; # networks. The secret file here is the same as the normal file but # with an SP1 key kurtosis run --enclave pp --args-file .github/tests/fork12-pessimistic-secret.yml . -kurtosis run --enclave pp --args-file .github/tests/attach-second-cdk.yml . +kurtosis run --enclave pp --args-file .github/tests/attach-second-cdk-pessimistic.yml . # At this point we should be able to confirm that things look right # for both chains. Recently, it seems like the fork id isn't initially diff --git a/docs/multi-pp-testing/README.md b/docs/multi-pp-testing/README.md index 4cc3fcc3..947e2b91 100644 --- a/docs/multi-pp-testing/README.md +++ b/docs/multi-pp-testing/README.md @@ -1,5 +1,5 @@ -```sh +``` #!/bin/bash echo "dont run this!" exit 1; @@ -21,9 +21,9 @@ First we're going to do a Kurtosis run to spin up both of the networks. The secret file here is the same as the normal file but with an SP1 key -```sh +``` kurtosis run --enclave pp --args-file .github/tests/fork12-pessimistic-secret.yml . -kurtosis run --enclave pp --args-file .github/tests/attach-second-cdk.yml . +kurtosis run --enclave pp --args-file .github/tests/attach-second-cdk-pessimistic.yml . ``` At this point we should be able to confirm that things look right @@ -31,7 +31,7 @@ for both chains. Recently, it seems like the fork id isn't initially detected by erigon which is causing the chain not to start up right away. -```sh +``` polycli monitor --rpc-url $(kurtosis port print pp cdk-erigon-rpc-001 rpc) polycli monitor --rpc-url $(kurtosis port print pp cdk-erigon-rpc-002 rpc) ``` @@ -40,7 +40,7 @@ In order to proceed, we'll need to grab the combined files from both chains. We'll specifically want the create rollup parameters file from the second chain because we need to know the gas token address. -```sh +``` kurtosis service exec pp contracts-001 "cat /opt/zkevm/combined-001.json" | tail -n +2 | jq '.' > combined-001.json kurtosis service exec pp contracts-002 "cat /opt/zkevm/combined-002.json" | tail -n +2 | jq '.' > combined-002.json kurtosis service exec pp contracts-002 "cat /opt/zkevm-contracts/deployment/v2/create_rollup_parameters.json" | tail -n +2 | jq -r '.gasTokenAddress' > gas-token-address.json @@ -49,14 +49,14 @@ kurtosis service exec pp contracts-002 "cat /opt/zkevm-contracts/deployment/v2/c This diagnosis isn't critical, but it's nice to confirm that we are using a real verifier. -```sh +``` cast code --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $(cat combined-001.json | jq -r '.verifierAddress') cast code --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $(cat combined-002.json | jq -r '.verifierAddress') ``` Check that the hash of the verifier is actually the sp1 verifier. It should be f33fc6bc90b5ea5e0272a7ab87d701bdd05ecd78b8111ca4f450eeff1e6df26a -```sh +``` kurtosis service exec pp contracts-001 'cat /opt/zkevm-contracts/artifacts/contracts/verifiers/SP1Verifier.sol/SP1Verifier.json' | tail -n +2 | jq -r '.deployedBytecode' | sha256sum cast code --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $(cat combined-001.json | jq -r '.verifierAddress') | sha256sum cast code --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $(cat combined-002.json | jq -r '.verifierAddress') | sha256sum @@ -64,16 +64,16 @@ cast code --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $( It's also worth while probably to confirm that the vkey matches! -```sh +``` kurtosis service exec pp agglayer "agglayer vkey" cast call --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $(cat combined-001.json | jq -r '.polygonRollupManagerAddress') 'rollupTypeMap(uint32)(address,address,uint64,uint8,bool,bytes32,bytes32)' 1 ``` Let's make sure both rollups have the same vkey -```sh -cast call --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $(cat combined-001.json | jq -r '.polygonRollupManagerAddress') 'rollupIDToRollupDataV2(uint32 rollupID)(address,uint64,address,uint64,bytes32,uint64,uint64,uint64,uint64,uint8,bytes32,bytes32)' 1 -cast call --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $(cat combined-001.json | jq -r '.polygonRollupManagerAddress') 'rollupIDToRollupDataV2(uint32 rollupID)(address,uint64,address,uint64,bytes32,uint64,uint64,uint64,uint64,uint8,bytes32,bytes32)' 2 +``` +cast call --json --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $(cat combined-001.json | jq -r '.polygonRollupManagerAddress') 'rollupIDToRollupDataV2(uint32 rollupID)(address,uint64,address,uint64,bytes32,uint64,uint64,uint64,uint64,uint8,bytes32,bytes32)' 1 | jq '.[11]' +cast call --json --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $(cat combined-001.json | jq -r '.polygonRollupManagerAddress') 'rollupIDToRollupDataV2(uint32 rollupID)(address,uint64,address,uint64,bytes32,uint64,uint64,uint64,uint64,uint8,bytes32,bytes32)' 2 | jq '.[11]' ``` At this point, the agglayer config needs to be manually updated for @@ -81,7 +81,7 @@ rollup2. This will add a second entry to the agglayer config. If the second chain is also pessimistic, this isn't strictly necessary, but there's no harm in it. -```sh +``` kurtosis service exec pp agglayer "sed -i 's/\[proof\-signers\]/2 = \"http:\/\/cdk-erigon-rpc-002:8123\"\n\[proof-signers\]/i' /etc/zkevm/agglayer-config.toml" kurtosis service stop pp agglayer kurtosis service start pp agglayer @@ -91,7 +91,7 @@ Let's create a clean EOA for receiving bridges so that we can see things show up. This is a good way to make sure we don't mess things up by trying to exit more than we've deposited -```sh +``` cast wallet new target_address=0xbecE3a31343c6019CDE0D5a4dF2AF8Df17ebcB0f target_private_key=0x51caa196504216b1730280feb63ddd8c5ae194d13e57e58d559f1f1dc3eda7c9 @@ -99,7 +99,7 @@ target_private_key=0x51caa196504216b1730280feb63ddd8c5ae194d13e57e58d559f1f1dc3e Let's setup some variables for future use -```sh +``` private_key="0x12d7de8621a77640c9241b2595ba78ce443d05e94090365ab3bb5e19df82c625" eth_address=$(cast wallet address --private-key $private_key) l1_rpc_url=http://$(kurtosis port print pp el-1-geth-lighthouse rpc) @@ -114,7 +114,7 @@ l2_pp2b_url=$(kurtosis port print pp zkevm-bridge-service-002 rpc) Now let's make sure we have balance everywhere -```sh +``` cast balance --ether --rpc-url $l1_rpc_url $eth_address cast balance --ether --rpc-url $l2_pp1_url $eth_address cast balance --ether --rpc-url $l2_pp2_url $eth_address @@ -126,7 +126,7 @@ from the chain configurations (so either input_parser or the args file). The claim tx manager will automatically perform claims on our behalf for bridge assets -```sh +``` cast send --legacy --value 100ether --rpc-url $l2_pp1_url --private-key $private_key 0x5f5dB0D4D58310F53713eF4Df80ba6717868A9f8 cast send --legacy --value 100ether --rpc-url $l2_pp2_url --private-key $private_key 0x93F63c24735f45Cd0266E87353071B64dd86bc05 ``` @@ -134,13 +134,13 @@ cast send --legacy --value 100ether --rpc-url $l2_pp2_url --private-key $private We should also fund the target address on L1 so that we can use this key for L1 bridge transfers -```sh +``` cast send --value 100ether --rpc-url $l1_rpc_url --private-key $private_key $target_address ``` Let's mint some POL token for testing purpsoes -```sh +``` cast send \ --rpc-url $l1_rpc_url \ --private-key $private_key \ @@ -151,7 +151,7 @@ cast send \ We also need to approve the token so that the bridge can spend it. -```sh +``` cast send \ --rpc-url $l1_rpc_url \ --private-key $private_key \ @@ -162,7 +162,7 @@ cast send \ Let's also mint some of the gas token for our second network -```sh +``` cast send \ --rpc-url $l1_rpc_url \ --private-key $private_key \ @@ -182,7 +182,7 @@ for additional test scenarios. The logic here is that we don't want to send Ether to the target address on L2 because we might risk withdrawing more than we deposit -```sh +``` cast send --rpc-url $l1_rpc_url --private-key $target_private_key $pol_address 'mint(address,uint256)' $target_address 10000000000000000000000 cast send --rpc-url $l1_rpc_url --private-key $target_private_key $pol_address 'approve(address,uint256)' $bridge_address 10000000000000000000000 @@ -196,7 +196,7 @@ is to mix bridges across a few scenarios - Bridge Message vs Bridge Asset - GER Updating -```sh +``` dry_run=false for token_addr in $(cast az) $pol_address $gas_token_address ; do for destination_network in 1 2 ; do @@ -236,7 +236,7 @@ At this point, we should be able to see our bridges in the bridge service for both chains. Recently, with this setup there has been an issue with network id detection in the bridge service -```sh +``` curl -s $l2_pp1b_url/bridges/$target_address | jq '.' curl -s $l2_pp2b_url/bridges/$target_address | jq '.' ``` @@ -246,56 +246,50 @@ be claimed manually. Most of the ones that need to be claimed manually should be `leaf_type` of `1` i.e. a message rather than an asset. -```sh +``` curl -s $l2_pp1b_url/bridges/$target_address | jq '.deposits[] | select(.ready_for_claim) | select(.claim_tx_hash == "")' curl -s $l2_pp2b_url/bridges/$target_address | jq '.deposits[] | select(.ready_for_claim) | select(.claim_tx_hash == "")' ``` We should be able to take these commands and then try to claim each -of the deposits. - -```sh -curl -s $l2_pp1b_url/bridges/$target_address | jq -c '.deposits[] | select(.ready_for_claim) | select(.claim_tx_hash == "")' | while read deposit ; do - polycli ulxly claim message \ - --bridge-address $bridge_address \ - --bridge-service-url $l2_pp1b_url \ - --rpc-url $l2_pp1_url \ - --deposit-count $(echo $deposit | jq -r '.deposit_cnt') \ - --deposit-network $(echo $deposit | jq -r '.orig_net') \ - --destination-address $(echo $deposit | jq -r '.dest_addr') \ - --private-key $private_key -done +of the deposits. This will print out some errors right now because +it's going to try to claim some deposits that are already claimed -curl -s $l2_pp2b_url/bridges/$target_address | jq -c '.deposits[] | select(.ready_for_claim) | select(.claim_tx_hash == "")' | while read deposit ; do - polycli ulxly claim message \ - --bridge-address $bridge_address \ - --bridge-service-url $l2_pp2b_url \ - --rpc-url $l2_pp2_url \ - --deposit-count $(echo $deposit | jq -r '.deposit_cnt') \ - --deposit-network $(echo $deposit | jq -r '.orig_net') \ - --destination-address $(echo $deposit | jq -r '.dest_addr') \ - --private-key $private_key -done +``` +polycli ulxly claim-everything \ + --bridge-address $bridge_address \ + --bridge-service-map 1=$l2_pp1b_url \ + --bridge-service-map 2=$l2_pp2b_url \ + --rpc-url $l2_pp1_url \ + --destination-address $target_address \ + --private-key $private_key +polycli ulxly claim-everything \ + --bridge-address $bridge_address \ + --bridge-service-map 1=$l2_pp1b_url \ + --bridge-service-map 2=$l2_pp2b_url \ + --rpc-url $l2_pp2_url \ + --destination-address $target_address \ + --private-key $private_key ``` Hopefully at this point everything has been claimed on L2. These calls should return empty. -```sh +``` curl -s $l2_pp1b_url/bridges/$target_address | jq '.deposits[] | select(.ready_for_claim) | select(.claim_tx_hash == "")' curl -s $l2_pp2b_url/bridges/$target_address | jq '.deposits[] | select(.ready_for_claim) | select(.claim_tx_hash == "")' ``` Let's see if our balances have grown (both should be non-zero) -```sh +``` cast balance --ether --rpc-url $l2_pp1_url $target_address cast balance --ether --rpc-url $l2_pp2_url $target_address ``` Let's check our L2 Pol token balance (both should be non-zero) -```sh +``` token_hash=$(cast keccak $(cast abi-encode --packed 'f(uint32,address)' 0 $pol_address)) l2_pol_address=$(cast call --rpc-url $l2_pp1_url $bridge_address 'tokenInfoToWrappedToken(bytes32)(address)' $token_hash) cast call --rpc-url $l2_pp1_url $l2_pol_address 'balanceOf(address)(uint256)' $target_address @@ -307,7 +301,7 @@ first network should have a balance because it's treated as ordinary token. The other network should have nothing because the bridge would have been received as a native token. -```sh +``` token_hash=$(cast keccak $(cast abi-encode --packed 'f(uint32,address)' 0 $gas_token_address)) l2_gas_address=$(cast call --rpc-url $l2_pp1_url $bridge_address 'tokenInfoToWrappedToken(bytes32)(address)' $token_hash) cast call --rpc-url $l2_pp1_url $l2_gas_address 'balanceOf(address)(uint256)' $target_address @@ -317,7 +311,7 @@ cast call --rpc-url $l2_pp2_url $l2_gas_address 'balanceOf(address)(uint256)' $t Similarly, we should confirm that on the second network we have some wrapped ETH. -```sh +``` pp2_weth_address=$(cast call --rpc-url $l2_pp2_url $bridge_address 'WETHToken()(address)') cast call --rpc-url $l2_pp2_url $pp2_weth_address 'balanceOf(address)(uint256)' $target_address ``` @@ -333,7 +327,7 @@ it might cause an issue with the agglayer that blocks our tests. Let's try a native bridge from PP1 back to layer one -```sh +``` polycli ulxly bridge asset \ --private-key $target_private_key \ --value $(date +%s) \ @@ -346,7 +340,7 @@ polycli ulxly bridge asset \ Now let's try a native bridge from PP1 back to PP2 -```sh +``` polycli ulxly bridge asset \ --private-key $target_private_key \ --value $(date +%s) \ @@ -360,7 +354,7 @@ polycli ulxly bridge asset \ Neither of these transactions will be claimed automatically. So let's claim them and make sure that works fine. -```sh +``` curl -s $l2_pp1b_url/bridges/$target_address | jq '.deposits[] | select(.ready_for_claim) | select(.claim_tx_hash == "")' deposit_cnt=0 polycli ulxly claim asset \ @@ -380,7 +374,7 @@ network's bridge service. And then we're making the claim against the network 2 RPC. The tricky thing is, the claim tx hash will never show up in the bridge service for this particular tx now. -```sh +``` deposit_cnt=1 polycli ulxly claim asset \ --bridge-address $bridge_address \ @@ -396,7 +390,7 @@ Let's try the same test now, but for PP2. Remember, PP2 is a gas token network, so when we bridge to other networks it should be turned into an ERC20 of some kind. -```sh +``` polycli ulxly bridge asset \ --private-key $target_private_key \ --value $(date +%s) \ @@ -428,7 +422,7 @@ polycli ulxly bridge weth \ Now we should try to claim these transactions again on Layer one and PP1 -```sh +``` curl -s $l2_pp2b_url/bridges/$target_address | jq '.deposits[] | select(.ready_for_claim) | select(.claim_tx_hash == "")' deposit_cnt=0 @@ -472,15 +466,15 @@ every combination of parameters, but as the number of parameters grows, this might become too difficult. I'm using a command like this to generate the test cases. -```sh -pict lxly.pict /f:json | jq -c '.[] | from_entries' | jq -s > test-scenarios.json +``` +pict docs/multi-pp-testing/lxly.pict /f:json | jq -c '.[] | from_entries' | jq -s > test-scenarios.json ``` For the sake of simplicity, I'm going to use the deterministic deployer so that I have the same ERC20 address on each chain. Here I'm adding some funds to the deterministict deployer address. -```sh +``` cast send --legacy --value 0.1ether --rpc-url $l1_rpc_url --private-key $private_key 0x3fab184622dc19b6109349b94811493bf2a45362 cast send --legacy --value 0.1ether --rpc-url $l2_pp1_url --private-key $private_key 0x3fab184622dc19b6109349b94811493bf2a45362 cast send --legacy --value 0.1ether --rpc-url $l2_pp2_url --private-key $private_key 0x3fab184622dc19b6109349b94811493bf2a45362 @@ -488,7 +482,7 @@ cast send --legacy --value 0.1ether --rpc-url $l2_pp2_url --private-key $private The tx data and address are standard for the deterministict deployer -```sh +``` deterministic_deployer_tx=0xf8a58085174876e800830186a08080b853604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf31ba02222222222222222222222222222222222222222222222222222222222222222a02222222222222222222222222222222222222222222222222222222222222222 deterministic_deployer_addr=0x4e59b44847b379578588920ca78fbf26c0b4956c @@ -510,11 +504,7 @@ test_erc20_addr=$(cast create2 --salt $salt --init-code $erc_20_bytecode$constru cast send --legacy --rpc-url $l1_rpc_url --private-key $target_private_key $test_erc20_addr 'approve(address,uint256)' $bridge_address 100000000000000000000 cast send --legacy --rpc-url $l2_pp1_url --private-key $target_private_key $test_erc20_addr 'approve(address,uint256)' $bridge_address 100000000000000000000 cast send --legacy --rpc-url $l2_pp2_url --private-key $target_private_key $test_erc20_addr 'approve(address,uint256)' $bridge_address 100000000000000000000 -``` - -docker run -v $PWD/src:/contracts ethereum/solc:0.7.6 --bin /contracts/tokens/ERC20Buggy.sol -```sh erc20_buggy_bytecode=608060405234801561001057600080fd5b506040516109013803806109018339818101604052606081101561003357600080fd5b810190808051604051939291908464010000000082111561005357600080fd5b90830190602082018581111561006857600080fd5b825164010000000081118282018810171561008257600080fd5b82525081516020918201929091019080838360005b838110156100af578181015183820152602001610097565b50505050905090810190601f1680156100dc5780820380516001836020036101000a031916815260200191505b50604052602001805160405193929190846401000000008211156100ff57600080fd5b90830190602082018581111561011457600080fd5b825164010000000081118282018810171561012e57600080fd5b82525081516020918201929091019080838360005b8381101561015b578181015183820152602001610143565b50505050905090810190601f1680156101885780820380516001836020036101000a031916815260200191505b5060405260209081015185519093506101a792506003918601906101d8565b5081516101bb9060049060208501906101d8565b506005805460ff191660ff92909216919091179055506102799050565b828054600181600116156101000203166002900490600052602060002090601f01602090048101928261020e5760008555610254565b82601f1061022757805160ff1916838001178555610254565b82800160010185558215610254579182015b82811115610254578251825591602001919060010190610239565b50610260929150610264565b5090565b5b808211156102605760008155600101610265565b610679806102886000396000f3fe608060405234801561001057600080fd5b50600436106100b45760003560e01c806370a082311161007157806370a082311461021257806395d89b41146102385780639dc29fac14610240578063a9059cbb1461026c578063b46310f614610298578063dd62ed3e146102c4576100b4565b806306fdde03146100b9578063095ea7b31461013657806318160ddd1461017657806323b872dd14610190578063313ce567146101c657806340c10f19146101e4575b600080fd5b6100c16102f2565b6040805160208082528351818301528351919283929083019185019080838360005b838110156100fb5781810151838201526020016100e3565b50505050905090810190601f1680156101285780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101626004803603604081101561014c57600080fd5b506001600160a01b038135169060200135610380565b604080519115158252519081900360200190f35b61017e6103e6565b60408051918252519081900360200190f35b610162600480360360608110156101a657600080fd5b506001600160a01b038135811691602081013590911690604001356103ec565b6101ce610466565b6040805160ff9092168252519081900360200190f35b610210600480360360408110156101fa57600080fd5b506001600160a01b03813516906020013561046f565b005b61017e6004803603602081101561022857600080fd5b50356001600160a01b031661047d565b6100c161048f565b6102106004803603604081101561025657600080fd5b506001600160a01b0381351690602001356104ea565b6101626004803603604081101561028257600080fd5b506001600160a01b0381351690602001356104f4565b610210600480360360408110156102ae57600080fd5b506001600160a01b03813516906020013561054f565b61017e600480360360408110156102da57600080fd5b506001600160a01b038135811691602001351661056b565b6003805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156103785780601f1061034d57610100808354040283529160200191610378565b820191906000526020600020905b81548152906001019060200180831161035b57829003601f168201915b505050505081565b3360008181526002602090815260408083206001600160a01b038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a350600192915050565b60005481565b6001600160a01b0380841660008181526002602090815260408083203384528252808320805487900390558383526001825280832080548790039055938616808352848320805487019055845186815294519294909392600080516020610624833981519152929181900390910190a35060019392505050565b60055460ff1681565b6104798282610588565b5050565b60016020526000908152604090205481565b6004805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156103785780601f1061034d57610100808354040283529160200191610378565b61047982826105d3565b336000818152600160209081526040808320805486900390556001600160a01b03861680845281842080548701905581518681529151939490939092600080516020610624833981519152928290030190a350600192915050565b6001600160a01b03909116600090815260016020526040902055565b600260209081526000928352604080842090915290825290205481565b6001600160a01b038216600081815260016020908152604080832080548601905582548501835580518581529051600080516020610624833981519152929181900390910190a35050565b6001600160a01b0382166000818152600160209081526040808320805486900390558254859003835580518581529051929392600080516020610624833981519152929181900390910190a3505056feddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa2646970667358221220364a383ccce0e270376267b8631412d1b7ddb1883c5379556b58cbefc1ca504564736f6c63430007060033 constructor_args=$(cast abi-encode 'f(string,string,uint8)' 'Buggy ERC20' 'BUG' "18" | sed 's/0x//') @@ -547,7 +537,7 @@ permit_sig_v=${permit_sig:130:2} The test cases are committed for convenience, we'll use that to dynamically to some testing -```sh +``` cat test-scenarios.json | jq -c '.[]' | while read scenario ; do testBridgeType=$(echo $scenario | jq -r '.BridgeType') testDepositChain=$(echo $scenario | jq -r '.DepositChain') @@ -568,12 +558,16 @@ cat test-scenarios.json | jq -c '.[]' | while read scenario ; do testCommand="$testCommand weth" fi + temp_rpc_url="" if [[ $testDepositChain == "L1" ]]; then testCommand="$testCommand --rpc-url $l1_rpc_url" + temp_rpc_url="$l1_rpc_url" elif [[ $testDepositChain == "PP1" ]]; then testCommand="$testCommand --rpc-url $l2_pp1_url" + temp_rpc_url="$l2_pp1_url" else testCommand="$testCommand --rpc-url $l2_pp2_url" + temp_rpc_url="$l2_pp2_url" fi if [[ $testDestinationChain == "L1" ]]; then @@ -598,8 +592,8 @@ cat test-scenarios.json | jq -c '.[]' | while read scenario ; do testCommand="$testCommand --token-address $test_erc20_addr" elif [[ $testToken == "WETH" ]]; then testCommand="$testCommand --token-address $pp2_weth_address" - elif [[ $testToken == "Invalid" ]]; then - testCommand="$testCommand --token-address $(< /dev/urandom xxd -p | tr -d "\n" | head -c 40)" + elif [[ $testToken == "Buggy" ]]; then + testCommand="$testCommand --token-address $test_erc20_buggy_addr" else testCommand="$testCommand --token-address 0x0000000000000000000000000000000000000000" fi @@ -620,6 +614,10 @@ cat test-scenarios.json | jq -c '.[]' | while read scenario ; do testCommand="$testCommand --value 0" elif [[ $testAmount == "1" ]]; then testCommand="$testCommand --value 1" + elif [[ $testAmount == "Max" ]]; then + cast send --legacy --rpc-url $temp_rpc_url --private-key $target_private_key $test_erc20_buggy_addr 'mint(address,uint256)' $target_address $(cast max-uint) + cast send --legacy --rpc-url $temp_rpc_url --private-key $target_private_key $test_erc20_buggy_addr 'setBalanceOf(address,uint256)' $bridge_address 0 + testCommand="$testCommand --value $(cast max-uint)" else testCommand="$testCommand --value $(date +%s)" fi @@ -630,57 +628,40 @@ cat test-scenarios.json | jq -c '.[]' | while read scenario ; do echo $scenario | jq -c '.' echo $testCommand $testCommand + + # In this particular case, we should zero the bridge out after the deposit is made + if [[ $testAmount == "Max" ]]; then + cast send --legacy --rpc-url $temp_rpc_url --private-key $target_private_key $test_erc20_buggy_addr 'setBalanceOf(address,uint256)' $bridge_address 0 + fi done -curl -s $l2_pp2b_url/bridges/$target_address | jq -c '.deposits[] | select(.network_id == 2) | select(.dest_net == 1)' | while read deposit ; do - echo $deposit | jq -c '.' - leaf_type=$(echo $deposit | jq -r '.leaf_type') - if [[ $leaf_type == "0" ]]; then - polycli ulxly claim asset \ - --bridge-address $bridge_address \ - --bridge-service-url $l2_pp2b_url \ - --rpc-url $l2_pp1_url \ - --deposit-count $(echo $deposit | jq -r '.deposit_cnt') \ - --deposit-network 2 \ - --destination-address $(echo $deposit | jq -r '.dest_addr') \ - --private-key $private_key +polycli ulxly claim-everything \ + --bridge-address $bridge_address \ + --bridge-service-map 1=$l2_pp1b_url \ + --bridge-service-map 2=$l2_pp2b_url \ + --rpc-url $l2_pp1_url \ + --destination-address $target_address \ + --private-key $private_key \ + --bridge-limit 100 - else - polycli ulxly claim message \ - --bridge-address $bridge_address \ - --bridge-service-url $l2_pp2b_url \ - --rpc-url $l2_pp1_url \ - --deposit-count $(echo $deposit | jq -r '.deposit_cnt') \ - --deposit-network 2 \ - --destination-address $(echo $deposit | jq -r '.dest_addr') \ - --private-key $private_key - fi -done -curl -s $l2_pp1b_url/bridges/$target_address | jq -c '.deposits[] | select(.network_id == 1) | select(.dest_net == 2)' | while read deposit ; do - echo $deposit | jq -c '.' - leaf_type=$(echo $deposit | jq -r '.leaf_type') - if [[ $leaf_type == "0" ]]; then - polycli ulxly claim asset \ - --bridge-address $bridge_address \ - --bridge-service-url $l2_pp1b_url \ - --rpc-url $l2_pp2_url \ - --deposit-count $(echo $deposit | jq -r '.deposit_cnt') \ - --deposit-network 1 \ - --destination-address $(echo $deposit | jq -r '.dest_addr') \ - --private-key $private_key +polycli ulxly claim-everything \ + --bridge-address $bridge_address \ + --bridge-service-map 1=$l2_pp1b_url \ + --bridge-service-map 2=$l2_pp2b_url \ + --rpc-url $l2_pp2_url \ + --destination-address $target_address \ + --private-key $private_key \ + --bridge-limit 100 - else - polycli ulxly claim message \ - --bridge-address $bridge_address \ - --bridge-service-url $l2_pp1b_url \ - --rpc-url $l2_pp2_url \ - --deposit-count $(echo $deposit | jq -r '.deposit_cnt') \ - --deposit-network 1 \ - --destination-address $(echo $deposit | jq -r '.dest_addr') \ - --private-key $private_key - fi -done +polycli ulxly claim-everything \ + --bridge-address $bridge_address \ + --bridge-service-map 1=$l2_pp1b_url \ + --bridge-service-map 2=$l2_pp2b_url \ + --rpc-url $l1_rpc_url \ + --destination-address $target_address \ + --private-key $private_key \ + --bridge-limit 100 ``` ## Buggy ERC 20 @@ -697,7 +678,7 @@ assumes we've already minted some Repeat that a few times just to make sure everything is okay. The commands below are for doing tests from PP1 to PP2 -```sh +``` polycli ulxly bridge asset \ --private-key $target_private_key \ --value 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe \ @@ -714,7 +695,7 @@ cast send --legacy --rpc-url $l2_pp1_url --private-key $target_private_key $test These commands do the same thing more or less but from PP2 to PP1 -```sh +``` polycli ulxly bridge asset \ --private-key $target_private_key \ --value 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe \ @@ -727,7 +708,23 @@ polycli ulxly bridge asset \ cast send --legacy --rpc-url $l2_pp2_url --private-key $target_private_key $test_erc20_buggy_addr 'mint(address,uint256)' $target_address $(cast max-uint) cast send --legacy --rpc-url $l2_pp2_url --private-key $target_private_key $test_erc20_buggy_addr 'setBalanceOf(address,uint256)' $bridge_address 0 +``` + +Then do the same thing for PP2 to L1 +``` +polycli ulxly bridge asset \ + --private-key $target_private_key \ + --value 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe \ + --bridge-address $bridge_address \ + --destination-network 0 \ + --destination-address $target_address \ + --rpc-url $l2_pp2_url \ + --token-address $test_erc20_buggy_addr \ + --force-update-root=true + +cast send --legacy --rpc-url $l2_pp2_url --private-key $target_private_key $test_erc20_buggy_addr 'mint(address,uint256)' $target_address $(cast max-uint) +cast send --legacy --rpc-url $l2_pp2_url --private-key $target_private_key $test_erc20_buggy_addr 'setBalanceOf(address,uint256)' $bridge_address 0 curl -s $l2_pp1b_url/bridges/$target_address ``` @@ -736,7 +733,7 @@ curl -s $l2_pp1b_url/bridges/$target_address The idea here is to do some transactions through a proxy or some kind so -```sh +``` lxly_proxy_bytecode=608060405234801561001057600080fd5b50604051610acb380380610acb83398101604081905261002f91610054565b600080546001600160a01b0319166001600160a01b0392909216919091179055610084565b60006020828403121561006657600080fd5b81516001600160a01b038116811461007d57600080fd5b9392505050565b610a38806100936000396000f3fe6080604052600436106100955760003560e01c8063b8b284d011610059578063b8b284d014610196578063ccaa2d11146101c9578063cd586579146101e9578063dd96eab7146101fc578063f5efcd79146101fc57610116565b80631c253d72146101965780631eb5f7aa146101b6578063240ff378146101b65780632c4422ca146101c95780635ea89907146101e957610116565b366101165760008054604051630481fe6f60e31b815263ffffffff34166004820152336024820152600160448201526080606482015260848101929092526001600160a01b03169063240ff3789060a401600060405180830381600087803b15801561010057600080fd5b505af1158015610114573d6000803e3d6000fd5b005b60008054604051630481fe6f60e31b815236916060916001600160a01b039091169063240ff37890610155903490339060019089908990600401610436565b600060405180830381600087803b15801561016f57600080fd5b505af1158015610183573d6000803e3d6000fd5b5050604080516020810190915260009052005b3480156101a257600080fd5b506101146101b136600461056f565b61021c565b6101146101c43660046105e8565b61028d565b3480156101d557600080fd5b506101146101e43660046106c5565b6102fb565b6101146101f7366004610799565b61037e565b34801561020857600080fd5b506101146102173660046106c5565b6103f2565b600054604051630b8b284d60e41b81526001600160a01b039091169063b8b284d0906102549088908890889088908890600401610867565b600060405180830381600087803b15801561026e57600080fd5b505af1158015610282573d6000803e3d6000fd5b505050505050505050565b600054604051630481fe6f60e31b81526001600160a01b039091169063240ff378906102c39087908790879087906004016108ad565b600060405180830381600087803b1580156102dd57600080fd5b505af11580156102f1573d6000803e3d6000fd5b5050505050505050565b60005460405163ccaa2d1160e01b81526001600160a01b039091169063ccaa2d119061033f908e908e908e908e908e908e908e908e908e908e908e9060040161091c565b600060405180830381600087803b15801561035957600080fd5b505af115801561036d573d6000803e3d6000fd5b505050505050505050505050505050565b60005460405163cd58657960e01b81526001600160a01b039091169063cd586579906103b8908990899089908990899089906004016109af565b600060405180830381600087803b1580156103d257600080fd5b505af11580156103e6573d6000803e3d6000fd5b50505050505050505050565b60005460405163f5efcd7960e01b81526001600160a01b039091169063f5efcd799061033f908e908e908e908e908e908e908e908e908e908e908e9060040161091c565b63ffffffff861681526001600160a01b038516602082015283151560408201526080606082018190528101829052818360a0830137600081830160a090810191909152601f909201601f19160101949350505050565b803563ffffffff811681146104a057600080fd5b919050565b80356001600160a01b03811681146104a057600080fd5b803580151581146104a057600080fd5b634e487b7160e01b600052604160045260246000fd5b600082601f8301126104f357600080fd5b813567ffffffffffffffff8082111561050e5761050e6104cc565b604051601f8301601f19908116603f01168101908282118183101715610536576105366104cc565b8160405283815286602085880101111561054f57600080fd5b836020870160208301376000602085830101528094505050505092915050565b600080600080600060a0868803121561058757600080fd5b6105908661048c565b945061059e602087016104a5565b9350604086013592506105b3606087016104bc565b9150608086013567ffffffffffffffff8111156105cf57600080fd5b6105db888289016104e2565b9150509295509295909350565b600080600080608085870312156105fe57600080fd5b6106078561048c565b9350610615602086016104a5565b9250610623604086016104bc565b9150606085013567ffffffffffffffff81111561063f57600080fd5b61064b878288016104e2565b91505092959194509250565b600082601f83011261066857600080fd5b60405161040080820182811067ffffffffffffffff8211171561068d5761068d6104cc565b604052830181858211156106a057600080fd5b845b828110156106ba5780358252602091820191016106a2565b509195945050505050565b60008060008060008060008060008060006109208c8e0312156106e757600080fd5b6106f18d8d610657565b9a506107018d6104008e01610657565b99506108008c013598506108208c013597506108408c013596506107286108608d0161048c565b95506107376108808d016104a5565b94506107466108a08d0161048c565b93506107556108c08d016104a5565b92506108e08c013591506109008c013567ffffffffffffffff81111561077a57600080fd5b6107868e828f016104e2565b9150509295989b509295989b9093969950565b60008060008060008060c087890312156107b257600080fd5b6107bb8761048c565b95506107c9602088016104a5565b9450604087013593506107de606088016104a5565b92506107ec608088016104bc565b915060a087013567ffffffffffffffff81111561080857600080fd5b61081489828a016104e2565b9150509295509295509295565b6000815180845260005b818110156108475760208185018101518683018201520161082b565b506000602082860101526020601f19601f83011685010191505092915050565b63ffffffff8616815260018060a01b0385166020820152836040820152821515606082015260a0608082015260006108a260a0830184610821565b979650505050505050565b63ffffffff851681526001600160a01b038416602082015282151560408201526080606082018190526000906108e590830184610821565b9695505050505050565b8060005b60208082106109025750610916565b8251855293840193909101906001016108f3565b50505050565b600061092061092b838f6108ef565b61093961040084018e6108ef565b61080083018c905261082083018b905261084083018a905263ffffffff8981166108608501526001600160a01b038981166108808601529088166108a085015286166108c08401526108e08301859052610900830181905261099d81840185610821565b9e9d5050505050505050505050505050565b63ffffffff871681526001600160a01b0386811660208301526040820186905284166060820152821515608082015260c060a082018190526000906109f690830184610821565b9897505050505050505056fea2646970667358221220b86e525972f2e2cc9d33328df79fceaa11e88478f9966dde327eeec360259b4964736f6c63430008140033 constructor_args=$(cast abi-encode 'f(address)' $bridge_address | sed 's/0x//') @@ -757,16 +754,25 @@ testing. You might not have this. The idea is to call the bridge contract from a bunch of contexts and ensure that things more or less still work -```sh -tester_contract_address=0xfBE07a394847c26b1d998B6e44EE78A9C8191f13 +``` +tester_contract_address=0xc54E34B55EF562FE82Ca858F70D1B73244e86388 +``` address_tester_actions="001 002 003 004 011 012 013 014 021 022 023 024 031 032 033 034 041 042 043 044 101 201 301 401 501 601 701 801 901" +``` +address_tester_actions="001 011 021 031 041 101 201 301 401 501 601 701 801 901" + for create_mode in 0 1 2; do for action in $address_tester_actions ; do - cast send --legacy --value 1 --rpc-url $l1_rpc_url --private-key $target_private_key $tester_contract_address $(cast abi-encode 'f(uint32, address, uint256)' 0x"$create_mode$action" $test_lxly_proxy_addr 1) - cast send --legacy --value 2 --rpc-url $l2_pp1_url --private-key $target_private_key $tester_contract_address $(cast abi-encode 'f(uint32, address, uint256)' 0x"$create_mode$action" $test_lxly_proxy_addr 2) - cast send --legacy --value 1 --rpc-url $l2_pp2_url --private-key $target_private_key $tester_contract_address $(cast abi-encode 'f(uint32, address, uint256)' 0x"$create_mode$action" $test_lxly_proxy_addr 1) + cast send --gas-limit 1000000 --legacy --value 1 --rpc-url $l1_rpc_url --private-key $target_private_key $tester_contract_address $(cast abi-encode 'f(uint32, address, uint256)' 0x"$create_mode$action" $test_lxly_proxy_addr 1) + cast send --gas-limit 1000000 --legacy --value 2 --rpc-url $l1_rpc_url --private-key $target_private_key $tester_contract_address $(cast abi-encode 'f(uint32, address, uint256)' 0x"$create_mode$action" $test_lxly_proxy_addr 2) + + cast send --gas-limit 1000000 --legacy --value 0 --rpc-url $l2_pp1_url --private-key $target_private_key $tester_contract_address $(cast abi-encode 'f(uint32, address, uint256)' 0x"$create_mode$action" $test_lxly_proxy_addr 0) + cast send --gas-limit 1000000 --legacy --value 2 --rpc-url $l2_pp1_url --private-key $target_private_key $tester_contract_address $(cast abi-encode 'f(uint32, address, uint256)' 0x"$create_mode$action" $test_lxly_proxy_addr 2) + + cast send --gas-limit 1000000 --legacy --value 0 --rpc-url $l2_pp2_url --private-key $target_private_key $tester_contract_address $(cast abi-encode 'f(uint32, address, uint256)' 0x"$create_mode$action" $test_lxly_proxy_addr 0) + cast send --gas-limit 1000000 --legacy --value 1 --rpc-url $l2_pp2_url --private-key $target_private_key $tester_contract_address $(cast abi-encode 'f(uint32, address, uint256)' 0x"$create_mode$action" $test_lxly_proxy_addr 1) done done ``` @@ -775,9 +781,52 @@ TODO add a test where there is more than uint256 funds TODO add some tests with reverting TODO add some tests where the bridge is called via a smart contract rather than directly TODO add a scneario that does a full sweep of the target account native token and the end to ensure all of the accounting looks good + +``` +cast send --legacy --gas-limit 1000000 --value 2 --rpc-url $l2_pp1_url --private-key $target_private_key $tester_contract_address $(cast abi-encode 'f(uint32, address, uint256)' 0x0201 $test_lxly_proxy_addr 2) + +polycli ulxly claim-everything \ + --bridge-address $bridge_address \ + --bridge-service-map 1=$l2_pp1b_url \ + --bridge-service-map 2=$l2_pp2b_url \ + --destination-address $target_address \ + --private-key $target_private_key \ + --rpc-url $l2_pp1_url \ + --bridge-limit 100 + +polycli ulxly claim-everything \ + --bridge-address $bridge_address \ + --bridge-service-map 1=$l2_pp1b_url \ + --bridge-service-map 2=$l2_pp2b_url \ + --destination-address $target_address \ + --private-key $target_private_key \ + --rpc-url $l2_pp2_url \ + --bridge-limit 100 + +polycli ulxly claim-everything \ + --bridge-address $bridge_address \ + --bridge-service-map 1=$l2_pp1b_url \ + --bridge-service-map 2=$l2_pp2b_url \ + --destination-address $target_address \ + --private-key $target_private_key \ + --rpc-url $l1_rpc_url \ + --bridge-limit 100 + +curl -s "$l2_pp1b_url/bridges/0xbecE3a31343c6019CDE0D5a4dF2AF8Df17ebcB0f?limit=150" | jq '.deposits[] | select(.deposit_cnt == 111)' +curl -s "$l2_pp1b_url/merkle-proof?deposit_cnt=111&net_id=0" | jq '.' +curl -s "$l2_pp1b_url/merkle-proof?deposit_cnt=111&net_id=1" | jq '.' +curl -s "$l2_pp1b_url/merkle-proof?deposit_cnt=111&net_id=2" | jq '.' + +curl -s "$l2_pp2b_url/bridges/0xbecE3a31343c6019CDE0D5a4dF2AF8Df17ebcB0f?limit=150" | jq '.deposits[] | select(.tx_hash == "0x932945c01362a5e121405b6bf38b14da8b6ddeee253732cdf362be74b455bea8")' +curl -s "$l2_pp2b_url/bridges/0xbecE3a31343c6019CDE0D5a4dF2AF8Df17ebcB0f?limit=150" | jq '.deposits[] | select(.deposit_cnt == 111)' +curl -s "$l2_pp2b_url/merkle-proof?deposit_cnt=111&net_id=0" | jq '.' +curl -s "$l2_pp2b_url/merkle-proof?deposit_cnt=111&net_id=1" | jq '.' +curl -s "$l2_pp2b_url/merkle-proof?deposit_cnt=111&net_id=2" | jq '.' +``` + ## State Capture Procedure -```sh +``` pushd $(mktemp -d) mkdir agglayer-storage docker cp agglayer--f3cc4c8d0bad44be9c0ea8eccedd0da1:/etc/zkevm/storage agglayer-storage/ @@ -791,3 +840,7 @@ popd tar caf agglayer-details.tar.xz /tmp/tmp.VKezDefjS6 ``` +drop table public.gorp_migrations; +drop schema sync cascade; +drop schema mt cascade; +delete from sync.claim where index = '14' and rollup_index = 0 and network_id = 2; From 8f001e9bfef19412c365d6acf4f70c2dad32af89 Mon Sep 17 00:00:00 2001 From: John Hilliard Date: Thu, 19 Dec 2024 11:19:38 -0500 Subject: [PATCH 29/38] docs: re-working docs for 3 networks --- docs/multi-pp-testing/README | 60 ++++++++++++++++++++++++++++------ docs/multi-pp-testing/net1.yml | 11 +++++++ docs/multi-pp-testing/net2.yml | 36 ++++++++++++++++++++ docs/multi-pp-testing/net3.yml | 31 ++++++++++++++++++ input_parser.star | 4 +-- 5 files changed, 130 insertions(+), 12 deletions(-) create mode 100644 docs/multi-pp-testing/net1.yml create mode 100644 docs/multi-pp-testing/net2.yml create mode 100644 docs/multi-pp-testing/net3.yml diff --git a/docs/multi-pp-testing/README b/docs/multi-pp-testing/README index c171d6df..09c5d71b 100755 --- a/docs/multi-pp-testing/README +++ b/docs/multi-pp-testing/README @@ -17,7 +17,9 @@ exit 1; # First we're going to do a Kurtosis run to spin up both of the # networks. The secret file here is the same as the normal file but # with an SP1 key -kurtosis run --enclave pp --args-file .github/tests/fork12-pessimistic-secret.yml . +kurtosis run --enclave pp --args-file docs/multi-pp-testing/net1.yml . +kurtosis run --enclave pp --args-file docs/multi-pp-testing/net2.yml . +kurtosis run --enclave pp --args-file docs/multi-pp-testing/net3.yml . kurtosis run --enclave pp --args-file .github/tests/attach-second-cdk-pessimistic.yml . # At this point we should be able to confirm that things look right @@ -26,6 +28,7 @@ kurtosis run --enclave pp --args-file .github/tests/attach-second-cdk-pessimisti # away. polycli monitor --rpc-url $(kurtosis port print pp cdk-erigon-rpc-001 rpc) polycli monitor --rpc-url $(kurtosis port print pp cdk-erigon-rpc-002 rpc) +polycli monitor --rpc-url $(kurtosis port print pp cdk-erigon-rpc-003 rpc) # In order to proceed, we'll need to grab the combined files from both # chains. We'll specifically want the create rollup parameters file @@ -33,6 +36,7 @@ polycli monitor --rpc-url $(kurtosis port print pp cdk-erigon-rpc-002 rpc) kurtosis service exec pp contracts-001 "cat /opt/zkevm/combined-001.json" | tail -n +2 | jq '.' > combined-001.json kurtosis service exec pp contracts-002 "cat /opt/zkevm/combined-002.json" | tail -n +2 | jq '.' > combined-002.json kurtosis service exec pp contracts-002 "cat /opt/zkevm-contracts/deployment/v2/create_rollup_parameters.json" | tail -n +2 | jq -r '.gasTokenAddress' > gas-token-address.json +kurtosis service exec pp contracts-003 "cat /opt/zkevm/combined-003.json" | tail -n +2 | jq '.' > combined-003.json # This diagnosis isn't critical, but it's nice to confirm that we are # using a real verifier. @@ -44,6 +48,9 @@ kurtosis service exec pp contracts-001 'cat /opt/zkevm-contracts/artifacts/contr cast code --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $(cat combined-001.json | jq -r '.verifierAddress') | sha256sum cast code --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $(cat combined-002.json | jq -r '.verifierAddress') | sha256sum +# The third network here should use a mock verifier and should be different +cast code --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $(cat combined-003.json | jq -r '.verifierAddress') | sha256sum + # It's also worth while probably to confirm that the vkey matches! kurtosis service exec pp agglayer "agglayer vkey" cast call --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $(cat combined-001.json | jq -r '.polygonRollupManagerAddress') 'rollupTypeMap(uint32)(address,address,uint64,uint8,bool,bytes32,bytes32)' 1 @@ -52,12 +59,12 @@ cast call --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $( cast call --json --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $(cat combined-001.json | jq -r '.polygonRollupManagerAddress') 'rollupIDToRollupDataV2(uint32 rollupID)(address,uint64,address,uint64,bytes32,uint64,uint64,uint64,uint64,uint8,bytes32,bytes32)' 1 | jq '.[11]' cast call --json --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $(cat combined-001.json | jq -r '.polygonRollupManagerAddress') 'rollupIDToRollupDataV2(uint32 rollupID)(address,uint64,address,uint64,bytes32,uint64,uint64,uint64,uint64,uint8,bytes32,bytes32)' 2 | jq '.[11]' - # At this point, the agglayer config needs to be manually updated for # rollup2. This will add a second entry to the agglayer config. If the # second chain is also pessimistic, this isn't strictly necessary, but # there's no harm in it. kurtosis service exec pp agglayer "sed -i 's/\[proof\-signers\]/2 = \"http:\/\/cdk-erigon-rpc-002:8123\"\n\[proof-signers\]/i' /etc/zkevm/agglayer-config.toml" +kurtosis service exec pp agglayer "sed -i 's/\[proof\-signers\]/3 = \"http:\/\/cdk-erigon-rpc-003:8123\"\n\[proof-signers\]/i' /etc/zkevm/agglayer-config.toml" kurtosis service stop pp agglayer kurtosis service start pp agglayer @@ -74,16 +81,19 @@ eth_address=$(cast wallet address --private-key $private_key) l1_rpc_url=http://$(kurtosis port print pp el-1-geth-lighthouse rpc) l2_pp1_url=$(kurtosis port print pp cdk-erigon-rpc-001 rpc) l2_pp2_url=$(kurtosis port print pp cdk-erigon-rpc-002 rpc) +l2_fep_url=$(kurtosis port print pp cdk-erigon-rpc-003 rpc) bridge_address=$(cat combined-001.json | jq -r .polygonZkEVMBridgeAddress) pol_address=$(cat combined-001.json | jq -r .polTokenAddress) gas_token_address=$( Date: Thu, 19 Dec 2024 11:23:13 -0500 Subject: [PATCH 30/38] should not work --- docs/multi-pp-testing/net1.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/multi-pp-testing/net1.yml b/docs/multi-pp-testing/net1.yml index 801465b0..ec1f8cf7 100644 --- a/docs/multi-pp-testing/net1.yml +++ b/docs/multi-pp-testing/net1.yml @@ -7,5 +7,5 @@ args: gas_token_enabled: false zkevm_use_real_verifier: true enable_normalcy: true - agglayer_prover_sp1_key: + agglayer_prover_sp1_key: bepp # DONOTCOMMIT From 4cb7bf524ea07f7d18f56320f99d60a1a3504f1a Mon Sep 17 00:00:00 2001 From: John Hilliard Date: Thu, 19 Dec 2024 13:02:04 -0500 Subject: [PATCH 31/38] feat: adding debug mode --- docs/multi-pp-testing/README | 25 ++++++++++----------- templates/bridge-infra/agglayer-config.toml | 2 ++ 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/docs/multi-pp-testing/README b/docs/multi-pp-testing/README index 09c5d71b..5cfcb97b 100755 --- a/docs/multi-pp-testing/README +++ b/docs/multi-pp-testing/README @@ -6,21 +6,20 @@ exit 1; # # ## Infra Setup # -# This is an example of a system where there are two PP chains -# attached to the rollup manager. One chain uses a gas token and the -# other does not. Between those two chains we're going to attempt a -# bunch of bridge scenarios. +# This is an example of a system where there are two PP chains and one +# FEP chain attached to the rollup manager. One chain uses a gas token +# and the others do not. Between those three chains we're going to +# attempt a bunch of bridge scenarios. # # To run this stuff you'll want to run most of these commands from # within the kurtosis-cdk repo root. # -# First we're going to do a Kurtosis run to spin up both of the -# networks. The secret file here is the same as the normal file but -# with an SP1 key +# First we're going to do a Kurtosis run to spin up the networks. If +# you're going to run this you *need an SP1 key* in the `net1.yml` +# file. kurtosis run --enclave pp --args-file docs/multi-pp-testing/net1.yml . kurtosis run --enclave pp --args-file docs/multi-pp-testing/net2.yml . kurtosis run --enclave pp --args-file docs/multi-pp-testing/net3.yml . -kurtosis run --enclave pp --args-file .github/tests/attach-second-cdk-pessimistic.yml . # At this point we should be able to confirm that things look right # for both chains. Recently, it seems like the fork id isn't initially @@ -142,11 +141,11 @@ cast send \ # for additional test scenarios. The logic here is that we don't want # to send Ether to the target address on L2 because we might risk # withdrawing more than we deposit -cast send --rpc-url $l1_rpc_url --private-key $target_private_key $pol_address 'mint(address,uint256)' $target_address 10000000000000000000000 -cast send --rpc-url $l1_rpc_url --private-key $target_private_key $pol_address 'approve(address,uint256)' $bridge_address 10000000000000000000000 +cast send --rpc-url $l1_rpc_url --private-key $private_key $pol_address 'mint(address,uint256)' $target_address 10000000000000000000000 +cast send --rpc-url $l1_rpc_url --private-key $private_key $pol_address 'approve(address,uint256)' $bridge_address 10000000000000000000000 -cast send --rpc-url $l1_rpc_url --private-key $target_private_key $gas_token_address 'mint(address,uint256)' $target_address 10000000000000000000000 -cast send --rpc-url $l1_rpc_url --private-key $target_private_key $gas_token_address 'approve(address,uint256)' $bridge_address 10000000000000000000000 +cast send --rpc-url $l1_rpc_url --private-key $private_key $gas_token_address 'mint(address,uint256)' $target_address 10000000000000000000000 +cast send --rpc-url $l1_rpc_url --private-key $private_key $gas_token_address 'approve(address,uint256)' $bridge_address 10000000000000000000000 # We're going to do a little matrix of L1 to L2 bridges here. The idea # is to mix bridges across a few scenarios @@ -301,7 +300,7 @@ polycli ulxly bridge asset \ --private-key $target_private_key \ --value $(date +%s) \ --bridge-address $bridge_address \ - --destination-network 2 \ + --destination-network 3 \ --destination-address $target_address \ --force-update-root=true \ --rpc-url $l2_pp1_url diff --git a/templates/bridge-infra/agglayer-config.toml b/templates/bridge-infra/agglayer-config.toml index d1fa7b45..51da9b10 100644 --- a/templates/bridge-infra/agglayer-config.toml +++ b/templates/bridge-infra/agglayer-config.toml @@ -1,4 +1,5 @@ prover-entrypoint = "{{.agglayer_prover_entrypoint}}" +debug-mode = true [full-node-rpcs] # TODO switch this to permissionless @@ -78,3 +79,4 @@ input-backpressure-buffer-size = 1000 [storage] db-path = "/etc/zkevm/storage" + From 605b1d2b8e46ede8bfe178a524a888f216e88184 Mon Sep 17 00:00:00 2001 From: John Hilliard Date: Thu, 19 Dec 2024 17:10:50 -0500 Subject: [PATCH 32/38] docs: latest docs --- docs/multi-pp-testing/README | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/multi-pp-testing/README b/docs/multi-pp-testing/README index 5cfcb97b..7d381bf0 100755 --- a/docs/multi-pp-testing/README +++ b/docs/multi-pp-testing/README @@ -38,9 +38,10 @@ kurtosis service exec pp contracts-002 "cat /opt/zkevm-contracts/deployment/v2/c kurtosis service exec pp contracts-003 "cat /opt/zkevm/combined-003.json" | tail -n +2 | jq '.' > combined-003.json # This diagnosis isn't critical, but it's nice to confirm that we are -# using a real verifier. +# using a real verifier for the PP networks and mock for the FEP. cast code --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $(cat combined-001.json | jq -r '.verifierAddress') cast code --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $(cat combined-002.json | jq -r '.verifierAddress') +cast code --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $(cat combined-003.json | jq -r '.verifierAddress') # Check that the hash of the verifier is actually the sp1 verifier. It should be f33fc6bc90b5ea5e0272a7ab87d701bdd05ecd78b8111ca4f450eeff1e6df26a kurtosis service exec pp contracts-001 'cat /opt/zkevm-contracts/artifacts/contracts/verifiers/SP1Verifier.sol/SP1Verifier.json' | tail -n +2 | jq -r '.deployedBytecode' | sha256sum @@ -52,7 +53,6 @@ cast code --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $( # It's also worth while probably to confirm that the vkey matches! kurtosis service exec pp agglayer "agglayer vkey" -cast call --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $(cat combined-001.json | jq -r '.polygonRollupManagerAddress') 'rollupTypeMap(uint32)(address,address,uint64,uint8,bool,bytes32,bytes32)' 1 # Let's make sure both rollups have the same vkey cast call --json --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $(cat combined-001.json | jq -r '.polygonRollupManagerAddress') 'rollupIDToRollupDataV2(uint32 rollupID)(address,uint64,address,uint64,bytes32,uint64,uint64,uint64,uint64,uint8,bytes32,bytes32)' 1 | jq '.[11]' @@ -748,6 +748,8 @@ mkdir cdk-001 docker cp cdk-node-001--bd52b030071a4c438cf82b6c281219e6:/tmp cdk-001/ mkdir cdk-002 docker cp cdk-node-002--3c9a92d0e1aa4259a795d7a60156188c:/tmp cdk-002/ +mkdir cdk-003 +docker cp cdk-node-003--60ace3d2425e43df8f0da4f8058d97f9:/tmp cdk-003/ kurtosis enclave dump pp popd From f344f3a24f68af26185f079a606abc5077db4200 Mon Sep 17 00:00:00 2001 From: John Hilliard Date: Thu, 19 Dec 2024 23:03:14 -0500 Subject: [PATCH 33/38] feat: latest docs --- docs/multi-pp-testing/README | 29 +++++++++++++++++++++++++---- docs/multi-pp-testing/lxly.pict | 10 +++++----- docs/network-ops.org | 17 +++++++++++++++++ input_parser.star | 2 +- 4 files changed, 48 insertions(+), 10 deletions(-) diff --git a/docs/multi-pp-testing/README b/docs/multi-pp-testing/README index 7d381bf0..86dd6a0f 100755 --- a/docs/multi-pp-testing/README +++ b/docs/multi-pp-testing/README @@ -305,7 +305,7 @@ polycli ulxly bridge asset \ --force-update-root=true \ --rpc-url $l2_pp1_url -# Neither of these transactions will be claimed automatically. So +# None of these transactions will be claimed automatically. So # let's claim them and make sure that works fine. curl -s $l2_pp1b_url/bridges/$target_address | jq '.deposits[] | select(.ready_for_claim) | select(.claim_tx_hash == "")' deposit_cnt=0 @@ -334,6 +334,16 @@ polycli ulxly claim asset \ --destination-address $target_address \ --private-key $private_key +deposit_cnt=2 +polycli ulxly claim asset \ + --bridge-address $bridge_address \ + --bridge-service-url $l2_pp1b_url \ + --rpc-url $l2_fep_url \ + --deposit-count $deposit_cnt \ + --deposit-network 1 \ + --destination-address $target_address \ + --private-key $private_key + # Let's try the same test now, but for PP2. Remember, PP2 is a gas # token network, so when we bridge to other networks it should be @@ -360,12 +370,13 @@ polycli ulxly bridge weth \ --private-key $target_private_key \ --value $(date +%s) \ --bridge-address $bridge_address \ - --destination-network 1 \ + --destination-network 3 \ --destination-address $target_address \ --force-update-root=true \ --token-address $pp2_weth_address \ --rpc-url $l2_pp2_url + # Now we should try to claim these transactions again on Layer one and PP1 curl -s $l2_pp2b_url/bridges/$target_address | jq '.deposits[] | select(.ready_for_claim) | select(.claim_tx_hash == "")' @@ -393,7 +404,7 @@ deposit_cnt=2 polycli ulxly claim message \ --bridge-address $bridge_address \ --bridge-service-url $l2_pp2b_url \ - --rpc-url $l2_pp1_url \ + --rpc-url $l2_fep_url \ --deposit-count $deposit_cnt \ --deposit-network 2 \ --destination-address $target_address \ @@ -401,7 +412,17 @@ polycli ulxly claim message \ cast call --rpc-url $l1_rpc_url $bridge_address 'depositCount() external view returns (uint256)' -# ## Pict Based Test Scenarios +# There are some more advanced test cases in the init.sh script and +# run.sh script in this folder + + + + + + + + +## Pict Based Test Scenarios # # The goal here is to have some methods for creating more robust # testing combinations. In theory, we can probably brute force test diff --git a/docs/multi-pp-testing/lxly.pict b/docs/multi-pp-testing/lxly.pict index 1b6f831c..0ec3a44f 100644 --- a/docs/multi-pp-testing/lxly.pict +++ b/docs/multi-pp-testing/lxly.pict @@ -1,14 +1,15 @@ # pict lxly.pict /f:json | jq -c '.[] | from_entries' -DepositChain : L1, PP1 (2), PP2 (2) -DestinationChain : L1, PP1, PP2 +DepositChain : L1, PP1, PP2, FEP +DestinationChain : L1, PP1, PP2, FEP DestinationAddress : EOA, Contract, Precompile BridgeType : Asset, Message, Weth -Token : NativeEther, LocalERC20, POL, Buggy, WETH +Token : NativeEther, LocalERC20, Buggy, WETH, GasToken MetaData : 0x, Random ForceUpdate : True (4), False Amount : 0, 1, Random, Max IF [DepositChain] = "L1" THEN [DestinationChain] <> "L1"; +IF [DepositChain] = "FEP" THEN [DestinationChain] <> "FEP"; IF [DepositChain] = "PP1" THEN [DestinationChain] <> "PP1"; IF [DepositChain] = "PP2" THEN [DestinationChain] <> "PP2"; IF [DepositChain] = "PP2" AND [BridgeType] = "Message" THEN [Amount] = "0"; @@ -17,9 +18,8 @@ IF [BridgeType] = "Message" THEN [Token] = "NativeEther"; IF [BridgeType] = "Weth" THEN [Token] = "WETH"; -IF [Token] = "POL" THEN [DepositChain] = "L1"; IF [Token] = "WETH" THEN [DepositChain] = "PP2"; -IF [Token] = "LocalERC20" OR [Token] = "WETH" OR [Token] = "POL" OR [Token] = "Buggy" THEN [MetaData] = "0x"; +IF [Token] = "LocalERC20" OR [Token] = "WETH" OR [Token] = "GasToken" OR [Token] = "Buggy" THEN [MetaData] = "0x"; IF [Amount] = "Max" THEN [Token] = "Buggy"; diff --git a/docs/network-ops.org b/docs/network-ops.org index 3c4dbc7f..bb45b502 100644 --- a/docs/network-ops.org +++ b/docs/network-ops.org @@ -85,3 +85,20 @@ Now I have the interface name ~br-edd588fc6880~ and I can use that for https://github.com/torvalds/linux/blob/55027e689933ba2e64f3d245fb1ff185b3e7fc81/Documentation/ABI/testing/sysfs-class-net#L188-L207 +* MITM + +#+begin_src bash +# start mitmproxy +docker run --name mitmproxy --rm -it -v ~/.mitmproxy:/home/mitmproxy/.mitmproxy --network kt-pp mitmproxy/mitmproxy mitmproxy -p 443 --mode reverse:https://target.whatever + +# copy to the ca to the container you want to intercept +docker cp ~/.mitmproxy/mitmproxy-ca.pem agglayer-prover--0072a38be52544f190d6e7addd236ca8:/usr/local/share/ca-certificates/mitm.crt + +# update the certs (assuming this is all installed) +docker exec agglayer-prover--0072a38be52544f190d6e7addd236ca8 update-ca-certificates + +# add an entry in the /etc/hosts file +# mitmip target.wahter +1.2.3.4 target.whatever +#+end_src + diff --git a/input_parser.star b/input_parser.star index 7d5c4517..469f87b7 100644 --- a/input_parser.star +++ b/input_parser.star @@ -239,7 +239,7 @@ DEFAULT_ROLLUP_ARGS = { # If we're using pessimistic consensus and a real verifier, we'll # need to know which vkey to use. This value is tightly coupled to # the agglayer version that's being used - "verifier_program_vkey": "0x00e360ff2c18d456d6ee96c17f4e746216b475b62174bd2e9e8775ed99368ca3", + "verifier_program_vkey": "0x002d324867c82b5b5e0c66a822b004694cb73166d74c0713add59a282b8ce3e0", # This flag will enable a stateless executor to verify the execution of the batches. # Set to true to run erigon as the sequencer. "erigon_strict_mode": True, From b926b0f9cf1ec65e13bd9d4c324828fda8a91026 Mon Sep 17 00:00:00 2001 From: John Hilliard Date: Thu, 19 Dec 2024 23:04:30 -0500 Subject: [PATCH 34/38] feat: latest changes --- docs/multi-pp-testing/README | 345 ---------------- docs/multi-pp-testing/README.md | 478 ++++------------------ docs/multi-pp-testing/init.sh | 196 +++++++++ docs/multi-pp-testing/run.sh | 226 ++++++++++ docs/multi-pp-testing/test-scenarios.json | 282 +++++++++++++ 5 files changed, 790 insertions(+), 737 deletions(-) create mode 100755 docs/multi-pp-testing/init.sh create mode 100755 docs/multi-pp-testing/run.sh create mode 100644 docs/multi-pp-testing/test-scenarios.json diff --git a/docs/multi-pp-testing/README b/docs/multi-pp-testing/README index 86dd6a0f..3fcac4ef 100755 --- a/docs/multi-pp-testing/README +++ b/docs/multi-pp-testing/README @@ -416,351 +416,6 @@ cast call --rpc-url $l1_rpc_url $bridge_address 'depositCount() external view re # run.sh script in this folder - - - - - - -## Pict Based Test Scenarios -# -# The goal here is to have some methods for creating more robust -# testing combinations. In theory, we can probably brute force test -# every combination of parameters, but as the number of parameters -# grows, this might become too difficult. I'm using a command like -# this to generate the test cases. -pict docs/multi-pp-testing/lxly.pict /f:json | jq -c '.[] | from_entries' | jq -s > test-scenarios.json - -# For the sake of simplicity, I'm going to use the deterministic -# deployer so that I have the same ERC20 address on each chain. Here -# I'm adding some funds to the deterministict deployer address. -cast send --legacy --value 0.1ether --rpc-url $l1_rpc_url --private-key $private_key 0x3fab184622dc19b6109349b94811493bf2a45362 -cast send --legacy --value 0.1ether --rpc-url $l2_pp1_url --private-key $private_key 0x3fab184622dc19b6109349b94811493bf2a45362 -cast send --legacy --value 0.1ether --rpc-url $l2_pp2_url --private-key $private_key 0x3fab184622dc19b6109349b94811493bf2a45362 - -# The tx data and address are standard for the deterministict deployer -deterministic_deployer_tx=0xf8a58085174876e800830186a08080b853604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf31ba02222222222222222222222222222222222222222222222222222222222222222a02222222222222222222222222222222222222222222222222222222222222222 -deterministic_deployer_addr=0x4e59b44847b379578588920ca78fbf26c0b4956c - -cast publish --rpc-url $l1_rpc_url $deterministic_deployer_tx -cast publish --rpc-url $l2_pp1_url $deterministic_deployer_tx -cast publish --rpc-url $l2_pp2_url $deterministic_deployer_tx - - -salt=0x6a6f686e2068696c6c696172642077617320686572650a000000000000000000 -erc_20_bytecode=60806040526040516200143a3803806200143a833981016040819052620000269162000201565b8383600362000036838262000322565b50600462000045828262000322565b5050506200005a82826200007160201b60201c565b505081516020909201919091206006555062000416565b6001600160a01b038216620000cc5760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015260640160405180910390fd5b8060026000828254620000e09190620003ee565b90915550506001600160a01b038216600081815260208181526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b505050565b634e487b7160e01b600052604160045260246000fd5b600082601f8301126200016457600080fd5b81516001600160401b03808211156200018157620001816200013c565b604051601f8301601f19908116603f01168101908282118183101715620001ac57620001ac6200013c565b81604052838152602092508683858801011115620001c957600080fd5b600091505b83821015620001ed5785820183015181830184015290820190620001ce565b600093810190920192909252949350505050565b600080600080608085870312156200021857600080fd5b84516001600160401b03808211156200023057600080fd5b6200023e8883890162000152565b955060208701519150808211156200025557600080fd5b50620002648782880162000152565b604087015190945090506001600160a01b03811681146200028457600080fd5b6060959095015193969295505050565b600181811c90821680620002a957607f821691505b602082108103620002ca57634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200013757600081815260208120601f850160051c81016020861015620002f95750805b601f850160051c820191505b818110156200031a5782815560010162000305565b505050505050565b81516001600160401b038111156200033e576200033e6200013c565b62000356816200034f845462000294565b84620002d0565b602080601f8311600181146200038e5760008415620003755750858301515b600019600386901b1c1916600185901b1785556200031a565b600085815260208120601f198616915b82811015620003bf578886015182559484019460019091019084016200039e565b5085821015620003de5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b808201808211156200041057634e487b7160e01b600052601160045260246000fd5b92915050565b61101480620004266000396000f3fe608060405234801561001057600080fd5b506004361061014d5760003560e01c806340c10f19116100c35780639e4e73181161007c5780639e4e73181461033c578063a457c2d714610363578063a9059cbb14610376578063c473af3314610389578063d505accf146103b0578063dd62ed3e146103c357600080fd5b806340c10f19146102b257806342966c68146102c557806356189cb4146102d857806370a08231146102eb5780637ecebe001461031457806395d89b411461033457600080fd5b806323b872dd1161011557806323b872dd146101c357806330adf81f146101d6578063313ce567146101fd5780633408e4701461020c5780633644e51514610212578063395093511461029f57600080fd5b806304622c2e1461015257806306fdde031461016e578063095ea7b31461018357806318160ddd146101a6578063222f5be0146101ae575b600080fd5b61015b60065481565b6040519081526020015b60405180910390f35b6101766103d6565b6040516101659190610db1565b610196610191366004610e1b565b610468565b6040519015158152602001610165565b60025461015b565b6101c16101bc366004610e45565b610482565b005b6101966101d1366004610e45565b610492565b61015b7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b60405160128152602001610165565b4661015b565b61015b6006546000907f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f907fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc646604080516020810195909552840192909252606083015260808201523060a082015260c00160405160208183030381529060405280519060200120905090565b6101966102ad366004610e1b565b6104b6565b6101c16102c0366004610e1b565b6104d8565b6101c16102d3366004610e81565b6104e6565b6101c16102e6366004610e45565b6104f3565b61015b6102f9366004610e9a565b6001600160a01b031660009081526020819052604090205490565b61015b610322366004610e9a565b60056020526000908152604090205481565b6101766104fe565b61015b7fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc681565b610196610371366004610e1b565b61050d565b610196610384366004610e1b565b61058d565b61015b7f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f81565b6101c16103be366004610ebc565b61059b565b61015b6103d1366004610f2f565b6106ae565b6060600380546103e590610f62565b80601f016020809104026020016040519081016040528092919081815260200182805461041190610f62565b801561045e5780601f106104335761010080835404028352916020019161045e565b820191906000526020600020905b81548152906001019060200180831161044157829003601f168201915b5050505050905090565b6000336104768185856106d9565b60019150505b92915050565b61048d8383836107fd565b505050565b6000336104a08582856109a3565b6104ab8585856107fd565b506001949350505050565b6000336104768185856104c983836106ae565b6104d39190610fb2565b6106d9565b6104e28282610a17565b5050565b6104f03382610ad6565b50565b61048d8383836106d9565b6060600480546103e590610f62565b6000338161051b82866106ae565b9050838110156105805760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b60648201526084015b60405180910390fd5b6104ab82868684036106d9565b6000336104768185856107fd565b428410156105eb5760405162461bcd60e51b815260206004820152601960248201527f48455a3a3a7065726d69743a20415554485f45585049524544000000000000006044820152606401610577565b6001600160a01b038716600090815260056020526040812080547f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9918a918a918a91908661063883610fc5565b909155506040805160208101969096526001600160a01b0394851690860152929091166060840152608083015260a082015260c0810186905260e0016040516020818303038152906040528051906020012090506106998882868686610c08565b6106a48888886106d9565b5050505050505050565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6001600160a01b03831661073b5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610577565b6001600160a01b03821661079c5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610577565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b0383166108615760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610577565b6001600160a01b0382166108c35760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610577565b6001600160a01b0383166000908152602081905260409020548181101561093b5760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610577565b6001600160a01b03848116600081815260208181526040808320878703905593871680835291849020805487019055925185815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35b50505050565b60006109af84846106ae565b9050600019811461099d5781811015610a0a5760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610577565b61099d84848484036106d9565b6001600160a01b038216610a6d5760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610577565b8060026000828254610a7f9190610fb2565b90915550506001600160a01b038216600081815260208181526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b6001600160a01b038216610b365760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b6064820152608401610577565b6001600160a01b03821660009081526020819052604090205481811015610baa5760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b6064820152608401610577565b6001600160a01b0383166000818152602081815260408083208686039055600280548790039055518581529192917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3505050565b600654604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f602080830191909152818301939093527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a0808301919091528251808303909101815260c082019092528151919092012061190160f01b60e083015260e282018190526101028201869052906000906101220160408051601f198184030181528282528051602091820120600080855291840180845281905260ff89169284019290925260608301879052608083018690529092509060019060a0016020604051602081039080840390855afa158015610d1b573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811615801590610d515750876001600160a01b0316816001600160a01b0316145b6106a45760405162461bcd60e51b815260206004820152602b60248201527f48455a3a3a5f76616c69646174655369676e6564446174613a20494e56414c4960448201526a445f5349474e415455524560a81b6064820152608401610577565b600060208083528351808285015260005b81811015610dde57858101830151858201604001528201610dc2565b506000604082860101526040601f19601f8301168501019250505092915050565b80356001600160a01b0381168114610e1657600080fd5b919050565b60008060408385031215610e2e57600080fd5b610e3783610dff565b946020939093013593505050565b600080600060608486031215610e5a57600080fd5b610e6384610dff565b9250610e7160208501610dff565b9150604084013590509250925092565b600060208284031215610e9357600080fd5b5035919050565b600060208284031215610eac57600080fd5b610eb582610dff565b9392505050565b600080600080600080600060e0888a031215610ed757600080fd5b610ee088610dff565b9650610eee60208901610dff565b95506040880135945060608801359350608088013560ff81168114610f1257600080fd5b9699959850939692959460a0840135945060c09093013592915050565b60008060408385031215610f4257600080fd5b610f4b83610dff565b9150610f5960208401610dff565b90509250929050565b600181811c90821680610f7657607f821691505b602082108103610f9657634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b8082018082111561047c5761047c610f9c565b600060018201610fd757610fd7610f9c565b506001019056fea26469706673582212207bede9966bc8e8634cc0c3dc076626579b27dff7bbcac0b645c87d4cf1812b9864736f6c63430008140033 -constructor_args=$(cast abi-encode 'f(string,string,address,uint256)' 'Bridge Test' 'BT' "$target_address" 100000000000000000000 | sed 's/0x//') - -cast send --legacy --rpc-url $l1_rpc_url --private-key $private_key $deterministic_deployer_addr $salt$erc_20_bytecode$constructor_args -cast send --legacy --rpc-url $l2_pp1_url --private-key $private_key $deterministic_deployer_addr $salt$erc_20_bytecode$constructor_args -cast send --legacy --rpc-url $l2_pp2_url --private-key $private_key $deterministic_deployer_addr $salt$erc_20_bytecode$constructor_args - -test_erc20_addr=$(cast create2 --salt $salt --init-code $erc_20_bytecode$constructor_args) - -cast send --legacy --rpc-url $l1_rpc_url --private-key $target_private_key $test_erc20_addr 'approve(address,uint256)' $bridge_address 100000000000000000000 -cast send --legacy --rpc-url $l2_pp1_url --private-key $target_private_key $test_erc20_addr 'approve(address,uint256)' $bridge_address 100000000000000000000 -cast send --legacy --rpc-url $l2_pp2_url --private-key $target_private_key $test_erc20_addr 'approve(address,uint256)' $bridge_address 100000000000000000000 - -erc20_buggy_bytecode=608060405234801561001057600080fd5b506040516109013803806109018339818101604052606081101561003357600080fd5b810190808051604051939291908464010000000082111561005357600080fd5b90830190602082018581111561006857600080fd5b825164010000000081118282018810171561008257600080fd5b82525081516020918201929091019080838360005b838110156100af578181015183820152602001610097565b50505050905090810190601f1680156100dc5780820380516001836020036101000a031916815260200191505b50604052602001805160405193929190846401000000008211156100ff57600080fd5b90830190602082018581111561011457600080fd5b825164010000000081118282018810171561012e57600080fd5b82525081516020918201929091019080838360005b8381101561015b578181015183820152602001610143565b50505050905090810190601f1680156101885780820380516001836020036101000a031916815260200191505b5060405260209081015185519093506101a792506003918601906101d8565b5081516101bb9060049060208501906101d8565b506005805460ff191660ff92909216919091179055506102799050565b828054600181600116156101000203166002900490600052602060002090601f01602090048101928261020e5760008555610254565b82601f1061022757805160ff1916838001178555610254565b82800160010185558215610254579182015b82811115610254578251825591602001919060010190610239565b50610260929150610264565b5090565b5b808211156102605760008155600101610265565b610679806102886000396000f3fe608060405234801561001057600080fd5b50600436106100b45760003560e01c806370a082311161007157806370a082311461021257806395d89b41146102385780639dc29fac14610240578063a9059cbb1461026c578063b46310f614610298578063dd62ed3e146102c4576100b4565b806306fdde03146100b9578063095ea7b31461013657806318160ddd1461017657806323b872dd14610190578063313ce567146101c657806340c10f19146101e4575b600080fd5b6100c16102f2565b6040805160208082528351818301528351919283929083019185019080838360005b838110156100fb5781810151838201526020016100e3565b50505050905090810190601f1680156101285780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101626004803603604081101561014c57600080fd5b506001600160a01b038135169060200135610380565b604080519115158252519081900360200190f35b61017e6103e6565b60408051918252519081900360200190f35b610162600480360360608110156101a657600080fd5b506001600160a01b038135811691602081013590911690604001356103ec565b6101ce610466565b6040805160ff9092168252519081900360200190f35b610210600480360360408110156101fa57600080fd5b506001600160a01b03813516906020013561046f565b005b61017e6004803603602081101561022857600080fd5b50356001600160a01b031661047d565b6100c161048f565b6102106004803603604081101561025657600080fd5b506001600160a01b0381351690602001356104ea565b6101626004803603604081101561028257600080fd5b506001600160a01b0381351690602001356104f4565b610210600480360360408110156102ae57600080fd5b506001600160a01b03813516906020013561054f565b61017e600480360360408110156102da57600080fd5b506001600160a01b038135811691602001351661056b565b6003805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156103785780601f1061034d57610100808354040283529160200191610378565b820191906000526020600020905b81548152906001019060200180831161035b57829003601f168201915b505050505081565b3360008181526002602090815260408083206001600160a01b038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a350600192915050565b60005481565b6001600160a01b0380841660008181526002602090815260408083203384528252808320805487900390558383526001825280832080548790039055938616808352848320805487019055845186815294519294909392600080516020610624833981519152929181900390910190a35060019392505050565b60055460ff1681565b6104798282610588565b5050565b60016020526000908152604090205481565b6004805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156103785780601f1061034d57610100808354040283529160200191610378565b61047982826105d3565b336000818152600160209081526040808320805486900390556001600160a01b03861680845281842080548701905581518681529151939490939092600080516020610624833981519152928290030190a350600192915050565b6001600160a01b03909116600090815260016020526040902055565b600260209081526000928352604080842090915290825290205481565b6001600160a01b038216600081815260016020908152604080832080548601905582548501835580518581529051600080516020610624833981519152929181900390910190a35050565b6001600160a01b0382166000818152600160209081526040808320805486900390558254859003835580518581529051929392600080516020610624833981519152929181900390910190a3505056feddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa2646970667358221220364a383ccce0e270376267b8631412d1b7ddb1883c5379556b58cbefc1ca504564736f6c63430007060033 -constructor_args=$(cast abi-encode 'f(string,string,uint8)' 'Buggy ERC20' 'BUG' "18" | sed 's/0x//') - -cast send --legacy --rpc-url $l1_rpc_url --private-key $private_key $deterministic_deployer_addr $salt$erc20_buggy_bytecode$constructor_args -cast send --legacy --rpc-url $l2_pp1_url --private-key $private_key $deterministic_deployer_addr $salt$erc20_buggy_bytecode$constructor_args -cast send --legacy --rpc-url $l2_pp2_url --private-key $private_key $deterministic_deployer_addr $salt$erc20_buggy_bytecode$constructor_args - -test_erc20_buggy_addr=$(cast create2 --salt $salt --init-code $erc20_buggy_bytecode$constructor_args) - -cast send --legacy --rpc-url $l1_rpc_url --private-key $target_private_key $test_erc20_buggy_addr 'mint(address,uint256)' $target_address $(cast max-uint) -cast send --legacy --rpc-url $l2_pp1_url --private-key $target_private_key $test_erc20_buggy_addr 'mint(address,uint256)' $target_address $(cast max-uint) -cast send --legacy --rpc-url $l2_pp2_url --private-key $target_private_key $test_erc20_buggy_addr 'mint(address,uint256)' $target_address $(cast max-uint) - -cast send --legacy --rpc-url $l1_rpc_url --private-key $target_private_key $test_erc20_buggy_addr 'approve(address,uint256)' $bridge_address $(cast max-uint) -cast send --legacy --rpc-url $l2_pp1_url --private-key $target_private_key $test_erc20_buggy_addr 'approve(address,uint256)' $bridge_address $(cast max-uint) -cast send --legacy --rpc-url $l2_pp2_url --private-key $target_private_key $test_erc20_buggy_addr 'approve(address,uint256)' $bridge_address $(cast max-uint) - -# One of the test cases that I've left out for now is a permit -# call. It'll take some work to get the signed permit data in place, -# but it seems doable. -# -# - https://eips.ethereum.org/EIPS/eip-2612 -# - https://eips.ethereum.org/EIPS/eip-712 -# -# permit_sig=$(cast wallet sign --private-key $target_private_key 0x$(< /dev/urandom xxd -p | tr -d "\n" | head -c 40)) -# permit_sig_r=${permit_sig:2:64} -# permit_sig_s=${permit_sig:66:64} -# permit_sig_v=${permit_sig:130:2} - -# The test cases are committed for convenience, we'll use that to -# dynamically to some testing -cat test-scenarios.json | jq -c '.[]' | while read scenario ; do - testBridgeType=$(echo $scenario | jq -r '.BridgeType') - testDepositChain=$(echo $scenario | jq -r '.DepositChain') - testDestinationChain=$(echo $scenario | jq -r '.DestinationChain') - testDestinationAddress=$(echo $scenario | jq -r '.DestinationAddress') - testToken=$(echo $scenario | jq -r '.Token') - testMetaData=$(echo $scenario | jq -r '.MetaData') - testForceUpdate=$(echo $scenario | jq -r '.ForceUpdate') - testAmount=$(echo $scenario | jq -r '.Amount') - - testCommand="polycli ulxly bridge" - - if [[ $testBridgeType == "Asset" ]]; then - testCommand="$testCommand asset" - elif [[ $testBridgeType == "Message" ]]; then - testCommand="$testCommand message" - else - testCommand="$testCommand weth" - fi - - temp_rpc_url="" - if [[ $testDepositChain == "L1" ]]; then - testCommand="$testCommand --rpc-url $l1_rpc_url" - temp_rpc_url="$l1_rpc_url" - elif [[ $testDepositChain == "PP1" ]]; then - testCommand="$testCommand --rpc-url $l2_pp1_url" - temp_rpc_url="$l2_pp1_url" - else - testCommand="$testCommand --rpc-url $l2_pp2_url" - temp_rpc_url="$l2_pp2_url" - fi - - if [[ $testDestinationChain == "L1" ]]; then - testCommand="$testCommand --destination-network 0" - elif [[ $testDestinationChain == "PP1" ]]; then - testCommand="$testCommand --destination-network 1" - else - testCommand="$testCommand --destination-network 2" - fi - - if [[ $testDestinationAddress == "Contract" ]]; then - testCommand="$testCommand --destination-address $bridge_address" - elif [[ $testDestinationAddress == "Precompile" ]]; then - testCommand="$testCommand --destination-address 0x0000000000000000000000000000000000000004" - else - testCommand="$testCommand --destination-address $target_address" - fi - - if [[ $testToken == "POL" ]]; then - testCommand="$testCommand --token-address $pol_address" - elif [[ $testToken == "LocalERC20" ]]; then - testCommand="$testCommand --token-address $test_erc20_addr" - elif [[ $testToken == "WETH" ]]; then - testCommand="$testCommand --token-address $pp2_weth_address" - elif [[ $testToken == "Buggy" ]]; then - testCommand="$testCommand --token-address $test_erc20_buggy_addr" - else - testCommand="$testCommand --token-address 0x0000000000000000000000000000000000000000" - fi - - if [[ $testMetaData == "Random" ]]; then - testCommand="$testCommand --call-data $(date +%s | xxd -p)" - else - testCommand="$testCommand --call-data 0x" - fi - - if [[ $testForceUpdate == "True" ]]; then - testCommand="$testCommand --force-update-root=true" - else - testCommand="$testCommand --force-update-root=false" - fi - - if [[ $testAmount == "0" ]]; then - testCommand="$testCommand --value 0" - elif [[ $testAmount == "1" ]]; then - testCommand="$testCommand --value 1" - elif [[ $testAmount == "Max" ]]; then - cast send --legacy --rpc-url $temp_rpc_url --private-key $target_private_key $test_erc20_buggy_addr 'mint(address,uint256)' $target_address $(cast max-uint) - cast send --legacy --rpc-url $temp_rpc_url --private-key $target_private_key $test_erc20_buggy_addr 'setBalanceOf(address,uint256)' $bridge_address 0 - testCommand="$testCommand --value $(cast max-uint)" - else - testCommand="$testCommand --value $(date +%s)" - fi - - testCommand="$testCommand --bridge-address $bridge_address" - testCommand="$testCommand --private-key $target_private_key" - - echo $scenario | jq -c '.' - echo $testCommand - $testCommand - - # In this particular case, we should zero the bridge out after the deposit is made - if [[ $testAmount == "Max" ]]; then - cast send --legacy --rpc-url $temp_rpc_url --private-key $target_private_key $test_erc20_buggy_addr 'setBalanceOf(address,uint256)' $bridge_address 0 - fi -done - - -polycli ulxly claim-everything \ - --bridge-address $bridge_address \ - --bridge-service-map 1=$l2_pp1b_url \ - --bridge-service-map 2=$l2_pp2b_url \ - --rpc-url $l2_pp1_url \ - --destination-address $target_address \ - --private-key $private_key \ - --bridge-limit 100 - -polycli ulxly claim-everything \ - --bridge-address $bridge_address \ - --bridge-service-map 1=$l2_pp1b_url \ - --bridge-service-map 2=$l2_pp2b_url \ - --rpc-url $l2_pp2_url \ - --destination-address $target_address \ - --private-key $private_key \ - --bridge-limit 100 - -polycli ulxly claim-everything \ - --bridge-address $bridge_address \ - --bridge-service-map 1=$l2_pp1b_url \ - --bridge-service-map 2=$l2_pp2b_url \ - --rpc-url $l1_rpc_url \ - --destination-address $target_address \ - --private-key $private_key \ - --bridge-limit 100 - -# ## Buggy ERC 20 -# -# These are some simple tests to try bridging more than the uint max -# limit to understand how the balance tree might be impacted. We're -# going to run thie snippt below a few times which does the following. -# -# 1. Bridge the max amount possible from the target address. This -# assumes we've already minted some -# 2. Mint the max amount again for the target address. -# 3. Zero out the balance of the bridge -# -# Repeat that a few times just to make sure everything is okay. The -# commands below are for doing tests from PP1 to PP2 - -polycli ulxly bridge asset \ - --private-key $target_private_key \ - --value 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe \ - --bridge-address $bridge_address \ - --destination-network 2 \ - --destination-address $target_address \ - --rpc-url $l2_pp1_url \ - --token-address $test_erc20_buggy_addr \ - --force-update-root=true - -cast send --legacy --rpc-url $l2_pp1_url --private-key $target_private_key $test_erc20_buggy_addr 'mint(address,uint256)' $target_address $(cast max-uint) -cast send --legacy --rpc-url $l2_pp1_url --private-key $target_private_key $test_erc20_buggy_addr 'setBalanceOf(address,uint256)' $bridge_address 0 - - -# These commands do the same thing more or less but from PP2 to PP1 -polycli ulxly bridge asset \ - --private-key $target_private_key \ - --value 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe \ - --bridge-address $bridge_address \ - --destination-network 1 \ - --destination-address $target_address \ - --rpc-url $l2_pp2_url \ - --token-address $test_erc20_buggy_addr \ - --force-update-root=true - -cast send --legacy --rpc-url $l2_pp2_url --private-key $target_private_key $test_erc20_buggy_addr 'mint(address,uint256)' $target_address $(cast max-uint) -cast send --legacy --rpc-url $l2_pp2_url --private-key $target_private_key $test_erc20_buggy_addr 'setBalanceOf(address,uint256)' $bridge_address 0 - -# Then do the same thing for PP2 to L1 -polycli ulxly bridge asset \ - --private-key $target_private_key \ - --value 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe \ - --bridge-address $bridge_address \ - --destination-network 0 \ - --destination-address $target_address \ - --rpc-url $l2_pp2_url \ - --token-address $test_erc20_buggy_addr \ - --force-update-root=true - -cast send --legacy --rpc-url $l2_pp2_url --private-key $target_private_key $test_erc20_buggy_addr 'mint(address,uint256)' $target_address $(cast max-uint) -cast send --legacy --rpc-url $l2_pp2_url --private-key $target_private_key $test_erc20_buggy_addr 'setBalanceOf(address,uint256)' $bridge_address 0 - -curl -s $l2_pp1b_url/bridges/$target_address - -# ## Calling through a smart contract of some kind -# -# The idea here is to do some transactions through a proxy or some kind so - -lxly_proxy_bytecode=608060405234801561001057600080fd5b50604051610acb380380610acb83398101604081905261002f91610054565b600080546001600160a01b0319166001600160a01b0392909216919091179055610084565b60006020828403121561006657600080fd5b81516001600160a01b038116811461007d57600080fd5b9392505050565b610a38806100936000396000f3fe6080604052600436106100955760003560e01c8063b8b284d011610059578063b8b284d014610196578063ccaa2d11146101c9578063cd586579146101e9578063dd96eab7146101fc578063f5efcd79146101fc57610116565b80631c253d72146101965780631eb5f7aa146101b6578063240ff378146101b65780632c4422ca146101c95780635ea89907146101e957610116565b366101165760008054604051630481fe6f60e31b815263ffffffff34166004820152336024820152600160448201526080606482015260848101929092526001600160a01b03169063240ff3789060a401600060405180830381600087803b15801561010057600080fd5b505af1158015610114573d6000803e3d6000fd5b005b60008054604051630481fe6f60e31b815236916060916001600160a01b039091169063240ff37890610155903490339060019089908990600401610436565b600060405180830381600087803b15801561016f57600080fd5b505af1158015610183573d6000803e3d6000fd5b5050604080516020810190915260009052005b3480156101a257600080fd5b506101146101b136600461056f565b61021c565b6101146101c43660046105e8565b61028d565b3480156101d557600080fd5b506101146101e43660046106c5565b6102fb565b6101146101f7366004610799565b61037e565b34801561020857600080fd5b506101146102173660046106c5565b6103f2565b600054604051630b8b284d60e41b81526001600160a01b039091169063b8b284d0906102549088908890889088908890600401610867565b600060405180830381600087803b15801561026e57600080fd5b505af1158015610282573d6000803e3d6000fd5b505050505050505050565b600054604051630481fe6f60e31b81526001600160a01b039091169063240ff378906102c39087908790879087906004016108ad565b600060405180830381600087803b1580156102dd57600080fd5b505af11580156102f1573d6000803e3d6000fd5b5050505050505050565b60005460405163ccaa2d1160e01b81526001600160a01b039091169063ccaa2d119061033f908e908e908e908e908e908e908e908e908e908e908e9060040161091c565b600060405180830381600087803b15801561035957600080fd5b505af115801561036d573d6000803e3d6000fd5b505050505050505050505050505050565b60005460405163cd58657960e01b81526001600160a01b039091169063cd586579906103b8908990899089908990899089906004016109af565b600060405180830381600087803b1580156103d257600080fd5b505af11580156103e6573d6000803e3d6000fd5b50505050505050505050565b60005460405163f5efcd7960e01b81526001600160a01b039091169063f5efcd799061033f908e908e908e908e908e908e908e908e908e908e908e9060040161091c565b63ffffffff861681526001600160a01b038516602082015283151560408201526080606082018190528101829052818360a0830137600081830160a090810191909152601f909201601f19160101949350505050565b803563ffffffff811681146104a057600080fd5b919050565b80356001600160a01b03811681146104a057600080fd5b803580151581146104a057600080fd5b634e487b7160e01b600052604160045260246000fd5b600082601f8301126104f357600080fd5b813567ffffffffffffffff8082111561050e5761050e6104cc565b604051601f8301601f19908116603f01168101908282118183101715610536576105366104cc565b8160405283815286602085880101111561054f57600080fd5b836020870160208301376000602085830101528094505050505092915050565b600080600080600060a0868803121561058757600080fd5b6105908661048c565b945061059e602087016104a5565b9350604086013592506105b3606087016104bc565b9150608086013567ffffffffffffffff8111156105cf57600080fd5b6105db888289016104e2565b9150509295509295909350565b600080600080608085870312156105fe57600080fd5b6106078561048c565b9350610615602086016104a5565b9250610623604086016104bc565b9150606085013567ffffffffffffffff81111561063f57600080fd5b61064b878288016104e2565b91505092959194509250565b600082601f83011261066857600080fd5b60405161040080820182811067ffffffffffffffff8211171561068d5761068d6104cc565b604052830181858211156106a057600080fd5b845b828110156106ba5780358252602091820191016106a2565b509195945050505050565b60008060008060008060008060008060006109208c8e0312156106e757600080fd5b6106f18d8d610657565b9a506107018d6104008e01610657565b99506108008c013598506108208c013597506108408c013596506107286108608d0161048c565b95506107376108808d016104a5565b94506107466108a08d0161048c565b93506107556108c08d016104a5565b92506108e08c013591506109008c013567ffffffffffffffff81111561077a57600080fd5b6107868e828f016104e2565b9150509295989b509295989b9093969950565b60008060008060008060c087890312156107b257600080fd5b6107bb8761048c565b95506107c9602088016104a5565b9450604087013593506107de606088016104a5565b92506107ec608088016104bc565b915060a087013567ffffffffffffffff81111561080857600080fd5b61081489828a016104e2565b9150509295509295509295565b6000815180845260005b818110156108475760208185018101518683018201520161082b565b506000602082860101526020601f19601f83011685010191505092915050565b63ffffffff8616815260018060a01b0385166020820152836040820152821515606082015260a0608082015260006108a260a0830184610821565b979650505050505050565b63ffffffff851681526001600160a01b038416602082015282151560408201526080606082018190526000906108e590830184610821565b9695505050505050565b8060005b60208082106109025750610916565b8251855293840193909101906001016108f3565b50505050565b600061092061092b838f6108ef565b61093961040084018e6108ef565b61080083018c905261082083018b905261084083018a905263ffffffff8981166108608501526001600160a01b038981166108808601529088166108a085015286166108c08401526108e08301859052610900830181905261099d81840185610821565b9e9d5050505050505050505050505050565b63ffffffff871681526001600160a01b0386811660208301526040820186905284166060820152821515608082015260c060a082018190526000906109f690830184610821565b9897505050505050505056fea2646970667358221220b86e525972f2e2cc9d33328df79fceaa11e88478f9966dde327eeec360259b4964736f6c63430008140033 - -constructor_args=$(cast abi-encode 'f(address)' $bridge_address | sed 's/0x//') - -cast send --legacy --rpc-url $l1_rpc_url --private-key $private_key $deterministic_deployer_addr $salt$lxly_proxy_bytecode$constructor_args -cast send --legacy --rpc-url $l2_pp1_url --private-key $private_key $deterministic_deployer_addr $salt$lxly_proxy_bytecode$constructor_args -cast send --legacy --rpc-url $l2_pp2_url --private-key $private_key $deterministic_deployer_addr $salt$lxly_proxy_bytecode$constructor_args - -test_lxly_proxy_addr=$(cast create2 --salt $salt --init-code $lxly_proxy_bytecode$constructor_args) - -cast send --legacy --value 2 --rpc-url $l1_rpc_url --private-key $target_private_key $test_lxly_proxy_addr -cast send --legacy --value 3 --rpc-url $l2_pp1_url --private-key $target_private_key $test_lxly_proxy_addr -cast send --legacy --value 1 --rpc-url $l2_pp2_url --private-key $target_private_key $test_lxly_proxy_addr - -# In in my test environment I've deployed a contract specifically for -# testing. You might not have this. The idea is to call the bridge -# contract from a bunch of contexts and ensure that things more or -# less still work -tester_contract_address=0xc54E34B55EF562FE82Ca858F70D1B73244e86388 - -# address_tester_actions="001 002 003 004 011 012 013 014 021 022 023 024 031 032 033 034 041 042 043 044 101 201 301 401 501 601 701 801 901" -address_tester_actions="001 011 021 031 041 101 201 301 401 501 601 701 801 901" - -for create_mode in 0 1 2; do - for action in $address_tester_actions ; do - cast send --gas-limit 1000000 --legacy --value 1 --rpc-url $l1_rpc_url --private-key $target_private_key $tester_contract_address $(cast abi-encode 'f(uint32, address, uint256)' 0x"$create_mode$action" $test_lxly_proxy_addr 1) - cast send --gas-limit 1000000 --legacy --value 2 --rpc-url $l1_rpc_url --private-key $target_private_key $tester_contract_address $(cast abi-encode 'f(uint32, address, uint256)' 0x"$create_mode$action" $test_lxly_proxy_addr 2) - - cast send --gas-limit 1000000 --legacy --value 0 --rpc-url $l2_pp1_url --private-key $target_private_key $tester_contract_address $(cast abi-encode 'f(uint32, address, uint256)' 0x"$create_mode$action" $test_lxly_proxy_addr 0) - cast send --gas-limit 1000000 --legacy --value 2 --rpc-url $l2_pp1_url --private-key $target_private_key $tester_contract_address $(cast abi-encode 'f(uint32, address, uint256)' 0x"$create_mode$action" $test_lxly_proxy_addr 2) - - cast send --gas-limit 1000000 --legacy --value 0 --rpc-url $l2_pp2_url --private-key $target_private_key $tester_contract_address $(cast abi-encode 'f(uint32, address, uint256)' 0x"$create_mode$action" $test_lxly_proxy_addr 0) - cast send --gas-limit 1000000 --legacy --value 1 --rpc-url $l2_pp2_url --private-key $target_private_key $tester_contract_address $(cast abi-encode 'f(uint32, address, uint256)' 0x"$create_mode$action" $test_lxly_proxy_addr 1) - done -done - -# TODO add a test where there is more than uint256 funds -# TODO add some tests with reverting -# TODO add some tests where the bridge is called via a smart contract rather than directly -# TODO add a scneario that does a full sweep of the target account native token and the end to ensure all of the accounting looks good - -cast send --legacy --gas-limit 1000000 --value 2 --rpc-url $l2_pp1_url --private-key $target_private_key $tester_contract_address $(cast abi-encode 'f(uint32, address, uint256)' 0x0201 $test_lxly_proxy_addr 2) - -polycli ulxly claim-everything \ - --bridge-address $bridge_address \ - --bridge-service-map 1=$l2_pp1b_url \ - --bridge-service-map 2=$l2_pp2b_url \ - --destination-address $target_address \ - --private-key $target_private_key \ - --rpc-url $l2_pp1_url \ - --bridge-limit 100 - -polycli ulxly claim-everything \ - --bridge-address $bridge_address \ - --bridge-service-map 1=$l2_pp1b_url \ - --bridge-service-map 2=$l2_pp2b_url \ - --destination-address $target_address \ - --private-key $target_private_key \ - --rpc-url $l2_pp2_url \ - --bridge-limit 100 - -polycli ulxly claim-everything \ - --bridge-address $bridge_address \ - --bridge-service-map 1=$l2_pp1b_url \ - --bridge-service-map 2=$l2_pp2b_url \ - --destination-address $target_address \ - --private-key $target_private_key \ - --rpc-url $l1_rpc_url \ - --bridge-limit 100 - -curl -s "$l2_pp1b_url/bridges/0xbecE3a31343c6019CDE0D5a4dF2AF8Df17ebcB0f?limit=150" | jq '.deposits[] | select(.deposit_cnt == 111)' -curl -s "$l2_pp1b_url/merkle-proof?deposit_cnt=111&net_id=0" | jq '.' -curl -s "$l2_pp1b_url/merkle-proof?deposit_cnt=111&net_id=1" | jq '.' -curl -s "$l2_pp1b_url/merkle-proof?deposit_cnt=111&net_id=2" | jq '.' - -curl -s "$l2_pp2b_url/bridges/0xbecE3a31343c6019CDE0D5a4dF2AF8Df17ebcB0f?limit=150" | jq '.deposits[] | select(.tx_hash == "0x932945c01362a5e121405b6bf38b14da8b6ddeee253732cdf362be74b455bea8")' -curl -s "$l2_pp2b_url/bridges/0xbecE3a31343c6019CDE0D5a4dF2AF8Df17ebcB0f?limit=150" | jq '.deposits[] | select(.deposit_cnt == 111)' -curl -s "$l2_pp2b_url/merkle-proof?deposit_cnt=111&net_id=0" | jq '.' -curl -s "$l2_pp2b_url/merkle-proof?deposit_cnt=111&net_id=1" | jq '.' -curl -s "$l2_pp2b_url/merkle-proof?deposit_cnt=111&net_id=2" | jq '.' - - # ## State Capture Procedure pushd $(mktemp -d) mkdir agglayer-storage diff --git a/docs/multi-pp-testing/README.md b/docs/multi-pp-testing/README.md index 947e2b91..9cd24c30 100644 --- a/docs/multi-pp-testing/README.md +++ b/docs/multi-pp-testing/README.md @@ -9,21 +9,22 @@ exit 1; ## Infra Setup -This is an example of a system where there are two PP chains -attached to the rollup manager. One chain uses a gas token and the -other does not. Between those two chains we're going to attempt a -bunch of bridge scenarios. +This is an example of a system where there are two PP chains and one +FEP chain attached to the rollup manager. One chain uses a gas token +and the others do not. Between those three chains we're going to +attempt a bunch of bridge scenarios. To run this stuff you'll want to run most of these commands from within the kurtosis-cdk repo root. -First we're going to do a Kurtosis run to spin up both of the -networks. The secret file here is the same as the normal file but -with an SP1 key +First we're going to do a Kurtosis run to spin up the networks. If +you're going to run this you *need an SP1 key* in the `net1.yml` +file. ``` -kurtosis run --enclave pp --args-file .github/tests/fork12-pessimistic-secret.yml . -kurtosis run --enclave pp --args-file .github/tests/attach-second-cdk-pessimistic.yml . +kurtosis run --enclave pp --args-file docs/multi-pp-testing/net1.yml . +kurtosis run --enclave pp --args-file docs/multi-pp-testing/net2.yml . +kurtosis run --enclave pp --args-file docs/multi-pp-testing/net3.yml . ``` At this point we should be able to confirm that things look right @@ -34,6 +35,7 @@ away. ``` polycli monitor --rpc-url $(kurtosis port print pp cdk-erigon-rpc-001 rpc) polycli monitor --rpc-url $(kurtosis port print pp cdk-erigon-rpc-002 rpc) +polycli monitor --rpc-url $(kurtosis port print pp cdk-erigon-rpc-003 rpc) ``` In order to proceed, we'll need to grab the combined files from both @@ -44,14 +46,16 @@ from the second chain because we need to know the gas token address. kurtosis service exec pp contracts-001 "cat /opt/zkevm/combined-001.json" | tail -n +2 | jq '.' > combined-001.json kurtosis service exec pp contracts-002 "cat /opt/zkevm/combined-002.json" | tail -n +2 | jq '.' > combined-002.json kurtosis service exec pp contracts-002 "cat /opt/zkevm-contracts/deployment/v2/create_rollup_parameters.json" | tail -n +2 | jq -r '.gasTokenAddress' > gas-token-address.json +kurtosis service exec pp contracts-003 "cat /opt/zkevm/combined-003.json" | tail -n +2 | jq '.' > combined-003.json ``` This diagnosis isn't critical, but it's nice to confirm that we are -using a real verifier. +using a real verifier for the PP networks and mock for the FEP. ``` cast code --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $(cat combined-001.json | jq -r '.verifierAddress') cast code --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $(cat combined-002.json | jq -r '.verifierAddress') +cast code --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $(cat combined-003.json | jq -r '.verifierAddress') ``` Check that the hash of the verifier is actually the sp1 verifier. It should be f33fc6bc90b5ea5e0272a7ab87d701bdd05ecd78b8111ca4f450eeff1e6df26a @@ -62,11 +66,16 @@ cast code --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $( cast code --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $(cat combined-002.json | jq -r '.verifierAddress') | sha256sum ``` +The third network here should use a mock verifier and should be different + +``` +cast code --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $(cat combined-003.json | jq -r '.verifierAddress') | sha256sum +``` + It's also worth while probably to confirm that the vkey matches! ``` kurtosis service exec pp agglayer "agglayer vkey" -cast call --rpc-url http://$(kurtosis port print pp el-1-geth-lighthouse rpc) $(cat combined-001.json | jq -r '.polygonRollupManagerAddress') 'rollupTypeMap(uint32)(address,address,uint64,uint8,bool,bytes32,bytes32)' 1 ``` Let's make sure both rollups have the same vkey @@ -83,6 +92,7 @@ there's no harm in it. ``` kurtosis service exec pp agglayer "sed -i 's/\[proof\-signers\]/2 = \"http:\/\/cdk-erigon-rpc-002:8123\"\n\[proof-signers\]/i' /etc/zkevm/agglayer-config.toml" +kurtosis service exec pp agglayer "sed -i 's/\[proof\-signers\]/3 = \"http:\/\/cdk-erigon-rpc-003:8123\"\n\[proof-signers\]/i' /etc/zkevm/agglayer-config.toml" kurtosis service stop pp agglayer kurtosis service start pp agglayer ``` @@ -105,11 +115,13 @@ eth_address=$(cast wallet address --private-key $private_key) l1_rpc_url=http://$(kurtosis port print pp el-1-geth-lighthouse rpc) l2_pp1_url=$(kurtosis port print pp cdk-erigon-rpc-001 rpc) l2_pp2_url=$(kurtosis port print pp cdk-erigon-rpc-002 rpc) +l2_fep_url=$(kurtosis port print pp cdk-erigon-rpc-003 rpc) bridge_address=$(cat combined-001.json | jq -r .polygonZkEVMBridgeAddress) pol_address=$(cat combined-001.json | jq -r .polTokenAddress) gas_token_address=$( test-scenarios.json -``` - -For the sake of simplicity, I'm going to use the deterministic -deployer so that I have the same ERC20 address on each chain. Here -I'm adding some funds to the deterministict deployer address. - -``` -cast send --legacy --value 0.1ether --rpc-url $l1_rpc_url --private-key $private_key 0x3fab184622dc19b6109349b94811493bf2a45362 -cast send --legacy --value 0.1ether --rpc-url $l2_pp1_url --private-key $private_key 0x3fab184622dc19b6109349b94811493bf2a45362 -cast send --legacy --value 0.1ether --rpc-url $l2_pp2_url --private-key $private_key 0x3fab184622dc19b6109349b94811493bf2a45362 -``` - -The tx data and address are standard for the deterministict deployer - -``` -deterministic_deployer_tx=0xf8a58085174876e800830186a08080b853604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf31ba02222222222222222222222222222222222222222222222222222222222222222a02222222222222222222222222222222222222222222222222222222222222222 -deterministic_deployer_addr=0x4e59b44847b379578588920ca78fbf26c0b4956c - -cast publish --rpc-url $l1_rpc_url $deterministic_deployer_tx -cast publish --rpc-url $l2_pp1_url $deterministic_deployer_tx -cast publish --rpc-url $l2_pp2_url $deterministic_deployer_tx - - -salt=0x6a6f686e2068696c6c696172642077617320686572650a000000000000000000 -erc_20_bytecode=60806040526040516200143a3803806200143a833981016040819052620000269162000201565b8383600362000036838262000322565b50600462000045828262000322565b5050506200005a82826200007160201b60201c565b505081516020909201919091206006555062000416565b6001600160a01b038216620000cc5760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015260640160405180910390fd5b8060026000828254620000e09190620003ee565b90915550506001600160a01b038216600081815260208181526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b505050565b634e487b7160e01b600052604160045260246000fd5b600082601f8301126200016457600080fd5b81516001600160401b03808211156200018157620001816200013c565b604051601f8301601f19908116603f01168101908282118183101715620001ac57620001ac6200013c565b81604052838152602092508683858801011115620001c957600080fd5b600091505b83821015620001ed5785820183015181830184015290820190620001ce565b600093810190920192909252949350505050565b600080600080608085870312156200021857600080fd5b84516001600160401b03808211156200023057600080fd5b6200023e8883890162000152565b955060208701519150808211156200025557600080fd5b50620002648782880162000152565b604087015190945090506001600160a01b03811681146200028457600080fd5b6060959095015193969295505050565b600181811c90821680620002a957607f821691505b602082108103620002ca57634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200013757600081815260208120601f850160051c81016020861015620002f95750805b601f850160051c820191505b818110156200031a5782815560010162000305565b505050505050565b81516001600160401b038111156200033e576200033e6200013c565b62000356816200034f845462000294565b84620002d0565b602080601f8311600181146200038e5760008415620003755750858301515b600019600386901b1c1916600185901b1785556200031a565b600085815260208120601f198616915b82811015620003bf578886015182559484019460019091019084016200039e565b5085821015620003de5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b808201808211156200041057634e487b7160e01b600052601160045260246000fd5b92915050565b61101480620004266000396000f3fe608060405234801561001057600080fd5b506004361061014d5760003560e01c806340c10f19116100c35780639e4e73181161007c5780639e4e73181461033c578063a457c2d714610363578063a9059cbb14610376578063c473af3314610389578063d505accf146103b0578063dd62ed3e146103c357600080fd5b806340c10f19146102b257806342966c68146102c557806356189cb4146102d857806370a08231146102eb5780637ecebe001461031457806395d89b411461033457600080fd5b806323b872dd1161011557806323b872dd146101c357806330adf81f146101d6578063313ce567146101fd5780633408e4701461020c5780633644e51514610212578063395093511461029f57600080fd5b806304622c2e1461015257806306fdde031461016e578063095ea7b31461018357806318160ddd146101a6578063222f5be0146101ae575b600080fd5b61015b60065481565b6040519081526020015b60405180910390f35b6101766103d6565b6040516101659190610db1565b610196610191366004610e1b565b610468565b6040519015158152602001610165565b60025461015b565b6101c16101bc366004610e45565b610482565b005b6101966101d1366004610e45565b610492565b61015b7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b60405160128152602001610165565b4661015b565b61015b6006546000907f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f907fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc646604080516020810195909552840192909252606083015260808201523060a082015260c00160405160208183030381529060405280519060200120905090565b6101966102ad366004610e1b565b6104b6565b6101c16102c0366004610e1b565b6104d8565b6101c16102d3366004610e81565b6104e6565b6101c16102e6366004610e45565b6104f3565b61015b6102f9366004610e9a565b6001600160a01b031660009081526020819052604090205490565b61015b610322366004610e9a565b60056020526000908152604090205481565b6101766104fe565b61015b7fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc681565b610196610371366004610e1b565b61050d565b610196610384366004610e1b565b61058d565b61015b7f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f81565b6101c16103be366004610ebc565b61059b565b61015b6103d1366004610f2f565b6106ae565b6060600380546103e590610f62565b80601f016020809104026020016040519081016040528092919081815260200182805461041190610f62565b801561045e5780601f106104335761010080835404028352916020019161045e565b820191906000526020600020905b81548152906001019060200180831161044157829003601f168201915b5050505050905090565b6000336104768185856106d9565b60019150505b92915050565b61048d8383836107fd565b505050565b6000336104a08582856109a3565b6104ab8585856107fd565b506001949350505050565b6000336104768185856104c983836106ae565b6104d39190610fb2565b6106d9565b6104e28282610a17565b5050565b6104f03382610ad6565b50565b61048d8383836106d9565b6060600480546103e590610f62565b6000338161051b82866106ae565b9050838110156105805760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b60648201526084015b60405180910390fd5b6104ab82868684036106d9565b6000336104768185856107fd565b428410156105eb5760405162461bcd60e51b815260206004820152601960248201527f48455a3a3a7065726d69743a20415554485f45585049524544000000000000006044820152606401610577565b6001600160a01b038716600090815260056020526040812080547f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9918a918a918a91908661063883610fc5565b909155506040805160208101969096526001600160a01b0394851690860152929091166060840152608083015260a082015260c0810186905260e0016040516020818303038152906040528051906020012090506106998882868686610c08565b6106a48888886106d9565b5050505050505050565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6001600160a01b03831661073b5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610577565b6001600160a01b03821661079c5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610577565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b0383166108615760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610577565b6001600160a01b0382166108c35760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610577565b6001600160a01b0383166000908152602081905260409020548181101561093b5760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610577565b6001600160a01b03848116600081815260208181526040808320878703905593871680835291849020805487019055925185815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35b50505050565b60006109af84846106ae565b9050600019811461099d5781811015610a0a5760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610577565b61099d84848484036106d9565b6001600160a01b038216610a6d5760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610577565b8060026000828254610a7f9190610fb2565b90915550506001600160a01b038216600081815260208181526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b6001600160a01b038216610b365760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b6064820152608401610577565b6001600160a01b03821660009081526020819052604090205481811015610baa5760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b6064820152608401610577565b6001600160a01b0383166000818152602081815260408083208686039055600280548790039055518581529192917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3505050565b600654604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f602080830191909152818301939093527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a0808301919091528251808303909101815260c082019092528151919092012061190160f01b60e083015260e282018190526101028201869052906000906101220160408051601f198184030181528282528051602091820120600080855291840180845281905260ff89169284019290925260608301879052608083018690529092509060019060a0016020604051602081039080840390855afa158015610d1b573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811615801590610d515750876001600160a01b0316816001600160a01b0316145b6106a45760405162461bcd60e51b815260206004820152602b60248201527f48455a3a3a5f76616c69646174655369676e6564446174613a20494e56414c4960448201526a445f5349474e415455524560a81b6064820152608401610577565b600060208083528351808285015260005b81811015610dde57858101830151858201604001528201610dc2565b506000604082860101526040601f19601f8301168501019250505092915050565b80356001600160a01b0381168114610e1657600080fd5b919050565b60008060408385031215610e2e57600080fd5b610e3783610dff565b946020939093013593505050565b600080600060608486031215610e5a57600080fd5b610e6384610dff565b9250610e7160208501610dff565b9150604084013590509250925092565b600060208284031215610e9357600080fd5b5035919050565b600060208284031215610eac57600080fd5b610eb582610dff565b9392505050565b600080600080600080600060e0888a031215610ed757600080fd5b610ee088610dff565b9650610eee60208901610dff565b95506040880135945060608801359350608088013560ff81168114610f1257600080fd5b9699959850939692959460a0840135945060c09093013592915050565b60008060408385031215610f4257600080fd5b610f4b83610dff565b9150610f5960208401610dff565b90509250929050565b600181811c90821680610f7657607f821691505b602082108103610f9657634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b8082018082111561047c5761047c610f9c565b600060018201610fd757610fd7610f9c565b506001019056fea26469706673582212207bede9966bc8e8634cc0c3dc076626579b27dff7bbcac0b645c87d4cf1812b9864736f6c63430008140033 -constructor_args=$(cast abi-encode 'f(string,string,address,uint256)' 'Bridge Test' 'BT' "$target_address" 100000000000000000000 | sed 's/0x//') - -cast send --legacy --rpc-url $l1_rpc_url --private-key $private_key $deterministic_deployer_addr $salt$erc_20_bytecode$constructor_args -cast send --legacy --rpc-url $l2_pp1_url --private-key $private_key $deterministic_deployer_addr $salt$erc_20_bytecode$constructor_args -cast send --legacy --rpc-url $l2_pp2_url --private-key $private_key $deterministic_deployer_addr $salt$erc_20_bytecode$constructor_args - -test_erc20_addr=$(cast create2 --salt $salt --init-code $erc_20_bytecode$constructor_args) - -cast send --legacy --rpc-url $l1_rpc_url --private-key $target_private_key $test_erc20_addr 'approve(address,uint256)' $bridge_address 100000000000000000000 -cast send --legacy --rpc-url $l2_pp1_url --private-key $target_private_key $test_erc20_addr 'approve(address,uint256)' $bridge_address 100000000000000000000 -cast send --legacy --rpc-url $l2_pp2_url --private-key $target_private_key $test_erc20_addr 'approve(address,uint256)' $bridge_address 100000000000000000000 - -erc20_buggy_bytecode=608060405234801561001057600080fd5b506040516109013803806109018339818101604052606081101561003357600080fd5b810190808051604051939291908464010000000082111561005357600080fd5b90830190602082018581111561006857600080fd5b825164010000000081118282018810171561008257600080fd5b82525081516020918201929091019080838360005b838110156100af578181015183820152602001610097565b50505050905090810190601f1680156100dc5780820380516001836020036101000a031916815260200191505b50604052602001805160405193929190846401000000008211156100ff57600080fd5b90830190602082018581111561011457600080fd5b825164010000000081118282018810171561012e57600080fd5b82525081516020918201929091019080838360005b8381101561015b578181015183820152602001610143565b50505050905090810190601f1680156101885780820380516001836020036101000a031916815260200191505b5060405260209081015185519093506101a792506003918601906101d8565b5081516101bb9060049060208501906101d8565b506005805460ff191660ff92909216919091179055506102799050565b828054600181600116156101000203166002900490600052602060002090601f01602090048101928261020e5760008555610254565b82601f1061022757805160ff1916838001178555610254565b82800160010185558215610254579182015b82811115610254578251825591602001919060010190610239565b50610260929150610264565b5090565b5b808211156102605760008155600101610265565b610679806102886000396000f3fe608060405234801561001057600080fd5b50600436106100b45760003560e01c806370a082311161007157806370a082311461021257806395d89b41146102385780639dc29fac14610240578063a9059cbb1461026c578063b46310f614610298578063dd62ed3e146102c4576100b4565b806306fdde03146100b9578063095ea7b31461013657806318160ddd1461017657806323b872dd14610190578063313ce567146101c657806340c10f19146101e4575b600080fd5b6100c16102f2565b6040805160208082528351818301528351919283929083019185019080838360005b838110156100fb5781810151838201526020016100e3565b50505050905090810190601f1680156101285780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101626004803603604081101561014c57600080fd5b506001600160a01b038135169060200135610380565b604080519115158252519081900360200190f35b61017e6103e6565b60408051918252519081900360200190f35b610162600480360360608110156101a657600080fd5b506001600160a01b038135811691602081013590911690604001356103ec565b6101ce610466565b6040805160ff9092168252519081900360200190f35b610210600480360360408110156101fa57600080fd5b506001600160a01b03813516906020013561046f565b005b61017e6004803603602081101561022857600080fd5b50356001600160a01b031661047d565b6100c161048f565b6102106004803603604081101561025657600080fd5b506001600160a01b0381351690602001356104ea565b6101626004803603604081101561028257600080fd5b506001600160a01b0381351690602001356104f4565b610210600480360360408110156102ae57600080fd5b506001600160a01b03813516906020013561054f565b61017e600480360360408110156102da57600080fd5b506001600160a01b038135811691602001351661056b565b6003805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156103785780601f1061034d57610100808354040283529160200191610378565b820191906000526020600020905b81548152906001019060200180831161035b57829003601f168201915b505050505081565b3360008181526002602090815260408083206001600160a01b038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a350600192915050565b60005481565b6001600160a01b0380841660008181526002602090815260408083203384528252808320805487900390558383526001825280832080548790039055938616808352848320805487019055845186815294519294909392600080516020610624833981519152929181900390910190a35060019392505050565b60055460ff1681565b6104798282610588565b5050565b60016020526000908152604090205481565b6004805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156103785780601f1061034d57610100808354040283529160200191610378565b61047982826105d3565b336000818152600160209081526040808320805486900390556001600160a01b03861680845281842080548701905581518681529151939490939092600080516020610624833981519152928290030190a350600192915050565b6001600160a01b03909116600090815260016020526040902055565b600260209081526000928352604080842090915290825290205481565b6001600160a01b038216600081815260016020908152604080832080548601905582548501835580518581529051600080516020610624833981519152929181900390910190a35050565b6001600160a01b0382166000818152600160209081526040808320805486900390558254859003835580518581529051929392600080516020610624833981519152929181900390910190a3505056feddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa2646970667358221220364a383ccce0e270376267b8631412d1b7ddb1883c5379556b58cbefc1ca504564736f6c63430007060033 -constructor_args=$(cast abi-encode 'f(string,string,uint8)' 'Buggy ERC20' 'BUG' "18" | sed 's/0x//') - -cast send --legacy --rpc-url $l1_rpc_url --private-key $private_key $deterministic_deployer_addr $salt$erc20_buggy_bytecode$constructor_args -cast send --legacy --rpc-url $l2_pp1_url --private-key $private_key $deterministic_deployer_addr $salt$erc20_buggy_bytecode$constructor_args -cast send --legacy --rpc-url $l2_pp2_url --private-key $private_key $deterministic_deployer_addr $salt$erc20_buggy_bytecode$constructor_args - -test_erc20_buggy_addr=$(cast create2 --salt $salt --init-code $erc20_buggy_bytecode$constructor_args) - -cast send --legacy --rpc-url $l1_rpc_url --private-key $target_private_key $test_erc20_buggy_addr 'mint(address,uint256)' $target_address $(cast max-uint) -cast send --legacy --rpc-url $l2_pp1_url --private-key $target_private_key $test_erc20_buggy_addr 'mint(address,uint256)' $target_address $(cast max-uint) -cast send --legacy --rpc-url $l2_pp2_url --private-key $target_private_key $test_erc20_buggy_addr 'mint(address,uint256)' $target_address $(cast max-uint) - -cast send --legacy --rpc-url $l1_rpc_url --private-key $target_private_key $test_erc20_buggy_addr 'approve(address,uint256)' $bridge_address $(cast max-uint) -cast send --legacy --rpc-url $l2_pp1_url --private-key $target_private_key $test_erc20_buggy_addr 'approve(address,uint256)' $bridge_address $(cast max-uint) -cast send --legacy --rpc-url $l2_pp2_url --private-key $target_private_key $test_erc20_buggy_addr 'approve(address,uint256)' $bridge_address $(cast max-uint) -``` - -One of the test cases that I've left out for now is a permit -call. It'll take some work to get the signed permit data in place, -but it seems doable. - -- https://eips.ethereum.org/EIPS/eip-2612 -- https://eips.ethereum.org/EIPS/eip-712 - -permit_sig=$(cast wallet sign --private-key $target_private_key 0x$(< /dev/urandom xxd -p | tr -d "\n" | head -c 40)) -permit_sig_r=${permit_sig:2:64} -permit_sig_s=${permit_sig:66:64} -permit_sig_v=${permit_sig:130:2} -The test cases are committed for convenience, we'll use that to -dynamically to some testing - -``` -cat test-scenarios.json | jq -c '.[]' | while read scenario ; do - testBridgeType=$(echo $scenario | jq -r '.BridgeType') - testDepositChain=$(echo $scenario | jq -r '.DepositChain') - testDestinationChain=$(echo $scenario | jq -r '.DestinationChain') - testDestinationAddress=$(echo $scenario | jq -r '.DestinationAddress') - testToken=$(echo $scenario | jq -r '.Token') - testMetaData=$(echo $scenario | jq -r '.MetaData') - testForceUpdate=$(echo $scenario | jq -r '.ForceUpdate') - testAmount=$(echo $scenario | jq -r '.Amount') - - testCommand="polycli ulxly bridge" - - if [[ $testBridgeType == "Asset" ]]; then - testCommand="$testCommand asset" - elif [[ $testBridgeType == "Message" ]]; then - testCommand="$testCommand message" - else - testCommand="$testCommand weth" - fi - - temp_rpc_url="" - if [[ $testDepositChain == "L1" ]]; then - testCommand="$testCommand --rpc-url $l1_rpc_url" - temp_rpc_url="$l1_rpc_url" - elif [[ $testDepositChain == "PP1" ]]; then - testCommand="$testCommand --rpc-url $l2_pp1_url" - temp_rpc_url="$l2_pp1_url" - else - testCommand="$testCommand --rpc-url $l2_pp2_url" - temp_rpc_url="$l2_pp2_url" - fi - - if [[ $testDestinationChain == "L1" ]]; then - testCommand="$testCommand --destination-network 0" - elif [[ $testDestinationChain == "PP1" ]]; then - testCommand="$testCommand --destination-network 1" - else - testCommand="$testCommand --destination-network 2" - fi - - if [[ $testDestinationAddress == "Contract" ]]; then - testCommand="$testCommand --destination-address $bridge_address" - elif [[ $testDestinationAddress == "Precompile" ]]; then - testCommand="$testCommand --destination-address 0x0000000000000000000000000000000000000004" - else - testCommand="$testCommand --destination-address $target_address" - fi - - if [[ $testToken == "POL" ]]; then - testCommand="$testCommand --token-address $pol_address" - elif [[ $testToken == "LocalERC20" ]]; then - testCommand="$testCommand --token-address $test_erc20_addr" - elif [[ $testToken == "WETH" ]]; then - testCommand="$testCommand --token-address $pp2_weth_address" - elif [[ $testToken == "Buggy" ]]; then - testCommand="$testCommand --token-address $test_erc20_buggy_addr" - else - testCommand="$testCommand --token-address 0x0000000000000000000000000000000000000000" - fi - - if [[ $testMetaData == "Random" ]]; then - testCommand="$testCommand --call-data $(date +%s | xxd -p)" - else - testCommand="$testCommand --call-data 0x" - fi - - if [[ $testForceUpdate == "True" ]]; then - testCommand="$testCommand --force-update-root=true" - else - testCommand="$testCommand --force-update-root=false" - fi - - if [[ $testAmount == "0" ]]; then - testCommand="$testCommand --value 0" - elif [[ $testAmount == "1" ]]; then - testCommand="$testCommand --value 1" - elif [[ $testAmount == "Max" ]]; then - cast send --legacy --rpc-url $temp_rpc_url --private-key $target_private_key $test_erc20_buggy_addr 'mint(address,uint256)' $target_address $(cast max-uint) - cast send --legacy --rpc-url $temp_rpc_url --private-key $target_private_key $test_erc20_buggy_addr 'setBalanceOf(address,uint256)' $bridge_address 0 - testCommand="$testCommand --value $(cast max-uint)" - else - testCommand="$testCommand --value $(date +%s)" - fi - - testCommand="$testCommand --bridge-address $bridge_address" - testCommand="$testCommand --private-key $target_private_key" - - echo $scenario | jq -c '.' - echo $testCommand - $testCommand - - # In this particular case, we should zero the bridge out after the deposit is made - if [[ $testAmount == "Max" ]]; then - cast send --legacy --rpc-url $temp_rpc_url --private-key $target_private_key $test_erc20_buggy_addr 'setBalanceOf(address,uint256)' $bridge_address 0 - fi -done - - -polycli ulxly claim-everything \ - --bridge-address $bridge_address \ - --bridge-service-map 1=$l2_pp1b_url \ - --bridge-service-map 2=$l2_pp2b_url \ - --rpc-url $l2_pp1_url \ - --destination-address $target_address \ - --private-key $private_key \ - --bridge-limit 100 - -polycli ulxly claim-everything \ - --bridge-address $bridge_address \ - --bridge-service-map 1=$l2_pp1b_url \ - --bridge-service-map 2=$l2_pp2b_url \ - --rpc-url $l2_pp2_url \ - --destination-address $target_address \ - --private-key $private_key \ - --bridge-limit 100 - -polycli ulxly claim-everything \ - --bridge-address $bridge_address \ - --bridge-service-map 1=$l2_pp1b_url \ - --bridge-service-map 2=$l2_pp2b_url \ - --rpc-url $l1_rpc_url \ - --destination-address $target_address \ - --private-key $private_key \ - --bridge-limit 100 -``` - -## Buggy ERC 20 - -These are some simple tests to try bridging more than the uint max -limit to understand how the balance tree might be impacted. We're -going to run thie snippt below a few times which does the following. - -1. Bridge the max amount possible from the target address. This -assumes we've already minted some -2. Mint the max amount again for the target address. -3. Zero out the balance of the bridge - -Repeat that a few times just to make sure everything is okay. The -commands below are for doing tests from PP1 to PP2 - -``` -polycli ulxly bridge asset \ - --private-key $target_private_key \ - --value 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe \ - --bridge-address $bridge_address \ - --destination-network 2 \ - --destination-address $target_address \ - --rpc-url $l2_pp1_url \ - --token-address $test_erc20_buggy_addr \ - --force-update-root=true - -cast send --legacy --rpc-url $l2_pp1_url --private-key $target_private_key $test_erc20_buggy_addr 'mint(address,uint256)' $target_address $(cast max-uint) -cast send --legacy --rpc-url $l2_pp1_url --private-key $target_private_key $test_erc20_buggy_addr 'setBalanceOf(address,uint256)' $bridge_address 0 -``` - -These commands do the same thing more or less but from PP2 to PP1 - -``` -polycli ulxly bridge asset \ - --private-key $target_private_key \ - --value 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe \ - --bridge-address $bridge_address \ - --destination-network 1 \ - --destination-address $target_address \ - --rpc-url $l2_pp2_url \ - --token-address $test_erc20_buggy_addr \ - --force-update-root=true - -cast send --legacy --rpc-url $l2_pp2_url --private-key $target_private_key $test_erc20_buggy_addr 'mint(address,uint256)' $target_address $(cast max-uint) -cast send --legacy --rpc-url $l2_pp2_url --private-key $target_private_key $test_erc20_buggy_addr 'setBalanceOf(address,uint256)' $bridge_address 0 -``` - -Then do the same thing for PP2 to L1 - -``` -polycli ulxly bridge asset \ - --private-key $target_private_key \ - --value 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe \ - --bridge-address $bridge_address \ - --destination-network 0 \ - --destination-address $target_address \ - --rpc-url $l2_pp2_url \ - --token-address $test_erc20_buggy_addr \ - --force-update-root=true - -cast send --legacy --rpc-url $l2_pp2_url --private-key $target_private_key $test_erc20_buggy_addr 'mint(address,uint256)' $target_address $(cast max-uint) -cast send --legacy --rpc-url $l2_pp2_url --private-key $target_private_key $test_erc20_buggy_addr 'setBalanceOf(address,uint256)' $bridge_address 0 - -curl -s $l2_pp1b_url/bridges/$target_address -``` - -## Calling through a smart contract of some kind - -The idea here is to do some transactions through a proxy or some kind so - -``` -lxly_proxy_bytecode=608060405234801561001057600080fd5b50604051610acb380380610acb83398101604081905261002f91610054565b600080546001600160a01b0319166001600160a01b0392909216919091179055610084565b60006020828403121561006657600080fd5b81516001600160a01b038116811461007d57600080fd5b9392505050565b610a38806100936000396000f3fe6080604052600436106100955760003560e01c8063b8b284d011610059578063b8b284d014610196578063ccaa2d11146101c9578063cd586579146101e9578063dd96eab7146101fc578063f5efcd79146101fc57610116565b80631c253d72146101965780631eb5f7aa146101b6578063240ff378146101b65780632c4422ca146101c95780635ea89907146101e957610116565b366101165760008054604051630481fe6f60e31b815263ffffffff34166004820152336024820152600160448201526080606482015260848101929092526001600160a01b03169063240ff3789060a401600060405180830381600087803b15801561010057600080fd5b505af1158015610114573d6000803e3d6000fd5b005b60008054604051630481fe6f60e31b815236916060916001600160a01b039091169063240ff37890610155903490339060019089908990600401610436565b600060405180830381600087803b15801561016f57600080fd5b505af1158015610183573d6000803e3d6000fd5b5050604080516020810190915260009052005b3480156101a257600080fd5b506101146101b136600461056f565b61021c565b6101146101c43660046105e8565b61028d565b3480156101d557600080fd5b506101146101e43660046106c5565b6102fb565b6101146101f7366004610799565b61037e565b34801561020857600080fd5b506101146102173660046106c5565b6103f2565b600054604051630b8b284d60e41b81526001600160a01b039091169063b8b284d0906102549088908890889088908890600401610867565b600060405180830381600087803b15801561026e57600080fd5b505af1158015610282573d6000803e3d6000fd5b505050505050505050565b600054604051630481fe6f60e31b81526001600160a01b039091169063240ff378906102c39087908790879087906004016108ad565b600060405180830381600087803b1580156102dd57600080fd5b505af11580156102f1573d6000803e3d6000fd5b5050505050505050565b60005460405163ccaa2d1160e01b81526001600160a01b039091169063ccaa2d119061033f908e908e908e908e908e908e908e908e908e908e908e9060040161091c565b600060405180830381600087803b15801561035957600080fd5b505af115801561036d573d6000803e3d6000fd5b505050505050505050505050505050565b60005460405163cd58657960e01b81526001600160a01b039091169063cd586579906103b8908990899089908990899089906004016109af565b600060405180830381600087803b1580156103d257600080fd5b505af11580156103e6573d6000803e3d6000fd5b50505050505050505050565b60005460405163f5efcd7960e01b81526001600160a01b039091169063f5efcd799061033f908e908e908e908e908e908e908e908e908e908e908e9060040161091c565b63ffffffff861681526001600160a01b038516602082015283151560408201526080606082018190528101829052818360a0830137600081830160a090810191909152601f909201601f19160101949350505050565b803563ffffffff811681146104a057600080fd5b919050565b80356001600160a01b03811681146104a057600080fd5b803580151581146104a057600080fd5b634e487b7160e01b600052604160045260246000fd5b600082601f8301126104f357600080fd5b813567ffffffffffffffff8082111561050e5761050e6104cc565b604051601f8301601f19908116603f01168101908282118183101715610536576105366104cc565b8160405283815286602085880101111561054f57600080fd5b836020870160208301376000602085830101528094505050505092915050565b600080600080600060a0868803121561058757600080fd5b6105908661048c565b945061059e602087016104a5565b9350604086013592506105b3606087016104bc565b9150608086013567ffffffffffffffff8111156105cf57600080fd5b6105db888289016104e2565b9150509295509295909350565b600080600080608085870312156105fe57600080fd5b6106078561048c565b9350610615602086016104a5565b9250610623604086016104bc565b9150606085013567ffffffffffffffff81111561063f57600080fd5b61064b878288016104e2565b91505092959194509250565b600082601f83011261066857600080fd5b60405161040080820182811067ffffffffffffffff8211171561068d5761068d6104cc565b604052830181858211156106a057600080fd5b845b828110156106ba5780358252602091820191016106a2565b509195945050505050565b60008060008060008060008060008060006109208c8e0312156106e757600080fd5b6106f18d8d610657565b9a506107018d6104008e01610657565b99506108008c013598506108208c013597506108408c013596506107286108608d0161048c565b95506107376108808d016104a5565b94506107466108a08d0161048c565b93506107556108c08d016104a5565b92506108e08c013591506109008c013567ffffffffffffffff81111561077a57600080fd5b6107868e828f016104e2565b9150509295989b509295989b9093969950565b60008060008060008060c087890312156107b257600080fd5b6107bb8761048c565b95506107c9602088016104a5565b9450604087013593506107de606088016104a5565b92506107ec608088016104bc565b915060a087013567ffffffffffffffff81111561080857600080fd5b61081489828a016104e2565b9150509295509295509295565b6000815180845260005b818110156108475760208185018101518683018201520161082b565b506000602082860101526020601f19601f83011685010191505092915050565b63ffffffff8616815260018060a01b0385166020820152836040820152821515606082015260a0608082015260006108a260a0830184610821565b979650505050505050565b63ffffffff851681526001600160a01b038416602082015282151560408201526080606082018190526000906108e590830184610821565b9695505050505050565b8060005b60208082106109025750610916565b8251855293840193909101906001016108f3565b50505050565b600061092061092b838f6108ef565b61093961040084018e6108ef565b61080083018c905261082083018b905261084083018a905263ffffffff8981166108608501526001600160a01b038981166108808601529088166108a085015286166108c08401526108e08301859052610900830181905261099d81840185610821565b9e9d5050505050505050505050505050565b63ffffffff871681526001600160a01b0386811660208301526040820186905284166060820152821515608082015260c060a082018190526000906109f690830184610821565b9897505050505050505056fea2646970667358221220b86e525972f2e2cc9d33328df79fceaa11e88478f9966dde327eeec360259b4964736f6c63430008140033 - -constructor_args=$(cast abi-encode 'f(address)' $bridge_address | sed 's/0x//') - -cast send --legacy --rpc-url $l1_rpc_url --private-key $private_key $deterministic_deployer_addr $salt$lxly_proxy_bytecode$constructor_args -cast send --legacy --rpc-url $l2_pp1_url --private-key $private_key $deterministic_deployer_addr $salt$lxly_proxy_bytecode$constructor_args -cast send --legacy --rpc-url $l2_pp2_url --private-key $private_key $deterministic_deployer_addr $salt$lxly_proxy_bytecode$constructor_args - -test_lxly_proxy_addr=$(cast create2 --salt $salt --init-code $lxly_proxy_bytecode$constructor_args) - -cast send --legacy --value 2 --rpc-url $l1_rpc_url --private-key $target_private_key $test_lxly_proxy_addr -cast send --legacy --value 3 --rpc-url $l2_pp1_url --private-key $target_private_key $test_lxly_proxy_addr -cast send --legacy --value 1 --rpc-url $l2_pp2_url --private-key $target_private_key $test_lxly_proxy_addr -``` - -In in my test environment I've deployed a contract specifically for -testing. You might not have this. The idea is to call the bridge -contract from a bunch of contexts and ensure that things more or -less still work - -``` -tester_contract_address=0xc54E34B55EF562FE82Ca858F70D1B73244e86388 -``` - -address_tester_actions="001 002 003 004 011 012 013 014 021 022 023 024 031 032 033 034 041 042 043 044 101 201 301 401 501 601 701 801 901" - -``` -address_tester_actions="001 011 021 031 041 101 201 301 401 501 601 701 801 901" - -for create_mode in 0 1 2; do - for action in $address_tester_actions ; do - cast send --gas-limit 1000000 --legacy --value 1 --rpc-url $l1_rpc_url --private-key $target_private_key $tester_contract_address $(cast abi-encode 'f(uint32, address, uint256)' 0x"$create_mode$action" $test_lxly_proxy_addr 1) - cast send --gas-limit 1000000 --legacy --value 2 --rpc-url $l1_rpc_url --private-key $target_private_key $tester_contract_address $(cast abi-encode 'f(uint32, address, uint256)' 0x"$create_mode$action" $test_lxly_proxy_addr 2) - - cast send --gas-limit 1000000 --legacy --value 0 --rpc-url $l2_pp1_url --private-key $target_private_key $tester_contract_address $(cast abi-encode 'f(uint32, address, uint256)' 0x"$create_mode$action" $test_lxly_proxy_addr 0) - cast send --gas-limit 1000000 --legacy --value 2 --rpc-url $l2_pp1_url --private-key $target_private_key $tester_contract_address $(cast abi-encode 'f(uint32, address, uint256)' 0x"$create_mode$action" $test_lxly_proxy_addr 2) - - cast send --gas-limit 1000000 --legacy --value 0 --rpc-url $l2_pp2_url --private-key $target_private_key $tester_contract_address $(cast abi-encode 'f(uint32, address, uint256)' 0x"$create_mode$action" $test_lxly_proxy_addr 0) - cast send --gas-limit 1000000 --legacy --value 1 --rpc-url $l2_pp2_url --private-key $target_private_key $tester_contract_address $(cast abi-encode 'f(uint32, address, uint256)' 0x"$create_mode$action" $test_lxly_proxy_addr 1) - done -done -``` - -TODO add a test where there is more than uint256 funds -TODO add some tests with reverting -TODO add some tests where the bridge is called via a smart contract rather than directly -TODO add a scneario that does a full sweep of the target account native token and the end to ensure all of the accounting looks good - -``` -cast send --legacy --gas-limit 1000000 --value 2 --rpc-url $l2_pp1_url --private-key $target_private_key $tester_contract_address $(cast abi-encode 'f(uint32, address, uint256)' 0x0201 $test_lxly_proxy_addr 2) - -polycli ulxly claim-everything \ - --bridge-address $bridge_address \ - --bridge-service-map 1=$l2_pp1b_url \ - --bridge-service-map 2=$l2_pp2b_url \ - --destination-address $target_address \ - --private-key $target_private_key \ - --rpc-url $l2_pp1_url \ - --bridge-limit 100 - -polycli ulxly claim-everything \ - --bridge-address $bridge_address \ - --bridge-service-map 1=$l2_pp1b_url \ - --bridge-service-map 2=$l2_pp2b_url \ - --destination-address $target_address \ - --private-key $target_private_key \ - --rpc-url $l2_pp2_url \ - --bridge-limit 100 - -polycli ulxly claim-everything \ - --bridge-address $bridge_address \ - --bridge-service-map 1=$l2_pp1b_url \ - --bridge-service-map 2=$l2_pp2b_url \ - --destination-address $target_address \ - --private-key $target_private_key \ - --rpc-url $l1_rpc_url \ - --bridge-limit 100 - -curl -s "$l2_pp1b_url/bridges/0xbecE3a31343c6019CDE0D5a4dF2AF8Df17ebcB0f?limit=150" | jq '.deposits[] | select(.deposit_cnt == 111)' -curl -s "$l2_pp1b_url/merkle-proof?deposit_cnt=111&net_id=0" | jq '.' -curl -s "$l2_pp1b_url/merkle-proof?deposit_cnt=111&net_id=1" | jq '.' -curl -s "$l2_pp1b_url/merkle-proof?deposit_cnt=111&net_id=2" | jq '.' - -curl -s "$l2_pp2b_url/bridges/0xbecE3a31343c6019CDE0D5a4dF2AF8Df17ebcB0f?limit=150" | jq '.deposits[] | select(.tx_hash == "0x932945c01362a5e121405b6bf38b14da8b6ddeee253732cdf362be74b455bea8")' -curl -s "$l2_pp2b_url/bridges/0xbecE3a31343c6019CDE0D5a4dF2AF8Df17ebcB0f?limit=150" | jq '.deposits[] | select(.deposit_cnt == 111)' -curl -s "$l2_pp2b_url/merkle-proof?deposit_cnt=111&net_id=0" | jq '.' -curl -s "$l2_pp2b_url/merkle-proof?deposit_cnt=111&net_id=1" | jq '.' -curl -s "$l2_pp2b_url/merkle-proof?deposit_cnt=111&net_id=2" | jq '.' -``` - +There are some more advanced test cases in the init.sh script and +run.sh script in this folder ## State Capture Procedure ``` @@ -834,6 +526,8 @@ mkdir cdk-001 docker cp cdk-node-001--bd52b030071a4c438cf82b6c281219e6:/tmp cdk-001/ mkdir cdk-002 docker cp cdk-node-002--3c9a92d0e1aa4259a795d7a60156188c:/tmp cdk-002/ +mkdir cdk-003 +docker cp cdk-node-003--60ace3d2425e43df8f0da4f8058d97f9:/tmp cdk-003/ kurtosis enclave dump pp popd diff --git a/docs/multi-pp-testing/init.sh b/docs/multi-pp-testing/init.sh new file mode 100755 index 00000000..e2039dff --- /dev/null +++ b/docs/multi-pp-testing/init.sh @@ -0,0 +1,196 @@ +#!/bin/bash + +if [[ ! -e gas-token-address.json ]]; then + echo "it looks like the gas-token-address.json file doesn't exist. Make sure you run this from the root directory" + exit 1 +fi + +if [[ ! -e combined-001.json ]]; then + echo "it looks like the combined-001.json file doesn't exist. Make sure you run this from the root directory" + exit 1 +fi + +l1_rpc_url=http://$(kurtosis port print pp el-1-geth-lighthouse rpc) +l2_pp1_url=$(kurtosis port print pp cdk-erigon-rpc-001 rpc) +l2_pp2_url=$(kurtosis port print pp cdk-erigon-rpc-002 rpc) +l2_fep_url=$(kurtosis port print pp cdk-erigon-rpc-003 rpc) + +l2_pp1b_url=$(kurtosis port print pp zkevm-bridge-service-001 rpc) +l2_pp2b_url=$(kurtosis port print pp zkevm-bridge-service-002 rpc) +l2_fepb_url=$(kurtosis port print pp zkevm-bridge-service-003 rpc) + +private_key="0x12d7de8621a77640c9241b2595ba78ce443d05e94090365ab3bb5e19df82c625" +eth_address="$(cast wallet address --private-key $private_key)" + +rpc_list="$l1_rpc_url $l2_fep_url $l2_pp1_url $l2_pp2_url" + +network_id_l1=0 +network_id_pp1=1 +network_id_pp2=2 +network_id_fep=3 + +bridge_address=$(cat combined-001.json | jq -r .polygonZkEVMBridgeAddress) +pol_address=$(cat combined-001.json | jq -r .polTokenAddress) +gas_token_address=$( docs/multi-pp-testing/test-scenarios.json diff --git a/docs/multi-pp-testing/run.sh b/docs/multi-pp-testing/run.sh new file mode 100755 index 00000000..9045f881 --- /dev/null +++ b/docs/multi-pp-testing/run.sh @@ -0,0 +1,226 @@ +#!/bin/bash + +if [[ ! -e docs/multi-pp-testing/test-scenarios.json ]]; then + echo "expected to find test scenarios in docs/multi-pp-testing/test-scenarios.json. Maybe we're not in the root of the repo?" + exit 1 +fi + +tester_contract_address=0xc54E34B55EF562FE82Ca858F70D1B73244e86388 +test_erc20_buggy_addr=0x22939b3A4dFD9Fc6211F99Cdc6bd9f6708ae2956 +test_lxly_proxy_addr=0x1786B94e55cA57b897aF0f59a1e5b31EA0469547 +tester_contract_address=0xc54E34B55EF562FE82Ca858F70D1B73244e86388 + +l1_rpc_url=http://$(kurtosis port print pp el-1-geth-lighthouse rpc) +l2_pp1_url=$(kurtosis port print pp cdk-erigon-rpc-001 rpc) +l2_pp2_url=$(kurtosis port print pp cdk-erigon-rpc-002 rpc) +l2_fep_url=$(kurtosis port print pp cdk-erigon-rpc-003 rpc) + +l2_pp1b_url=$(kurtosis port print pp zkevm-bridge-service-001 rpc) +l2_pp2b_url=$(kurtosis port print pp zkevm-bridge-service-002 rpc) +l2_fepb_url=$(kurtosis port print pp zkevm-bridge-service-003 rpc) + +private_key="0x12d7de8621a77640c9241b2595ba78ce443d05e94090365ab3bb5e19df82c625" +eth_address="$(cast wallet address --private-key $private_key)" + +rpc_list="$l1_rpc_url $l2_fep_url $l2_pp1_url $l2_pp2_url" + +network_id_l1=0 +network_id_pp1=1 +network_id_pp2=2 +network_id_fep=3 + +bridge_address=$(cat combined-001.json | jq -r .polygonZkEVMBridgeAddress) +pol_address=$(cat combined-001.json | jq -r .polTokenAddress) +gas_token_address=$( Date: Mon, 6 Jan 2025 11:14:30 -0500 Subject: [PATCH 35/38] fix: tempoarily disable --- .github/workflows/test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4b00d8f1..b801fee8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,7 +3,8 @@ # https://github.com/0xPolygon/cdk/blob/main/.github/workflows/test-e2e.yml name: Test -on: +on: + workflow_dispatch: # This keeps the workflow valid but prevents it from being triggered automatically. pull_request: push: branches: [main] From 498a8db0ff612a5a127ef11c93d4d9b8dfa84524 Mon Sep 17 00:00:00 2001 From: John Hilliard Date: Mon, 6 Jan 2025 11:30:53 -0500 Subject: [PATCH 36/38] fix: dropping some ci --- .github/workflows/lint.yml | 2 +- .github/workflows/test.yml | 27 ++++++++++++++------------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 9bd2d5f7..0dd622b8 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -50,7 +50,7 @@ jobs: run: find . -type f -name '*.Dockerfile' | sort | xargs -I {} hadolint --config ${{ github.workspace }}/.hadolint.yml {} - name: Run shellcheck - run: find . -type f -name '*.sh' | sort | xargs -I {} shellcheck {} + run: find . -type f -name '*.sh' | grep -v "./docs" | sort | xargs -I {} shellcheck {} check-test-combinations-and-cdk-version-matrix: runs-on: ubuntu-latest diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b801fee8..1de16014 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,7 +4,6 @@ name: Test on: - workflow_dispatch: # This keeps the workflow valid but prevents it from being triggered automatically. pull_request: push: branches: [main] @@ -19,6 +18,7 @@ env: jobs: build-cdk-image: + if: false runs-on: ubuntu-latest timeout-minutes: 10 steps: @@ -39,10 +39,10 @@ jobs: - name: Build cdk docker image working-directory: cdk run: make build-docker - + - name: Save cdk image to archive run: docker save --output /tmp/cdk.tar cdk - + - name: Upload archive uses: actions/upload-artifact@v4 with: @@ -50,6 +50,7 @@ jobs: path: /tmp/cdk.tar cdk-e2e-tests: + if: false runs-on: ubuntu-latest timeout-minutes: 45 needs: build-cdk-image @@ -64,7 +65,7 @@ jobs: - "fork12-pessimistic" steps: - uses: actions/checkout@v4 - + - name: Login to Docker Hub uses: docker/login-action@v3 with: @@ -76,15 +77,15 @@ jobs: env: DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} - + - name: Install Kurtosis CDK tools uses: ./.github/actions/setup-kurtosis-cdk - + - name: Install polycli run: | - tmp_dir=$(mktemp -d) - curl -L "https://github.com/0xPolygon/polygon-cli/releases/download/${{ env.POLYCLI_VERSION }}/polycli_${{ env.POLYCLI_VERSION }}_linux_amd64.tar.gz" | tar -xz -C "$tmp_dir" - mv "$tmp_dir"/* /usr/local/bin/polycli + tmp_dir=$(mktemp -d) + curl -L "https://github.com/0xPolygon/polygon-cli/releases/download/${{ env.POLYCLI_VERSION }}/polycli_${{ env.POLYCLI_VERSION }}_linux_amd64.tar.gz" | tar -xz -C "$tmp_dir" + mv "$tmp_dir"/* /usr/local/bin/polycli rm -rf "$tmp_dir" sudo chmod +x /usr/local/bin/polycli /usr/local/bin/polycli version @@ -98,13 +99,13 @@ jobs: - name: Setup bats uses: bats-core/bats-action@3.0.0 - + - name: Download cdk archive uses: actions/download-artifact@v4 with: name: cdk path: /tmp - + - name: Load cdk image run: | docker load --input /tmp/cdk.tar @@ -121,11 +122,11 @@ jobs: KURTOSIS_FOLDER: ${{ github.workspace }} BATS_LIB_PATH: /usr/lib/ agglayer_prover_sp1_key: ${{ secrets.SP1_PRIVATE_KEY }} - + - name: Dump enclave if: failure() run: kurtosis enclave dump cdk ./dump - + - name: Generate archive name if: failure() run: | From 5ca6eae019470cdbb0a7ace36cd2ccdf09bdc90f Mon Sep 17 00:00:00 2001 From: John Hilliard Date: Mon, 6 Jan 2025 11:58:11 -0500 Subject: [PATCH 37/38] feat: adding reasonable default --- docs/multi-pp-testing/net1.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/multi-pp-testing/net1.yml b/docs/multi-pp-testing/net1.yml index ec1f8cf7..a60f1d28 100644 --- a/docs/multi-pp-testing/net1.yml +++ b/docs/multi-pp-testing/net1.yml @@ -7,5 +7,5 @@ args: gas_token_enabled: false zkevm_use_real_verifier: true enable_normalcy: true - agglayer_prover_sp1_key: bepp # DONOTCOMMIT + agglayer_prover_sp1_key: 0xSOME_SP1_KEY From 5152850f72dca7237b9360b438e705c028447e2b Mon Sep 17 00:00:00 2001 From: John Hilliard Date: Mon, 6 Jan 2025 12:04:02 -0500 Subject: [PATCH 38/38] feat: bumping bridge service version --- input_parser.star | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/input_parser.star b/input_parser.star index f91388f3..264e31d9 100644 --- a/input_parser.star +++ b/input_parser.star @@ -38,7 +38,7 @@ DEFAULT_IMAGES = { "cdk_node_image": "ghcr.io/0xpolygon/cdk:0.5.0-beta10", # https://github.com/0xpolygon/cdk/pkgs/container/cdk "cdk_validium_node_image": "0xpolygon/cdk-validium-node:0.7.0-cdk", # https://hub.docker.com/r/0xpolygon/cdk-validium-node/tags "zkevm_bridge_proxy_image": "haproxy:3.1-bookworm", # https://hub.docker.com/_/haproxy/tags - "zkevm_bridge_service_image": "hermeznetwork/zkevm-bridge-service:v0.6.0-RC4", # https://hub.docker.com/r/hermeznetwork/zkevm-bridge-service/tags + "zkevm_bridge_service_image": "hermeznetwork/zkevm-bridge-service:v0.6.0-RC5", # https://hub.docker.com/r/hermeznetwork/zkevm-bridge-service/tags "zkevm_bridge_ui_image": "leovct/zkevm-bridge-ui:multi-network", # https://hub.docker.com/r/leovct/zkevm-bridge-ui/tags "zkevm_contracts_image": "leovct/zkevm-contracts:v8.0.0-fork.12-patch.1", # https://hub.docker.com/repository/docker/leovct/zkevm-contracts/tags "zkevm_da_image": "0xpolygon/cdk-data-availability:0.0.11", # https://hub.docker.com/r/0xpolygon/cdk-data-availability/tags