diff --git a/DistTestCore/Codex/CodexContainerRecipe.cs b/DistTestCore/Codex/CodexContainerRecipe.cs index b7c3b94..2500ef5 100644 --- a/DistTestCore/Codex/CodexContainerRecipe.cs +++ b/DistTestCore/Codex/CodexContainerRecipe.cs @@ -1,15 +1,16 @@ using DistTestCore.Marketplace; using KubernetesWorkflow; +using System.Net.Sockets; namespace DistTestCore.Codex { public class CodexContainerRecipe : ContainerRecipeFactory { #if Arm64 - public const string DockerImage = "codexstorage/nim-codex:sha-7b88ea0"; + public const string DockerImage = "codexstorage/nim-codex:sha-f053135"; #else - public const string DockerImage = "thatbenbierens/nim-codex:dhting"; - //public const string DockerImage = "codexstorage/nim-codex:sha-7b88ea0"; + //public const string DockerImage = "thatbenbierens/nim-codex:dhting"; + public const string DockerImage = "codexstorage/nim-codex:sha-f053135"; #endif public const string MetricsPortTag = "metrics_port"; public const string DiscoveryPortTag = "discovery-port"; @@ -24,26 +25,32 @@ namespace DistTestCore.Codex { var config = startupConfig.Get(); - AddExposedPortAndVar("API_PORT"); - AddEnvVar("DATA_DIR", $"datadir{ContainerNumber}"); - AddInternalPortAndVar("DISC_PORT", DiscoveryPortTag); - AddEnvVar("LOG_LEVEL", config.LogLevel.ToString()!.ToUpperInvariant()); + AddExposedPortAndVar("CODEX_API_PORT"); + AddEnvVar("CODEX_API_BINDADDR", "0.0.0.0"); + + AddEnvVar("CODEX_DATA_DIR", $"datadir{ContainerNumber}"); + AddInternalPortAndVar("CODEX_DISC_PORT", DiscoveryPortTag); + AddEnvVar("CODEX_LOG_LEVEL", config.LogLevel.ToString()!.ToUpperInvariant()); + + // This makes the node announce itself to its local (pod) IP address. + AddEnvVar("CODEX_NAT_ADDR", "$(hostname --ip-address)"); var listenPort = AddInternalPort(); - AddEnvVar("LISTEN_ADDRS", $"/ip4/0.0.0.0/tcp/{listenPort.Number}"); + AddEnvVar("CODEX_LISTEN_ADDRS", $"/ip4/0.0.0.0/tcp/{listenPort.Number}"); if (!string.IsNullOrEmpty(config.BootstrapSpr)) { - AddEnvVar("BOOTSTRAP_SPR", config.BootstrapSpr); + AddEnvVar("CODEX_BOOTSTRAP_NODE", config.BootstrapSpr); } if (config.StorageQuota != null) { - AddEnvVar("STORAGE_QUOTA", config.StorageQuota.SizeInBytes.ToString()!); + AddEnvVar("CODEX_STORAGE_QUOTA", config.StorageQuota.SizeInBytes.ToString()!); } if (config.MetricsEnabled) { - AddEnvVar("METRICS_ADDR", "0.0.0.0"); - AddInternalPortAndVar("METRICS_PORT", tag: MetricsPortTag); + AddEnvVar("CODEX_METRICS", "true"); + AddEnvVar("CODEX_METRICS_ADDRESS", "0.0.0.0"); + AddInternalPortAndVar("CODEX_METRICS_PORT", tag: MetricsPortTag); } if (config.MarketplaceConfig != null) @@ -56,14 +63,14 @@ namespace DistTestCore.Codex var ip = companionNode.RunningContainer.Pod.PodInfo.Ip; var port = companionNode.RunningContainer.Recipe.GetPortByTag(GethContainerRecipe.HttpPortTag).Number; - AddEnvVar("ETH_PROVIDER", $"ws://{ip}:{port}"); - AddEnvVar("ETH_ACCOUNT", companionNodeAccount.Account); - AddEnvVar("ETH_MARKETPLACE_ADDRESS", gethConfig.MarketplaceNetwork.Marketplace.Address); - AddEnvVar("PERSISTENCE", "1"); + AddEnvVar("CODEX_ETH_PROVIDER", $"ws://{ip}:{port}"); + AddEnvVar("CODEX_ETH_ACCOUNT", companionNodeAccount.Account); + AddEnvVar("CODEX_MARKETPLACE_ADDRESS", gethConfig.MarketplaceNetwork.Marketplace.Address); + AddEnvVar("CODEX_PERSISTENCE", "true"); if (config.MarketplaceConfig.IsValidator) { - AddEnvVar("VALIDATOR", "1"); + AddEnvVar("CODEX_VALIDATOR", "true"); } } } diff --git a/DistTestCore/Marketplace/MarketplaceAccess.cs b/DistTestCore/Marketplace/MarketplaceAccess.cs index 858717d..8a67564 100644 --- a/DistTestCore/Marketplace/MarketplaceAccess.cs +++ b/DistTestCore/Marketplace/MarketplaceAccess.cs @@ -34,10 +34,10 @@ namespace DistTestCore.Marketplace { var request = new CodexSalesRequestStorageRequest { - duration = ToHexBigInt(duration.TotalSeconds), - proofProbability = ToHexBigInt(proofProbability), - reward = ToHexBigInt(pricePerSlotPerSecond), - collateral = ToHexBigInt(requiredCollateral), + duration = ToDecInt(duration.TotalSeconds), + proofProbability = ToDecInt(proofProbability), + reward = ToDecInt(pricePerSlotPerSecond), + collateral = ToDecInt(requiredCollateral), expiry = null, nodes = minRequiredNumberOfNodes, tolerance = null, @@ -62,19 +62,19 @@ namespace DistTestCore.Marketplace return response; } - public string MakeStorageAvailable(ByteSize totalSpace, TestToken minPriceForTotalSpace, TestToken maxCollateral, TimeSpan maxDuration) + public string MakeStorageAvailable(ByteSize size, TestToken minPricePerBytePerSecond, TestToken maxCollateral, TimeSpan maxDuration) { var request = new CodexSalesAvailabilityRequest { - size = ToHexBigInt(totalSpace.SizeInBytes), - duration = ToHexBigInt(maxDuration.TotalSeconds), - maxCollateral = ToHexBigInt(maxCollateral), - minPrice = ToHexBigInt(minPriceForTotalSpace) + size = ToDecInt(size.SizeInBytes), + duration = ToDecInt(maxDuration.TotalSeconds), + maxCollateral = ToDecInt(maxCollateral), + minPrice = ToDecInt(minPricePerBytePerSecond) }; Log($"Making storage available... (" + - $"size: {totalSpace}, " + - $"minPricePerBytePerSecond: {minPriceForTotalSpace}, " + + $"size: {size}, " + + $"minPricePerBytePerSecond: {minPricePerBytePerSecond}, " + $"maxCollateral: {maxCollateral}, " + $"maxDuration: {Time.FormatDuration(maxDuration)})"); @@ -85,15 +85,16 @@ namespace DistTestCore.Marketplace return response.id; } - private string ToHexBigInt(double d) + private string ToDecInt(double d) { - return "0x" + string.Format("{0:X}", Convert.ToInt64(d)); + var i = new BigInteger(d); + return i.ToString("D"); } - public string ToHexBigInt(TestToken t) + public string ToDecInt(TestToken t) { - var bigInt = new BigInteger(t.Amount); - return "0x" + bigInt.ToString("X"); + var i = new BigInteger(t.Amount); + return i.ToString("D"); } public void AssertThatBalance(IResolveConstraint constraint, string message = "")