From 82e6d28e828288b8450e84c9cbdffcdd47512580 Mon Sep 17 00:00:00 2001 From: georgehao Date: Fri, 1 Sep 2023 11:42:04 +0800 Subject: [PATCH] feat(rollup-relayer): pretty the send transaction log (#896) Co-authored-by: georgehao Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com> --- .../internal/controller/relayer/l2_relayer.go | 37 +++++++++++++------ .../internal/controller/sender/estimategas.go | 7 ++++ common/version/version.go | 2 +- 3 files changed, 34 insertions(+), 12 deletions(-) diff --git a/bridge/internal/controller/relayer/l2_relayer.go b/bridge/internal/controller/relayer/l2_relayer.go index 70aa64f7ec..89c4bf2175 100644 --- a/bridge/internal/controller/relayer/l2_relayer.go +++ b/bridge/internal/controller/relayer/l2_relayer.go @@ -398,6 +398,13 @@ func (r *Layer2Relayer) ProcessPendingBatches() { txHash, err := r.commitSender.SendTransaction(txID, &r.cfg.RollupContractAddress, big.NewInt(0), calldata, 0) if err != nil { log.Error( + "Failed to send commitBatch tx to layer1", + "index", batch.Index, + "hash", batch.Hash, + "RollupContractAddress", r.cfg.RollupContractAddress, + "err", err, + ) + log.Debug( "Failed to send commitBatch tx to layer1", "index", batch.Index, "hash", batch.Hash, @@ -451,17 +458,17 @@ func (r *Layer2Relayer) ProcessCommittedBatches() { r.metrics.bridgeL2RelayerProcessCommittedBatchesFinalizedTotal.Inc() // Check batch status before send `finalizeBatchWithProof` tx. - batchStatus, err := r.getBatchStatusByIndex(batch.Index) - if err != nil { - r.metrics.bridgeL2ChainMonitorLatestFailedCall.Inc() - log.Warn("failed to get batch status, please check chain_monitor api server", "batch_index", batch.Index, "err", err) - return - } - if !batchStatus { - r.metrics.bridgeL2ChainMonitorLatestFailedBatchStatus.Inc() - log.Error("the batch status is not right, stop finalize batch and check the reason", "batch_index", batch.Index) - return - } + //batchStatus, err := r.getBatchStatusByIndex(batch.Index) + //if err != nil { + // r.metrics.bridgeL2ChainMonitorLatestFailedCall.Inc() + // log.Warn("failed to get batch status, please check chain_monitor api server", "batch_index", batch.Index, "err", err) + // return + //} + //if !batchStatus { + // r.metrics.bridgeL2ChainMonitorLatestFailedBatchStatus.Inc() + // log.Error("the batch status is not right, stop finalize batch and check the reason", "batch_index", batch.Index) + // return + //} var parentBatchStateRoot string if batch.Index > 0 { @@ -510,6 +517,14 @@ func (r *Layer2Relayer) ProcessCommittedBatches() { // the client does not see the 1st tx's updates at this point. // TODO: add more fine-grained error handling log.Error( + "finalizeBatchWithProof in layer1 failed", + "index", batch.Index, + "hash", batch.Hash, + "RollupContractAddress", r.cfg.RollupContractAddress, + "err", err, + ) + + log.Debug( "finalizeBatchWithProof in layer1 failed", "index", batch.Index, "hash", batch.Hash, diff --git a/bridge/internal/controller/sender/estimategas.go b/bridge/internal/controller/sender/estimategas.go index ddece28598..9f7c81bcd7 100644 --- a/bridge/internal/controller/sender/estimategas.go +++ b/bridge/internal/controller/sender/estimategas.go @@ -7,15 +7,19 @@ import ( "github.com/scroll-tech/go-ethereum" "github.com/scroll-tech/go-ethereum/accounts/abi/bind" "github.com/scroll-tech/go-ethereum/common" + "github.com/scroll-tech/go-ethereum/log" ) func (s *Sender) estimateLegacyGas(auth *bind.TransactOpts, contract *common.Address, value *big.Int, input []byte, minGasLimit uint64) (*FeeData, error) { gasPrice, err := s.client.SuggestGasPrice(s.ctx) if err != nil { + log.Error("estimateLegacyGas SuggestGasPrice failure", "error", err) return nil, err } + gasLimit, err := s.estimateGasLimit(auth, contract, input, gasPrice, nil, nil, value, minGasLimit) if err != nil { + log.Error("estimateLegacyGas estimateGasLimit failure", "gasPrice", gasPrice, "error", err) return nil, err } return &FeeData{ @@ -27,6 +31,7 @@ func (s *Sender) estimateLegacyGas(auth *bind.TransactOpts, contract *common.Add func (s *Sender) estimateDynamicGas(auth *bind.TransactOpts, contract *common.Address, value *big.Int, input []byte, minGasLimit uint64) (*FeeData, error) { gasTipCap, err := s.client.SuggestGasTipCap(s.ctx) if err != nil { + log.Error("estimateDynamicGas SuggestGasTipCap failure", "error", err) return nil, err } @@ -40,6 +45,7 @@ func (s *Sender) estimateDynamicGas(auth *bind.TransactOpts, contract *common.Ad ) gasLimit, err := s.estimateGasLimit(auth, contract, input, nil, gasTipCap, gasFeeCap, value, minGasLimit) if err != nil { + log.Error("estimateDynamicGas estimateGasLimit failure", "error", err) return nil, err } return &FeeData{ @@ -61,6 +67,7 @@ func (s *Sender) estimateGasLimit(opts *bind.TransactOpts, contract *common.Addr } gasLimit, err := s.client.EstimateGas(s.ctx, msg) if err != nil { + log.Error("estimateGasLimit EstimateGas failure", "msg", msg, "error", err) return 0, err } if minGasLimit > gasLimit { diff --git a/common/version/version.go b/common/version/version.go index 0349de375d..590382e5f6 100644 --- a/common/version/version.go +++ b/common/version/version.go @@ -7,7 +7,7 @@ import ( "strings" ) -var tag = "v4.2.10" +var tag = "v4.2.11" var commit = func() string { if info, ok := debug.ReadBuildInfo(); ok {