diff --git a/benchmark/main.go b/benchmark/main.go index 20d2e8d4..092e4b22 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) + receipt, err := evmClient.WaitForTransaction(ctx, backend, tx, time.Minute) 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/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/orchestrator/config.go b/cmd/blobstream/orchestrator/config.go index a81675e7..22cd1afb 100644 --- a/cmd/blobstream/orchestrator/config.go +++ b/cmd/blobstream/orchestrator/config.go @@ -243,7 +243,7 @@ func LoadFileConfiguration(homeDir string) (*StartConfig, error) { } } - conf, err := getStartConfig(v, configPath) + conf, err := GetStartConfig(v, configPath) if err != nil { return nil, fmt.Errorf("couldn't get client config: %v", err) } @@ -279,8 +279,8 @@ func writeConfigToFile(configFilePath string, config *StartConfig) error { return os.WriteFile(configFilePath, buffer.Bytes(), 0o600) } -// getStartConfig reads values from config.toml file and unmarshalls them into StartConfig -func getStartConfig(v *viper.Viper, configPath string) (*StartConfig, error) { +// GetStartConfig reads values from config.toml file and unmarshalls them into StartConfig +func GetStartConfig(v *viper.Viper, configPath string) (*StartConfig, error) { v.AddConfigPath(configPath) v.SetConfigName("config") v.SetConfigType("toml") diff --git a/cmd/blobstream/query/cmd.go b/cmd/blobstream/query/cmd.go index a35d8c58..da31f748 100644 --- a/cmd/blobstream/query/cmd.go +++ b/cmd/blobstream/query/cmd.go @@ -6,9 +6,15 @@ import ( "fmt" "math/big" "os" + "path/filepath" "strconv" "time" + "github.com/celestiaorg/orchestrator-relayer/cmd/blobstream/base" + "github.com/celestiaorg/orchestrator-relayer/cmd/blobstream/orchestrator" + "github.com/celestiaorg/orchestrator-relayer/cmd/blobstream/relayer" + "github.com/spf13/viper" + common2 "github.com/ethereum/go-ethereum/common" celestiatypes "github.com/celestiaorg/celestia-app/x/qgb/types" @@ -52,13 +58,17 @@ func Signers() *cobra.Command { " will query signatures for. It should be either a specific nonce starting from 2 and on." + " Or, use 'latest' as argument to check the latest attestation nonce", RunE: func(cmd *cobra.Command, args []string) error { - config, err := parseFlags(cmd) + // creating the logger + logger := tmlog.NewTMLogger(os.Stdout) + fileConfig, err := tryToGetExistingConfig(cmd, logger) + if err != nil { + return err + } + config, err := parseFlags(cmd, &fileConfig) if err != nil { return err } - // creating the logger - logger := tmlog.NewTMLogger(os.Stdout) logger.Debug("initializing queriers") ctx, cancel := context.WithCancel(cmd.Context()) @@ -75,7 +85,12 @@ func Signers() *cobra.Command { }() // create tm querier and app querier - tmQuerier, appQuerier, stops, err := common.NewTmAndAppQuerier(logger, config.coreRPC, config.coreGRPC, config.grpcInsecure) + tmQuerier, appQuerier, stops, err := common.NewTmAndAppQuerier( + logger, + config.coreRPC, + config.coreGRPC, + config.grpcInsecure, + ) stopFuncs = append(stopFuncs, stops...) if err != nil { return err @@ -335,13 +350,17 @@ func Signature() *cobra.Command { " nonce that the command will query signatures for. The EVM address is the address registered by the validator " + "in the staking module.", RunE: func(cmd *cobra.Command, args []string) error { - config, err := parseFlags(cmd) + // creating the logger + logger := tmlog.NewTMLogger(os.Stdout) + fileConfig, err := tryToGetExistingConfig(cmd, logger) + if err != nil { + return err + } + config, err := parseFlags(cmd, &fileConfig) if err != nil { return err } - // creating the logger - logger := tmlog.NewTMLogger(os.Stdout) logger.Debug("initializing queriers") ctx, cancel := context.WithCancel(cmd.Context()) @@ -358,7 +377,7 @@ func Signature() *cobra.Command { }() // create tm querier and app querier - tmQuerier, appQuerier, stops, err := common.NewTmAndAppQuerier(logger, config.coreRPC, config.coreGRPC, config.grpcInsecure) + tmQuerier, appQuerier, stops, err := common.NewTmAndAppQuerier(logger, config.coreRPC, config.coreRPC, config.grpcInsecure) stopFuncs = append(stopFuncs, stops...) if err != nil { return err @@ -478,3 +497,82 @@ func getSignatureAndPrintIt( } return nil } + +// tryToGetExistingConfig tries to get the query config from existing +// orchestrator/relayer homes. It first checks whether the `--home` flag was +// changed. If so, it gets the config from there. If not, then it tries the +// orchestrator default home directory, then the relayer default home directory. +func tryToGetExistingConfig(cmd *cobra.Command, logger tmlog.Logger) (Config, error) { + v := viper.New() + v.SetEnvPrefix("") + v.AutomaticEnv() + homeDir, changed, err := base.GetHomeFlag(cmd) + if err != nil { + return Config{}, err + } + // the --home flag was set to some directory + if changed && homeDir != "" { + logger.Debug("using home", "home", homeDir) + configPath := filepath.Join(homeDir, "config") + + // assume this home is an orchestrator home directory + orchConf, err := orchestrator.GetStartConfig(v, configPath) + if err == nil { + // it is an orchestrator, so we get the config from it + return *NewPartialConfig( + orchConf.CoreGRPC, + orchConf.CoreRPC, + orchConf.Bootstrappers, + orchConf.GRPCInsecure, + ), nil + } + + // assume this home is a relayer home directory + relConf, err := relayer.GetStartConfig(v, configPath) + if err == nil { + // it is a relayer, so we get the config from it + return *NewPartialConfig( + relConf.CoreGRPC, + relConf.CoreRPC, + relConf.Bootstrappers, + relConf.GrpcInsecure, + ), nil + } + return Config{}, fmt.Errorf("the provided home directory is neither an orchestrator nor a relayer home directory") + } + // try to get the config from the orchestrator home directory + orchHome, err := base.GetHomeDirectory(cmd, orchestrator.ServiceNameOrchestrator) + if err != nil { + return Config{}, err + } + orchConf, err := orchestrator.GetStartConfig(v, filepath.Join(orchHome, "config")) + if err == nil { + // found orchestrator home, get the config from it + logger.Debug("using home", "home", orchHome) + return *NewPartialConfig( + orchConf.CoreGRPC, + orchConf.CoreRPC, + orchConf.Bootstrappers, + orchConf.GRPCInsecure, + ), nil + } + + // try to get the config from the relayer home directory + relHome, err := base.GetHomeDirectory(cmd, relayer.ServiceNameRelayer) + if err != nil { + return Config{}, err + } + relConf, err := relayer.GetStartConfig(v, filepath.Join(relHome, "config")) + if err == nil { + // found relayer home, so we get the config from it + logger.Debug("using home", "home", relHome) + return *NewPartialConfig( + relConf.CoreGRPC, + relConf.CoreRPC, + relConf.Bootstrappers, + relConf.GrpcInsecure, + ), nil + } + + return *DefaultConfig(), nil +} diff --git a/cmd/blobstream/query/config.go b/cmd/blobstream/query/config.go index 530bab99..4373ef69 100644 --- a/cmd/blobstream/query/config.go +++ b/cmd/blobstream/query/config.go @@ -20,7 +20,7 @@ func addFlags(cmd *cobra.Command) *cobra.Command { cmd.Flags().String(FlagP2PNode, "", "P2P target node multiaddress (eg. /ip4/127.0.0.1/tcp/30000/p2p/12D3KooWBSMasWzRSRKXREhediFUwABNZwzJbkZcYz5rYr9Zdmfn)") cmd.Flags().String(FlagOutputFile, "", "Path to an output file path if the results need to be written to a json file. Leaving it as empty will result in printing the result to stdout") base.AddGRPCInsecureFlag(cmd) - + cmd.Flags().String(base.FlagHome, "", "The Blobstream orchestrator|relayer home directory. If this flag is not set, it will try the orchestrator's default home directory, then the relayer's default home directory to get the necessary configuration") return cmd } @@ -31,35 +31,75 @@ type Config struct { grpcInsecure bool } -func parseFlags(cmd *cobra.Command) (Config, error) { - coreRPC, err := cmd.Flags().GetString(base.FlagCoreRPC) +func NewPartialConfig(coreGRPC, coreRPC, targetNode string, grpcInsecure bool) *Config { + return &Config{ + coreGRPC: coreGRPC, + coreRPC: coreRPC, + targetNode: targetNode, + grpcInsecure: grpcInsecure, + } +} + +func DefaultConfig() *Config { + return &Config{ + coreGRPC: "localhost:9090", + coreRPC: "tcp://localhost:26657", + targetNode: "", + outputFile: "", + grpcInsecure: true, + } +} + +func parseFlags(cmd *cobra.Command, startConf *Config) (Config, error) { + coreRPC, changed, err := base.GetCoreRPCFlag(cmd) if err != nil { return Config{}, err } - if !strings.HasPrefix(coreRPC, "tcp://") { - coreRPC = fmt.Sprintf("tcp://%s", coreRPC) + if changed { + if !strings.HasPrefix(coreRPC, "tcp://") { + coreRPC = fmt.Sprintf("tcp://%s", coreRPC) + } + startConf.coreRPC = coreRPC } - coreGRPC, err := cmd.Flags().GetString(base.FlagCoreGRPC) + + coreGRPC, changed, err := base.GetCoreGRPCFlag(cmd) if err != nil { return Config{}, err } - targetNode, err := cmd.Flags().GetString(FlagP2PNode) + if changed { + startConf.coreGRPC = coreGRPC + } + + targetNode, changed, err := getP2PNodeFlag(cmd) if err != nil { return Config{}, err } + if changed { + startConf.targetNode = targetNode + } + outputFile, err := cmd.Flags().GetString(FlagOutputFile) if err != nil { return Config{}, err } - grpcInsecure, err := cmd.Flags().GetBool(base.FlagGRPCInsecure) + startConf.outputFile = outputFile + + grpcInsecure, changed, err := base.GetGRPCInsecureFlag(cmd) if err != nil { return Config{}, err } - return Config{ - coreGRPC: coreGRPC, - coreRPC: coreRPC, - targetNode: targetNode, - outputFile: outputFile, - grpcInsecure: grpcInsecure, - }, nil + if changed { + startConf.grpcInsecure = grpcInsecure + } + + return *startConf, nil +} + +func getP2PNodeFlag(cmd *cobra.Command) (string, bool, error) { + changed := cmd.Flags().Changed(FlagP2PNode) + val, err := cmd.Flags().GetString(FlagP2PNode) + if err != nil { + return "", changed, err + } + return val, changed, nil } 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..4ae53b1a 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 } @@ -306,7 +321,7 @@ func LoadFileConfiguration(homeDir string) (*StartConfig, error) { } } - conf, err := getStartConfig(v, configPath) + conf, err := GetStartConfig(v, configPath) if err != nil { return nil, fmt.Errorf("couldn't get client config: %v", err) } @@ -342,8 +357,8 @@ func writeConfigToFile(configFilePath string, config *StartConfig) error { return os.WriteFile(configFilePath, buffer.Bytes(), 0o600) } -// getStartConfig reads values from config.toml file and unmarshalls them into StartConfig -func getStartConfig(v *viper.Viper, configPath string) (*StartConfig, error) { +// GetStartConfig reads values from config.toml file and unmarshalls them into StartConfig +func GetStartConfig(v *viper.Viper, configPath string) (*StartConfig, error) { v.AddConfigPath(configPath) v.SetConfigName("config") v.SetConfigType("toml") diff --git a/docs/orchestrator.md b/docs/orchestrator.md index 916f6bf1..ca61b599 100644 --- a/docs/orchestrator.md +++ b/docs/orchestrator.md @@ -10,6 +10,9 @@ description: Learn about the Blobstream Orchestrator. The role of the orchestrator is to sign attestations using its corresponding validator EVM private key. These attestations are generated within the Blobstream module of the Celestia-app state machine. To learn more about what attestations are, you can refer to [the Blobstream overview](https://github.com/celestiaorg/celestia-app/tree/main/x/blobstream). +> **_NOTE:_** +> Running a Blobstream orchestrator is an incredibly important aspect of running a validator. The signatures created there will be used to commit to block data in the exact way as the signatures included in the commit. Not running an orchestrator potentially has the same consequences (enforced by social slashing and eventually the protocol itself) as not signing a block. + ## How it works The orchestrator does the following: diff --git a/e2e/go.mod b/e2e/go.mod index ae112f3f..b3c583ff 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 ) @@ -224,7 +224,7 @@ require ( github.com/libp2p/go-cidranger v1.1.0 // indirect github.com/libp2p/go-flow-metrics v0.1.0 // indirect github.com/libp2p/go-libp2p-asn-util v0.3.0 // indirect - github.com/libp2p/go-libp2p-kad-dht v0.25.1 // indirect + github.com/libp2p/go-libp2p-kad-dht v0.25.2 // indirect github.com/libp2p/go-libp2p-kbucket v0.6.3 // indirect github.com/libp2p/go-libp2p-record v0.2.0 // indirect github.com/libp2p/go-libp2p-routing-helpers v0.7.2 // indirect diff --git a/e2e/go.sum b/e2e/go.sum index ae8a73b0..8881a322 100644 --- a/e2e/go.sum +++ b/e2e/go.sum @@ -1255,8 +1255,8 @@ github.com/libp2p/go-libp2p v0.32.0 h1:86I4B7nBUPIyTgw3+5Ibq6K7DdKRCuZw8URCfPc1h github.com/libp2p/go-libp2p v0.32.0/go.mod h1:hXXC3kXPlBZ1eu8Q2hptGrMB4mZ3048JUoS4EKaHW5c= github.com/libp2p/go-libp2p-asn-util v0.3.0 h1:gMDcMyYiZKkocGXDQ5nsUQyquC9+H+iLEQHwOCZ7s8s= github.com/libp2p/go-libp2p-asn-util v0.3.0/go.mod h1:B1mcOrKUE35Xq/ASTmQ4tN3LNzVVaMNmq2NACuqyB9w= -github.com/libp2p/go-libp2p-kad-dht v0.25.1 h1:ofFNrf6MMEy4vi3R1VbJ7LOcTn3Csh0cDcaWHTxtWNA= -github.com/libp2p/go-libp2p-kad-dht v0.25.1/go.mod h1:6za56ncRHYXX4Nc2vn8z7CZK0P4QiMcrn77acKLM2Oo= +github.com/libp2p/go-libp2p-kad-dht v0.25.2 h1:FOIk9gHoe4YRWXTu8SY9Z1d0RILol0TrtApsMDPjAVQ= +github.com/libp2p/go-libp2p-kad-dht v0.25.2/go.mod h1:6za56ncRHYXX4Nc2vn8z7CZK0P4QiMcrn77acKLM2Oo= github.com/libp2p/go-libp2p-kbucket v0.6.3 h1:p507271wWzpy2f1XxPzCQG9NiN6R6lHL9GiSErbQQo0= github.com/libp2p/go-libp2p-kbucket v0.6.3/go.mod h1:RCseT7AH6eJWxxk2ol03xtP9pEHetYSPXOaJnOiD8i0= github.com/libp2p/go-libp2p-record v0.2.0 h1:oiNUOCWno2BFuxt3my4i1frNrt7PerzB3queqa1NkQ0= @@ -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/evm/evm_client.go b/evm/evm_client.go index 9b4384fe..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" @@ -82,7 +83,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 +110,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 { @@ -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/go.mod b/go.mod index 7dd25c9a..21e03e0d 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 ) @@ -32,7 +32,7 @@ require ( github.com/ipfs/go-datastore v0.6.0 github.com/ipfs/go-ds-badger2 v0.1.3 github.com/libp2p/go-libp2p v0.32.0 - github.com/libp2p/go-libp2p-kad-dht v0.25.1 + github.com/libp2p/go-libp2p-kad-dht v0.25.2 github.com/mitchellh/go-homedir v1.1.0 github.com/multiformats/go-multiaddr v0.12.0 github.com/rs/zerolog v1.31.0 diff --git a/go.sum b/go.sum index b6b42eba..4a354e5d 100644 --- a/go.sum +++ b/go.sum @@ -1079,8 +1079,8 @@ github.com/libp2p/go-libp2p v0.32.0 h1:86I4B7nBUPIyTgw3+5Ibq6K7DdKRCuZw8URCfPc1h github.com/libp2p/go-libp2p v0.32.0/go.mod h1:hXXC3kXPlBZ1eu8Q2hptGrMB4mZ3048JUoS4EKaHW5c= github.com/libp2p/go-libp2p-asn-util v0.3.0 h1:gMDcMyYiZKkocGXDQ5nsUQyquC9+H+iLEQHwOCZ7s8s= github.com/libp2p/go-libp2p-asn-util v0.3.0/go.mod h1:B1mcOrKUE35Xq/ASTmQ4tN3LNzVVaMNmq2NACuqyB9w= -github.com/libp2p/go-libp2p-kad-dht v0.25.1 h1:ofFNrf6MMEy4vi3R1VbJ7LOcTn3Csh0cDcaWHTxtWNA= -github.com/libp2p/go-libp2p-kad-dht v0.25.1/go.mod h1:6za56ncRHYXX4Nc2vn8z7CZK0P4QiMcrn77acKLM2Oo= +github.com/libp2p/go-libp2p-kad-dht v0.25.2 h1:FOIk9gHoe4YRWXTu8SY9Z1d0RILol0TrtApsMDPjAVQ= +github.com/libp2p/go-libp2p-kad-dht v0.25.2/go.mod h1:6za56ncRHYXX4Nc2vn8z7CZK0P4QiMcrn77acKLM2Oo= github.com/libp2p/go-libp2p-kbucket v0.6.3 h1:p507271wWzpy2f1XxPzCQG9NiN6R6lHL9GiSErbQQo0= github.com/libp2p/go-libp2p-kbucket v0.6.3/go.mod h1:RCseT7AH6eJWxxk2ol03xtP9pEHetYSPXOaJnOiD8i0= github.com/libp2p/go-libp2p-record v0.2.0 h1:oiNUOCWno2BFuxt3my4i1frNrt7PerzB3queqa1NkQ0= @@ -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= 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.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 586ccd78..f8863eef 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" @@ -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) @@ -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) @@ -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/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 98% rename from testing/qgb.go rename to testing/blobstream.go index 28de55a7..8dfedd26 100644 --- a/testing/qgb.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 } 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()