From e0071506e1e64e97c4f3474c765be3ba93e7b57a Mon Sep 17 00:00:00 2001 From: David Date: Fri, 24 May 2024 22:50:38 +0800 Subject: [PATCH] fix(taiko-client): fix an issue in `checkMinEthAndToken` (#17320) --- .../integration_test/deploy_l1_contract.sh | 3 +- packages/taiko-client/prover/server/api.go | 40 ++++++++++--------- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/packages/taiko-client/integration_test/deploy_l1_contract.sh b/packages/taiko-client/integration_test/deploy_l1_contract.sh index 2fd8ccfc347..71e635df468 100755 --- a/packages/taiko-client/integration_test/deploy_l1_contract.sh +++ b/packages/taiko-client/integration_test/deploy_l1_contract.sh @@ -13,4 +13,5 @@ cd ../protocol && -vvvvv \ --evm-version cancun \ --private-key "$PRIVATE_KEY" \ - --block-gas-limit 100000000 + --block-gas-limit 100000000 \ + --legacy diff --git a/packages/taiko-client/prover/server/api.go b/packages/taiko-client/prover/server/api.go index ba3c6136959..62c0c81a93a 100644 --- a/packages/taiko-client/prover/server/api.go +++ b/packages/taiko-client/prover/server/api.go @@ -246,31 +246,33 @@ func (s *ProverServer) CreateAssignment(c echo.Context) error { }) } -// checkMinEthAndToken checks if the prover has the required minimum on-chain ETH and Taiko token balance. +// checkMinEthAndToken checks if the prover has the required minimum on-chain Taiko token balance. func (s *ProverServer) checkMinEthAndToken(ctx context.Context, proverAddress common.Address) (bool, error) { ctx, cancel := context.WithTimeout(ctx, rpcTimeout) defer cancel() - // 1. Check prover's ETH balance. - ethBalance, err := s.rpc.L1.BalanceAt(ctx, proverAddress, nil) - if err != nil { - return false, err - } - - log.Info( - "Prover's ETH balance", - "balance", utils.WeiToEther(ethBalance), - "address", proverAddress, - ) + // 1. Check prover's ETH balance, if it's using proverSet. + if proverAddress == s.proverAddress { + ethBalance, err := s.rpc.L1.BalanceAt(ctx, proverAddress, nil) + if err != nil { + return false, err + } - if ethBalance.Cmp(s.minEthBalance) <= 0 { - log.Warn( - "Prover does not have required minimum on-chain ETH balance", - "providedProver", proverAddress, - "ethBalance", utils.WeiToEther(ethBalance), - "minEthBalance", utils.WeiToEther(s.minEthBalance), + log.Info( + "Prover's ETH balance", + "balance", utils.WeiToEther(ethBalance), + "address", proverAddress, ) - return false, nil + + if ethBalance.Cmp(s.minEthBalance) <= 0 { + log.Warn( + "Prover does not have required minimum on-chain ETH balance", + "providedProver", proverAddress, + "ethBalance", utils.WeiToEther(ethBalance), + "minEthBalance", utils.WeiToEther(s.minEthBalance), + ) + return false, nil + } } // 2. Check prover's Taiko token balance.