Requires new contracts image with configurable marketplace config

This commit is contained in:
Ben 2025-08-25 11:11:56 +02:00
parent 275937a814
commit e03f5982d3
No known key found for this signature in database
GPG Key ID: 0F16E812E736C24B
3 changed files with 40 additions and 2 deletions

View File

@ -1,4 +1,5 @@
using Utils;
using System.Globalization;
using Utils;
namespace KubernetesWorkflow.Recipe
{
@ -88,6 +89,11 @@ namespace KubernetesWorkflow.Recipe
envVars.Add(factory.CreateEnvVar(name, value));
}
protected void AddEnvVar(string name, int value)
{
envVars.Add(factory.CreateEnvVar(name, value.ToString(CultureInfo.InvariantCulture)));
}
protected void AddEnvVar(string name, Port value)
{
envVars.Add(factory.CreateEnvVar(name, value.Number));

View File

@ -9,6 +9,11 @@ namespace CodexContractsPlugin
{
public const string DeployedAddressesFilename = "/hardhat/ignition/deployments/chain-789988/deployed_addresses.json";
public const string MarketplaceArtifactFilename = "/hardhat/artifacts/contracts/Marketplace.sol/Marketplace.json";
public const int PeriodSeconds = 60;
public const int TimeoutSeconds = 30;
public const int DowntimeSeconds = 128;
private readonly DebugInfoVersion versionInfo;
public override string AppName => "codex-contracts";
@ -28,6 +33,22 @@ namespace CodexContractsPlugin
SetSchedulingAffinity(notIn: "false");
AddEnvVar("DISTTEST_NETWORK_URL", address.ToString());
// Default values:
AddEnvVar("DISTTEST_REPAIRREWARD", 10);
AddEnvVar("DISTTEST_MAXSLASHES", 2);
AddEnvVar("DISTTEST_SLASHPERCENTAGE", 20);
AddEnvVar("DISTTEST_VALIDATORREWARD", 20);
AddEnvVar("DISTTEST_DOWNTIMEPRODUCT", 67);
AddEnvVar("DISTTEST_MAXRESERVATIONS", 3);
AddEnvVar("DISTTEST_MAXDURATION", Convert.ToInt32(TimeSpan.FromDays(30).TotalSeconds));
// Customized values, required to operate in a network with
// block frequency of 1.
AddEnvVar("DISTTEST_PERIOD", PeriodSeconds);
AddEnvVar("DISTTEST_TIMEOUT", TimeoutSeconds);
AddEnvVar("DISTTEST_DOWNTIME", DowntimeSeconds);
AddEnvVar("HARDHAT_NETWORK", "codexdisttestnetwork");
AddEnvVar("HARDHAT_IGNITION_CONFIRM_DEPLOYMENT", "false");
AddEnvVar("KEEP_ALIVE", "1");

View File

@ -92,12 +92,23 @@ namespace CodexContractsPlugin
Log("Synced. Codex SmartContracts deployed. Getting configuration...");
var config = GetMarketplaceConfiguration(marketplaceAddress, gethNode);
Log("Got config: " + JsonConvert.SerializeObject(config));
ConfigShouldEqual(config.Proofs.Period, CodexContractsContainerRecipe.PeriodSeconds, "Period");
ConfigShouldEqual(config.Proofs.Timeout, CodexContractsContainerRecipe.TimeoutSeconds, "Timeout");
ConfigShouldEqual(config.Proofs.Downtime, CodexContractsContainerRecipe.DowntimeSeconds, "Downtime");
return new CodexContractsDeployment(config, marketplaceAddress, abi, tokenAddress);
}
private void ConfigShouldEqual(ulong value, int expected, string name)
{
if (Convert.ToInt32(value) != expected)
{
throw new Exception($"Config value '{name}' should be deployed as '{expected}' but was '{value}'");
}
}
private MarketplaceConfig GetMarketplaceConfiguration(string marketplaceAddress, IGethNode gethNode)
{
var func = new ConfigurationFunctionBase();