Updates to hardhat ignition

This commit is contained in:
Ben 2025-06-25 14:30:53 +02:00
parent 52f6941244
commit 30610b7f20
No known key found for this signature in database
GPG Key ID: 0F16E812E736C24B
5 changed files with 68 additions and 8 deletions

View File

@ -7,7 +7,7 @@ namespace CodexContractsPlugin
{
public class CodexContractsContainerRecipe : ContainerRecipeFactory
{
public const string MarketplaceAddressFilename = "/hardhat/deployments/codexdisttestnetwork/Marketplace.json";
public const string DeployedAddressesFilename = "/hardhat/ignition/deployments/chain-789988/deployed_addresses.json";
public const string MarketplaceArtifactFilename = "/hardhat/artifacts/contracts/Marketplace.sol/Marketplace.json";
private readonly DebugInfoVersion versionInfo;

View File

@ -74,11 +74,16 @@ namespace CodexContractsPlugin
var extractor = new ContractsContainerInfoExtractor(tools.GetLog(), workflow, container);
var marketplaceAddress = extractor.ExtractMarketplaceAddress();
if (string.IsNullOrEmpty(marketplaceAddress)) throw new Exception("Marketplace address not received.");
var (abi, bytecode) = extractor.ExtractMarketplaceAbiAndByteCode();
if (string.IsNullOrEmpty(abi)) throw new Exception("ABI not received.");
if (string.IsNullOrEmpty(bytecode)) throw new Exception("bytecode not received.");
EnsureCompatbility(abi, bytecode);
var interaction = new ContractInteractions(tools.GetLog(), gethNode);
var tokenAddress = interaction.GetTokenAddress(marketplaceAddress);
if (string.IsNullOrEmpty(tokenAddress)) throw new Exception("Token address not received.");
Log("TokenAddress: " + tokenAddress);
Log("Extract completed. Checking sync...");

View File

@ -27,7 +27,7 @@ namespace CodexContractsPlugin
var marketplaceAddress = Retry(FetchMarketplaceAddress);
if (string.IsNullOrEmpty(marketplaceAddress)) throw new InvalidOperationException("Unable to fetch marketplace account from codex-contracts node. Test infra failure.");
log.Debug("Got MarketplaceAddress: " + marketplaceAddress);
log.Log("MarketplaceAddress: " + marketplaceAddress);
return marketplaceAddress;
}
@ -43,9 +43,10 @@ namespace CodexContractsPlugin
private string FetchMarketplaceAddress()
{
var json = workflow.ExecuteCommand(container, "cat", CodexContractsContainerRecipe.MarketplaceAddressFilename);
var marketplace = JsonConvert.DeserializeObject<MarketplaceJson>(json);
return marketplace!.address;
var json = workflow.ExecuteCommand(container, "cat", CodexContractsContainerRecipe.DeployedAddressesFilename);
json = json.Replace("#", "_");
var addresses = JsonConvert.DeserializeObject<DeployedAddressesJson>(json);
return addresses!.Marketplace_Marketplace;
}
private (string, string) FetchMarketplaceAbiAndByteCode()
@ -67,8 +68,10 @@ namespace CodexContractsPlugin
}
}
public class MarketplaceJson
public class DeployedAddressesJson
{
public string address { get; set; } = string.Empty;
public string Token_TestToken { get; set; } = string.Empty;
public string Verifier_Groth16Verifier { get; set; } = string.Empty;
public string Marketplace_Marketplace { get; set; } = string.Empty;
}
}

File diff suppressed because one or more lines are too long

View File

@ -92,5 +92,57 @@ namespace CodexReleaseTests.DataTests
Assert.That(cleanupSpace.QuotaUsedBytes, Is.EqualTo(startSpace.QuotaUsedBytes));
Assert.That(cleanupSpace.FreeBytes, Is.EqualTo(startSpace.FreeBytes));
}
[Test]
public void StorageRequestsKeepManifests()
{
var blockTtl = TimeSpan.FromMinutes(1.0);
var bootstrapNode = StartCodex();
var geth = StartGethNode(s => s.IsMiner());
var contracts = Ci.StartCodexContracts(geth, bootstrapNode.Version);
var client = StartCodex(s => s
.WithBootstrapNode(bootstrapNode)
.EnableMarketplace(geth, contracts, m => m.WithInitial(100.Eth(), 100.Tst()))
.WithBlockTTL(blockTtl)
.WithBlockMaintenanceInterval(TimeSpan.FromSeconds(10.0))
.WithBlockMaintenanceNumber(100000)
);
var hosts = StartCodex(3, s => s
.WithBootstrapNode(bootstrapNode)
.EnableMarketplace(geth, contracts, m => m.AsStorageNode().WithInitial(100.Eth(), 100.Tst()))
.WithBlockTTL(blockTtl)
.WithBlockMaintenanceInterval(TimeSpan.FromSeconds(10.0))
.WithBlockMaintenanceNumber(100000)
);
foreach (var host in hosts) host.Marketplace.MakeStorageAvailable(new CodexClient.CreateStorageAvailability(
totalSpace: 2.GB(),
maxDuration: TimeSpan.FromDays(2.0),
minPricePerBytePerSecond: 1.TstWei(),
totalCollateral: 10.Tst()));
var uploadCid = client.UploadFile(GenerateTestFile(1.MB()));
var request = client.Marketplace.RequestStorage(new CodexClient.StoragePurchaseRequest(uploadCid)
{
CollateralPerByte = 1.TstWei(),
Duration = TimeSpan.FromDays(1.0),
Expiry = TimeSpan.FromHours(1.0),
MinRequiredNumberOfNodes = 3,
NodeFailureTolerance = 1,
PricePerBytePerSecond = 1.Tst(),
ProofProbability = 99999
});
request.WaitForStorageContractStarted();
var storeCid = request.ContentId;
client.Stop(waitTillStopped: true);
Thread.Sleep(blockTtl * 2.0);
var checker = StartCodex(s => s.WithBootstrapNode(bootstrapNode));
var manifest = checker.DownloadManifestOnly(storeCid);
Assert.That(manifest.Manifest.Protected, Is.True);
}
}
}