From 90b90be3cbf0d95dcc29f781a654fb35ad039d66 Mon Sep 17 00:00:00 2001 From: Ben Date: Wed, 13 Mar 2024 10:29:26 +0100 Subject: [PATCH] Updates usages of EnableMarketplace --- .../CodexPlugin/CodexContainerRecipe.cs | 7 ++----- ProjectPlugins/CodexPlugin/CodexSetup.cs | 17 +++++++---------- .../BasicTests/ContinuousSubstitute.cs | 4 +++- Tests/CodexTests/BasicTests/ExampleTests.cs | 4 +++- Tools/CodexNetDeployer/CodexNodeStarter.cs | 6 +++++- 5 files changed, 20 insertions(+), 18 deletions(-) diff --git a/ProjectPlugins/CodexPlugin/CodexContainerRecipe.cs b/ProjectPlugins/CodexPlugin/CodexContainerRecipe.cs index 78bb4f2..b48f605 100644 --- a/ProjectPlugins/CodexPlugin/CodexContainerRecipe.cs +++ b/ProjectPlugins/CodexPlugin/CodexContainerRecipe.cs @@ -128,14 +128,11 @@ namespace CodexPlugin private void SetCommandOverride(MarketplaceSetup ms) { - var persistenceRequired = ms.IsClientNode || ms.IsStorageNode || ms.IsValidator; - var proverRequired = ms.IsStorageNode; - - if (persistenceRequired && proverRequired) + if (ms.IsStorageNode) { OverrideCommand("codex", "persistence", "prover"); } - else if (persistenceRequired) + else { OverrideCommand("codex", "persistence"); } diff --git a/ProjectPlugins/CodexPlugin/CodexSetup.cs b/ProjectPlugins/CodexPlugin/CodexSetup.cs index 7e42121..54be6a9 100644 --- a/ProjectPlugins/CodexPlugin/CodexSetup.cs +++ b/ProjectPlugins/CodexPlugin/CodexSetup.cs @@ -17,6 +17,7 @@ namespace CodexPlugin ICodexSetup WithBlockMaintenanceInterval(TimeSpan duration); ICodexSetup WithBlockMaintenanceNumber(int numberOfBlocks); ICodexSetup EnableMetrics(); + ICodexSetup EnableMarketplace(IGethNode gethNode, ICodexContracts codexContracts, Ether initialEth, TestToken initialTokens); ICodexSetup EnableMarketplace(IGethNode gethNode, ICodexContracts codexContracts, Ether initialEth, TestToken initialTokens, Action marketplaceSetup); /// /// Provides an invalid proof every N proofs @@ -28,7 +29,6 @@ namespace CodexPlugin public interface IMarketplaceSetup { IMarketplaceSetup AsStorageNode(); - IMarketplaceSetup AsClientNode(); IMarketplaceSetup AsValidator(); } @@ -122,6 +122,11 @@ namespace CodexPlugin return this; } + public ICodexSetup EnableMarketplace(IGethNode gethNode, ICodexContracts codexContracts, Ether initialEth, TestToken initialTokens) + { + return EnableMarketplace(gethNode, codexContracts, initialEth, initialTokens, s => { }); + } + public ICodexSetup EnableMarketplace(IGethNode gethNode, ICodexContracts codexContracts, Ether initialEth, TestToken initialTokens, Action marketplaceSetup) { var ms = new MarketplaceSetup(); @@ -162,16 +167,9 @@ namespace CodexPlugin public class MarketplaceSetup : IMarketplaceSetup { - public bool IsClientNode { get; private set; } public bool IsStorageNode { get; private set; } public bool IsValidator { get; private set; } - public IMarketplaceSetup AsClientNode() - { - IsClientNode = true; - return this; - } - public IMarketplaceSetup AsStorageNode() { IsStorageNode = true; @@ -186,8 +184,7 @@ namespace CodexPlugin public override string ToString() { - var result = "["; - result += IsClientNode ? "(clientNode)" : "()"; + var result = "[(clientNode)"; // When marketplace is enabled, being a clientNode is implicit. result += IsStorageNode ? "(storageNode)" : "()"; result += IsValidator ? "(validator)" : "()"; result += "]"; diff --git a/Tests/CodexTests/BasicTests/ContinuousSubstitute.cs b/Tests/CodexTests/BasicTests/ContinuousSubstitute.cs index 9974d7d..ad22bac 100644 --- a/Tests/CodexTests/BasicTests/ContinuousSubstitute.cs +++ b/Tests/CodexTests/BasicTests/ContinuousSubstitute.cs @@ -21,7 +21,9 @@ namespace CodexTests.BasicTests var group = AddCodex(5, o => o .EnableMetrics() - .EnableMarketplace(geth, contract, 10.Eth(), 100000.TestTokens(), isValidator: true) + .EnableMarketplace(geth, contract, 10.Eth(), 100000.TestTokens(), s => s + .AsStorageNode() + .AsValidator()) .WithBlockTTL(TimeSpan.FromMinutes(5)) .WithBlockMaintenanceInterval(TimeSpan.FromSeconds(10)) .WithBlockMaintenanceNumber(100) diff --git a/Tests/CodexTests/BasicTests/ExampleTests.cs b/Tests/CodexTests/BasicTests/ExampleTests.cs index fb2edcf..c70b5aa 100644 --- a/Tests/CodexTests/BasicTests/ExampleTests.cs +++ b/Tests/CodexTests/BasicTests/ExampleTests.cs @@ -64,7 +64,9 @@ namespace CodexTests.BasicTests .WithName("Seller") .WithLogLevel(CodexLogLevel.Trace, new CodexLogCustomTopics(CodexLogLevel.Error, CodexLogLevel.Error, CodexLogLevel.Warn)) .WithStorageQuota(11.GB()) - .EnableMarketplace(geth, contracts, initialEth: 10.Eth(), initialTokens: sellerInitialBalance, isValidator: true) + .EnableMarketplace(geth, contracts, initialEth: 10.Eth(), initialTokens: sellerInitialBalance, s => s + .AsStorageNode() + .AsValidator()) .WithSimulateProofFailures(failEveryNProofs: 3)); AssertBalance(contracts, seller, Is.EqualTo(sellerInitialBalance)); diff --git a/Tools/CodexNetDeployer/CodexNodeStarter.cs b/Tools/CodexNetDeployer/CodexNodeStarter.cs index 7b54001..71e7a6a 100644 --- a/Tools/CodexNetDeployer/CodexNodeStarter.cs +++ b/Tools/CodexNetDeployer/CodexNodeStarter.cs @@ -41,7 +41,11 @@ namespace CodexNetDeployer if (config.ShouldMakeStorageAvailable) { - s.EnableMarketplace(gethNode, contracts, 100.Eth(), config.InitialTestTokens.TestTokens(), validatorsLeft > 0); + s.EnableMarketplace(gethNode, contracts, 100.Eth(), config.InitialTestTokens.TestTokens(), s => + { + if (validatorsLeft > 0) s.AsValidator(); + if (config.ShouldMakeStorageAvailable) s.AsStorageNode(); + }); } if (bootstrapNode != null) s.WithBootstrapNode(bootstrapNode);