Skip to content

Commit

Permalink
cgh: fix rpc blockNumber and bash warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
marcello33 committed Nov 13, 2024
1 parent c84b35b commit 8c95b0e
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 10 deletions.
22 changes: 21 additions & 1 deletion helper/call.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"context"
"errors"
"fmt"
"github.com/ethereum/go-ethereum/common/hexutil"
"math/big"
"strings"
"time"
Expand Down Expand Up @@ -465,7 +466,11 @@ func (c *ContractCaller) GetMaticChainBlock(blockNum *big.Int) (header *ethTypes
var latestBlock *ethTypes.Header

if c.MaticGrpcFlag {
latestBlock, err = c.MaticGrpcClient.HeaderByNumber(ctx, blockNum.Uint64())
if blockNum == nil {
latestBlock, err = c.MaticGrpcClient.HeaderByNumber(ctx, uint64(rpc.LatestBlockNumber.Int64()))
} else {
latestBlock, err = c.MaticGrpcClient.HeaderByNumber(ctx, blockNum.Uint64())
}
} else {
latestBlock, err = c.MaticChainClient.HeaderByNumber(ctx, blockNum)
}
Expand Down Expand Up @@ -1016,3 +1021,18 @@ func chooseContractCallerABI(contractCallerObj *ContractCaller, abi string) (*ab
func getABI(data string) (abi.ABI, error) {
return abi.JSON(strings.NewReader(data))
}

func toBlockNumArg(number *big.Int) string {

Check failure on line 1025 in helper/call.go

View workflow job for this annotation

GitHub Actions / lint

func `toBlockNumArg` is unused (unused)
if number == nil {
return "latest"
}
if number.Sign() >= 0 {
return hexutil.EncodeBig(number)
}
// It's negative.
if number.IsInt64() {
return rpc.BlockNumber(number.Int64()).String()
}
// It's negative and large, which is invalid.
return fmt.Sprintf("<invalid %d>", number)
}
4 changes: 2 additions & 2 deletions integration-tests/bor_health.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ do
fi
done

echo $peers
echo $block
echo "$peers"
echo "$block"
14 changes: 7 additions & 7 deletions integration-tests/smoke_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,27 @@ do
exit 1
fi

if (( $balance > $balanceInit )); then
if [ $stateSyncFound != "true" ]; then
if (( balance > balanceInit )); then
if [ "$stateSyncFound" != "true" ]; then
stateSyncTime=$(( SECONDS - start_time ))
stateSyncFound="true"
fi
fi

checkpointID=$(curl -sL http://localhost:1317/checkpoints/latest | jq .result.id)

if [ $checkpointID != "null" ]; then
if [ $checkpointFound != "true" ]; then
if [ "$checkpointID" != "null" ]; then
if [ "$checkpointFound" != "true" ]; then
checkpointTime=$(( SECONDS - start_time ))
checkpointFound="true"
fi
fi

if [ $stateSyncFound == "true" ] && [ $checkpointFound == "true" ]; then
if [ "$stateSyncFound" == "true" ] && [ "$checkpointFound" == "true" ]; then
break
fi

done
echo "Both state sync and checkpoint went through. All tests have passed!"
echo "Time taken for state sync: $(printf '%02dm:%02ds\n' $(($stateSyncTime%3600/60)) $(($stateSyncTime%60)))"
echo "Time taken for checkpoint: $(printf '%02dm:%02ds\n' $(($checkpointTime%3600/60)) $(($checkpointTime%60)))"
echo "Time taken for state sync: $(printf '%02dm:%02ds\n' $((stateSyncTime%3600/60)) $((stateSyncTime%60)))"
echo "Time taken for checkpoint: $(printf '%02dm:%02ds\n' $((checkpointTime%3600/60)) $((checkpointTime%60)))"

0 comments on commit 8c95b0e

Please sign in to comment.