Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions apps/chain_pusher/pkg/evm/interactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ func NewContractInteractor(
}

func (eci *ContractInteractor) ConnectHTTP(ctx context.Context, url string) error {
eci.logger.Info().Str("url", url).Msg("ConnectHTTP")

client, err := ethclient.Dial(url)
if err != nil {
return fmt.Errorf("failed to connect to RPC: %w", err)
Expand All @@ -129,13 +131,14 @@ func (eci *ContractInteractor) ConnectHTTP(ctx context.Context, url string) erro
versionStr, err := eci.contract.Version(makeCallOpts(ctx))
if err != nil {
eci.logger.Error().Err(err).Msg("Failed to get contract version")
} else {
version, err := semver.NewVersion(versionStr)
if err != nil {
eci.logger.Error().Err(err).Msg("Failed to parse contract version")
}
eci.version = version
eci.logger.Info().Interface("version", eci.version).Msg("contract version")
}
version, err := semver.NewVersion(versionStr)
if err != nil {
eci.logger.Error().Err(err).Msg("Failed to parse contract version")
}
eci.version = version
eci.logger.Info().Interface("version", eci.version).Msg("contract version")

// set single update fee
singleUpdateFee, err := eci.getSingleUpdateFee(ctx)
Expand All @@ -144,6 +147,10 @@ func (eci *ContractInteractor) ConnectHTTP(ctx context.Context, url string) erro
}
eci.singleUpdateFee = singleUpdateFee

if err = eci.nonceManager.ResetNonce(ctx, eci.client, crypto.PubkeyToAddress(eci.privateKey.PublicKey)); err != nil {
eci.logger.Error().Err(err).Msg("Failed to reset nonce")
}

return nil
}

Expand Down Expand Up @@ -684,7 +691,7 @@ func (eci *ContractInteractor) submitTransaction(

if txErr != nil {
if strings.Contains(txErr.Error(), "nonce") {
eci.logger.Warn().Msg("Nonce mismatch, resetting nonce")
eci.logger.Warn().Err(txErr).Msg("Nonce mismatch, resetting nonce")
err := eci.nonceManager.ResetNonce(ctx, eci.client, crypto.PubkeyToAddress(eci.privateKey.PublicKey))
if err != nil {
return nil, fmt.Errorf("failed to reset nonce: %w", err)
Expand All @@ -707,7 +714,7 @@ func (eci *ContractInteractor) submitTransaction(
if revertData, ok := ethclient.RevertErrorData(txErr); ok {
eci.logger.Error().Str("revertData", hex.EncodeToString(revertData)).Msg("transaction reverted with data")
} else if strings.Contains(txErr.Error(), "nonce") {
eci.logger.Warn().Msg("Nonce mismatch, resetting nonce")
eci.logger.Warn().Err(txErr).Msg("Nonce mismatch, resetting nonce")
err := eci.nonceManager.ResetNonce(ctx, eci.client, crypto.PubkeyToAddress(eci.privateKey.PublicKey))
if err != nil {
return nil, fmt.Errorf("failed to reset nonce: %w", err)
Expand Down
6 changes: 0 additions & 6 deletions apps/chain_pusher/pkg/evm/interactor_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package evm
import (
"context"
"errors"
"fmt"
"sync"
"testing"
"time"
Expand Down Expand Up @@ -38,11 +37,6 @@ func (s *InteractorTestSuite) SetupSuite() {
s.Require().NoError(env.Parse(&s.config))
s.ctx, s.cancel = context.WithCancel(context.Background())

fmt.Println("RpcUrl: ", s.config.RpcUrl)
fmt.Println("WsUrl: ", s.config.WsUrl)
fmt.Println("ContractAddress: ", s.config.ContractAddress)
fmt.Println("PrivateKey: ", s.config.PrivateKey)

s.logger = PusherLogger(s.config.RpcUrl, s.config.ContractAddress)

var err error
Expand Down
Loading