Merge branch 'master' into feature/multi-codex-folder-saver

This commit is contained in:
ThatBen 2025-06-09 10:14:39 +02:00
commit ccd6dc6e51
No known key found for this signature in database
GPG Key ID: 62C543548433D43E
15 changed files with 118 additions and 20 deletions

View File

@ -66,7 +66,7 @@ namespace CodexClient
public class Manifest
{
public string RootHash { get; set; } = string.Empty;
public ByteSize OriginalBytes { get; set; } = ByteSize.Zero;
public ByteSize DatasetSize { get; set; } = ByteSize.Zero;
public ByteSize BlockSize { get; set; } = ByteSize.Zero;
public bool Protected { get; set; }
}

View File

@ -208,7 +208,7 @@ namespace CodexClient
return new Manifest
{
BlockSize = new ByteSize(Convert.ToInt64(manifest.BlockSize)),
OriginalBytes = new ByteSize(Convert.ToInt64(manifest.DatasetSize)),
DatasetSize = new ByteSize(Convert.ToInt64(manifest.DatasetSize)),
RootHash = manifest.TreeCid,
Protected = manifest.Protected
};

View File

@ -96,8 +96,23 @@ namespace CodexContractsPlugin.Marketplace
public partial class MarketplaceConfig : IMarketplaceConfigInput
{
public int MaxNumberOfSlashes => this.Collateral.MaxNumberOfSlashes;
public TimeSpan PeriodDuration => TimeSpan.FromSeconds(this.Proofs.Period);
public int MaxNumberOfSlashes
{
get
{
if (Collateral == null) return -1;
return Collateral.MaxNumberOfSlashes;
}
}
public TimeSpan PeriodDuration
{
get
{
if (Proofs == null) return TimeSpan.MinValue;
return TimeSpan.FromSeconds(this.Proofs.Period);
}
}
}
}
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.

View File

@ -33,9 +33,9 @@ namespace CodexReleaseTests.DataTests
var local2 = localFiles.Content.Single(f => f.Cid == cid2);
Assert.That(local1.Manifest.Protected, Is.False);
Assert.That(local1.Manifest.OriginalBytes, Is.EqualTo(size1));
Assert.That(local1.Manifest.DatasetSize, Is.EqualTo(size1));
Assert.That(local2.Manifest.Protected, Is.False);
Assert.That(local2.Manifest.OriginalBytes, Is.EqualTo(size2));
Assert.That(local2.Manifest.DatasetSize, Is.EqualTo(size2));
}
}
}

View File

@ -27,7 +27,7 @@ namespace CodexReleaseTests.DataTests
Assert.That(spaceDiff, Is.LessThan(64.KB().SizeInBytes));
Assert.That(localDataset.Cid, Is.EqualTo(cid));
Assert.That(localDataset.Manifest.OriginalBytes.SizeInBytes, Is.EqualTo(file.GetFilesize().SizeInBytes));
Assert.That(localDataset.Manifest.DatasetSize.SizeInBytes, Is.EqualTo(file.GetFilesize().SizeInBytes));
}
}
}

View File

@ -22,7 +22,7 @@ namespace CodexReleaseTests.DataTests
var localDataset = downloader.DownloadStreamlessWait(cid, size);
Assert.That(localDataset.Cid, Is.EqualTo(cid));
Assert.That(localDataset.Manifest.OriginalBytes.SizeInBytes, Is.EqualTo(file.GetFilesize().SizeInBytes));
Assert.That(localDataset.Manifest.DatasetSize.SizeInBytes, Is.EqualTo(file.GetFilesize().SizeInBytes));
// Stop the uploader node and verify that the downloader has the data.
uploader.Stop(waitTillStopped: true);

View File

@ -21,7 +21,7 @@ namespace CodexReleaseTests.MarketTests
[Test]
[Combinatorial]
public void Fail(
[Values([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16])] int rerun
[Rerun] int rerun
)
{
var hosts = StartHosts();

View File

@ -22,12 +22,12 @@ namespace CodexReleaseTests.MarketTests
protected override int NumberOfHosts => hosts;
protected override int NumberOfClients => 1;
protected override ByteSize HostAvailabilitySize => purchaseParams.SlotSize.Multiply(5.1);
protected override TimeSpan HostAvailabilityMaxDuration => Get8TimesConfiguredPeriodDuration() * 12;
protected override TimeSpan HostAvailabilityMaxDuration => GetContractDuration() * 2;
[Test]
[Combinatorial]
public void Finish(
[Values([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16])] int rerun
[Rerun] int rerun
)
{
var hosts = StartHosts();

View File

@ -0,0 +1,72 @@
using CodexClient;
using CodexReleaseTests.Utils;
using NUnit.Framework;
using Utils;
namespace CodexReleaseTests.MarketTests
{
public class MaxCapacityTest : MarketplaceAutoBootstrapDistTest
{
private readonly TestToken pricePerBytePerSecond = 10.TstWei();
private readonly PurchaseParams purchaseParams = new PurchaseParams(
nodes: 10,
tolerance: 5,
uploadFilesize: 10.MB()
);
protected override int NumberOfHosts => purchaseParams.Nodes / 2;
protected override int NumberOfClients => 1;
protected override ByteSize HostAvailabilitySize => purchaseParams.SlotSize.Multiply(2.1);
protected override TimeSpan HostAvailabilityMaxDuration => GetContractDuration() * 2;
[Test]
[Combinatorial]
public void TwoSlotsEach(
[Rerun] int rerun
)
{
var hosts = StartHosts();
var client = StartClients().Single();
AssertHostAvailabilitiesAreEmpty(hosts);
var request = CreateStorageRequest(client);
request.WaitForStorageContractSubmitted();
AssertContractIsOnChain(request);
WaitForContractStarted(request);
AssertContractSlotsAreFilledByHosts(request, hosts);
}
private IStoragePurchaseContract CreateStorageRequest(ICodexNode client)
{
var cid = client.UploadFile(GenerateTestFile(purchaseParams.UploadFilesize));
var config = GetContracts().Deployment.Config;
return client.Marketplace.RequestStorage(new StoragePurchaseRequest(cid)
{
Duration = GetContractDuration(),
Expiry = GetContractExpiry(),
MinRequiredNumberOfNodes = (uint)purchaseParams.Nodes,
NodeFailureTolerance = (uint)purchaseParams.Tolerance,
PricePerBytePerSecond = pricePerBytePerSecond,
ProofProbability = 20,
CollateralPerByte = 100.TstWei()
});
}
private TimeSpan GetContractExpiry()
{
return GetContractDuration() / 2;
}
private TimeSpan GetContractDuration()
{
return Get8TimesConfiguredPeriodDuration();
}
private TimeSpan Get8TimesConfiguredPeriodDuration()
{
return GetPeriodDuration() * 8.0;
}
}
}

View File

@ -34,7 +34,7 @@ namespace CodexReleaseTests.MarketTests
[Test]
[Combinatorial]
public void RollingRepairSingleFailure(
[Values([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16])] int rerun,
[Rerun] int rerun,
[Values(10)] int numFailures)
{
var hosts = StartHosts().ToList();

View File

@ -21,7 +21,7 @@ namespace CodexReleaseTests.MarketTests
protected override int NumberOfHosts => hosts;
protected override int NumberOfClients => 6;
protected override ByteSize HostAvailabilitySize => purchaseParams.SlotSize.Multiply(100.0);
protected override TimeSpan HostAvailabilityMaxDuration => Get8TimesConfiguredPeriodDuration() * 12;
protected override TimeSpan HostAvailabilityMaxDuration => GetContractDuration() * 2;
private readonly TestToken pricePerBytePerSecond = 10.TstWei();
[Test]

View File

@ -23,7 +23,7 @@ namespace CodexReleaseTests.MarketTests
[Test]
[Combinatorial]
public void Start(
[Values([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16])] int rerun
[Rerun] int rerun
)
{
var hosts = StartHosts();

View File

@ -0,0 +1,16 @@
using NUnit.Framework;
namespace CodexReleaseTests
{
public class RerunAttribute : ValuesAttribute
{
private const int NumberOfReRuns = 8;
public RerunAttribute()
{
var list = new List<object>();
for (var i = 0; i < NumberOfReRuns; i++) list.Add(i);
data = list.ToArray();
}
}
}

View File

@ -163,7 +163,7 @@ namespace BiblioTech.CodexChecking
private bool IsManifestLengthCompatible(ICheckResponseHandler handler, TransferCheck check, Manifest manifest)
{
var dataLength = check.UniqueData.Length;
var manifestLength = manifest.OriginalBytes.SizeInBytes;
var manifestLength = manifest.DatasetSize.SizeInBytes;
Log($"Checking manifest length: dataLength={dataLength},manifestLength={manifestLength}");

View File

@ -86,11 +86,6 @@ namespace TraceContract
Add(requestEvent.Block.Utc, $"Slot reservations full. Index: {slotIndex}");
}
public void LogReserveSlotCalls(ReserveSlotFunction[] reserveSlotFunctions)
{
foreach (var call in reserveSlotFunctions) LogReserveSlotCall(call);
}
public void WriteContractEvents()
{
var sorted = entries.OrderBy(e => e.Utc).ToArray();