From 4280f910ae95ecdea8cf44cd1a339a087af71c3d Mon Sep 17 00:00:00 2001 From: benbierens Date: Mon, 23 Oct 2023 12:52:47 +0200 Subject: [PATCH] Makes making storage available optional. --- Tools/CodexNetDeployer/CodexNodeStarter.cs | 34 ++++++++++++------- Tools/CodexNetDeployer/Configuration.cs | 19 ++++++----- Tools/CodexNetDeployer/Program.cs | 3 +- .../deploy-continuous-testnet.sh | 1 + .../CodexNetDeployer/deploy-public-testnet.sh | 6 +--- 5 files changed, 37 insertions(+), 26 deletions(-) diff --git a/Tools/CodexNetDeployer/CodexNodeStarter.cs b/Tools/CodexNetDeployer/CodexNodeStarter.cs index e1b1aa9..51e92b0 100644 --- a/Tools/CodexNetDeployer/CodexNodeStarter.cs +++ b/Tools/CodexNetDeployer/CodexNodeStarter.cs @@ -38,7 +38,11 @@ namespace CodexNetDeployer s.WithName(name); s.WithLogLevel(config.CodexLogLevel, new CodexLogCustomTopics(config.Discv5LogLevel, config.Libp2pLogLevel)); s.WithStorageQuota(config.StorageQuota!.Value.MB()); - s.EnableMarketplace(gethNode, contracts, 100.Eth(), config.InitialTestTokens.TestTokens(), validatorsLeft > 0); + + if (config.ShouldMakeStorageAvailable) + { + s.EnableMarketplace(gethNode, contracts, 100.Eth(), config.InitialTestTokens.TestTokens(), validatorsLeft > 0); + } if (bootstrapNode != null) s.WithBootstrapNode(bootstrapNode); if (config.MetricsEndpoints) s.EnableMetrics(); @@ -52,20 +56,26 @@ namespace CodexNetDeployer { Console.Write("Online\t"); - var response = codexNode.Marketplace.MakeStorageAvailable( - size: config.StorageSell!.Value.MB(), - minPriceForTotalSpace: config.MinPrice.TestTokens(), - maxCollateral: config.MaxCollateral.TestTokens(), - maxDuration: TimeSpan.FromSeconds(config.MaxDuration)); - - if (!string.IsNullOrEmpty(response)) + if (config.ShouldMakeStorageAvailable) { - Console.Write("Storage available\tOK" + Environment.NewLine); + var response = codexNode.Marketplace.MakeStorageAvailable( + size: config.StorageSell!.Value.MB(), + minPriceForTotalSpace: config.MinPrice.TestTokens(), + maxCollateral: config.MaxCollateral.TestTokens(), + maxDuration: TimeSpan.FromSeconds(config.MaxDuration)); - validatorsLeft--; - if (bootstrapNode == null) bootstrapNode = codexNode; - return new CodexNodeStartResult(codexNode); + if (!string.IsNullOrEmpty(response)) + { + Console.Write("Storage available\t"); + } + else throw new Exception("Failed to make storage available."); } + + Console.Write("OK" + Environment.NewLine); + + validatorsLeft--; + if (bootstrapNode == null) bootstrapNode = codexNode; + return new CodexNodeStartResult(codexNode); } } catch (Exception ex) diff --git a/Tools/CodexNetDeployer/Configuration.cs b/Tools/CodexNetDeployer/Configuration.cs index 3d24e0b..2d7d295 100644 --- a/Tools/CodexNetDeployer/Configuration.cs +++ b/Tools/CodexNetDeployer/Configuration.cs @@ -34,9 +34,6 @@ namespace CodexNetDeployer [Uniform("storage-quota", "sq", "STORAGEQUOTA", true, "Storage quota in megabytes used by each Codex node.")] public int? StorageQuota { get; set; } - [Uniform("storage-sell", "ss", "STORAGESELL", true, "Number of megabytes of storage quota to make available for selling.")] - public int? StorageSell { get; set; } - [Uniform("log-level", "l", "LOGLEVEL", true, "Log level used by each Codex node. [Trace, Debug*, Info, Warn, Error]")] public CodexLogLevel CodexLogLevel { get; set; } = CodexLogLevel.Debug; @@ -46,16 +43,22 @@ namespace CodexNetDeployer [Uniform("log-level-discv5", "ldv5", "LOGLEVELDISCV5", true, "Log level for all discv5 topics. [Trace, Debug, Info, Warn*, Error]")] public CodexLogLevel Discv5LogLevel { get; set; } = CodexLogLevel.Warn; - [Uniform("test-tokens", "tt", "TESTTOKENS", true, "Initial amount of test-tokens minted for each Codex node.")] - public int InitialTestTokens { get; set; } = int.MaxValue; + [Uniform("make-storage-available", "msa", "MAKESTORAGEAVAILABLE", true, "Is true, storage will be made available using the next configuration parameters.")] + public bool ShouldMakeStorageAvailable { get; set; } = false; - [Uniform("min-price", "mp", "MINPRICE", true, "Minimum price for the storage space for which contracts will be accepted.")] + [Uniform("storage-sell", "ss", "STORAGESELL", false, "Number of megabytes of storage quota to make available for selling.")] + public int? StorageSell { get; set; } + + [Uniform("test-tokens", "tt", "TESTTOKENS", false, "Initial amount of test-tokens minted for each Codex node.")] + public int InitialTestTokens { get; set; } + + [Uniform("min-price", "mp", "MINPRICE", false, "Minimum price for the storage space for which contracts will be accepted.")] public int MinPrice { get; set; } - [Uniform("max-collateral", "mc", "MAXCOLLATERAL", true, "Maximum collateral that will be placed for the total storage space.")] + [Uniform("max-collateral", "mc", "MAXCOLLATERAL", false, "Maximum collateral that will be placed for the total storage space.")] public int MaxCollateral { get; set; } - [Uniform("max-duration", "md", "MAXDURATION", true, "Maximum duration in seconds for contracts which will be accepted.")] + [Uniform("max-duration", "md", "MAXDURATION", false, "Maximum duration in seconds for contracts which will be accepted.")] public int MaxDuration { get; set; } [Uniform("block-ttl", "bt", "BLOCKTTL", false, "Block timeout in seconds. Default is 24 hours.")] diff --git a/Tools/CodexNetDeployer/Program.cs b/Tools/CodexNetDeployer/Program.cs index aad5fab..807d09b 100644 --- a/Tools/CodexNetDeployer/Program.cs +++ b/Tools/CodexNetDeployer/Program.cs @@ -26,8 +26,9 @@ public class Program var deployer = new Deployer(config); deployer.AnnouncePlugins(); - if (!args.Any(a => a == "-y")) + if (config.IsPublicTestNet || !args.Any(a => a == "-y")) { + if (config.IsPublicTestNet) Console.WriteLine("Deployment is configured as public testnet."); Console.WriteLine("Does the above config look good? [y/n]"); if (Console.ReadLine()!.ToLowerInvariant() != "y") return; Console.WriteLine("I think so too."); diff --git a/Tools/CodexNetDeployer/deploy-continuous-testnet.sh b/Tools/CodexNetDeployer/deploy-continuous-testnet.sh index 25175e5..5269f22 100644 --- a/Tools/CodexNetDeployer/deploy-continuous-testnet.sh +++ b/Tools/CodexNetDeployer/deploy-continuous-testnet.sh @@ -7,6 +7,7 @@ dotnet run \ --validators=3 \ --log-level=Trace \ --storage-quota=2048 \ + --make-storage-available=1 \ --storage-sell=1024 \ --min-price=1024 \ --max-collateral=1024 \ diff --git a/Tools/CodexNetDeployer/deploy-public-testnet.sh b/Tools/CodexNetDeployer/deploy-public-testnet.sh index fd93214..7bb70cb 100644 --- a/Tools/CodexNetDeployer/deploy-public-testnet.sh +++ b/Tools/CodexNetDeployer/deploy-public-testnet.sh @@ -6,11 +6,7 @@ dotnet run \ --nodes=3 \ --validators=1 \ --log-level=Trace \ - --storage-quota=2048 \ - --storage-sell=1024 \ - --min-price=1024 \ - --max-collateral=1024 \ - --max-duration=3600000 \ + --make-storage-available=0 \ --block-ttl=180 \ --block-mi=120 \ --block-mn=10000 \