From df0670e8e363f262948cd3ac01073bce7b94a986 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Wed, 11 Oct 2023 22:26:22 +0200 Subject: [PATCH 1/5] tapcfg: allow running tapd on mainnet --- tapcfg/config.go | 9 ++++++--- tapcfg/server.go | 8 ++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/tapcfg/config.go b/tapcfg/config.go index 65e0f1a0c..c65860b26 100644 --- a/tapcfg/config.go +++ b/tapcfg/config.go @@ -48,9 +48,12 @@ const ( defaultLetsEncryptDirname = "letsencrypt" defaultLetsEncryptListen = ":80" + defaultNetwork = "mainnet" + defaultMaxLogFiles = 3 defaultMaxLogFileSize = 10 + defaultMainnetFederationServer = "universe.lightning.finance:10029" defaultTestnetFederationServer = "testnet.universe.lightning.finance:10029" // DefaultAutogenValidity is the default validity of a self-signed @@ -121,8 +124,6 @@ var ( // file. DefaultConfigFile = filepath.Join(DefaultTapdDir, defaultConfigFileName) - defaultNetwork = "testnet" - defaultDataDir = filepath.Join(DefaultTapdDir, defaultDataDirname) defaultLogDir = filepath.Join(DefaultTapdDir, defaultLogDirname) @@ -175,7 +176,7 @@ var ( // ChainConfig houses the configuration options that govern which chain/network // we operate on. type ChainConfig struct { - Network string `long:"network" description:"network to run on" choice:"regtest" choice:"testnet" choice:"simnet" choice:"signet"` + Network string `long:"network" description:"network to run on" choice:"mainnet" choice:"regtest" choice:"testnet" choice:"simnet" choice:"signet"` SigNetChallenge string `long:"signetchallenge" description:"Connect to a custom signet network defined by this challenge instead of using the global default signet test network -- Can be specified multiple times"` } @@ -541,6 +542,8 @@ func ValidateConfig(cfg Config, cfgLogger btclog.Logger) (*Config, error) { // network flags passed; assign active network params // while we're at it. switch cfg.ChainConf.Network { + case "mainnet": + cfg.ActiveNetParams = chaincfg.MainNetParams case "testnet": cfg.ActiveNetParams = chaincfg.TestNet3Params case "regtest": diff --git a/tapcfg/server.go b/tapcfg/server.go index df644bf43..171c16ee9 100644 --- a/tapcfg/server.go +++ b/tapcfg/server.go @@ -236,6 +236,14 @@ func genServerConfig(cfg *Config, cfgLogger btclog.Logger, federationMembers := cfg.Universe.FederationServers switch cfg.ChainConf.Network { + case "mainnet": + cfgLogger.Infof("Configuring %v as initial Universe "+ + "federation server", defaultMainnetFederationServer) + + federationMembers = append( + federationMembers, defaultMainnetFederationServer, + ) + case "testnet": cfgLogger.Infof("Configuring %v as initial Universe "+ "federation server", defaultTestnetFederationServer) From 16b444be850cef079c5596fe8fd31dbdaa27cc1b Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Wed, 11 Oct 2023 23:46:21 +0200 Subject: [PATCH 2/5] tapcfg: make the universe proof courier the default --- tapcfg/config.go | 22 +++++++++++------ tapcfg/server.go | 63 ++++++++++++++++++++++++++++++++---------------- 2 files changed, 57 insertions(+), 28 deletions(-) diff --git a/tapcfg/config.go b/tapcfg/config.go index c65860b26..140f24b7f 100644 --- a/tapcfg/config.go +++ b/tapcfg/config.go @@ -72,6 +72,10 @@ const ( // proofs for asynchronous sends. fallbackHashMailAddr = "mailbox.terminal.lightning.today:443" + // fallbackUniverseAddr is the fallback address we'll use to deliver + // proofs for asynchronous sends. + fallbackUniverseAddr = defaultMainnetFederationServer + // DatabaseBackendSqlite is the name of the SQLite database backend. DatabaseBackendSqlite = "sqlite" @@ -155,6 +159,12 @@ var ( defaultDataDir, defaultNetwork, defaultSqliteDatabaseFileName, ) + // defaultProofCourierAddr is the default proof courier address URI + // we'll use to deliver proofs for asynchronous sends. + defaultProofCourierAddr = fmt.Sprintf( + "%s://%s", proof.UniverseRpcCourierType, fallbackUniverseAddr, + ) + // minimalCompatibleVersion is the minimum version and build tags // required in lnd to run tapd. minimalCompatibleVersion = &verrpc.Version{ @@ -335,13 +345,11 @@ func DefaultConfig() Config { Port: 5432, MaxOpenConnections: 10, }, - LogWriter: build.NewRotatingLogWriter(), - Prometheus: monitoring.DefaultPrometheusConfig(), - BatchMintingInterval: defaultBatchMintingInterval, - ReOrgSafeDepth: defaultReOrgSafeDepth, - DefaultProofCourierAddr: fmt.Sprintf( - "%s://%s", proof.HashmailCourierType, fallbackHashMailAddr, - ), + LogWriter: build.NewRotatingLogWriter(), + Prometheus: monitoring.DefaultPrometheusConfig(), + BatchMintingInterval: defaultBatchMintingInterval, + ReOrgSafeDepth: defaultReOrgSafeDepth, + DefaultProofCourierAddr: defaultProofCourierAddr, HashMailCourier: &proof.HashMailCourierCfg{ ReceiverAckTimeout: defaultProofTransferReceiverAckTimeout, BackoffCfg: &proof.BackoffCfg{ diff --git a/tapcfg/server.go b/tapcfg/server.go index 171c16ee9..e8d99f080 100644 --- a/tapcfg/server.go +++ b/tapcfg/server.go @@ -35,7 +35,7 @@ type databaseBackend interface { // genServerConfig generates a server config from the given tapd config. // // NOTE: The RPCConfig and SignalInterceptor fields must be set by the caller -// after genereting the server config. +// after generating the server config. func genServerConfig(cfg *Config, cfgLogger btclog.Logger, lndServices *lndclient.LndServices, mainErrChan chan<- error) (*tap.Config, error) { @@ -161,6 +161,46 @@ func genServerConfig(cfg *Config, cfgLogger btclog.Logger, assetStore, proofFileStore, ) + federationMembers := cfg.Universe.FederationServers + switch cfg.ChainConf.Network { + case "mainnet": + cfgLogger.Infof("Configuring %v as initial Universe "+ + "federation server", defaultMainnetFederationServer) + + federationMembers = append( + federationMembers, defaultMainnetFederationServer, + ) + + case "testnet": + cfgLogger.Infof("Configuring %v as initial Universe "+ + "federation server", defaultTestnetFederationServer) + + federationMembers = append( + federationMembers, defaultTestnetFederationServer, + ) + + // For testnet, we need to overwrite the default universe proof + // courier address to use the testnet server. + if cfg.DefaultProofCourierAddr == defaultProofCourierAddr { + cfg.DefaultProofCourierAddr = fmt.Sprintf( + "%s://%s", proof.UniverseRpcCourierType, + fallbackUniverseAddr, + ) + } + + default: + // For any other network, such as regtest, we can't use a + // universe proof courier by default, as we don't know what + // server to pick. So if there is no explicit value set, we fall + // back to using the hashmail courier, which works in all cases. + if cfg.DefaultProofCourierAddr == defaultProofCourierAddr { + cfg.DefaultProofCourierAddr = fmt.Sprintf( + "%s://%s", proof.HashmailCourierType, + fallbackHashMailAddr, + ) + } + } + // If no default proof courier address is set, use the fallback hashmail // address. fallbackHashmailCourierAddr := fmt.Sprintf( @@ -185,10 +225,10 @@ func genServerConfig(cfg *Config, cfgLogger btclog.Logger, } } - var proofCourierCfg *proof.CourierCfg // TODO(ffranr): This logic is leftover for integration tests which // do not yet enable a proof courier. Remove once all integration tests // support a proof courier. + var proofCourierCfg *proof.CourierCfg if cfg.HashMailCourier != nil { proofCourierCfg = &proof.CourierCfg{ ReceiverAckTimeout: cfg.HashMailCourier.ReceiverAckTimeout, @@ -234,25 +274,6 @@ func genServerConfig(cfg *Config, cfgLogger btclog.Logger, SyncBatchSize: defaultUniverseSyncBatchSize, }) - federationMembers := cfg.Universe.FederationServers - switch cfg.ChainConf.Network { - case "mainnet": - cfgLogger.Infof("Configuring %v as initial Universe "+ - "federation server", defaultMainnetFederationServer) - - federationMembers = append( - federationMembers, defaultMainnetFederationServer, - ) - - case "testnet": - cfgLogger.Infof("Configuring %v as initial Universe "+ - "federation server", defaultTestnetFederationServer) - - federationMembers = append( - federationMembers, defaultTestnetFederationServer, - ) - } - runtimeID := prand.Int63() // nolint:gosec universeFederation := universe.NewFederationEnvoy( universe.FederationConfig{ From 0758968043d24197cf85f1545a050cf46bf62e42 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Thu, 12 Oct 2023 00:43:49 +0200 Subject: [PATCH 3/5] cmd/tapcli: allow using tapcli on mainnet --- cmd/tapcli/main.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cmd/tapcli/main.go b/cmd/tapcli/main.go index b7b7e7d21..d625ebf07 100644 --- a/cmd/tapcli/main.go +++ b/cmd/tapcli/main.go @@ -219,7 +219,7 @@ func extractPathArgs(ctx *cli.Context) (string, string, error) { // determine the correct path to the macaroon when not specified. network := strings.ToLower(ctx.GlobalString("network")) switch network { - case "testnet", "regtest", "simnet", "signet": + case "mainnet", "testnet", "regtest", "simnet", "signet": default: return "", "", fmt.Errorf("unknown network: %v", network) } @@ -234,7 +234,9 @@ func extractPathArgs(ctx *cli.Context) (string, string, error) { // target the specified file. var macPath string if ctx.GlobalString("macaroonpath") != "" { - macPath = lncfg.CleanAndExpandPath(ctx.GlobalString("macaroonpath")) + macPath = lncfg.CleanAndExpandPath(ctx.GlobalString( + "macaroonpath", + )) } else { // Otherwise, we'll go into the path: // tapddir/data/ in order to fetch the @@ -291,7 +293,7 @@ func main() { Name: "network, n", Usage: "The network tapd is running on, e.g. " + "mainnet, testnet, etc.", - Value: "testnet", + Value: "mainnet", }, cli.BoolFlag{ Name: "no-macaroons", From d78e93b40acd093b3a3fa69f6ac4c719300b0aa1 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Wed, 11 Oct 2023 20:47:12 -0700 Subject: [PATCH 4/5] tapcfg: retain testnet as the default network --- cmd/tapcli/main.go | 2 +- tapcfg/config.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/tapcli/main.go b/cmd/tapcli/main.go index d625ebf07..f01f3baf6 100644 --- a/cmd/tapcli/main.go +++ b/cmd/tapcli/main.go @@ -293,7 +293,7 @@ func main() { Name: "network, n", Usage: "The network tapd is running on, e.g. " + "mainnet, testnet, etc.", - Value: "mainnet", + Value: "testnet", }, cli.BoolFlag{ Name: "no-macaroons", diff --git a/tapcfg/config.go b/tapcfg/config.go index 140f24b7f..6dbcd9f36 100644 --- a/tapcfg/config.go +++ b/tapcfg/config.go @@ -48,7 +48,7 @@ const ( defaultLetsEncryptDirname = "letsencrypt" defaultLetsEncryptListen = ":80" - defaultNetwork = "mainnet" + defaultNetwork = "testnet" defaultMaxLogFiles = 3 defaultMaxLogFileSize = 10 From 9c66fa1c9c5ab8c764e4ed1df921fab273d15cb6 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Wed, 11 Oct 2023 20:51:15 -0700 Subject: [PATCH 5/5] build: bump version to v0.3.0-alpha --- version.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/version.go b/version.go index ea868fc8d..63bec6d3f 100644 --- a/version.go +++ b/version.go @@ -42,10 +42,10 @@ const ( AppMajor uint = 0 // AppMinor defines the minor version of this binary. - AppMinor uint = 2 + AppMinor uint = 3 // AppPatch defines the application patch for this binary. - AppPatch uint = 3 + AppPatch uint = 0 // AppPreRelease MUST only contain characters from semanticAlphabet // per the semantic versioning spec.