Skip to content

Commit 30610b7

Browse files
committed
Updates to hardhat ignition
1 parent 52f6941 commit 30610b7

File tree

5 files changed

+68
-8
lines changed

5 files changed

+68
-8
lines changed

ProjectPlugins/CodexContractsPlugin/CodexContractsContainerRecipe.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace CodexContractsPlugin
77
{
88
public class CodexContractsContainerRecipe : ContainerRecipeFactory
99
{
10-
public const string MarketplaceAddressFilename = "/hardhat/deployments/codexdisttestnetwork/Marketplace.json";
10+
public const string DeployedAddressesFilename = "/hardhat/ignition/deployments/chain-789988/deployed_addresses.json";
1111
public const string MarketplaceArtifactFilename = "/hardhat/artifacts/contracts/Marketplace.sol/Marketplace.json";
1212
private readonly DebugInfoVersion versionInfo;
1313

ProjectPlugins/CodexContractsPlugin/CodexContractsStarter.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,16 @@ private CodexContractsDeployment DeployContract(RunningContainer container, ISta
7474

7575
var extractor = new ContractsContainerInfoExtractor(tools.GetLog(), workflow, container);
7676
var marketplaceAddress = extractor.ExtractMarketplaceAddress();
77+
if (string.IsNullOrEmpty(marketplaceAddress)) throw new Exception("Marketplace address not received.");
7778
var (abi, bytecode) = extractor.ExtractMarketplaceAbiAndByteCode();
79+
if (string.IsNullOrEmpty(abi)) throw new Exception("ABI not received.");
80+
if (string.IsNullOrEmpty(bytecode)) throw new Exception("bytecode not received.");
7881
EnsureCompatbility(abi, bytecode);
7982

8083
var interaction = new ContractInteractions(tools.GetLog(), gethNode);
8184
var tokenAddress = interaction.GetTokenAddress(marketplaceAddress);
85+
if (string.IsNullOrEmpty(tokenAddress)) throw new Exception("Token address not received.");
86+
Log("TokenAddress: " + tokenAddress);
8287

8388
Log("Extract completed. Checking sync...");
8489

ProjectPlugins/CodexContractsPlugin/ContractsContainerInfoExtractor.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public string ExtractMarketplaceAddress()
2727
var marketplaceAddress = Retry(FetchMarketplaceAddress);
2828
if (string.IsNullOrEmpty(marketplaceAddress)) throw new InvalidOperationException("Unable to fetch marketplace account from codex-contracts node. Test infra failure.");
2929

30-
log.Debug("Got MarketplaceAddress: " + marketplaceAddress);
30+
log.Log("MarketplaceAddress: " + marketplaceAddress);
3131
return marketplaceAddress;
3232
}
3333

@@ -43,9 +43,10 @@ public string ExtractMarketplaceAddress()
4343

4444
private string FetchMarketplaceAddress()
4545
{
46-
var json = workflow.ExecuteCommand(container, "cat", CodexContractsContainerRecipe.MarketplaceAddressFilename);
47-
var marketplace = JsonConvert.DeserializeObject<MarketplaceJson>(json);
48-
return marketplace!.address;
46+
var json = workflow.ExecuteCommand(container, "cat", CodexContractsContainerRecipe.DeployedAddressesFilename);
47+
json = json.Replace("#", "_");
48+
var addresses = JsonConvert.DeserializeObject<DeployedAddressesJson>(json);
49+
return addresses!.Marketplace_Marketplace;
4950
}
5051

5152
private (string, string) FetchMarketplaceAbiAndByteCode()
@@ -67,8 +68,10 @@ private static T Retry<T>(Func<T> fetch)
6768
}
6869
}
6970

70-
public class MarketplaceJson
71+
public class DeployedAddressesJson
7172
{
72-
public string address { get; set; } = string.Empty;
73+
public string Token_TestToken { get; set; } = string.Empty;
74+
public string Verifier_Groth16Verifier { get; set; } = string.Empty;
75+
public string Marketplace_Marketplace { get; set; } = string.Empty;
7376
}
7477
}

ProjectPlugins/CodexContractsPlugin/Marketplace/Marketplace.cs

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

Tests/CodexReleaseTests/DataTests/DataExpiryTest.cs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,5 +92,57 @@ public void DeletesExpiredDataUsedByStorageRequests()
9292
Assert.That(cleanupSpace.QuotaUsedBytes, Is.EqualTo(startSpace.QuotaUsedBytes));
9393
Assert.That(cleanupSpace.FreeBytes, Is.EqualTo(startSpace.FreeBytes));
9494
}
95+
96+
[Test]
97+
public void StorageRequestsKeepManifests()
98+
{
99+
var blockTtl = TimeSpan.FromMinutes(1.0);
100+
101+
var bootstrapNode = StartCodex();
102+
var geth = StartGethNode(s => s.IsMiner());
103+
var contracts = Ci.StartCodexContracts(geth, bootstrapNode.Version);
104+
var client = StartCodex(s => s
105+
.WithBootstrapNode(bootstrapNode)
106+
.EnableMarketplace(geth, contracts, m => m.WithInitial(100.Eth(), 100.Tst()))
107+
.WithBlockTTL(blockTtl)
108+
.WithBlockMaintenanceInterval(TimeSpan.FromSeconds(10.0))
109+
.WithBlockMaintenanceNumber(100000)
110+
);
111+
112+
var hosts = StartCodex(3, s => s
113+
.WithBootstrapNode(bootstrapNode)
114+
.EnableMarketplace(geth, contracts, m => m.AsStorageNode().WithInitial(100.Eth(), 100.Tst()))
115+
.WithBlockTTL(blockTtl)
116+
.WithBlockMaintenanceInterval(TimeSpan.FromSeconds(10.0))
117+
.WithBlockMaintenanceNumber(100000)
118+
);
119+
foreach (var host in hosts) host.Marketplace.MakeStorageAvailable(new CodexClient.CreateStorageAvailability(
120+
totalSpace: 2.GB(),
121+
maxDuration: TimeSpan.FromDays(2.0),
122+
minPricePerBytePerSecond: 1.TstWei(),
123+
totalCollateral: 10.Tst()));
124+
125+
var uploadCid = client.UploadFile(GenerateTestFile(1.MB()));
126+
var request = client.Marketplace.RequestStorage(new CodexClient.StoragePurchaseRequest(uploadCid)
127+
{
128+
CollateralPerByte = 1.TstWei(),
129+
Duration = TimeSpan.FromDays(1.0),
130+
Expiry = TimeSpan.FromHours(1.0),
131+
MinRequiredNumberOfNodes = 3,
132+
NodeFailureTolerance = 1,
133+
PricePerBytePerSecond = 1.Tst(),
134+
ProofProbability = 99999
135+
});
136+
request.WaitForStorageContractStarted();
137+
var storeCid = request.ContentId;
138+
139+
client.Stop(waitTillStopped: true);
140+
141+
Thread.Sleep(blockTtl * 2.0);
142+
143+
var checker = StartCodex(s => s.WithBootstrapNode(bootstrapNode));
144+
var manifest = checker.DownloadManifestOnly(storeCid);
145+
Assert.That(manifest.Manifest.Protected, Is.True);
146+
}
95147
}
96148
}

0 commit comments

Comments
 (0)