2
0
mirror of synced 2025-02-23 13:38:07 +00:00

Makes making storage available optional.

This commit is contained in:
benbierens 2023-10-23 12:52:47 +02:00
parent ec8a041257
commit 4280f910ae
No known key found for this signature in database
GPG Key ID: FE44815D96D0A1AA
5 changed files with 37 additions and 26 deletions

View File

@ -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)

View File

@ -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.")]

View File

@ -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.");

View File

@ -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 \

View File

@ -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 \