From 1eb1c760ff0beb418041fccc938ff5c118967509 Mon Sep 17 00:00:00 2001 From: David Date: Fri, 26 Apr 2024 12:42:13 +0800 Subject: [PATCH] feat(pkg): add more `utils.WeiToEther` in logs --- prover/event_handler/block_proposed.go | 3 ++- prover/event_handler/transition_contested.go | 5 +++-- prover/init.go | 11 ++++++----- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/prover/event_handler/block_proposed.go b/prover/event_handler/block_proposed.go index d647e7582..7192be5a2 100644 --- a/prover/event_handler/block_proposed.go +++ b/prover/event_handler/block_proposed.go @@ -15,6 +15,7 @@ import ( "github.com/taikoxyz/taiko-client/bindings" "github.com/taikoxyz/taiko-client/bindings/encoding" "github.com/taikoxyz/taiko-client/internal/metrics" + "github.com/taikoxyz/taiko-client/internal/utils" eventIterator "github.com/taikoxyz/taiko-client/pkg/chain_iterator/event_iterator" "github.com/taikoxyz/taiko-client/pkg/rpc" guardianProverHeartbeater "github.com/taikoxyz/taiko-client/prover/guardian_prover_heartbeater" @@ -125,7 +126,7 @@ func (h *BlockProposedEventHandler) Handle( "removed", e.Raw.Removed, "assignedProver", e.AssignedProver, "blobHash", common.Bytes2Hex(e.Meta.BlobHash[:]), - "livenessBond", e.LivenessBond, + "livenessBond", utils.WeiToEther(e.LivenessBond), "minTier", e.Meta.MinTier, "blobUsed", e.Meta.BlobUsed, ) diff --git a/prover/event_handler/transition_contested.go b/prover/event_handler/transition_contested.go index 25345f33f..5ead16769 100644 --- a/prover/event_handler/transition_contested.go +++ b/prover/event_handler/transition_contested.go @@ -9,6 +9,7 @@ import ( "github.com/ethereum/go-ethereum/log" "github.com/taikoxyz/taiko-client/bindings" + "github.com/taikoxyz/taiko-client/internal/utils" "github.com/taikoxyz/taiko-client/pkg/rpc" proofProducer "github.com/taikoxyz/taiko-client/prover/proof_producer" ) @@ -41,7 +42,7 @@ func (h *TransitionContestedEventHandler) Handle( "hash", common.Bytes2Hex(e.Tran.BlockHash[:]), "stateRoot", common.BytesToHash(e.Tran.StateRoot[:]), "contester", e.Contester, - "bond", e.ContestBond, + "bond", utils.WeiToEther(e.ContestBond), ) // If this prover is not in contester mode, we simply output a log and return. @@ -78,7 +79,7 @@ func (h *TransitionContestedEventHandler) Handle( "hash", common.Bytes2Hex(contestedTransition.BlockHash[:]), "stateRoot", common.BytesToHash(contestedTransition.StateRoot[:]), "contester", e.Contester, - "bond", e.ContestBond, + "bond", utils.WeiToEther(e.ContestBond), ) return nil } diff --git a/prover/init.go b/prover/init.go index 5eb143628..85d2b7c68 100644 --- a/prover/init.go +++ b/prover/init.go @@ -13,6 +13,7 @@ import ( "github.com/ethereum/go-ethereum/log" "github.com/taikoxyz/taiko-client/bindings/encoding" + "github.com/taikoxyz/taiko-client/internal/utils" handler "github.com/taikoxyz/taiko-client/prover/event_handler" proofProducer "github.com/taikoxyz/taiko-client/prover/proof_producer" proofSubmitter "github.com/taikoxyz/taiko-client/prover/proof_submitter" @@ -39,20 +40,20 @@ func (p *Prover) setApprovalAmount(ctx context.Context, contract common.Address) return err } - log.Info("Existing allowance for the contract", "allowance", allowance.String(), "contract", contract) + log.Info("Existing allowance for the contract", "allowance", allowance, "contract", contract) // If the existing allowance is greater or equal to the configured allowance, skip setting allowance. if allowance.Cmp(p.cfg.Allowance) >= 0 { log.Info( "Skipping setting allowance, allowance already greater or equal", - "allowance", allowance.String(), - "approvalAmount", p.cfg.Allowance.String(), + "allowance", utils.WeiToEther(allowance), + "approvalAmount", p.cfg.Allowance, "contract", contract, ) return nil } - log.Info("Approving the contract for taiko token", "allowance", p.cfg.Allowance.String(), "contract", contract) + log.Info("Approving the contract for taiko token", "allowance", p.cfg.Allowance, "contract", contract) data, err := encoding.TaikoTokenABI.Pack("approve", contract, p.cfg.Allowance) if err != nil { return err @@ -84,7 +85,7 @@ func (p *Prover) setApprovalAmount(ctx context.Context, contract common.Address) return err } - log.Info("New allowance for the contract", "allowance", allowance.String(), "contract", contract) + log.Info("New allowance for the contract", "allowance", utils.WeiToEther(allowance), "contract", contract) return nil }