From 1fb05b85922bc3dd1e3e695aa998d2fe34958137 Mon Sep 17 00:00:00 2001 From: joanestebanr <129153821+joanestebanr@users.noreply.github.com> Date: Fri, 20 Dec 2024 10:48:28 +0100 Subject: [PATCH] fix: PR comments --- aggsender/aggsender.go | 14 +++++++------- test/bats/helpers/common-multi_cdk-setup.bash | 16 +++++++--------- test/bats/helpers/lxly-bridge.bash | 14 +++++++------- test/bats/pp-multi/bridge-l2_to_l2-e2e.bats | 2 +- 4 files changed, 22 insertions(+), 24 deletions(-) diff --git a/aggsender/aggsender.go b/aggsender/aggsender.go index 3454584a..b44c0085 100644 --- a/aggsender/aggsender.go +++ b/aggsender/aggsender.go @@ -185,7 +185,7 @@ func (a *AggSender) sendCertificate(ctx context.Context) (*agglayer.SignedCertif return nil, nil } - lasL2BlockSynced, err := a.l2Syncer.GetLastProcessedBlock(ctx) + lastL2BlockSynced, err := a.l2Syncer.GetLastProcessedBlock(ctx) if err != nil { return nil, fmt.Errorf("error getting last processed block from l2: %w", err) } @@ -197,14 +197,14 @@ func (a *AggSender) sendCertificate(ctx context.Context) (*agglayer.SignedCertif previousToBlock, retryCount := getLastSentBlockAndRetryCount(lastSentCertificateInfo) - if previousToBlock >= lasL2BlockSynced { + if previousToBlock >= lastL2BlockSynced { a.log.Infof("no new blocks to send a certificate, last certificate block: %d, last L2 block: %d", - previousToBlock, lasL2BlockSynced) + previousToBlock, lastL2BlockSynced) return nil, nil } fromBlock := previousToBlock + 1 - toBlock := lasL2BlockSynced + toBlock := lastL2BlockSynced bridges, err := a.l2Syncer.GetBridgesPublished(ctx, fromBlock, toBlock) if err != nil { @@ -867,17 +867,17 @@ func getLastSentBlockAndRetryCount(lastSentCertificateInfo *types.CertificateInf } retryCount := 0 - previousToBlock := lastSentCertificateInfo.ToBlock + lastSentBlock := lastSentCertificateInfo.ToBlock if lastSentCertificateInfo.Status == agglayer.InError { // if the last certificate was in error, we need to resend it // from the block before the error if lastSentCertificateInfo.FromBlock > 0 { - previousToBlock = lastSentCertificateInfo.FromBlock - 1 + lastSentBlock = lastSentCertificateInfo.FromBlock - 1 } retryCount = lastSentCertificateInfo.RetryCount + 1 } - return previousToBlock, retryCount + return lastSentBlock, retryCount } diff --git a/test/bats/helpers/common-multi_cdk-setup.bash b/test/bats/helpers/common-multi_cdk-setup.bash index d421cccc..2758c9f7 100644 --- a/test/bats/helpers/common-multi_cdk-setup.bash +++ b/test/bats/helpers/common-multi_cdk-setup.bash @@ -24,12 +24,10 @@ _common_multi_setup() { readonly l2_pp1_cdk_node_url=$(kurtosis port print $enclave cdk-node-001 rpc) readonly l2_pp2_cdk_node_url=$(kurtosis port print $enclave cdk-node-002 rpc) - #readonly l1_rpc_network_id=$(cast call --rpc-url $l1_rpc_url $bridge_addr 'networkID() (uint32)') - #readonly l2_pp1b_network_id=$(cast call --rpc-url $l2_pp1_url $bridge_addr 'networkID() (uint32)') - #readonly l2_pp2b_network_id=$(cast call --rpc-url $l2_pp2_url $bridge_addr 'networkID() (uint32)') - readonly l1_rpc_network_id=0 - readonly l2_pp1b_network_id=1 - readonly l2_pp2b_network_id=2 + readonly l1_rpc_network_id=$(cast call --rpc-url $l1_rpc_url $bridge_address 'networkID() (uint32)') + readonly l2_pp1b_network_id=$(cast call --rpc-url $l2_pp1_url $bridge_address 'networkID() (uint32)') + readonly l2_pp2b_network_id=$(cast call --rpc-url $l2_pp2_url $bridge_address 'networkID() (uint32)') + readonly aggsender_find_imported_bridge="../target/aggsender_find_imported_bridge" echo "=== Bridge address=$bridge_address ===" >&3 echo "=== POL address=$pol_address ===" >&3 @@ -66,18 +64,18 @@ fund_claim_tx_manager(){ mint_pol_token(){ - echo "=== Mining POL ===" >&3 + echo "=== Minting POL ===" >&3 cast send \ --rpc-url $l1_rpc_url \ --private-key $private_key \ $pol_address \ - 'mint(address,uint256)' \ + "$mint_fn_sig" \ $eth_address 10000000000000000000000 # Allow bridge to spend it cast send \ --rpc-url $l1_rpc_url \ --private-key $private_key \ $pol_address \ - 'approve(address,uint256)' \ + "$approve_fn_sig" \ $bridge_address 10000000000000000000000 } diff --git a/test/bats/helpers/lxly-bridge.bash b/test/bats/helpers/lxly-bridge.bash index 3d46d819..a8180f9d 100644 --- a/test/bats/helpers/lxly-bridge.bash +++ b/test/bats/helpers/lxly-bridge.bash @@ -141,7 +141,7 @@ function claim_tx_hash() { tx_hash="$2" local destination_addr="$3" local destination_rpc_url="$4" - local bridge_provide_merkel_proof="$5" + local bridge_merkle_proof_url="$5" readonly bridge_deposit_file=$(mktemp) local ready_for_claim="false" @@ -156,7 +156,7 @@ function claim_tx_hash() { echo " $current_time > $end_time" >&3 exit 1 fi - curl -s "$bridge_provide_merkel_proof/bridges/$destination_addr?limit=100&offset=0" | jq "[.deposits[] | select(.tx_hash == \"$tx_hash\" )]" > $bridge_deposit_file + curl -s "$bridge_merkle_proof_url/bridges/$destination_addr?limit=100&offset=0" | jq "[.deposits[] | select(.tx_hash == \"$tx_hash\" )]" > $bridge_deposit_file deposit_count=$(jq '. | length' $bridge_deposit_file) if [[ $deposit_count == 0 ]]; then echo "...[$(date '+%Y-%m-%d %H:%M:%S')] ❌ the tx_hash [$tx_hash] not found (elapsed: $elpased_time / timeout:$timeout)" >&3 @@ -185,7 +185,7 @@ function claim_tx_hash() { jq '.[(0|tonumber)]' $bridge_deposit_file | tee $current_deposit readonly current_proof=$(mktemp) echo ".... requesting merkel proof for $tx_hash deposit_cnt=$curr_deposit_cnt network_id: $curr_network_id" >&3 - request_merkel_proof "$curr_deposit_cnt" "$curr_network_id" "$bridge_provide_merkel_proof" "$current_proof" + request_merkle_proof "$curr_deposit_cnt" "$curr_network_id" "$bridge_merkle_proof_url" "$current_proof" echo "FILE current_deposit=$current_deposit" echo "FILE bridge_deposit_file=$bridge_deposit_file" echo "FILE current_proof=$current_proof" @@ -225,13 +225,13 @@ function claim_tx_hash() { rm $bridge_deposit_file } -function request_merkel_proof(){ +function request_merkle_proof(){ local curr_deposit_cnt="$1" local curr_network_id="$2" - local bridge_provide_merkel_proof="$3" + local bridge_merkle_proof_url="$3" local result_proof_file="$4" - curl -s "$bridge_provide_merkel_proof/merkle-proof?deposit_cnt=$curr_deposit_cnt&net_id=$curr_network_id" | jq '.' > $result_proof_file - echo "request_merkel_proof: $result_proof_file" + curl -s "$bridge_merkle_proof_url/merkle-proof?deposit_cnt=$curr_deposit_cnt&net_id=$curr_network_id" | jq '.' > $result_proof_file + echo "request_merkle_proof: $result_proof_file" } # This function is used to claim a concrete tx hash diff --git a/test/bats/pp-multi/bridge-l2_to_l2-e2e.bats b/test/bats/pp-multi/bridge-l2_to_l2-e2e.bats index 8c428581..d39fb4c7 100644 --- a/test/bats/pp-multi/bridge-l2_to_l2-e2e.bats +++ b/test/bats/pp-multi/bridge-l2_to_l2-e2e.bats @@ -67,7 +67,7 @@ setup() { echo "... deposit [$global_index]" global_index_pp2_to_pp1="$global_index" - # Now a need to do a bridge on L2(PP1) to trigger a certificate: + # Now we need to do a bridge on L2(PP1) to trigger a certificate: ether_value=${ETHER_VALUE:-"0.0100000054"} amount=$(cast to-wei $ether_value ether) echo "=== Running LxLy bridge eth L2(PP1) to L1 (trigger a certificate on PP1) amount:$amount" >&3