![]() |
VOOZH | about |
dotnet add package Nethereum.AppChain.Sync --version 6.1.0-preview
NuGet\Install-Package Nethereum.AppChain.Sync -Version 6.1.0-preview
<PackageReference Include="Nethereum.AppChain.Sync" Version="6.1.0-preview" />
<PackageVersion Include="Nethereum.AppChain.Sync" Version="6.1.0-preview" />Directory.Packages.props
<PackageReference Include="Nethereum.AppChain.Sync" />Project file
paket add Nethereum.AppChain.Sync --version 6.1.0-preview
#r "nuget: Nethereum.AppChain.Sync, 6.1.0-preview"
#:package Nethereum.AppChain.Sync@6.1.0-preview
#addin nuget:?package=Nethereum.AppChain.Sync&version=6.1.0-preview&prereleaseInstall as a Cake Addin
#tool nuget:?package=Nethereum.AppChain.Sync&version=6.1.0-preview&prereleaseInstall as a Cake Tool
PREVIEW — This package is in preview. APIs may change between releases.
Synchronisation services for follower nodes — enabling anyone to independently sync, verify, and read AppChain state.
A core promise of the AppChain model is that state is synchronisable by anyone. This package delivers on that promise: follower nodes catch up with the sequencer and maintain a verified copy of the chain state, with every block re-executed and every state root validated.
It implements a two-phase sync strategy: batch-based historical import from L1-anchored checkpoints followed by live block polling from peers. The package includes multi-peer management with automatic failover, state reconstruction through block re-execution, finality tracking (soft vs L1-finalized blocks), and coordinated sync that transitions seamlessly between batch and live phases.
dotnet add package Nethereum.AppChain.Sync
TransactionProcessor, IncrementalStateRootCalculator, storage interfacesPhase 1 (Batch Sync): Import pre-packaged block batches from anchored history. Batches are downloaded from the sequencer or mirror URLs, verified against their hash, and imported into local storage. This provides fast, finalized catch-up.
Phase 2 (Live Sync): Poll peers for new blocks as they are produced. MultiPeerSyncService follows the chain head with configurable poll intervals and automatic peer switching on failures.
Blocks have two finality levels:
The IFinalityTracker manages these states, enabling dApps to choose their safety guarantees.
BlockReExecutor optionally re-executes transactions during sync to reconstruct state locally. This validates that block state roots match headers and allows followers to serve state queries:
var reExecutor = new BlockReExecutor(
transactionProcessor, stateStore, chainConfig, stateRootCalculator);
PeerManager maintains a health-checked pool of sync peers with automatic selection of the best peer by block height and latency:
var peerManager = new PeerManager(config, clientFactory);
peerManager.AddPeer("http://sequencer:8546");
await peerManager.StartHealthCheckAsync();
var bestClient = await peerManager.GetHealthyClientAsync();
using Nethereum.AppChain.Sync;
var peerManager = new PeerManager(new PeerManagerConfig());
peerManager.AddPeer("http://sequencer:8546");
var syncConfig = new MultiPeerSyncConfig
{
PollIntervalMs = 100,
AutoFollow = true,
RejectOnStateRootMismatch = true
};
var syncService = new MultiPeerSyncService(syncConfig,
blockStore, txStore, receiptStore, logStore,
finalityTracker, peerManager, blockReExecutor);
await syncService.StartAsync();
using Nethereum.AppChain.Sync;
var syncService = new MultiPeerSyncService(
new MultiPeerSyncConfig { PollIntervalMs = 100, AutoFollow = true },
blockStore, txStore, receiptStore, logStore,
finalityTracker, peerManager, blockReExecutor);
syncService.BlockImported += (sender, args) =>
{
Console.WriteLine($"Block {args.Header.BlockNumber} imported");
};
syncService.Error += (sender, args) =>
{
Console.WriteLine($"Sync error: {args.Message}");
};
await syncService.StartAsync();
using Nethereum.AppChain.Sync;
var coordinated = new CoordinatedSyncService(
new CoordinatedSyncConfig { AutoStart = true },
batchSyncService, liveSyncService,
finalityTracker, anchorService, batchStore);
coordinated.SyncProgressChanged += (sender, args) =>
{
Console.WriteLine($"Phase: {args.Phase}, Block: {args.BlockNumber}");
};
coordinated.BatchFinalized += (sender, args) =>
{
Console.WriteLine($"Batch finalized up to block {args.ToBlock}");
};
await coordinated.StartAsync();
using Nethereum.AppChain.Sync;
var importer = new BatchImporter(blockStore, txStore, receiptStore, logStore);
var result = await importer.ImportBatchFromFileAsync(
filePath: "chain-420420-blocks-0-100.gz",
expectedHash: batchHash,
verificationMode: BatchVerificationMode.Full,
compressed: true);
Console.WriteLine($"Imported {result.BlockCount} blocks, {result.TransactionCount} transactions");
using Nethereum.AppChain.Sync;
var peerManager = new PeerManager(new PeerManagerConfig
{
HealthCheckIntervalMs = 5000,
HealthCheckTimeoutMs = 3000,
MaxFailuresBeforeRemoval = 5
});
peerManager.AddPeer("http://node1:8546");
peerManager.AddPeer("http://node2:8546");
peerManager.AddPeer("http://node3:8546");
peerManager.PeerStatusChanged += (sender, args) =>
{
Console.WriteLine($"Peer {args.Url}: healthy={args.IsHealthy}");
};
await peerManager.StartHealthCheckAsync();
var best = peerManager.GetBestPeer();
Real-time block following with multi-peer failover.
public class MultiPeerSyncService : ILiveBlockSync
{
public long LocalTip { get; }
public long RemoteTip { get; }
public LiveSyncState State { get; }
public Task StartAsync(CancellationToken ct = default);
public Task StopAsync();
public Task SyncToLatestAsync();
public Task SyncToBlockAsync(long blockNumber);
public event EventHandler<BlockImportedEventArgs>? BlockImported;
public event EventHandler<SyncErrorEventArgs>? Error;
}
Two-phase sync orchestration (batch then live).
public class CoordinatedSyncService
{
public Task StartAsync(CancellationToken ct = default);
public Task StopAsync();
public event EventHandler<SyncProgressEventArgs>? SyncProgressChanged;
public event EventHandler<BatchFinalizedEventArgs>? BatchFinalized;
}
Peer pool with health checking and best-peer selection.
public class PeerManager : IPeerManager
{
public void AddPeer(string url);
public void RemovePeer(string url);
public SyncPeer? GetBestPeer();
public Task<ISequencerRpcClient?> GetHealthyClientAsync();
public Task StartHealthCheckAsync(CancellationToken ct = default);
}
Block finality state management.
public interface IFinalityTracker
{
Task<bool> IsFinalizedAsync(long blockNumber);
Task<bool> IsSoftAsync(long blockNumber);
Task MarkAsFinalizedAsync(long blockNumber);
Task MarkRangeAsFinalizedAsync(long fromBlock, long toBlock);
Task<long> GetLatestFinalizedBlockAsync();
}
Batch metadata structure.
Key properties:
FromBlock / ToBlock - Block rangeBatchHash - Content hash for verificationStatus - Pending, Created, Written, Anchored, Verified, Imported, FailedToBlockStateRoot / ToBlockTxRoot / ToBlockReceiptRoot - Root hashes| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
Showing the top 1 NuGet packages that depend on Nethereum.AppChain.Sync:
| Package | Downloads |
|---|---|
|
Nethereum.AppChain.Sequencer
Nethereum AppChain Sequencer - Block production, transaction ordering, and consensus-driven sequencing for AppChain nodes |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 6.1.0-preview | 66 | 3/25/2026 |
| 6.0.4-preview | 70 | 3/18/2026 |
| 6.0.3-preview | 61 | 3/18/2026 |
| 6.0.1-preview | 66 | 3/17/2026 |
| 6.0.0-preview | 71 | 3/16/2026 |