diff --git a/orchestrator/batch_request.go b/orchestrator/batch_request.go index 72f628d4..7ee1e01d 100644 --- a/orchestrator/batch_request.go +++ b/orchestrator/batch_request.go @@ -47,7 +47,7 @@ func (l *batchRequestLoop) requestBatches(ctx context.Context) error { } if len(fees) == 0 { - l.Logger().Debugln("no outgoing withdrawals to batch") + l.Logger().Debugln("no withdrawals to batch") return nil } diff --git a/orchestrator/ethereum/committer/eth_committer.go b/orchestrator/ethereum/committer/eth_committer.go index b231f1b8..19444bed 100644 --- a/orchestrator/ethereum/committer/eth_committer.go +++ b/orchestrator/ethereum/committer/eth_committer.go @@ -2,6 +2,7 @@ package committer import ( "context" + "github.com/ethereum/go-ethereum" "math/big" "strings" @@ -114,6 +115,22 @@ func (e *ethCommitter) SendTx( return common.Hash{}, errors.Errorf("Suggested gas price %v is greater than max gas price %v", opts.GasPrice.Int64(), maxGasPrice.Int64()) } + // estimate gas limit + msg := ethereum.CallMsg{ + From: opts.From, + To: &recipient, + GasPrice: gasPrice, + Value: new(big.Int), + Data: txData, + } + + gasLimit, err := e.evmProvider.EstimateGas(opts.Context, msg) + if err != nil { + return common.Hash{}, errors.Wrap(err, "failed to estimate gas") + } + + opts.GasLimit = gasLimit + resyncNonces := func(from common.Address) { e.nonceCache.Sync(from, func() (uint64, error) { nonce, err := e.evmProvider.PendingNonceAt(context.TODO(), from) diff --git a/orchestrator/ethereum/peggy/submit_batch.go b/orchestrator/ethereum/peggy/submit_batch.go index 427e09b9..4a15cfcf 100644 --- a/orchestrator/ethereum/peggy/submit_batch.go +++ b/orchestrator/ethereum/peggy/submit_batch.go @@ -25,9 +25,9 @@ func (s *peggyContract) SendTransactionBatch( log.WithFields(log.Fields{ "token_contract": batch.TokenContract, "batch_nonce": batch.BatchNonce, - "transactions": len(batch.Transactions), + "txs": len(batch.Transactions), "confirmations": len(confirms), - }).Debugln("checking signatures and submitting batch") + }).Infoln("checking signatures and submitting batch") validators, powers, sigV, sigR, sigS, err := checkBatchSigsAndRepack(currentValset, confirms) if err != nil { @@ -93,7 +93,7 @@ func (s *peggyContract) SendTransactionBatch( txHash, err := s.SendTx(ctx, s.peggyAddress, txData) if err != nil { metrics.ReportFuncError(s.svcTags) - log.WithError(err).WithField("tx_hash", txHash.Hex()).Errorln("Failed to sign and submit (Peggy submitBatch) to EVM") + log.WithError(err).WithField("tx_hash", txHash.Hex()).Errorln("failed to sign and submit (Peggy submitBatch) to EVM") return nil, err } diff --git a/orchestrator/ethereum/peggy/valset_update.go b/orchestrator/ethereum/peggy/valset_update.go index 8fbbc7b6..18bd1a42 100644 --- a/orchestrator/ethereum/peggy/valset_update.go +++ b/orchestrator/ethereum/peggy/valset_update.go @@ -41,7 +41,7 @@ func (s *peggyContract) SendEthValsetUpdate( "valset_nonce": newValset.Nonce, "validators": len(newValset.Members), "confirmations": len(confirms), - }).Debugln("checking signatures and submitting valset update") + }).Infoln("checking signatures and submitting valset update") newValidators, newPowers := validatorsAndPowers(newValset) newValsetNonce := new(big.Int).SetUint64(newValset.Nonce) diff --git a/orchestrator/relayer.go b/orchestrator/relayer.go index 7eb61507..17e5b9d2 100644 --- a/orchestrator/relayer.go +++ b/orchestrator/relayer.go @@ -125,6 +125,7 @@ func (l *relayerLoop) relayValset(ctx context.Context) error { } if oldestConfirmedValset.Nonce <= currentEthValset.Nonce { + l.Logger().WithFields(log.Fields{"eth_nonce": currentEthValset.Nonce, "inj_nonce": currentEthValset.Nonce}).Debugln("valset already updated on Ethereum") return nil } @@ -135,10 +136,11 @@ func (l *relayerLoop) relayValset(ctx context.Context) error { // Check if other validators already updated the valset if oldestConfirmedValset.Nonce <= latestEthereumValsetNonce.Uint64() { + l.Logger().WithFields(log.Fields{"eth_nonce": latestEthereumValsetNonce, "inj_nonce": currentEthValset.Nonce}).Debugln("valset already updated on Ethereum") return nil } - l.Logger().WithFields(log.Fields{"inj_valset_nonce": oldestConfirmedValset.Nonce, "eth_valset_nonce": latestEthereumValsetNonce.Uint64()}).Debugln("latest valset updates") + l.Logger().WithFields(log.Fields{"inj_nonce": oldestConfirmedValset.Nonce, "eth_nonce": latestEthereumValsetNonce.Uint64()}).Debugln("latest valset updates") // Check custom time delay offset blockTime, err := l.inj.GetBlockCreationTime(ctx, int64(oldestConfirmedValset.Height)) @@ -148,7 +150,7 @@ func (l *relayerLoop) relayValset(ctx context.Context) error { if timeElapsed := time.Since(blockTime); timeElapsed <= l.relayValsetOffsetDur { timeRemaining := time.Duration(int64(l.relayValsetOffsetDur) - int64(timeElapsed)) - l.Logger().WithField("time_remaining", timeRemaining.String()).Debugln("valset relay offset duration not expired") + l.Logger().WithField("time_remaining", timeRemaining.String()).Debugln("valset relay offset not reached yet") return nil } @@ -162,7 +164,7 @@ func (l *relayerLoop) relayValset(ctx context.Context) error { return err } - l.Logger().WithField("tx_hash", txHash.Hex()).Infoln("sent valset update to Ethereum") + l.Logger().WithField("tx_hash", txHash.Hex()).Infoln("sent valset tx to Ethereum") return nil } @@ -195,7 +197,7 @@ func (l *relayerLoop) relayBatch(ctx context.Context) error { } if oldestConfirmedBatch == nil { - l.Logger().Debugln("no outgoing batch to relay") + l.Logger().Debugln("no batch to relay") return nil } @@ -212,6 +214,7 @@ func (l *relayerLoop) relayBatch(ctx context.Context) error { } if oldestConfirmedBatch.BatchNonce <= latestEthereumBatch.Uint64() { + l.Logger().WithFields(log.Fields{"eth_nonce": latestEthereumBatch.Uint64(), "inj_nonce": oldestConfirmedBatch.BatchNonce}).Debugln("batch already updated on Ethereum") return nil } @@ -222,10 +225,11 @@ func (l *relayerLoop) relayBatch(ctx context.Context) error { // Check if ethereum batch was updated by other validators if oldestConfirmedBatch.BatchNonce <= latestEthereumBatch.Uint64() { + l.Logger().WithFields(log.Fields{"eth_nonce": latestEthereumBatch.Uint64(), "inj_nonce": oldestConfirmedBatch.BatchNonce}).Debugln("batch already updated on Ethereum") return nil } - l.Logger().WithFields(log.Fields{"inj_batch_nonce": oldestConfirmedBatch.BatchNonce, "eth_batch_nonce": latestEthereumBatch.Uint64()}).Debugln("latest batch updates") + l.Logger().WithFields(log.Fields{"inj_nonce": oldestConfirmedBatch.BatchNonce, "eth_nonce": latestEthereumBatch.Uint64()}).Debugln("latest batch updates") // Check custom time delay offset blockTime, err := l.inj.GetBlockCreationTime(ctx, int64(oldestConfirmedBatch.Block)) @@ -235,7 +239,7 @@ func (l *relayerLoop) relayBatch(ctx context.Context) error { if timeElapsed := time.Since(blockTime); timeElapsed <= l.relayBatchOffsetDur { timeRemaining := time.Duration(int64(l.relayBatchOffsetDur) - int64(timeElapsed)) - l.Logger().WithField("time_remaining", timeRemaining.String()).Debugln("batch relay offset duration not expired") + l.Logger().WithField("time_remaining", timeRemaining.String()).Debugln("batch relay offset not reached yet") return nil } @@ -245,7 +249,7 @@ func (l *relayerLoop) relayBatch(ctx context.Context) error { return err } - l.Logger().WithField("tx_hash", txHash.Hex()).Infoln("sent tx batch to Ethereum") + l.Logger().WithField("tx_hash", txHash.Hex()).Infoln("sent batch tx to Ethereum") return nil } diff --git a/orchestrator/signer.go b/orchestrator/signer.go index cdb9b688..9b429f0d 100644 --- a/orchestrator/signer.go +++ b/orchestrator/signer.go @@ -110,7 +110,7 @@ func (l *ethSignerLoop) signNewBatch(ctx context.Context) error { } if oldestUnsignedTransactionBatch == nil { - l.Logger().Debugln("no outgoing batch to confirm") + l.Logger().Debugln("no batch to confirm") return nil }