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

Commit d2f88a1

Browse files
feat(pkg): add more utils.WeiToEther in logs (#764)
1 parent e170aba commit d2f88a1

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

prover/event_handler/block_proposed.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"github.com/taikoxyz/taiko-client/bindings"
1616
"github.com/taikoxyz/taiko-client/bindings/encoding"
1717
"github.com/taikoxyz/taiko-client/internal/metrics"
18+
"github.com/taikoxyz/taiko-client/internal/utils"
1819
eventIterator "github.com/taikoxyz/taiko-client/pkg/chain_iterator/event_iterator"
1920
"github.com/taikoxyz/taiko-client/pkg/rpc"
2021
guardianProverHeartbeater "github.com/taikoxyz/taiko-client/prover/guardian_prover_heartbeater"
@@ -125,7 +126,7 @@ func (h *BlockProposedEventHandler) Handle(
125126
"removed", e.Raw.Removed,
126127
"assignedProver", e.AssignedProver,
127128
"blobHash", common.Bytes2Hex(e.Meta.BlobHash[:]),
128-
"livenessBond", e.LivenessBond,
129+
"livenessBond", utils.WeiToEther(e.LivenessBond),
129130
"minTier", e.Meta.MinTier,
130131
"blobUsed", e.Meta.BlobUsed,
131132
)

prover/event_handler/transition_contested.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/ethereum/go-ethereum/log"
1010

1111
"github.com/taikoxyz/taiko-client/bindings"
12+
"github.com/taikoxyz/taiko-client/internal/utils"
1213
"github.com/taikoxyz/taiko-client/pkg/rpc"
1314
proofProducer "github.com/taikoxyz/taiko-client/prover/proof_producer"
1415
)
@@ -41,7 +42,7 @@ func (h *TransitionContestedEventHandler) Handle(
4142
"hash", common.Bytes2Hex(e.Tran.BlockHash[:]),
4243
"stateRoot", common.BytesToHash(e.Tran.StateRoot[:]),
4344
"contester", e.Contester,
44-
"bond", e.ContestBond,
45+
"bond", utils.WeiToEther(e.ContestBond),
4546
)
4647

4748
// If this prover is not in contester mode, we simply output a log and return.
@@ -78,7 +79,7 @@ func (h *TransitionContestedEventHandler) Handle(
7879
"hash", common.Bytes2Hex(contestedTransition.BlockHash[:]),
7980
"stateRoot", common.BytesToHash(contestedTransition.StateRoot[:]),
8081
"contester", e.Contester,
81-
"bond", e.ContestBond,
82+
"bond", utils.WeiToEther(e.ContestBond),
8283
)
8384
return nil
8485
}

prover/init.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"github.com/ethereum/go-ethereum/log"
1414

1515
"github.com/taikoxyz/taiko-client/bindings/encoding"
16+
"github.com/taikoxyz/taiko-client/internal/utils"
1617
handler "github.com/taikoxyz/taiko-client/prover/event_handler"
1718
proofProducer "github.com/taikoxyz/taiko-client/prover/proof_producer"
1819
proofSubmitter "github.com/taikoxyz/taiko-client/prover/proof_submitter"
@@ -39,20 +40,20 @@ func (p *Prover) setApprovalAmount(ctx context.Context, contract common.Address)
3940
return err
4041
}
4142

42-
log.Info("Existing allowance for the contract", "allowance", allowance.String(), "contract", contract)
43+
log.Info("Existing allowance for the contract", "allowance", utils.WeiToEther(allowance), "contract", contract)
4344

4445
// If the existing allowance is greater or equal to the configured allowance, skip setting allowance.
4546
if allowance.Cmp(p.cfg.Allowance) >= 0 {
4647
log.Info(
4748
"Skipping setting allowance, allowance already greater or equal",
48-
"allowance", allowance.String(),
49-
"approvalAmount", p.cfg.Allowance.String(),
49+
"allowance", utils.WeiToEther(allowance),
50+
"approvalAmount", p.cfg.Allowance,
5051
"contract", contract,
5152
)
5253
return nil
5354
}
5455

55-
log.Info("Approving the contract for taiko token", "allowance", p.cfg.Allowance.String(), "contract", contract)
56+
log.Info("Approving the contract for taiko token", "allowance", p.cfg.Allowance, "contract", contract)
5657
data, err := encoding.TaikoTokenABI.Pack("approve", contract, p.cfg.Allowance)
5758
if err != nil {
5859
return err
@@ -84,7 +85,7 @@ func (p *Prover) setApprovalAmount(ctx context.Context, contract common.Address)
8485
return err
8586
}
8687

87-
log.Info("New allowance for the contract", "allowance", allowance.String(), "contract", contract)
88+
log.Info("New allowance for the contract", "allowance", utils.WeiToEther(allowance), "contract", contract)
8889

8990
return nil
9091
}

0 commit comments

Comments
 (0)