Skip to content

Commit

Permalink
fix(taiko-client): fix an issue in checkMinEthAndToken (#17320)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtaikocha authored May 24, 2024
1 parent f0b26b9 commit e007150
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 20 deletions.
3 changes: 2 additions & 1 deletion packages/taiko-client/integration_test/deploy_l1_contract.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ cd ../protocol &&
-vvvvv \
--evm-version cancun \
--private-key "$PRIVATE_KEY" \
--block-gas-limit 100000000
--block-gas-limit 100000000 \
--legacy
40 changes: 21 additions & 19 deletions packages/taiko-client/prover/server/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit e007150

Please sign in to comment.