Skip to content
This repository has been archived by the owner on May 11, 2024. It is now read-only.

Commit

Permalink
feat(pkg): add more utils.WeiToEther in logs
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtaikocha committed Apr 26, 2024
1 parent e170aba commit 1eb1c76
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
3 changes: 2 additions & 1 deletion prover/event_handler/block_proposed.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
)
Expand Down
5 changes: 3 additions & 2 deletions prover/event_handler/transition_contested.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
}
Expand Down
11 changes: 6 additions & 5 deletions prover/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 1eb1c76

Please sign in to comment.