Skip to content

Commit

Permalink
fix: PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
joanestebanr committed Dec 20, 2024
1 parent 98c2e9f commit 1fb05b8
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 24 deletions.
14 changes: 7 additions & 7 deletions aggsender/aggsender.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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 {
Expand Down Expand Up @@ -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
}
16 changes: 7 additions & 9 deletions test/bats/helpers/common-multi_cdk-setup.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
14 changes: 7 additions & 7 deletions test/bats/helpers/lxly-bridge.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/bats/pp-multi/bridge-l2_to_l2-e2e.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1fb05b8

Please sign in to comment.