From 010a6aaff7486ce41664d8da66e34e7958d13b35 Mon Sep 17 00:00:00 2001 From: CHAMI Rachid Date: Mon, 27 Nov 2023 15:29:52 +0100 Subject: [PATCH 1/3] chore: rename residual QGB mentions to Blobstream (#622) --- benchmark/main.go | 6 +++--- evm/evm_client.go | 4 ++-- orchestrator/orchestrator_test.go | 10 +++++----- relayer/relayer_test.go | 12 ++++++------ store/init.go | 4 ++-- testing/{qgb.go => blobstream.go} | 0 testing/celestia_network.go | 2 +- 7 files changed, 19 insertions(+), 19 deletions(-) rename testing/{qgb.go => blobstream.go} (100%) diff --git a/benchmark/main.go b/benchmark/main.go index 20d2e8d4..03e44cc3 100644 --- a/benchmark/main.go +++ b/benchmark/main.go @@ -47,7 +47,7 @@ func main() { func DeployContractAndSubmitDataCommitment() error { logger := tmlog.NewTMLogger(os.Stdout) - path, err := os.MkdirTemp(os.TempDir(), "qgb_bench") + path, err := os.MkdirTemp(os.TempDir(), "blobstream_bench") if err != nil { return nil } @@ -107,13 +107,13 @@ func DeployContractAndSubmitDataCommitment() error { address, tx, bridge, err := evmClient.DeployBlobstreamContract(txOpts, backend, vs, vs.Nonce, true) if err != nil { - logger.Error("failed to deploy QGB contract") + logger.Error("failed to deploy Blobstream contract") return err } receipt, err := evmClient.WaitForTransaction(ctx, backend, tx) if err == nil && receipt != nil && receipt.Status == 1 { - logger.Info("deployed QGB contract", "proxy_address", address.Hex(), "tx_hash", tx.Hash().String()) + logger.Info("deployed Blobstream contract", "proxy_address", address.Hex(), "tx_hash", tx.Hash().String()) } txOpts.Nonce.Add(txOpts.Nonce, big.NewInt(1)) diff --git a/evm/evm_client.go b/evm/evm_client.go index 9b4384fe..8b1e381c 100644 --- a/evm/evm_client.go +++ b/evm/evm_client.go @@ -82,7 +82,7 @@ func (ec *Client) DeployBlobstreamContract( return gethcommon.Address{}, nil, nil, err } - ec.logger.Info("deploying QGB implementation contract...", "address", impAddr.Hex(), "tx_hash", impTx.Hash().Hex()) + ec.logger.Info("deploying Blobstream implementation contract...", "address", impAddr.Hex(), "tx_hash", impTx.Hash().Hex()) // encode the Blobstream contract initialization data using the chain parameters ethVsCheckpoint, err := contractInitValset.SignBytes() @@ -109,7 +109,7 @@ func (ec *Client) DeployBlobstreamContract( return gethcommon.Address{}, nil, nil, err } - ec.logger.Info("deploying QGB proxy contract...", "address", proxyAddr, "tx_hash", tx.Hash().Hex()) + ec.logger.Info("deploying Blobstream proxy contract...", "address", proxyAddr, "tx_hash", tx.Hash().Hex()) bridge, err := blobstreamwrapper.NewWrappers(proxyAddr, contractBackend) if err != nil { diff --git a/orchestrator/orchestrator_test.go b/orchestrator/orchestrator_test.go index 0f03b5ed..b3aef9b4 100644 --- a/orchestrator/orchestrator_test.go +++ b/orchestrator/orchestrator_test.go @@ -7,7 +7,7 @@ import ( "time" "github.com/celestiaorg/celestia-app/test/util/testnode" - qgbtesting "github.com/celestiaorg/orchestrator-relayer/testing" + blobstreamtesting "github.com/celestiaorg/orchestrator-relayer/testing" "github.com/celestiaorg/celestia-app/app" "github.com/celestiaorg/celestia-app/app/encoding" @@ -198,13 +198,13 @@ func TestProcessWithoutValsetInStore(t *testing.T) { defer cancel() codec := encoding.MakeConfig(app.ModuleEncodingRegisters...).Codec - node := qgbtesting.NewTestNode( + node := blobstreamtesting.NewTestNode( ctx, t, - qgbtesting.CelestiaNetworkParams{ + blobstreamtesting.CelestiaNetworkParams{ GenesisOpts: []testnode.GenesisOption{ testnode.ImmediateProposals(codec), - qgbtesting.SetDataCommitmentWindowParams(codec, celestiatypes.Params{DataCommitmentWindow: 101}), + blobstreamtesting.SetDataCommitmentWindowParams(codec, celestiatypes.Params{DataCommitmentWindow: 101}), }, TimeIotaMs: 6048000, // to have enough time to sign attestations after they're pruned Pruning: "default", @@ -214,7 +214,7 @@ func TestProcessWithoutValsetInStore(t *testing.T) { _, err := node.CelestiaNetwork.WaitForHeight(400) require.NoError(t, err) - orch := qgbtesting.NewOrchestrator(t, node) + orch := blobstreamtesting.NewOrchestrator(t, node) latestNonce, err := orch.AppQuerier.QueryLatestAttestationNonce(ctx) require.NoError(t, err) diff --git a/relayer/relayer_test.go b/relayer/relayer_test.go index 586ccd78..302cb0bf 100644 --- a/relayer/relayer_test.go +++ b/relayer/relayer_test.go @@ -10,7 +10,7 @@ import ( "github.com/celestiaorg/celestia-app/app" "github.com/celestiaorg/celestia-app/app/encoding" "github.com/celestiaorg/celestia-app/test/util/testnode" - qgbtesting "github.com/celestiaorg/orchestrator-relayer/testing" + blobstreamtesting "github.com/celestiaorg/orchestrator-relayer/testing" "github.com/celestiaorg/orchestrator-relayer/p2p" "github.com/ipfs/go-datastore" @@ -60,13 +60,13 @@ func TestUseValsetFromP2P(t *testing.T) { defer cancel() codec := encoding.MakeConfig(app.ModuleEncodingRegisters...).Codec - node := qgbtesting.NewTestNode( + node := blobstreamtesting.NewTestNode( ctx, t, - qgbtesting.CelestiaNetworkParams{ + blobstreamtesting.CelestiaNetworkParams{ GenesisOpts: []testnode.GenesisOption{ testnode.ImmediateProposals(codec), - qgbtesting.SetDataCommitmentWindowParams(codec, types.Params{DataCommitmentWindow: 101}), + blobstreamtesting.SetDataCommitmentWindowParams(codec, types.Params{DataCommitmentWindow: 101}), }, TimeIotaMs: 2000000, // so attestations are pruned after they're queried Pruning: "default", @@ -75,7 +75,7 @@ func TestUseValsetFromP2P(t *testing.T) { ) // process valset nonce so that it is added to the DHT - orch := qgbtesting.NewOrchestrator(t, node) + orch := blobstreamtesting.NewOrchestrator(t, node) vs, err := orch.AppQuerier.QueryLatestValset(ctx) require.NoError(t, err) err = orch.ProcessValsetEvent(ctx, *vs) @@ -104,7 +104,7 @@ func TestUseValsetFromP2P(t *testing.T) { err = orch.ProcessDataCommitmentEvent(ctx, *att, dataRootTupleRoot) require.NoError(t, err) - relayer := qgbtesting.NewRelayer(t, node) + relayer := blobstreamtesting.NewRelayer(t, node) go node.EVMChain.PeriodicCommit(ctx, time.Millisecond) _, _, _, err = relayer.EVMClient.DeployBlobstreamContract(node.EVMChain.Auth, node.EVMChain.Backend, *latestValset.ToValset(), latestValset.Nonce, true) require.NoError(t, err) diff --git a/store/init.go b/store/init.go index afe36b23..ee9c59e5 100644 --- a/store/init.go +++ b/store/init.go @@ -44,7 +44,7 @@ func Init(log tmlog.Logger, path string, options InitOptions) error { if err != nil { return err } - log.Info("initializing qgb store", "path", path) + log.Info("initializing Blobstream store", "path", path) err = initRoot(path) if err != nil { @@ -100,7 +100,7 @@ func Init(log tmlog.Logger, path string, options InitOptions) error { return err } - log.Info("qgb store initialized", "path", path) + log.Info("Blobstream store initialized", "path", path) return nil } diff --git a/testing/qgb.go b/testing/blobstream.go similarity index 100% rename from testing/qgb.go rename to testing/blobstream.go diff --git a/testing/celestia_network.go b/testing/celestia_network.go index 8ec98aec..559bf65e 100644 --- a/testing/celestia_network.go +++ b/testing/celestia_network.go @@ -91,7 +91,7 @@ func NewCelestiaNetwork(ctx context.Context, t *testing.T, params CelestiaNetwor WithTendermintConfig(tmCfg). WithAccounts(accounts). WithGenesisOptions(params.GenesisOpts...). - WithChainID("qgb-test"), + WithChainID("blobstream-test"), ) appRPC := clientContext.GRPCClient.Target() From 7680a2415aed472f6fc0033597d53de02fa44da2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 28 Nov 2023 09:34:12 +0000 Subject: [PATCH 2/3] chore(deps): bump golang.org/x/term from 0.14.0 to 0.15.0 (#625) * chore(deps): bump golang.org/x/term from 0.14.0 to 0.15.0 Bumps [golang.org/x/term](https://github.com/golang/term) from 0.14.0 to 0.15.0. - [Commits](https://github.com/golang/term/compare/v0.14.0...v0.15.0) --- updated-dependencies: - dependency-name: golang.org/x/term dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] * go mod tidy --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: sweexordious --- e2e/go.mod | 4 ++-- e2e/go.sum | 8 ++++---- go.mod | 4 ++-- go.sum | 8 ++++---- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/e2e/go.mod b/e2e/go.mod index ae112f3f..04c9e222 100644 --- a/e2e/go.mod +++ b/e2e/go.mod @@ -19,8 +19,8 @@ require ( github.com/tendermint/tm-db v0.6.7 // indirect golang.org/x/crypto v0.14.0 // indirect golang.org/x/net v0.17.0 // indirect - golang.org/x/sys v0.14.0 // indirect - golang.org/x/term v0.14.0 // indirect + golang.org/x/sys v0.15.0 // indirect + golang.org/x/term v0.15.0 // indirect google.golang.org/genproto v0.0.0-20231002182017-d307bd883b97 // indirect google.golang.org/grpc v1.59.0 ) diff --git a/e2e/go.sum b/e2e/go.sum index ae8a73b0..a683c884 100644 --- a/e2e/go.sum +++ b/e2e/go.sum @@ -2308,16 +2308,16 @@ golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q= -golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= +golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210503060354-a79de5458b56/go.mod h1:tfny5GFUkzUvx4ps4ajbZsCe5lw1metzhBm9T3x7oIY= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.14.0 h1:LGK9IlZ8T9jvdy6cTdfKUCltatMFOehAQo9SRC46UQ8= -golang.org/x/term v0.14.0/go.mod h1:TySc+nGkYR6qt8km8wUhuFRTVSMIX3XPR58y2lC8vww= +golang.org/x/term v0.15.0 h1:y/Oo/a/q3IXu26lQgl04j/gjuBDOBlx7X6Om1j2CPW4= +golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/go.mod b/go.mod index 7dd25c9a..12c24655 100644 --- a/go.mod +++ b/go.mod @@ -17,8 +17,8 @@ require ( github.com/tendermint/tm-db v0.6.7 // indirect golang.org/x/crypto v0.14.0 // indirect golang.org/x/net v0.17.0 // indirect - golang.org/x/sys v0.14.0 // indirect - golang.org/x/term v0.14.0 + golang.org/x/sys v0.15.0 // indirect + golang.org/x/term v0.15.0 google.golang.org/genproto v0.0.0-20231002182017-d307bd883b97 // indirect google.golang.org/grpc v1.59.0 ) diff --git a/go.sum b/go.sum index b6b42eba..5766f142 100644 --- a/go.sum +++ b/go.sum @@ -2008,14 +2008,14 @@ golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q= -golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= +golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.14.0 h1:LGK9IlZ8T9jvdy6cTdfKUCltatMFOehAQo9SRC46UQ8= -golang.org/x/term v0.14.0/go.mod h1:TySc+nGkYR6qt8km8wUhuFRTVSMIX3XPR58y2lC8vww= +golang.org/x/term v0.15.0 h1:y/Oo/a/q3IXu26lQgl04j/gjuBDOBlx7X6Om1j2CPW4= +golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= From 577f257fef334209290ba54dbbe5459f8aae0b75 Mon Sep 17 00:00:00 2001 From: CHAMI Rachid Date: Tue, 28 Nov 2023 17:09:23 +0100 Subject: [PATCH 3/3] feat: add timeout when waiting for transaction to be minted (#621) * feat: add timeout when waiting for transaction to be minted * feat: expose the evm retry timeout as flag --- benchmark/main.go | 2 +- cmd/blobstream/base/config.go | 18 ++++++++++ cmd/blobstream/deploy/cmd.go | 3 +- cmd/blobstream/relayer/cmd.go | 1 + cmd/blobstream/relayer/config.go | 57 ++++++++++++++++++++------------ evm/evm_client.go | 5 +++ relayer/relayer.go | 5 ++- relayer/relayer_test.go | 4 +-- testing/blobstream.go | 2 +- 9 files changed, 70 insertions(+), 27 deletions(-) diff --git a/benchmark/main.go b/benchmark/main.go index 03e44cc3..092e4b22 100644 --- a/benchmark/main.go +++ b/benchmark/main.go @@ -111,7 +111,7 @@ func DeployContractAndSubmitDataCommitment() error { return err } - receipt, err := evmClient.WaitForTransaction(ctx, backend, tx) + receipt, err := evmClient.WaitForTransaction(ctx, backend, tx, time.Minute) if err == nil && receipt != nil && receipt.Status == 1 { logger.Info("deployed Blobstream contract", "proxy_address", address.Hex(), "tx_hash", tx.Hash().String()) } diff --git a/cmd/blobstream/base/config.go b/cmd/blobstream/base/config.go index 4649413d..e18ebca0 100644 --- a/cmd/blobstream/base/config.go +++ b/cmd/blobstream/base/config.go @@ -76,6 +76,7 @@ const ( FlagEVMRPC = "evm.rpc" FlagEVMGasLimit = "evm.gas-limit" FlagEVMContractAddress = "evm.contract-address" + FlagEVMRetryTimeout = "evm.retry-timeout" FlagCoreGRPC = "core.grpc" FlagCoreRPC = "core.rpc" @@ -337,3 +338,20 @@ func GetLogger(level string, format string) (tmlog.Logger, error) { return server.ZeroLogWrapper{Logger: zerolog.New(logWriter).Level(logLvl).With().Timestamp().Logger()}, nil } + +func GetEVMRetryTimeoutFlag(cmd *cobra.Command) (uint64, bool, error) { + changed := cmd.Flags().Changed(FlagEVMRetryTimeout) + val, err := cmd.Flags().GetUint64(FlagEVMRetryTimeout) + if err != nil { + return 0, changed, err + } + return val, changed, nil +} + +func AddEVMRetryTimeoutFlag(cmd *cobra.Command) { + cmd.Flags().Uint64( + FlagEVMRetryTimeout, + 15, + "The time, in minutes, to wait for transactions to be mined on the target EVM chain before recreating them with a different gas price", + ) +} diff --git a/cmd/blobstream/deploy/cmd.go b/cmd/blobstream/deploy/cmd.go index fa37840b..9a590555 100644 --- a/cmd/blobstream/deploy/cmd.go +++ b/cmd/blobstream/deploy/cmd.go @@ -3,6 +3,7 @@ package deploy import ( "context" "strconv" + "time" "github.com/celestiaorg/orchestrator-relayer/cmd/blobstream/base" @@ -138,7 +139,7 @@ func Command() *cobra.Command { return err } - receipt, err := evmClient.WaitForTransaction(cmd.Context(), backend, tx) + receipt, err := evmClient.WaitForTransaction(cmd.Context(), backend, tx, 5*time.Minute) if err == nil && receipt != nil && receipt.Status == 1 { logger.Info("deployed Blobstream contract", "proxy_address", address.Hex(), "tx_hash", tx.Hash().String()) } diff --git a/cmd/blobstream/relayer/cmd.go b/cmd/blobstream/relayer/cmd.go index 91b8842f..9cc813d5 100644 --- a/cmd/blobstream/relayer/cmd.go +++ b/cmd/blobstream/relayer/cmd.go @@ -201,6 +201,7 @@ func Start() *cobra.Command { logger, retrier, s.SignatureStore, + time.Duration(config.EVMRetryTimeout)*time.Minute, ) // Listen for and trap any OS signal to graceful shutdown and exit diff --git a/cmd/blobstream/relayer/config.go b/cmd/blobstream/relayer/config.go index 40f6bdb7..86c7e733 100644 --- a/cmd/blobstream/relayer/config.go +++ b/cmd/blobstream/relayer/config.go @@ -63,6 +63,10 @@ contract-address = "{{ .ContractAddr }}" # Evm gas limit. gas-limit = "{{ .EvmGasLimit }}" + +# The time, in minutes, to wait for transactions to be mined +# on the target EVM chain before recreating them with a different gas price. +retry-timeout = "{{ .EVMRetryTimeout }}" ` func addRelayerStartFlags(cmd *cobra.Command) *cobra.Command { @@ -85,37 +89,40 @@ func addRelayerStartFlags(cmd *cobra.Command) *cobra.Command { base.AddGRPCInsecureFlag(cmd) base.AddLogLevelFlag(cmd) base.AddLogFormatFlag(cmd) + base.AddEVMRetryTimeoutFlag(cmd) return cmd } type StartConfig struct { base.Config - EvmChainID uint64 `mapstructure:"evm-chain-id" json:"evm-chain-id"` - EvmRPC string `mapstructure:"evm-rpc" json:"evm-rpc"` - CoreGRPC string `mapstructure:"core-grpc" json:"core-grpc"` - CoreRPC string `mapstructure:"core-rpc" json:"core-rpc"` - evmAccAddress string - ContractAddr string `mapstructure:"contract-address" json:"contract-address"` - EvmGasLimit uint64 `mapstructure:"gas-limit" json:"gas-limit"` - Bootstrappers string `mapstructure:"bootstrappers" json:"bootstrappers"` - P2PListenAddr string `mapstructure:"listen-addr" json:"listen-addr"` - p2pNickname string - GrpcInsecure bool `mapstructure:"grpc-insecure" json:"grpc-insecure"` - LogLevel string - LogFormat string + EvmChainID uint64 `mapstructure:"evm-chain-id" json:"evm-chain-id"` + EvmRPC string `mapstructure:"evm-rpc" json:"evm-rpc"` + CoreGRPC string `mapstructure:"core-grpc" json:"core-grpc"` + CoreRPC string `mapstructure:"core-rpc" json:"core-rpc"` + evmAccAddress string + ContractAddr string `mapstructure:"contract-address" json:"contract-address"` + EvmGasLimit uint64 `mapstructure:"gas-limit" json:"gas-limit"` + Bootstrappers string `mapstructure:"bootstrappers" json:"bootstrappers"` + P2PListenAddr string `mapstructure:"listen-addr" json:"listen-addr"` + p2pNickname string + GrpcInsecure bool `mapstructure:"grpc-insecure" json:"grpc-insecure"` + LogLevel string + LogFormat string + EVMRetryTimeout uint64 `mapstructure:"retry-timeout" json:"retry-timeout"` } func DefaultStartConfig() *StartConfig { return &StartConfig{ - CoreRPC: "tcp://localhost:26657", - CoreGRPC: "localhost:9090", - Bootstrappers: "", - P2PListenAddr: "/ip4/0.0.0.0/tcp/30000", - GrpcInsecure: true, - EvmChainID: 5, - EvmRPC: "http://localhost:8545", - EvmGasLimit: 2500000, + CoreRPC: "tcp://localhost:26657", + CoreGRPC: "localhost:9090", + Bootstrappers: "", + P2PListenAddr: "/ip4/0.0.0.0/tcp/30000", + GrpcInsecure: true, + EvmChainID: 5, + EvmRPC: "http://localhost:8545", + EvmGasLimit: 2500000, + EVMRetryTimeout: 15, } } @@ -241,6 +248,14 @@ func parseRelayerStartFlags(cmd *cobra.Command, fileConfig *StartConfig) (StartC } fileConfig.LogFormat = logFormat + retryTimeout, changed, err := base.GetEVMRetryTimeoutFlag(cmd) + if err != nil { + return StartConfig{}, err + } + if changed { + fileConfig.EVMRetryTimeout = retryTimeout + } + return *fileConfig, nil } diff --git a/evm/evm_client.go b/evm/evm_client.go index 8b1e381c..f5d1647b 100644 --- a/evm/evm_client.go +++ b/evm/evm_client.go @@ -4,6 +4,7 @@ import ( "context" "errors" "math/big" + "time" "github.com/ethereum/go-ethereum/accounts" "github.com/ethereum/go-ethereum/accounts/keystore" @@ -228,9 +229,13 @@ func (ec *Client) WaitForTransaction( ctx context.Context, backend bind.DeployBackend, tx *coregethtypes.Transaction, + timeout time.Duration, ) (*coregethtypes.Receipt, error) { ec.logger.Debug("waiting for transaction to be confirmed", "hash", tx.Hash().String()) + ctx, cancel := context.WithTimeout(ctx, timeout) + defer cancel() + receipt, err := bind.WaitMined(ctx, backend, tx) if err == nil && receipt != nil && receipt.Status == 1 { ec.logger.Info("transaction confirmed", "hash", tx.Hash().String(), "block", receipt.BlockNumber.Uint64()) diff --git a/relayer/relayer.go b/relayer/relayer.go index f6a58752..a79ea0bf 100644 --- a/relayer/relayer.go +++ b/relayer/relayer.go @@ -38,6 +38,7 @@ type Relayer struct { logger tmlog.Logger Retrier *helpers.Retrier SignatureStore *badger.Datastore + RetryTimeout time.Duration } func NewRelayer( @@ -48,6 +49,7 @@ func NewRelayer( logger tmlog.Logger, retrier *helpers.Retrier, sigStore *badger.Datastore, + retryTimeout time.Duration, ) *Relayer { return &Relayer{ TmQuerier: tmQuerier, @@ -57,6 +59,7 @@ func NewRelayer( logger: logger, Retrier: retrier, SignatureStore: sigStore, + RetryTimeout: retryTimeout, } } @@ -111,7 +114,7 @@ func (r *Relayer) Start(ctx context.Context) error { } // wait for transaction to be mined - _, err = r.EVMClient.WaitForTransaction(ctx, ethClient, tx) + _, err = r.EVMClient.WaitForTransaction(ctx, ethClient, tx, r.RetryTimeout) if err != nil { return err } diff --git a/relayer/relayer_test.go b/relayer/relayer_test.go index 302cb0bf..f8863eef 100644 --- a/relayer/relayer_test.go +++ b/relayer/relayer_test.go @@ -40,7 +40,7 @@ func (s *RelayerTestSuite) TestProcessAttestation() { tx, err := s.Relayer.ProcessAttestation(ctx, s.Node.EVMChain.Auth, att) require.NoError(t, err) - receipt, err := s.Relayer.EVMClient.WaitForTransaction(ctx, s.Node.EVMChain.Backend, tx) + receipt, err := s.Relayer.EVMClient.WaitForTransaction(ctx, s.Node.EVMChain.Backend, tx, 20*time.Second) assert.NoError(t, err) assert.Equal(t, uint64(1), receipt.Status) @@ -113,7 +113,7 @@ func TestUseValsetFromP2P(t *testing.T) { tx, err := relayer.ProcessAttestation(ctx, node.EVMChain.Auth, att) require.NoError(t, err) - receipt, err := relayer.EVMClient.WaitForTransaction(ctx, node.EVMChain.Backend, tx) + receipt, err := relayer.EVMClient.WaitForTransaction(ctx, node.EVMChain.Backend, tx, 20*time.Second) assert.NoError(t, err) assert.Equal(t, uint64(1), receipt.Status) diff --git a/testing/blobstream.go b/testing/blobstream.go index 28de55a7..8dfedd26 100644 --- a/testing/blobstream.go +++ b/testing/blobstream.go @@ -49,7 +49,7 @@ func NewRelayer( tempDir := t.TempDir() sigStore, err := badger.NewDatastore(tempDir, store.DefaultBadgerOptions(tempDir)) require.NoError(t, err) - r := relayer.NewRelayer(tmQuerier, appQuerier, p2pQuerier, evmClient, logger, retrier, sigStore) + r := relayer.NewRelayer(tmQuerier, appQuerier, p2pQuerier, evmClient, logger, retrier, sigStore, 30*time.Second) return r }