Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(taiko-client): fix an issue in checkMinEthAndToken #17320

Merged
merged 2 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading