From 12350133c3af0e79e4c7bf87ff43657c0e446f08 Mon Sep 17 00:00:00 2001 From: MacOMNI <414294494@qq.com> Date: Mon, 7 Apr 2025 15:43:05 +0800 Subject: [PATCH 01/54] update Work-report distribution --- .../NetworkingProtocol/NetworkManager.swift | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/Node/Sources/Node/NetworkingProtocol/NetworkManager.swift b/Node/Sources/Node/NetworkingProtocol/NetworkManager.swift index abc341c5..543fbc96 100644 --- a/Node/Sources/Node/NetworkingProtocol/NetworkManager.swift +++ b/Node/Sources/Node/NetworkingProtocol/NetworkManager.swift @@ -112,6 +112,13 @@ public final class NetworkManager: Sendable { ) { [weak self] event in await self?.on(beforeEpochChange: event) } + + await subscriptions.subscribe( + RuntimeEvents.WorkReportGenerated.self, + id: "NetworkManager.WorkReportGenerated" + ) { [weak self] event in + await self?.on(workReportGenerated: event) + } } } @@ -263,6 +270,21 @@ public final class NetworkManager: Sendable { } } + private func on(workReportGenerated event: RuntimeEvents.WorkReportGenerated) async { + logger.trace("sending guaranteed work-report", + metadata: ["slot": "\(event.slot)", + "signatures": "\(event.signatures.count)"]) + + await broadcast( + to: .currentValidators, + message: .workReportDistrubution(.init( + workReport: event.workReport, + slot: event.slot, + signatures: event.signatures + )) + ) + } + public var peersCount: Int { network.peersCount } @@ -312,7 +334,7 @@ struct HandlerImpl: NetworkProtocolHandler { } return [encoder.data] case let .stateRequest(message): - try blockchain + blockchain .publish( event: RuntimeEvents .StateRequestReceived( From b94eaa1ca0cff394bf2edd9474fee773143955b3 Mon Sep 17 00:00:00 2001 From: MacOMNI <414294494@qq.com> Date: Mon, 7 Apr 2025 16:24:00 +0800 Subject: [PATCH 02/54] update workReportRequest --- .../Node/NetworkingProtocol/NetworkManager.swift | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Node/Sources/Node/NetworkingProtocol/NetworkManager.swift b/Node/Sources/Node/NetworkingProtocol/NetworkManager.swift index 543fbc96..58b42326 100644 --- a/Node/Sources/Node/NetworkingProtocol/NetworkManager.swift +++ b/Node/Sources/Node/NetworkingProtocol/NetworkManager.swift @@ -410,11 +410,15 @@ struct HandlerImpl: NetworkProtocolHandler { return [] case let .workReportRequest(message): blockchain.publish(event: RuntimeEvents.WorkReportRequestReceived(workReportHash: message.workReportHash)) - // TODO: waitfor WorkReportRequestResponse - // let resp = try await blockchain.waitFor(RuntimeEvents.WorkReportRequestResponse.self) { event in - // message.workReportHash == event.workReport.hash() - // } - return [] + let resp = try await blockchain.waitFor(RuntimeEvents.WorkReportRequestResponse.self) { event in + message.workReportHash == event.workReportHash + } + switch resp.result { + case let .success(workReport): + return try [JamEncoder.encode(workReport)] + case let .failure(error): + throw error + } case let .shardDistribution(message): blockchain .publish(event: RuntimeEvents.ShardDistributionReceived(erasureRoot: message.erasureRoot, shardIndex: message.shardIndex)) From daa2f98e7134e563ad3090777228c8093b596f19 Mon Sep 17 00:00:00 2001 From: MacOMNI <414294494@qq.com> Date: Tue, 8 Apr 2025 10:50:36 +0800 Subject: [PATCH 03/54] update WorkReportRef --- .../Blockchain/Types/WorkReportRef.swift | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 Blockchain/Sources/Blockchain/Types/WorkReportRef.swift diff --git a/Blockchain/Sources/Blockchain/Types/WorkReportRef.swift b/Blockchain/Sources/Blockchain/Types/WorkReportRef.swift new file mode 100644 index 00000000..0d2e1067 --- /dev/null +++ b/Blockchain/Sources/Blockchain/Types/WorkReportRef.swift @@ -0,0 +1,70 @@ +import Codec +import Foundation +import Utils + +public final class WorkReportRef: RefWithHash, @unchecked Sendable { + public var packageSpecification: AvailabilitySpecifications { value.packageSpecification } + public var refinementContext: RefinementContext { value.refinementContext } + public var coreIndex: CoreIndex { value.coreIndex } + public var authorizerHash: Data32 { value.authorizerHash } + public var authorizationOutput: Data { value.authorizationOutput } + public var lookup: [Data32: Data32] { value.lookup } + public var results: ConfigLimitedSizeArray { value.results } + public var authGasUsed: UInt { value.authGasUsed } + + public convenience init( + authorizerHash: Data32, + coreIndex: CoreIndex, + authorizationOutput: Data, + refinementContext: RefinementContext, + packageSpecification: AvailabilitySpecifications, + lookup: [Data32: Data32], + results: ConfigLimitedSizeArray, + authGasUsed: UInt + ) { + self.init(WorkReport( + authorizerHash: authorizerHash, + coreIndex: coreIndex, + authorizationOutput: authorizationOutput, + refinementContext: refinementContext, + packageSpecification: packageSpecification, + lookup: lookup, + results: results, + authGasUsed: authGasUsed + )) + } +} + +extension WorkReportRef: Codable { + public convenience init(from decoder: Decoder) throws { + try self.init(WorkReport(from: decoder)) + } + + public func encode(to encoder: Encoder) throws { + try value.encode(to: encoder) + } +} + +extension WorkReportRef { + public func validate(config: ProtocolConfigRef) throws { + try value.validate(config: config) + } +} + +extension WorkReportRef { + public static func dummy(config: ProtocolConfigRef) -> WorkReportRef { + WorkReportRef( + authorizerHash: Data32(), + coreIndex: 0, + authorizationOutput: Data(), + refinementContext: RefinementContext.dummy(config: config), + packageSpecification: AvailabilitySpecifications.dummy(config: config), + lookup: [:], + results: try! ConfigLimitedSizeArray( + config: config, + defaultValue: WorkResult.dummy(config: config) + ), + authGasUsed: 0 + ) + } +} From 3a55564ad2e930af55d198fb44fc22ae2768fe27 Mon Sep 17 00:00:00 2001 From: MacOMNI <414294494@qq.com> Date: Tue, 8 Apr 2025 10:50:56 +0800 Subject: [PATCH 04/54] update blockchain From c61f8106ce050adf0e6f533ad180c9c232300068 Mon Sep 17 00:00:00 2001 From: MacOMNI <414294494@qq.com> Date: Tue, 8 Apr 2025 16:16:19 +0800 Subject: [PATCH 05/54] update workreport --- .../BlockchainDataProvider.swift | 4 ++ .../BlockchainDataProviderProtocol.swift | 6 ++- .../Blockchain/Types/WorkReportRef.swift | 40 ++++--------------- 3 files changed, 16 insertions(+), 34 deletions(-) diff --git a/Blockchain/Sources/Blockchain/BlockchainDataProvider/BlockchainDataProvider.swift b/Blockchain/Sources/Blockchain/BlockchainDataProvider/BlockchainDataProvider.swift index f186abd1..8c25f34b 100644 --- a/Blockchain/Sources/Blockchain/BlockchainDataProvider/BlockchainDataProvider.swift +++ b/Blockchain/Sources/Blockchain/BlockchainDataProvider/BlockchainDataProvider.swift @@ -58,6 +58,10 @@ public actor BlockchainDataProvider { } extension BlockchainDataProvider { +// public func hasWorkReport(hash: Data32) async throws -> Bool { +// try await dataProvider.hasWorkReport(hash: hash) +// } + public func hasBlock(hash: Data32) async throws -> Bool { try await dataProvider.hasBlock(hash: hash) } diff --git a/Blockchain/Sources/Blockchain/BlockchainDataProvider/BlockchainDataProviderProtocol.swift b/Blockchain/Sources/Blockchain/BlockchainDataProvider/BlockchainDataProviderProtocol.swift index 8c8ac352..7605621c 100644 --- a/Blockchain/Sources/Blockchain/BlockchainDataProvider/BlockchainDataProviderProtocol.swift +++ b/Blockchain/Sources/Blockchain/BlockchainDataProvider/BlockchainDataProviderProtocol.swift @@ -1,6 +1,7 @@ import Utils public protocol BlockchainDataProviderProtocol: Sendable { +// func hasWorkReport(hash: Data32) async throws -> Bool func hasBlock(hash: Data32) async throws -> Bool func hasState(hash: Data32) async throws -> Bool func isHead(hash: Data32) async throws -> Bool @@ -9,6 +10,8 @@ public protocol BlockchainDataProviderProtocol: Sendable { func getHeader(hash: Data32) async throws -> HeaderRef? +// func getWorkReport(hash: Data32) async throws -> WorkReportRef? + func getBlock(hash: Data32) async throws -> BlockRef? func getState(hash: Data32) async throws -> StateRef? @@ -26,6 +29,7 @@ public protocol BlockchainDataProviderProtocol: Sendable { /// return empty set if not found func getBlockHash(byNumber number: UInt32) async throws -> Set +// func addWorkReport(workReport: WorkReportRef) async throws func add(block: BlockRef) async throws func add(state: StateRef) async throws func setFinalizedHead(hash: Data32) async throws @@ -33,7 +37,7 @@ public protocol BlockchainDataProviderProtocol: Sendable { /// throw BlockchainDataProviderError.noData if parent is not a head func updateHead(hash: Data32, parent: Data32) async throws - /// remove header, block and state + /// remove header, block, workReport, state func remove(hash: Data32) async throws var genesisBlockHash: Data32 { get } diff --git a/Blockchain/Sources/Blockchain/Types/WorkReportRef.swift b/Blockchain/Sources/Blockchain/Types/WorkReportRef.swift index 0d2e1067..5a452384 100644 --- a/Blockchain/Sources/Blockchain/Types/WorkReportRef.swift +++ b/Blockchain/Sources/Blockchain/Types/WorkReportRef.swift @@ -12,26 +12,12 @@ public final class WorkReportRef: RefWithHash, @unchecked Sendable { public var results: ConfigLimitedSizeArray { value.results } public var authGasUsed: UInt { value.authGasUsed } - public convenience init( - authorizerHash: Data32, - coreIndex: CoreIndex, - authorizationOutput: Data, - refinementContext: RefinementContext, - packageSpecification: AvailabilitySpecifications, - lookup: [Data32: Data32], - results: ConfigLimitedSizeArray, - authGasUsed: UInt - ) { - self.init(WorkReport( - authorizerHash: authorizerHash, - coreIndex: coreIndex, - authorizationOutput: authorizationOutput, - refinementContext: refinementContext, - packageSpecification: packageSpecification, - lookup: lookup, - results: results, - authGasUsed: authGasUsed - )) + override public var description: String { + "WorkReportRef(hash: \(hash), core: \(coreIndex), results: \(results.count), gas: \(authGasUsed))" + } + + public required init(_ workReport: WorkReport) { + super.init(workReport) } } @@ -53,18 +39,6 @@ extension WorkReportRef { extension WorkReportRef { public static func dummy(config: ProtocolConfigRef) -> WorkReportRef { - WorkReportRef( - authorizerHash: Data32(), - coreIndex: 0, - authorizationOutput: Data(), - refinementContext: RefinementContext.dummy(config: config), - packageSpecification: AvailabilitySpecifications.dummy(config: config), - lookup: [:], - results: try! ConfigLimitedSizeArray( - config: config, - defaultValue: WorkResult.dummy(config: config) - ), - authGasUsed: 0 - ) + WorkReportRef(WorkReport.dummy(config: config)) } } From abf31c4405eb224630182a0a43d3799dd41a06b0 Mon Sep 17 00:00:00 2001 From: MacOMNI <414294494@qq.com> Date: Wed, 9 Apr 2025 07:24:56 +0800 Subject: [PATCH 06/54] update swift testing --- Blockchain/Package.resolved | 12 ++++++------ Blockchain/Package.swift | 2 +- Boka/Package.swift | 2 +- Codec/Package.swift | 2 +- Database/Package.swift | 2 +- JAMTests/Package.swift | 2 +- Networking/Package.swift | 2 +- Node/Package.swift | 2 +- PolkaVM/Package.swift | 2 +- RPC/Package.swift | 2 +- Utils/Package.resolved | 12 ++++++------ Utils/Package.swift | 2 +- 12 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Blockchain/Package.resolved b/Blockchain/Package.resolved index fdd3bd60..1f3e32fb 100644 --- a/Blockchain/Package.resolved +++ b/Blockchain/Package.resolved @@ -1,5 +1,5 @@ { - "originHash" : "72d6aa1fce2803c836be5d4b1c239fb67e531e7ed4619f96c34745064c756ba8", + "originHash" : "e78fa0f1a342325c4024ac6414e4b9953a8da0561286b04d5e06c8c2b092aaa4", "pins" : [ { "identity" : "blake2.swift", @@ -76,10 +76,10 @@ { "identity" : "swift-syntax", "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-syntax.git", + "location" : "https://github.com/swiftlang/swift-syntax.git", "state" : { - "revision" : "4c6cc0a3b9e8f14b3ae2307c5ccae4de6167ac2c", - "version" : "600.0.0-prerelease-2024-06-12" + "revision" : "f99ae8aa18f0cf0d53481901f88a0991dc3bd4a2", + "version" : "601.0.1" } }, { @@ -87,8 +87,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-testing.git", "state" : { - "branch" : "0.10.0", - "revision" : "69d59cfc76e5daf498ca61f5af409f594768eef9" + "branch" : "6.1", + "revision" : "43b6f88e2f2712e0f2a97e6acc75b55f22234299" } } ], diff --git a/Blockchain/Package.swift b/Blockchain/Package.swift index 9f02304c..a5d3344b 100644 --- a/Blockchain/Package.swift +++ b/Blockchain/Package.swift @@ -20,7 +20,7 @@ let package = Package( .package(path: "../Utils"), .package(path: "../TracingUtils"), .package(path: "../PolkaVM"), - .package(url: "https://github.com/apple/swift-testing.git", branch: "0.10.0"), + .package(url: "https://github.com/apple/swift-testing.git", branch: "6.1"), ], targets: [ // Targets are the basic building blocks of a package, defining a module or a test suite. diff --git a/Boka/Package.swift b/Boka/Package.swift index 35a89f20..e46b3cc0 100644 --- a/Boka/Package.swift +++ b/Boka/Package.swift @@ -14,7 +14,7 @@ let package = Package( .package(url: "https://github.com/slashmo/swift-otel.git", from: "0.9.0"), .package(url: "https://github.com/swift-server/swift-service-lifecycle.git", from: "2.6.0"), .package(url: "https://github.com/vapor/console-kit.git", from: "4.15.0"), - .package(url: "https://github.com/apple/swift-testing.git", branch: "0.10.0"), + .package(url: "https://github.com/apple/swift-testing.git", branch: "6.1"), .package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.5.0"), ], targets: [ diff --git a/Codec/Package.swift b/Codec/Package.swift index c8cf459c..8ed78eca 100644 --- a/Codec/Package.swift +++ b/Codec/Package.swift @@ -16,7 +16,7 @@ let package = Package( ), ], dependencies: [ - .package(url: "https://github.com/apple/swift-testing.git", branch: "0.10.0"), + .package(url: "https://github.com/apple/swift-testing.git", branch: "6.1"), ], targets: [ // Targets are the basic building blocks of a package, defining a module or a test suite. diff --git a/Database/Package.swift b/Database/Package.swift index e820ad24..f549c362 100644 --- a/Database/Package.swift +++ b/Database/Package.swift @@ -19,7 +19,7 @@ let package = Package( .package(path: "../Blockchain"), .package(path: "../Codec"), .package(path: "../Utils"), - .package(url: "https://github.com/apple/swift-testing.git", branch: "0.10.0"), + .package(url: "https://github.com/apple/swift-testing.git", branch: "6.1"), ], targets: [ .target( diff --git a/JAMTests/Package.swift b/JAMTests/Package.swift index 99e636a5..3b74fb72 100644 --- a/JAMTests/Package.swift +++ b/JAMTests/Package.swift @@ -21,7 +21,7 @@ let package = Package( .package(path: "../TracingUtils"), .package(path: "../Blockchain"), .package(path: "../PolkaVM"), - .package(url: "https://github.com/apple/swift-testing.git", branch: "0.10.0"), + .package(url: "https://github.com/apple/swift-testing.git", branch: "6.1"), ], targets: [ // Targets are the basic building blocks of a package, defining a module or a test suite. diff --git a/Networking/Package.swift b/Networking/Package.swift index ee9b929a..aa4e2679 100644 --- a/Networking/Package.swift +++ b/Networking/Package.swift @@ -19,7 +19,7 @@ let package = Package( .package(path: "../Utils"), .package(url: "https://github.com/apple/swift-log.git", from: "1.6.0"), .package(url: "https://github.com/apple/swift-certificates.git", from: "1.5.0"), - .package(url: "https://github.com/apple/swift-testing.git", branch: "0.10.0"), + .package(url: "https://github.com/apple/swift-testing.git", branch: "6.1"), .package(url: "https://github.com/gh123man/Async-Channels.git", from: "1.0.2"), ], targets: [ diff --git a/Node/Package.swift b/Node/Package.swift index a7a3e4d7..753b8355 100644 --- a/Node/Package.swift +++ b/Node/Package.swift @@ -22,7 +22,7 @@ let package = Package( .package(path: "../TracingUtils"), .package(path: "../Utils"), .package(path: "../Database"), - .package(url: "https://github.com/apple/swift-testing.git", branch: "0.10.0"), + .package(url: "https://github.com/apple/swift-testing.git", branch: "6.1"), .package(url: "https://github.com/gh123man/Async-Channels.git", from: "1.0.2"), ], targets: [ diff --git a/PolkaVM/Package.swift b/PolkaVM/Package.swift index 88e789e1..aaf50561 100644 --- a/PolkaVM/Package.swift +++ b/PolkaVM/Package.swift @@ -17,7 +17,7 @@ let package = Package( dependencies: [ .package(path: "../Utils"), .package(path: "../TracingUtils"), - .package(url: "https://github.com/apple/swift-testing.git", branch: "0.10.0"), + .package(url: "https://github.com/apple/swift-testing.git", branch: "6.1"), .package(url: "https://github.com/apple/swift-log.git", from: "1.6.0"), .package(url: "https://github.com/nicklockwood/LRUCache.git", from: "1.0.7"), ], diff --git a/RPC/Package.swift b/RPC/Package.swift index bebdb1c7..6176b3f1 100644 --- a/RPC/Package.swift +++ b/RPC/Package.swift @@ -20,7 +20,7 @@ let package = Package( .package(path: "../Utils"), .package(url: "https://github.com/vapor/vapor.git", from: "4.106.0"), .package(url: "https://github.com/vapor/async-kit.git", from: "1.20.0"), - .package(url: "https://github.com/apple/swift-testing.git", branch: "0.10.0"), + .package(url: "https://github.com/apple/swift-testing.git", branch: "6.1"), ], targets: [ diff --git a/Utils/Package.resolved b/Utils/Package.resolved index 8c7162ca..d1be45e0 100644 --- a/Utils/Package.resolved +++ b/Utils/Package.resolved @@ -1,5 +1,5 @@ { - "originHash" : "3af4fa15534a1d00e66459fc585003c2f7835023bebcf2a960f70e34d14438b2", + "originHash" : "58cf105575b46ad7fba6c2a1e8924751af596842a801a9c8d41493126bb7ca1a", "pins" : [ { "identity" : "blake2.swift", @@ -67,10 +67,10 @@ { "identity" : "swift-syntax", "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-syntax.git", + "location" : "https://github.com/swiftlang/swift-syntax.git", "state" : { - "revision" : "4c6cc0a3b9e8f14b3ae2307c5ccae4de6167ac2c", - "version" : "600.0.0-prerelease-2024-06-12" + "revision" : "f99ae8aa18f0cf0d53481901f88a0991dc3bd4a2", + "version" : "601.0.1" } }, { @@ -78,8 +78,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-testing.git", "state" : { - "branch" : "0.10.0", - "revision" : "69d59cfc76e5daf498ca61f5af409f594768eef9" + "branch" : "6.1", + "revision" : "43b6f88e2f2712e0f2a97e6acc75b55f22234299" } } ], diff --git a/Utils/Package.swift b/Utils/Package.swift index 17386e22..2179554b 100644 --- a/Utils/Package.swift +++ b/Utils/Package.swift @@ -20,7 +20,7 @@ let package = Package( .package(path: "../TracingUtils"), .package(url: "https://github.com/tesseract-one/Blake2.swift.git", from: "0.2.0"), .package(url: "https://github.com/apple/swift-crypto.git", "1.0.0" ..< "4.0.0"), - .package(url: "https://github.com/apple/swift-testing.git", branch: "0.10.0"), + .package(url: "https://github.com/apple/swift-testing.git", branch: "6.1"), .package(url: "https://github.com/apple/swift-numerics.git", branch: "main"), ], targets: [ From 64e90d0b019bb60dcbf5fc1bbbccac0fd8a03682 Mon Sep 17 00:00:00 2001 From: MacOMNI <414294494@qq.com> Date: Wed, 9 Apr 2025 07:27:25 +0800 Subject: [PATCH 07/54] update package --- RPC/Package.resolved | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/RPC/Package.resolved b/RPC/Package.resolved index 6a32554f..ee23644d 100644 --- a/RPC/Package.resolved +++ b/RPC/Package.resolved @@ -1,5 +1,5 @@ { - "originHash" : "0eb45f2fc8fa9cfa864623c83d1048088ec88a1e8a0d9e55289c5970e6ea29bd", + "originHash" : "85ab166a80e0358079b74f7774716a68fd1213f7890849b330819d067322c3e3", "pins" : [ { "identity" : "async-http-client", @@ -202,10 +202,10 @@ { "identity" : "swift-syntax", "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-syntax.git", + "location" : "https://github.com/swiftlang/swift-syntax.git", "state" : { - "revision" : "0687f71944021d616d34d922343dcef086855920", - "version" : "600.0.1" + "revision" : "f99ae8aa18f0cf0d53481901f88a0991dc3bd4a2", + "version" : "601.0.1" } }, { @@ -222,8 +222,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-testing.git", "state" : { - "branch" : "0.10.0", - "revision" : "69d59cfc76e5daf498ca61f5af409f594768eef9" + "branch" : "6.1", + "revision" : "43b6f88e2f2712e0f2a97e6acc75b55f22234299" } }, { From 8f2ed97fed68f3d88a3910ca06e6636c4051bceb Mon Sep 17 00:00:00 2001 From: MacOMNI <414294494@qq.com> Date: Wed, 9 Apr 2025 10:01:47 +0800 Subject: [PATCH 08/54] fix xcode udpate issues --- Blockchain/Package.resolved | 10 +- Blockchain/Package.swift | 2 +- Boka/Package.resolved | 339 ------------------ Boka/Package.swift | 2 +- Codec/Package.resolved | 24 -- Codec/Package.swift | 2 +- Database/Package.resolved | 105 ------ Database/Package.swift | 2 +- JAMTests/Package.resolved | 96 ----- JAMTests/Package.swift | 2 +- Networking/Package.swift | 2 +- Node/Package.resolved | 276 -------------- Node/Package.swift | 2 +- .../NetworkingProtocol/NetworkManager.swift | 19 +- PolkaVM/Package.resolved | 96 ----- PolkaVM/Package.swift | 2 +- RPC/Package.resolved | 249 ------------- RPC/Package.swift | 4 +- Tools/Package.swift | 2 +- Utils/Package.resolved | 10 +- Utils/Package.swift | 2 +- .../xcshareddata/swiftpm/Package.resolved | 59 +-- 22 files changed, 66 insertions(+), 1241 deletions(-) delete mode 100644 Boka/Package.resolved delete mode 100644 Codec/Package.resolved delete mode 100644 Database/Package.resolved delete mode 100644 JAMTests/Package.resolved delete mode 100644 Node/Package.resolved delete mode 100644 PolkaVM/Package.resolved delete mode 100644 RPC/Package.resolved diff --git a/Blockchain/Package.resolved b/Blockchain/Package.resolved index 1f3e32fb..d93d6f5d 100644 --- a/Blockchain/Package.resolved +++ b/Blockchain/Package.resolved @@ -1,5 +1,5 @@ { - "originHash" : "e78fa0f1a342325c4024ac6414e4b9953a8da0561286b04d5e06c8c2b092aaa4", + "originHash" : "653eff92c0b101b13d9ec17170dd383380bf31cf51922af0915e8046af171eb5", "pins" : [ { "identity" : "blake2.swift", @@ -78,8 +78,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/swiftlang/swift-syntax.git", "state" : { - "revision" : "f99ae8aa18f0cf0d53481901f88a0991dc3bd4a2", - "version" : "601.0.1" + "revision" : "0687f71944021d616d34d922343dcef086855920", + "version" : "600.0.1" } }, { @@ -87,8 +87,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-testing.git", "state" : { - "branch" : "6.1", - "revision" : "43b6f88e2f2712e0f2a97e6acc75b55f22234299" + "branch" : "6.0.3", + "revision" : "18c42c19cac3fafd61cab1156d4088664b7424ae" } } ], diff --git a/Blockchain/Package.swift b/Blockchain/Package.swift index a5d3344b..ee2f2f52 100644 --- a/Blockchain/Package.swift +++ b/Blockchain/Package.swift @@ -20,7 +20,7 @@ let package = Package( .package(path: "../Utils"), .package(path: "../TracingUtils"), .package(path: "../PolkaVM"), - .package(url: "https://github.com/apple/swift-testing.git", branch: "6.1"), + .package(url: "https://github.com/apple/swift-testing.git", branch: "6.0.3"), ], targets: [ // Targets are the basic building blocks of a package, defining a module or a test suite. diff --git a/Boka/Package.resolved b/Boka/Package.resolved deleted file mode 100644 index 3221b295..00000000 --- a/Boka/Package.resolved +++ /dev/null @@ -1,339 +0,0 @@ -{ - "originHash" : "21fd16bf620160741466e113b8b7b90cd924166bfee31bc2fb85ad79912ba6dc", - "pins" : [ - { - "identity" : "async-channels", - "kind" : "remoteSourceControl", - "location" : "https://github.com/gh123man/Async-Channels.git", - "state" : { - "revision" : "e4c71cd0364532d34b27e76f4ab7229abaaaefb4", - "version" : "1.0.2" - } - }, - { - "identity" : "async-http-client", - "kind" : "remoteSourceControl", - "location" : "https://github.com/swift-server/async-http-client.git", - "state" : { - "revision" : "64abc77edf1ef81e69bd90a2ac386de615c8e8ea", - "version" : "1.23.0" - } - }, - { - "identity" : "async-kit", - "kind" : "remoteSourceControl", - "location" : "https://github.com/vapor/async-kit.git", - "state" : { - "revision" : "e048c8ee94967e8d8a1c2ec0e1156d6f7fa34d31", - "version" : "1.20.0" - } - }, - { - "identity" : "blake2.swift", - "kind" : "remoteSourceControl", - "location" : "https://github.com/tesseract-one/Blake2.swift.git", - "state" : { - "revision" : "29c55c8fe42d6661e5a32cc5bbbad1fff64fd01e", - "version" : "0.2.0" - } - }, - { - "identity" : "console-kit", - "kind" : "remoteSourceControl", - "location" : "https://github.com/vapor/console-kit.git", - "state" : { - "revision" : "78c0dd739df8cb9ee14a8bbbf770facc4fc3402a", - "version" : "4.15.0" - } - }, - { - "identity" : "grpc-swift", - "kind" : "remoteSourceControl", - "location" : "https://github.com/grpc/grpc-swift.git", - "state" : { - "revision" : "3ef3a9f42a11bfca767de880f1a0aedd2b65b840", - "version" : "1.24.1" - } - }, - { - "identity" : "lrucache", - "kind" : "remoteSourceControl", - "location" : "https://github.com/nicklockwood/LRUCache.git", - "state" : { - "revision" : "542f0449556327415409ededc9c43a4bd0a397dc", - "version" : "1.0.7" - } - }, - { - "identity" : "multipart-kit", - "kind" : "remoteSourceControl", - "location" : "https://github.com/vapor/multipart-kit.git", - "state" : { - "revision" : "a31236f24bfd2ea2f520a74575881f6731d7ae68", - "version" : "4.7.0" - } - }, - { - "identity" : "routing-kit", - "kind" : "remoteSourceControl", - "location" : "https://github.com/vapor/routing-kit.git", - "state" : { - "revision" : "8c9a227476555c55837e569be71944e02a056b72", - "version" : "4.9.1" - } - }, - { - "identity" : "swift-algorithms", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-algorithms.git", - "state" : { - "revision" : "f6919dfc309e7f1b56224378b11e28bab5bccc42", - "version" : "1.2.0" - } - }, - { - "identity" : "swift-argument-parser", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-argument-parser.git", - "state" : { - "revision" : "41982a3656a71c768319979febd796c6fd111d5c", - "version" : "1.5.0" - } - }, - { - "identity" : "swift-asn1", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-asn1.git", - "state" : { - "revision" : "7faebca1ea4f9aaf0cda1cef7c43aecd2311ddf6", - "version" : "1.3.0" - } - }, - { - "identity" : "swift-async-algorithms", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-async-algorithms.git", - "state" : { - "revision" : "5c8bd186f48c16af0775972700626f0b74588278", - "version" : "1.0.2" - } - }, - { - "identity" : "swift-atomics", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-atomics.git", - "state" : { - "revision" : "cd142fd2f64be2100422d658e7411e39489da985", - "version" : "1.2.0" - } - }, - { - "identity" : "swift-certificates", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-certificates.git", - "state" : { - "revision" : "1fbb6ef21f1525ed5faf4c95207b9c11bea27e94", - "version" : "1.6.1" - } - }, - { - "identity" : "swift-collections", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-collections.git", - "state" : { - "revision" : "671108c96644956dddcd89dd59c203dcdb36cec7", - "version" : "1.1.4" - } - }, - { - "identity" : "swift-crypto", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-crypto.git", - "state" : { - "revision" : "ffca28be3c9c6a86a579949d23f68818a4b9b5d8", - "version" : "3.8.0" - } - }, - { - "identity" : "swift-distributed-tracing", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-distributed-tracing.git", - "state" : { - "revision" : "6483d340853a944c96dbcc28b27dd10b6c581703", - "version" : "1.1.2" - } - }, - { - "identity" : "swift-http-types", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-http-types", - "state" : { - "revision" : "ae67c8178eb46944fd85e4dc6dd970e1f3ed6ccd", - "version" : "1.3.0" - } - }, - { - "identity" : "swift-log", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-log.git", - "state" : { - "revision" : "9cb486020ebf03bfa5b5df985387a14a98744537", - "version" : "1.6.1" - } - }, - { - "identity" : "swift-metrics", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-metrics.git", - "state" : { - "revision" : "e0165b53d49b413dd987526b641e05e246782685", - "version" : "2.5.0" - } - }, - { - "identity" : "swift-nio", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-nio.git", - "state" : { - "revision" : "665206000b8307cab5ac51203d29b0f232d7e31b", - "version" : "2.74.0" - } - }, - { - "identity" : "swift-nio-extras", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-nio-extras.git", - "state" : { - "revision" : "d1ead62745cc3269e482f1c51f27608057174379", - "version" : "1.24.0" - } - }, - { - "identity" : "swift-nio-http2", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-nio-http2.git", - "state" : { - "revision" : "eaa71bb6ae082eee5a07407b1ad0cbd8f48f9dca", - "version" : "1.34.1" - } - }, - { - "identity" : "swift-nio-ssl", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-nio-ssl.git", - "state" : { - "revision" : "7b84abbdcef69cc3be6573ac12440220789dcd69", - "version" : "2.27.2" - } - }, - { - "identity" : "swift-nio-transport-services", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-nio-transport-services.git", - "state" : { - "revision" : "dbace16f126fdcd80d58dc54526c561ca17327d7", - "version" : "1.22.0" - } - }, - { - "identity" : "swift-numerics", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-numerics", - "state" : { - "branch" : "main", - "revision" : "e30276bff2ff5ed80566fbdca49f50aa160b0e83" - } - }, - { - "identity" : "swift-otel", - "kind" : "remoteSourceControl", - "location" : "https://github.com/slashmo/swift-otel.git", - "state" : { - "revision" : "90d63b478fbc4c97f396c1cf9ad011979a83f10b", - "version" : "0.10.1" - } - }, - { - "identity" : "swift-protobuf", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-protobuf.git", - "state" : { - "revision" : "ebc7251dd5b37f627c93698e4374084d98409633", - "version" : "1.28.2" - } - }, - { - "identity" : "swift-service-context", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-service-context.git", - "state" : { - "revision" : "0c62c5b4601d6c125050b5c3a97f20cce881d32b", - "version" : "1.1.0" - } - }, - { - "identity" : "swift-service-lifecycle", - "kind" : "remoteSourceControl", - "location" : "https://github.com/swift-server/swift-service-lifecycle.git", - "state" : { - "revision" : "24c800fb494fbee6e42bc156dc94232dc08971af", - "version" : "2.6.1" - } - }, - { - "identity" : "swift-syntax", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-syntax.git", - "state" : { - "revision" : "0687f71944021d616d34d922343dcef086855920", - "version" : "600.0.1" - } - }, - { - "identity" : "swift-system", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-system.git", - "state" : { - "revision" : "d2ba781702a1d8285419c15ee62fd734a9437ff5", - "version" : "1.3.2" - } - }, - { - "identity" : "swift-testing", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-testing.git", - "state" : { - "branch" : "0.10.0", - "revision" : "69d59cfc76e5daf498ca61f5af409f594768eef9" - } - }, - { - "identity" : "swift-w3c-trace-context", - "kind" : "remoteSourceControl", - "location" : "https://github.com/slashmo/swift-w3c-trace-context.git", - "state" : { - "revision" : "3da4b79545b38cf5551f1c525d800756f38cb697", - "version" : "1.0.0-beta.3" - } - }, - { - "identity" : "vapor", - "kind" : "remoteSourceControl", - "location" : "https://github.com/vapor/vapor.git", - "state" : { - "revision" : "1466c50e4ad39072143e2fcdf13b4ba11be375a0", - "version" : "4.106.0" - } - }, - { - "identity" : "websocket-kit", - "kind" : "remoteSourceControl", - "location" : "https://github.com/vapor/websocket-kit.git", - "state" : { - "revision" : "4232d34efa49f633ba61afde365d3896fc7f8740", - "version" : "2.15.0" - } - } - ], - "version" : 3 -} diff --git a/Boka/Package.swift b/Boka/Package.swift index e46b3cc0..59429639 100644 --- a/Boka/Package.swift +++ b/Boka/Package.swift @@ -14,7 +14,7 @@ let package = Package( .package(url: "https://github.com/slashmo/swift-otel.git", from: "0.9.0"), .package(url: "https://github.com/swift-server/swift-service-lifecycle.git", from: "2.6.0"), .package(url: "https://github.com/vapor/console-kit.git", from: "4.15.0"), - .package(url: "https://github.com/apple/swift-testing.git", branch: "6.1"), + .package(url: "https://github.com/apple/swift-testing.git", branch: "6.0.3"), .package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.5.0"), ], targets: [ diff --git a/Codec/Package.resolved b/Codec/Package.resolved deleted file mode 100644 index aa699247..00000000 --- a/Codec/Package.resolved +++ /dev/null @@ -1,24 +0,0 @@ -{ - "originHash" : "027931fd6146ff8a703e948ec61abe2a52a77db3285ba4722225d611e17904e6", - "pins" : [ - { - "identity" : "swift-syntax", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-syntax.git", - "state" : { - "revision" : "515f79b522918f83483068d99c68daeb5116342d", - "version" : "600.0.0-prerelease-2024-08-14" - } - }, - { - "identity" : "swift-testing", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-testing.git", - "state" : { - "branch" : "0.10.0", - "revision" : "69d59cfc76e5daf498ca61f5af409f594768eef9" - } - } - ], - "version" : 3 -} diff --git a/Codec/Package.swift b/Codec/Package.swift index 8ed78eca..1b3fcf01 100644 --- a/Codec/Package.swift +++ b/Codec/Package.swift @@ -16,7 +16,7 @@ let package = Package( ), ], dependencies: [ - .package(url: "https://github.com/apple/swift-testing.git", branch: "6.1"), + .package(url: "https://github.com/apple/swift-testing.git", branch: "6.0.3"), ], targets: [ // Targets are the basic building blocks of a package, defining a module or a test suite. diff --git a/Database/Package.resolved b/Database/Package.resolved deleted file mode 100644 index 66a2c042..00000000 --- a/Database/Package.resolved +++ /dev/null @@ -1,105 +0,0 @@ -{ - "originHash" : "71ac75472e411174f6e43bdf064f1565f45d087a55de16d382092ae064ca91eb", - "pins" : [ - { - "identity" : "blake2.swift", - "kind" : "remoteSourceControl", - "location" : "https://github.com/tesseract-one/Blake2.swift.git", - "state" : { - "revision" : "29c55c8fe42d6661e5a32cc5bbbad1fff64fd01e", - "version" : "0.2.0" - } - }, - { - "identity" : "lrucache", - "kind" : "remoteSourceControl", - "location" : "https://github.com/nicklockwood/LRUCache.git", - "state" : { - "revision" : "542f0449556327415409ededc9c43a4bd0a397dc", - "version" : "1.0.7" - } - }, - { - "identity" : "swift-asn1", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-asn1.git", - "state" : { - "revision" : "7faebca1ea4f9aaf0cda1cef7c43aecd2311ddf6", - "version" : "1.3.0" - } - }, - { - "identity" : "swift-crypto", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-crypto.git", - "state" : { - "revision" : "ff0f781cf7c6a22d52957e50b104f5768b50c779", - "version" : "3.10.0" - } - }, - { - "identity" : "swift-distributed-tracing", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-distributed-tracing.git", - "state" : { - "revision" : "6483d340853a944c96dbcc28b27dd10b6c581703", - "version" : "1.1.2" - } - }, - { - "identity" : "swift-log", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-log.git", - "state" : { - "revision" : "96a2f8a0fa41e9e09af4585e2724c4e825410b91", - "version" : "1.6.2" - } - }, - { - "identity" : "swift-metrics", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-metrics.git", - "state" : { - "revision" : "e0165b53d49b413dd987526b641e05e246782685", - "version" : "2.5.0" - } - }, - { - "identity" : "swift-numerics", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-numerics.git", - "state" : { - "branch" : "main", - "revision" : "e30276bff2ff5ed80566fbdca49f50aa160b0e83" - } - }, - { - "identity" : "swift-service-context", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-service-context.git", - "state" : { - "revision" : "0c62c5b4601d6c125050b5c3a97f20cce881d32b", - "version" : "1.1.0" - } - }, - { - "identity" : "swift-syntax", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-syntax.git", - "state" : { - "revision" : "4c6cc0a3b9e8f14b3ae2307c5ccae4de6167ac2c", - "version" : "600.0.0-prerelease-2024-06-12" - } - }, - { - "identity" : "swift-testing", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-testing.git", - "state" : { - "branch" : "0.10.0", - "revision" : "69d59cfc76e5daf498ca61f5af409f594768eef9" - } - } - ], - "version" : 3 -} diff --git a/Database/Package.swift b/Database/Package.swift index f549c362..9d4d083f 100644 --- a/Database/Package.swift +++ b/Database/Package.swift @@ -19,7 +19,7 @@ let package = Package( .package(path: "../Blockchain"), .package(path: "../Codec"), .package(path: "../Utils"), - .package(url: "https://github.com/apple/swift-testing.git", branch: "6.1"), + .package(url: "https://github.com/apple/swift-testing.git", branch: "6.0.3"), ], targets: [ .target( diff --git a/JAMTests/Package.resolved b/JAMTests/Package.resolved deleted file mode 100644 index 8a4e0f98..00000000 --- a/JAMTests/Package.resolved +++ /dev/null @@ -1,96 +0,0 @@ -{ - "originHash" : "d1c16170b6583ee1b137012237d778a580dd5133ce298fe722c0dd6851f6018d", - "pins" : [ - { - "identity" : "blake2.swift", - "kind" : "remoteSourceControl", - "location" : "https://github.com/tesseract-one/Blake2.swift.git", - "state" : { - "revision" : "29c55c8fe42d6661e5a32cc5bbbad1fff64fd01e", - "version" : "0.2.0" - } - }, - { - "identity" : "lrucache", - "kind" : "remoteSourceControl", - "location" : "https://github.com/nicklockwood/LRUCache.git", - "state" : { - "revision" : "542f0449556327415409ededc9c43a4bd0a397dc", - "version" : "1.0.7" - } - }, - { - "identity" : "swift-crypto", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-crypto.git", - "state" : { - "revision" : "33f65a3cbc52f8c19295723af9cbecc2195484e1", - "version" : "3.5.0" - } - }, - { - "identity" : "swift-distributed-tracing", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-distributed-tracing.git", - "state" : { - "revision" : "11c756c5c4d7de0eeed8595695cadd7fa107aa19", - "version" : "1.1.1" - } - }, - { - "identity" : "swift-log", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-log.git", - "state" : { - "revision" : "9cb486020ebf03bfa5b5df985387a14a98744537", - "version" : "1.6.1" - } - }, - { - "identity" : "swift-metrics", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-metrics.git", - "state" : { - "revision" : "e0165b53d49b413dd987526b641e05e246782685", - "version" : "2.5.0" - } - }, - { - "identity" : "swift-numerics", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-numerics", - "state" : { - "branch" : "main", - "revision" : "e30276bff2ff5ed80566fbdca49f50aa160b0e83" - } - }, - { - "identity" : "swift-service-context", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-service-context.git", - "state" : { - "revision" : "0c62c5b4601d6c125050b5c3a97f20cce881d32b", - "version" : "1.1.0" - } - }, - { - "identity" : "swift-syntax", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-syntax.git", - "state" : { - "revision" : "4c6cc0a3b9e8f14b3ae2307c5ccae4de6167ac2c", - "version" : "600.0.0-prerelease-2024-06-12" - } - }, - { - "identity" : "swift-testing", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-testing.git", - "state" : { - "branch" : "0.10.0", - "revision" : "69d59cfc76e5daf498ca61f5af409f594768eef9" - } - } - ], - "version" : 3 -} diff --git a/JAMTests/Package.swift b/JAMTests/Package.swift index 3b74fb72..f1ea0cbc 100644 --- a/JAMTests/Package.swift +++ b/JAMTests/Package.swift @@ -21,7 +21,7 @@ let package = Package( .package(path: "../TracingUtils"), .package(path: "../Blockchain"), .package(path: "../PolkaVM"), - .package(url: "https://github.com/apple/swift-testing.git", branch: "6.1"), + .package(url: "https://github.com/apple/swift-testing.git", branch: "6.0.3"), ], targets: [ // Targets are the basic building blocks of a package, defining a module or a test suite. diff --git a/Networking/Package.swift b/Networking/Package.swift index aa4e2679..b05f5221 100644 --- a/Networking/Package.swift +++ b/Networking/Package.swift @@ -19,7 +19,7 @@ let package = Package( .package(path: "../Utils"), .package(url: "https://github.com/apple/swift-log.git", from: "1.6.0"), .package(url: "https://github.com/apple/swift-certificates.git", from: "1.5.0"), - .package(url: "https://github.com/apple/swift-testing.git", branch: "6.1"), + .package(url: "https://github.com/apple/swift-testing.git", branch: "6.0.3"), .package(url: "https://github.com/gh123man/Async-Channels.git", from: "1.0.2"), ], targets: [ diff --git a/Node/Package.resolved b/Node/Package.resolved deleted file mode 100644 index 88a24089..00000000 --- a/Node/Package.resolved +++ /dev/null @@ -1,276 +0,0 @@ -{ - "originHash" : "fd50b22dcf258877cc79f49fe7cb855a71ce6974bd1a2732a13b0d3e49c057fc", - "pins" : [ - { - "identity" : "async-channels", - "kind" : "remoteSourceControl", - "location" : "https://github.com/gh123man/Async-Channels.git", - "state" : { - "revision" : "e4c71cd0364532d34b27e76f4ab7229abaaaefb4", - "version" : "1.0.2" - } - }, - { - "identity" : "async-http-client", - "kind" : "remoteSourceControl", - "location" : "https://github.com/swift-server/async-http-client.git", - "state" : { - "revision" : "0ae99db85b2b9d1e79b362bd31fd1ffe492f7c47", - "version" : "1.21.2" - } - }, - { - "identity" : "async-kit", - "kind" : "remoteSourceControl", - "location" : "https://github.com/vapor/async-kit.git", - "state" : { - "revision" : "e048c8ee94967e8d8a1c2ec0e1156d6f7fa34d31", - "version" : "1.20.0" - } - }, - { - "identity" : "blake2.swift", - "kind" : "remoteSourceControl", - "location" : "https://github.com/tesseract-one/Blake2.swift.git", - "state" : { - "revision" : "29c55c8fe42d6661e5a32cc5bbbad1fff64fd01e", - "version" : "0.2.0" - } - }, - { - "identity" : "console-kit", - "kind" : "remoteSourceControl", - "location" : "https://github.com/vapor/console-kit.git", - "state" : { - "revision" : "9f7932f22ab6f64aafadc14491e694179b7d0f6f", - "version" : "4.14.3" - } - }, - { - "identity" : "lrucache", - "kind" : "remoteSourceControl", - "location" : "https://github.com/nicklockwood/LRUCache.git", - "state" : { - "revision" : "542f0449556327415409ededc9c43a4bd0a397dc", - "version" : "1.0.7" - } - }, - { - "identity" : "multipart-kit", - "kind" : "remoteSourceControl", - "location" : "https://github.com/vapor/multipart-kit.git", - "state" : { - "revision" : "a31236f24bfd2ea2f520a74575881f6731d7ae68", - "version" : "4.7.0" - } - }, - { - "identity" : "routing-kit", - "kind" : "remoteSourceControl", - "location" : "https://github.com/vapor/routing-kit.git", - "state" : { - "revision" : "8c9a227476555c55837e569be71944e02a056b72", - "version" : "4.9.1" - } - }, - { - "identity" : "swift-algorithms", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-algorithms.git", - "state" : { - "revision" : "f6919dfc309e7f1b56224378b11e28bab5bccc42", - "version" : "1.2.0" - } - }, - { - "identity" : "swift-asn1", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-asn1.git", - "state" : { - "revision" : "7faebca1ea4f9aaf0cda1cef7c43aecd2311ddf6", - "version" : "1.3.0" - } - }, - { - "identity" : "swift-atomics", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-atomics.git", - "state" : { - "revision" : "cd142fd2f64be2100422d658e7411e39489da985", - "version" : "1.2.0" - } - }, - { - "identity" : "swift-certificates", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-certificates.git", - "state" : { - "revision" : "1fbb6ef21f1525ed5faf4c95207b9c11bea27e94", - "version" : "1.6.1" - } - }, - { - "identity" : "swift-collections", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-collections.git", - "state" : { - "revision" : "671108c96644956dddcd89dd59c203dcdb36cec7", - "version" : "1.1.4" - } - }, - { - "identity" : "swift-crypto", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-crypto.git", - "state" : { - "revision" : "bc1c29221f6dfeb0ebbfbc98eb95cd3d4967868e", - "version" : "3.4.0" - } - }, - { - "identity" : "swift-distributed-tracing", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-distributed-tracing.git", - "state" : { - "revision" : "11c756c5c4d7de0eeed8595695cadd7fa107aa19", - "version" : "1.1.1" - } - }, - { - "identity" : "swift-http-types", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-http-types", - "state" : { - "revision" : "ae67c8178eb46944fd85e4dc6dd970e1f3ed6ccd", - "version" : "1.3.0" - } - }, - { - "identity" : "swift-log", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-log.git", - "state" : { - "revision" : "9cb486020ebf03bfa5b5df985387a14a98744537", - "version" : "1.6.1" - } - }, - { - "identity" : "swift-metrics", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-metrics.git", - "state" : { - "revision" : "e0165b53d49b413dd987526b641e05e246782685", - "version" : "2.5.0" - } - }, - { - "identity" : "swift-nio", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-nio.git", - "state" : { - "revision" : "4c4453b489cf76e6b3b0f300aba663eb78182fad", - "version" : "2.70.0" - } - }, - { - "identity" : "swift-nio-extras", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-nio-extras.git", - "state" : { - "revision" : "d1ead62745cc3269e482f1c51f27608057174379", - "version" : "1.24.0" - } - }, - { - "identity" : "swift-nio-http2", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-nio-http2.git", - "state" : { - "revision" : "b5f7062b60e4add1e8c343ba4eb8da2e324b3a94", - "version" : "1.34.0" - } - }, - { - "identity" : "swift-nio-ssl", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-nio-ssl.git", - "state" : { - "revision" : "a9fa5efd86e7ce2e5c1b6de113262e58035ca251", - "version" : "2.27.1" - } - }, - { - "identity" : "swift-nio-transport-services", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-nio-transport-services.git", - "state" : { - "revision" : "38ac8221dd20674682148d6451367f89c2652980", - "version" : "1.21.0" - } - }, - { - "identity" : "swift-numerics", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-numerics", - "state" : { - "branch" : "main", - "revision" : "e30276bff2ff5ed80566fbdca49f50aa160b0e83" - } - }, - { - "identity" : "swift-service-context", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-service-context.git", - "state" : { - "revision" : "0c62c5b4601d6c125050b5c3a97f20cce881d32b", - "version" : "1.1.0" - } - }, - { - "identity" : "swift-syntax", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-syntax.git", - "state" : { - "revision" : "0687f71944021d616d34d922343dcef086855920", - "version" : "600.0.1" - } - }, - { - "identity" : "swift-system", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-system.git", - "state" : { - "revision" : "d2ba781702a1d8285419c15ee62fd734a9437ff5", - "version" : "1.3.2" - } - }, - { - "identity" : "swift-testing", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-testing.git", - "state" : { - "branch" : "0.10.0", - "revision" : "69d59cfc76e5daf498ca61f5af409f594768eef9" - } - }, - { - "identity" : "vapor", - "kind" : "remoteSourceControl", - "location" : "https://github.com/vapor/vapor.git", - "state" : { - "revision" : "1466c50e4ad39072143e2fcdf13b4ba11be375a0", - "version" : "4.106.0" - } - }, - { - "identity" : "websocket-kit", - "kind" : "remoteSourceControl", - "location" : "https://github.com/vapor/websocket-kit.git", - "state" : { - "revision" : "4232d34efa49f633ba61afde365d3896fc7f8740", - "version" : "2.15.0" - } - } - ], - "version" : 3 -} diff --git a/Node/Package.swift b/Node/Package.swift index 753b8355..9b22869b 100644 --- a/Node/Package.swift +++ b/Node/Package.swift @@ -22,7 +22,7 @@ let package = Package( .package(path: "../TracingUtils"), .package(path: "../Utils"), .package(path: "../Database"), - .package(url: "https://github.com/apple/swift-testing.git", branch: "6.1"), + .package(url: "https://github.com/apple/swift-testing.git", branch: "6.0.3"), .package(url: "https://github.com/gh123man/Async-Channels.git", from: "1.0.2"), ], targets: [ diff --git a/Node/Sources/Node/NetworkingProtocol/NetworkManager.swift b/Node/Sources/Node/NetworkingProtocol/NetworkManager.swift index 58b42326..3eab44ea 100644 --- a/Node/Sources/Node/NetworkingProtocol/NetworkManager.swift +++ b/Node/Sources/Node/NetworkingProtocol/NetworkManager.swift @@ -410,15 +410,16 @@ struct HandlerImpl: NetworkProtocolHandler { return [] case let .workReportRequest(message): blockchain.publish(event: RuntimeEvents.WorkReportRequestReceived(workReportHash: message.workReportHash)) - let resp = try await blockchain.waitFor(RuntimeEvents.WorkReportRequestResponse.self) { event in - message.workReportHash == event.workReportHash - } - switch resp.result { - case let .success(workReport): - return try [JamEncoder.encode(workReport)] - case let .failure(error): - throw error - } +// let resp = try await blockchain.waitFor(RuntimeEvents.WorkReportRequestResponse.self) { event in +// message.workReportHash == event.workReportHash +// } +// switch resp.result { +// case let .success(workReport): +// return try [JamEncoder.encode(workReport)] +// case let .failure(error): +// throw error +// } + return [] case let .shardDistribution(message): blockchain .publish(event: RuntimeEvents.ShardDistributionReceived(erasureRoot: message.erasureRoot, shardIndex: message.shardIndex)) diff --git a/PolkaVM/Package.resolved b/PolkaVM/Package.resolved deleted file mode 100644 index a57c3ba5..00000000 --- a/PolkaVM/Package.resolved +++ /dev/null @@ -1,96 +0,0 @@ -{ - "originHash" : "5f5f6662e0a341792801f498df286aec16ade8bbccd3121439d34662fc774385", - "pins" : [ - { - "identity" : "blake2.swift", - "kind" : "remoteSourceControl", - "location" : "https://github.com/tesseract-one/Blake2.swift.git", - "state" : { - "revision" : "29c55c8fe42d6661e5a32cc5bbbad1fff64fd01e", - "version" : "0.2.0" - } - }, - { - "identity" : "lrucache", - "kind" : "remoteSourceControl", - "location" : "https://github.com/nicklockwood/LRUCache.git", - "state" : { - "revision" : "542f0449556327415409ededc9c43a4bd0a397dc", - "version" : "1.0.7" - } - }, - { - "identity" : "swift-crypto", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-crypto.git", - "state" : { - "revision" : "46072478ca365fe48370993833cb22de9b41567f", - "version" : "3.5.2" - } - }, - { - "identity" : "swift-distributed-tracing", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-distributed-tracing.git", - "state" : { - "revision" : "11c756c5c4d7de0eeed8595695cadd7fa107aa19", - "version" : "1.1.1" - } - }, - { - "identity" : "swift-log", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-log.git", - "state" : { - "revision" : "9cb486020ebf03bfa5b5df985387a14a98744537", - "version" : "1.6.1" - } - }, - { - "identity" : "swift-metrics", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-metrics.git", - "state" : { - "revision" : "e0165b53d49b413dd987526b641e05e246782685", - "version" : "2.5.0" - } - }, - { - "identity" : "swift-numerics", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-numerics", - "state" : { - "branch" : "main", - "revision" : "e30276bff2ff5ed80566fbdca49f50aa160b0e83" - } - }, - { - "identity" : "swift-service-context", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-service-context.git", - "state" : { - "revision" : "0c62c5b4601d6c125050b5c3a97f20cce881d32b", - "version" : "1.1.0" - } - }, - { - "identity" : "swift-syntax", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-syntax.git", - "state" : { - "revision" : "4c6cc0a3b9e8f14b3ae2307c5ccae4de6167ac2c", - "version" : "600.0.0-prerelease-2024-06-12" - } - }, - { - "identity" : "swift-testing", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-testing.git", - "state" : { - "branch" : "0.10.0", - "revision" : "69d59cfc76e5daf498ca61f5af409f594768eef9" - } - } - ], - "version" : 3 -} diff --git a/PolkaVM/Package.swift b/PolkaVM/Package.swift index aaf50561..f3e61464 100644 --- a/PolkaVM/Package.swift +++ b/PolkaVM/Package.swift @@ -17,7 +17,7 @@ let package = Package( dependencies: [ .package(path: "../Utils"), .package(path: "../TracingUtils"), - .package(url: "https://github.com/apple/swift-testing.git", branch: "6.1"), + .package(url: "https://github.com/apple/swift-testing.git", branch: "6.0.3"), .package(url: "https://github.com/apple/swift-log.git", from: "1.6.0"), .package(url: "https://github.com/nicklockwood/LRUCache.git", from: "1.0.7"), ], diff --git a/RPC/Package.resolved b/RPC/Package.resolved deleted file mode 100644 index ee23644d..00000000 --- a/RPC/Package.resolved +++ /dev/null @@ -1,249 +0,0 @@ -{ - "originHash" : "85ab166a80e0358079b74f7774716a68fd1213f7890849b330819d067322c3e3", - "pins" : [ - { - "identity" : "async-http-client", - "kind" : "remoteSourceControl", - "location" : "https://github.com/swift-server/async-http-client.git", - "state" : { - "revision" : "64abc77edf1ef81e69bd90a2ac386de615c8e8ea", - "version" : "1.23.0" - } - }, - { - "identity" : "async-kit", - "kind" : "remoteSourceControl", - "location" : "https://github.com/vapor/async-kit.git", - "state" : { - "revision" : "e048c8ee94967e8d8a1c2ec0e1156d6f7fa34d31", - "version" : "1.20.0" - } - }, - { - "identity" : "blake2.swift", - "kind" : "remoteSourceControl", - "location" : "https://github.com/tesseract-one/Blake2.swift.git", - "state" : { - "revision" : "29c55c8fe42d6661e5a32cc5bbbad1fff64fd01e", - "version" : "0.2.0" - } - }, - { - "identity" : "console-kit", - "kind" : "remoteSourceControl", - "location" : "https://github.com/vapor/console-kit.git", - "state" : { - "revision" : "78c0dd739df8cb9ee14a8bbbf770facc4fc3402a", - "version" : "4.15.0" - } - }, - { - "identity" : "lrucache", - "kind" : "remoteSourceControl", - "location" : "https://github.com/nicklockwood/LRUCache.git", - "state" : { - "revision" : "542f0449556327415409ededc9c43a4bd0a397dc", - "version" : "1.0.7" - } - }, - { - "identity" : "multipart-kit", - "kind" : "remoteSourceControl", - "location" : "https://github.com/vapor/multipart-kit.git", - "state" : { - "revision" : "a31236f24bfd2ea2f520a74575881f6731d7ae68", - "version" : "4.7.0" - } - }, - { - "identity" : "routing-kit", - "kind" : "remoteSourceControl", - "location" : "https://github.com/vapor/routing-kit.git", - "state" : { - "revision" : "8c9a227476555c55837e569be71944e02a056b72", - "version" : "4.9.1" - } - }, - { - "identity" : "swift-algorithms", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-algorithms.git", - "state" : { - "revision" : "f6919dfc309e7f1b56224378b11e28bab5bccc42", - "version" : "1.2.0" - } - }, - { - "identity" : "swift-atomics", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-atomics.git", - "state" : { - "revision" : "cd142fd2f64be2100422d658e7411e39489da985", - "version" : "1.2.0" - } - }, - { - "identity" : "swift-collections", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-collections.git", - "state" : { - "revision" : "671108c96644956dddcd89dd59c203dcdb36cec7", - "version" : "1.1.4" - } - }, - { - "identity" : "swift-crypto", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-crypto.git", - "state" : { - "revision" : "ffca28be3c9c6a86a579949d23f68818a4b9b5d8", - "version" : "3.8.0" - } - }, - { - "identity" : "swift-distributed-tracing", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-distributed-tracing.git", - "state" : { - "revision" : "6483d340853a944c96dbcc28b27dd10b6c581703", - "version" : "1.1.2" - } - }, - { - "identity" : "swift-http-types", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-http-types", - "state" : { - "revision" : "ae67c8178eb46944fd85e4dc6dd970e1f3ed6ccd", - "version" : "1.3.0" - } - }, - { - "identity" : "swift-log", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-log.git", - "state" : { - "revision" : "9cb486020ebf03bfa5b5df985387a14a98744537", - "version" : "1.6.1" - } - }, - { - "identity" : "swift-metrics", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-metrics.git", - "state" : { - "revision" : "e0165b53d49b413dd987526b641e05e246782685", - "version" : "2.5.0" - } - }, - { - "identity" : "swift-nio", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-nio.git", - "state" : { - "revision" : "665206000b8307cab5ac51203d29b0f232d7e31b", - "version" : "2.74.0" - } - }, - { - "identity" : "swift-nio-extras", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-nio-extras.git", - "state" : { - "revision" : "d1ead62745cc3269e482f1c51f27608057174379", - "version" : "1.24.0" - } - }, - { - "identity" : "swift-nio-http2", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-nio-http2.git", - "state" : { - "revision" : "eaa71bb6ae082eee5a07407b1ad0cbd8f48f9dca", - "version" : "1.34.1" - } - }, - { - "identity" : "swift-nio-ssl", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-nio-ssl.git", - "state" : { - "revision" : "7b84abbdcef69cc3be6573ac12440220789dcd69", - "version" : "2.27.2" - } - }, - { - "identity" : "swift-nio-transport-services", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-nio-transport-services.git", - "state" : { - "revision" : "dbace16f126fdcd80d58dc54526c561ca17327d7", - "version" : "1.22.0" - } - }, - { - "identity" : "swift-numerics", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-numerics.git", - "state" : { - "branch" : "main", - "revision" : "e30276bff2ff5ed80566fbdca49f50aa160b0e83" - } - }, - { - "identity" : "swift-service-context", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-service-context.git", - "state" : { - "revision" : "0c62c5b4601d6c125050b5c3a97f20cce881d32b", - "version" : "1.1.0" - } - }, - { - "identity" : "swift-syntax", - "kind" : "remoteSourceControl", - "location" : "https://github.com/swiftlang/swift-syntax.git", - "state" : { - "revision" : "f99ae8aa18f0cf0d53481901f88a0991dc3bd4a2", - "version" : "601.0.1" - } - }, - { - "identity" : "swift-system", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-system.git", - "state" : { - "revision" : "d2ba781702a1d8285419c15ee62fd734a9437ff5", - "version" : "1.3.2" - } - }, - { - "identity" : "swift-testing", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-testing.git", - "state" : { - "branch" : "6.1", - "revision" : "43b6f88e2f2712e0f2a97e6acc75b55f22234299" - } - }, - { - "identity" : "vapor", - "kind" : "remoteSourceControl", - "location" : "https://github.com/vapor/vapor.git", - "state" : { - "revision" : "1466c50e4ad39072143e2fcdf13b4ba11be375a0", - "version" : "4.106.0" - } - }, - { - "identity" : "websocket-kit", - "kind" : "remoteSourceControl", - "location" : "https://github.com/vapor/websocket-kit.git", - "state" : { - "revision" : "4232d34efa49f633ba61afde365d3896fc7f8740", - "version" : "2.15.0" - } - } - ], - "version" : 3 -} diff --git a/RPC/Package.swift b/RPC/Package.swift index 6176b3f1..c55fd150 100644 --- a/RPC/Package.swift +++ b/RPC/Package.swift @@ -18,9 +18,9 @@ let package = Package( dependencies: [ .package(path: "../Blockchain"), .package(path: "../Utils"), - .package(url: "https://github.com/vapor/vapor.git", from: "4.106.0"), + .package(url: "https://github.com/vapor/vapor.git", from: "4.111.0"), .package(url: "https://github.com/vapor/async-kit.git", from: "1.20.0"), - .package(url: "https://github.com/apple/swift-testing.git", branch: "6.1"), + .package(url: "https://github.com/apple/swift-testing.git", branch: "6.0.3"), ], targets: [ diff --git a/Tools/Package.swift b/Tools/Package.swift index a8b9fb7f..da28bc8f 100644 --- a/Tools/Package.swift +++ b/Tools/Package.swift @@ -13,7 +13,7 @@ let package = Package( .package(path: "../TracingUtils"), .package(path: "../Utils"), .package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.5.0"), - .package(url: "https://github.com/ajevans99/swift-json-schema.git", exact: "0.2.1"), + .package(url: "https://github.com/ajevans99/swift-json-schema.git", from: "0.3.2"), .package(url: "https://github.com/wickwirew/Runtime.git", from: "2.2.7"), ], targets: [ diff --git a/Utils/Package.resolved b/Utils/Package.resolved index d1be45e0..1549cb9f 100644 --- a/Utils/Package.resolved +++ b/Utils/Package.resolved @@ -1,5 +1,5 @@ { - "originHash" : "58cf105575b46ad7fba6c2a1e8924751af596842a801a9c8d41493126bb7ca1a", + "originHash" : "0685a96f04661159428431b8747ce4f61898018d240efed51e5918b3894d1393", "pins" : [ { "identity" : "blake2.swift", @@ -69,8 +69,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/swiftlang/swift-syntax.git", "state" : { - "revision" : "f99ae8aa18f0cf0d53481901f88a0991dc3bd4a2", - "version" : "601.0.1" + "revision" : "0687f71944021d616d34d922343dcef086855920", + "version" : "600.0.1" } }, { @@ -78,8 +78,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-testing.git", "state" : { - "branch" : "6.1", - "revision" : "43b6f88e2f2712e0f2a97e6acc75b55f22234299" + "branch" : "6.0.3", + "revision" : "18c42c19cac3fafd61cab1156d4088664b7424ae" } } ], diff --git a/Utils/Package.swift b/Utils/Package.swift index 2179554b..f58412a8 100644 --- a/Utils/Package.swift +++ b/Utils/Package.swift @@ -20,7 +20,7 @@ let package = Package( .package(path: "../TracingUtils"), .package(url: "https://github.com/tesseract-one/Blake2.swift.git", from: "0.2.0"), .package(url: "https://github.com/apple/swift-crypto.git", "1.0.0" ..< "4.0.0"), - .package(url: "https://github.com/apple/swift-testing.git", branch: "6.1"), + .package(url: "https://github.com/apple/swift-testing.git", branch: "6.0.3"), .package(url: "https://github.com/apple/swift-numerics.git", branch: "main"), ], targets: [ diff --git a/boka.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/boka.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 82640dcc..7ab6c539 100644 --- a/boka.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/boka.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -1,5 +1,5 @@ { - "originHash" : "b28090dfdf5ab8e8dee9a65a599ae5b90407e31d8811503956bc2c2b1fdeaa66", + "originHash" : "a665e9a8fd18c09063611f8c8d8375b6bc7fc9c3b56edf7c4923e3d0302506f0", "pins" : [ { "identity" : "async-channels", @@ -15,8 +15,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/swift-server/async-http-client.git", "state" : { - "revision" : "0ae99db85b2b9d1e79b362bd31fd1ffe492f7c47", - "version" : "1.21.2" + "revision" : "333f51104b75d1a5b94cb3b99e4c58a3b442c9f7", + "version" : "1.25.2" } }, { @@ -69,8 +69,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/vapor/multipart-kit.git", "state" : { - "revision" : "a31236f24bfd2ea2f520a74575881f6731d7ae68", - "version" : "4.7.0" + "revision" : "3498e60218e6003894ff95192d756e238c01f44e", + "version" : "4.7.1" } }, { @@ -172,13 +172,22 @@ "version" : "1.1.1" } }, + { + "identity" : "swift-http-structured-headers", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-http-structured-headers.git", + "state" : { + "revision" : "8e769facea6b7d46ea60e5e93635a384fd573480", + "version" : "1.2.1" + } + }, { "identity" : "swift-http-types", "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-http-types", + "location" : "https://github.com/apple/swift-http-types.git", "state" : { - "revision" : "ae67c8178eb46944fd85e4dc6dd970e1f3ed6ccd", - "version" : "1.3.0" + "revision" : "a0a57e949a8903563aba4615869310c0ebf14c03", + "version" : "1.4.0" } }, { @@ -186,8 +195,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/ajevans99/swift-json-schema.git", "state" : { - "revision" : "671f1777a96343b99435d2eb8af72bcb49d175bd", - "version" : "0.2.1" + "revision" : "707fc4c2d53138e8fbb4ee9e6669b050ba4b2239", + "version" : "0.3.2" } }, { @@ -213,8 +222,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-nio.git", "state" : { - "revision" : "4c4453b489cf76e6b3b0f300aba663eb78182fad", - "version" : "2.70.0" + "revision" : "c51907a839e63ebf0ba2076bba73dd96436bd1b9", + "version" : "2.81.0" } }, { @@ -222,8 +231,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-nio-extras.git", "state" : { - "revision" : "d1ead62745cc3269e482f1c51f27608057174379", - "version" : "1.24.0" + "revision" : "00f3f72d2f9942d0e2dc96057ab50a37ced150d4", + "version" : "1.25.0" } }, { @@ -231,8 +240,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-nio-http2.git", "state" : { - "revision" : "b5f7062b60e4add1e8c343ba4eb8da2e324b3a94", - "version" : "1.34.0" + "revision" : "170f4ca06b6a9c57b811293cebcb96e81b661310", + "version" : "1.35.0" } }, { @@ -240,8 +249,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-nio-ssl.git", "state" : { - "revision" : "7b84abbdcef69cc3be6573ac12440220789dcd69", - "version" : "2.27.2" + "revision" : "0cc3528ff48129d64ab9cab0b1cd621634edfc6b", + "version" : "2.29.3" } }, { @@ -301,7 +310,7 @@ { "identity" : "swift-syntax", "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-syntax.git", + "location" : "https://github.com/swiftlang/swift-syntax.git", "state" : { "revision" : "0687f71944021d616d34d922343dcef086855920", "version" : "600.0.1" @@ -312,8 +321,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-system.git", "state" : { - "revision" : "d2ba781702a1d8285419c15ee62fd734a9437ff5", - "version" : "1.3.2" + "revision" : "a34201439c74b53f0fd71ef11741af7e7caf01e1", + "version" : "1.4.2" } }, { @@ -321,8 +330,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-testing.git", "state" : { - "branch" : "0.10.0", - "revision" : "69d59cfc76e5daf498ca61f5af409f594768eef9" + "branch" : "6.0.3", + "revision" : "18c42c19cac3fafd61cab1156d4088664b7424ae" } }, { @@ -330,8 +339,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/vapor/vapor.git", "state" : { - "revision" : "1466c50e4ad39072143e2fcdf13b4ba11be375a0", - "version" : "4.106.0" + "revision" : "87b0edd2633c35de543cb7573efe5fbf456181bc", + "version" : "4.114.1" } }, { From 032e49fd539dad31a4a40bdab10b0b2bbaae5b57 Mon Sep 17 00:00:00 2001 From: MacOMNI <414294494@qq.com> Date: Wed, 9 Apr 2025 10:34:29 +0800 Subject: [PATCH 09/54] update tests --- Node/Tests/NodeTests/NetworkManagerTests.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Node/Tests/NodeTests/NetworkManagerTests.swift b/Node/Tests/NodeTests/NetworkManagerTests.swift index 9dd10c0f..6c848b77 100644 --- a/Node/Tests/NodeTests/NetworkManagerTests.swift +++ b/Node/Tests/NodeTests/NetworkManagerTests.swift @@ -99,6 +99,7 @@ struct NetworkManagerTests { // Wait for event processing let events = await storeMiddleware.wait() + try await Task.sleep(for: .microseconds(100)) // Verify network calls #expect( @@ -115,6 +116,7 @@ struct NetworkManagerTests { ]), "network calls: \(network.calls)" ) + try await Task.sleep(for: .microseconds(200)) let event = try #require(events.first { $0 is RuntimeEvents.WorkPackageBundleReceivedReply } as? RuntimeEvents .WorkPackageBundleReceivedReply) From fccdc1137479dc1afc79d3bd9a58729d562aa8f0 Mon Sep 17 00:00:00 2001 From: MacOMNI <414294494@qq.com> Date: Wed, 9 Apr 2025 14:56:10 +0800 Subject: [PATCH 10/54] update guaranteedWorkReport --- .../BlockchainDataProvider.swift | 14 ++++-- .../BlockchainDataProviderProtocol.swift | 6 +-- .../InMemoryDataProvider.swift | 10 +++++ .../Types/GuaranteedWorkReport.swift | 44 +++++++++++++++++++ .../Blockchain/Types/WorkReportRef.swift | 44 ------------------- .../Validator/GuaranteeingService.swift | 4 +- .../Sources/Database/RocksDBBackend.swift | 10 +++++ .../NetworkingProtocol/NetworkManager.swift | 19 ++++---- .../Tests/NodeTests/NetworkManagerTests.swift | 6 +-- 9 files changed, 90 insertions(+), 67 deletions(-) create mode 100644 Blockchain/Sources/Blockchain/Types/GuaranteedWorkReport.swift delete mode 100644 Blockchain/Sources/Blockchain/Types/WorkReportRef.swift diff --git a/Blockchain/Sources/Blockchain/BlockchainDataProvider/BlockchainDataProvider.swift b/Blockchain/Sources/Blockchain/BlockchainDataProvider/BlockchainDataProvider.swift index 8c25f34b..de8bf2da 100644 --- a/Blockchain/Sources/Blockchain/BlockchainDataProvider/BlockchainDataProvider.swift +++ b/Blockchain/Sources/Blockchain/BlockchainDataProvider/BlockchainDataProvider.swift @@ -58,9 +58,17 @@ public actor BlockchainDataProvider { } extension BlockchainDataProvider { -// public func hasWorkReport(hash: Data32) async throws -> Bool { -// try await dataProvider.hasWorkReport(hash: hash) -// } + public func hasGuaranteedWorkReport(hash: Data32) async throws -> Bool { + try await dataProvider.hasGuaranteedWorkReport(hash: hash) + } + + public func getGuaranteedWorkReport(hash: Data32) async throws -> GuaranteedWorkReportRef? { + try await dataProvider.getGuaranteedWorkReport(hash: hash) + } + + public func add(guaranteedWorkReport: GuaranteedWorkReportRef) async throws { + try await dataProvider.add(guaranteedWorkReport: guaranteedWorkReport) + } public func hasBlock(hash: Data32) async throws -> Bool { try await dataProvider.hasBlock(hash: hash) diff --git a/Blockchain/Sources/Blockchain/BlockchainDataProvider/BlockchainDataProviderProtocol.swift b/Blockchain/Sources/Blockchain/BlockchainDataProvider/BlockchainDataProviderProtocol.swift index 7605621c..1dd5241d 100644 --- a/Blockchain/Sources/Blockchain/BlockchainDataProvider/BlockchainDataProviderProtocol.swift +++ b/Blockchain/Sources/Blockchain/BlockchainDataProvider/BlockchainDataProviderProtocol.swift @@ -1,7 +1,7 @@ import Utils public protocol BlockchainDataProviderProtocol: Sendable { -// func hasWorkReport(hash: Data32) async throws -> Bool + func hasGuaranteedWorkReport(hash: Data32) async throws -> Bool func hasBlock(hash: Data32) async throws -> Bool func hasState(hash: Data32) async throws -> Bool func isHead(hash: Data32) async throws -> Bool @@ -10,7 +10,7 @@ public protocol BlockchainDataProviderProtocol: Sendable { func getHeader(hash: Data32) async throws -> HeaderRef? -// func getWorkReport(hash: Data32) async throws -> WorkReportRef? + func getGuaranteedWorkReport(hash: Data32) async throws -> GuaranteedWorkReportRef? func getBlock(hash: Data32) async throws -> BlockRef? @@ -29,7 +29,7 @@ public protocol BlockchainDataProviderProtocol: Sendable { /// return empty set if not found func getBlockHash(byNumber number: UInt32) async throws -> Set -// func addWorkReport(workReport: WorkReportRef) async throws + func add(guaranteedWorkReport: GuaranteedWorkReportRef) async throws func add(block: BlockRef) async throws func add(state: StateRef) async throws func setFinalizedHead(hash: Data32) async throws diff --git a/Blockchain/Sources/Blockchain/BlockchainDataProvider/InMemoryDataProvider.swift b/Blockchain/Sources/Blockchain/BlockchainDataProvider/InMemoryDataProvider.swift index 3f9c1b57..10f45059 100644 --- a/Blockchain/Sources/Blockchain/BlockchainDataProvider/InMemoryDataProvider.swift +++ b/Blockchain/Sources/Blockchain/BlockchainDataProvider/InMemoryDataProvider.swift @@ -22,6 +22,16 @@ public actor InMemoryDataProvider { } extension InMemoryDataProvider: BlockchainDataProviderProtocol { + public func hasGuaranteedWorkReport(hash _: Data32) async throws -> Bool { + true + } + + public func getGuaranteedWorkReport(hash _: Data32) async throws -> GuaranteedWorkReportRef? { + nil + } + + public func add(guaranteedWorkReport _: GuaranteedWorkReportRef) async throws {} + public func getKeys(prefix: Data32, count: UInt32, startKey: Data32?, blockHash: Data32?) async throws -> [String] { guard let stateRef = try getState(hash: blockHash ?? genesisBlockHash) else { return [] diff --git a/Blockchain/Sources/Blockchain/Types/GuaranteedWorkReport.swift b/Blockchain/Sources/Blockchain/Types/GuaranteedWorkReport.swift new file mode 100644 index 00000000..2f4b8c72 --- /dev/null +++ b/Blockchain/Sources/Blockchain/Types/GuaranteedWorkReport.swift @@ -0,0 +1,44 @@ +import Codec +import Foundation +import Utils + +public struct GuaranteedWorkReport: Sendable, Equatable, Codable, Hashable { + public let workReport: WorkReport + public let slot: UInt32 + public let signatures: [ValidatorSignature] + + public init( + workReport: WorkReport, + slot: UInt32, + signatures: [ValidatorSignature] + ) { + self.workReport = workReport + self.slot = slot + self.signatures = signatures + } +} + +extension GuaranteedWorkReport: Hashable32 { + public func hash() -> Data32 { + try! JamEncoder.encode(self).blake2b256hash() + } +} + +extension GuaranteedWorkReport: Dummy { + public typealias Config = ProtocolConfigRef + public static func dummy(config: Config) -> GuaranteedWorkReport { + GuaranteedWorkReport( + workReport: WorkReport.dummy(config: config), + slot: 0, + signatures: [] + ) + } +} + +extension GuaranteedWorkReport { + public func asRef() -> GuaranteedWorkReportRef { + GuaranteedWorkReportRef(self) + } +} + +public typealias GuaranteedWorkReportRef = RefWithHash diff --git a/Blockchain/Sources/Blockchain/Types/WorkReportRef.swift b/Blockchain/Sources/Blockchain/Types/WorkReportRef.swift deleted file mode 100644 index 5a452384..00000000 --- a/Blockchain/Sources/Blockchain/Types/WorkReportRef.swift +++ /dev/null @@ -1,44 +0,0 @@ -import Codec -import Foundation -import Utils - -public final class WorkReportRef: RefWithHash, @unchecked Sendable { - public var packageSpecification: AvailabilitySpecifications { value.packageSpecification } - public var refinementContext: RefinementContext { value.refinementContext } - public var coreIndex: CoreIndex { value.coreIndex } - public var authorizerHash: Data32 { value.authorizerHash } - public var authorizationOutput: Data { value.authorizationOutput } - public var lookup: [Data32: Data32] { value.lookup } - public var results: ConfigLimitedSizeArray { value.results } - public var authGasUsed: UInt { value.authGasUsed } - - override public var description: String { - "WorkReportRef(hash: \(hash), core: \(coreIndex), results: \(results.count), gas: \(authGasUsed))" - } - - public required init(_ workReport: WorkReport) { - super.init(workReport) - } -} - -extension WorkReportRef: Codable { - public convenience init(from decoder: Decoder) throws { - try self.init(WorkReport(from: decoder)) - } - - public func encode(to encoder: Encoder) throws { - try value.encode(to: encoder) - } -} - -extension WorkReportRef { - public func validate(config: ProtocolConfigRef) throws { - try value.validate(config: config) - } -} - -extension WorkReportRef { - public static func dummy(config: ProtocolConfigRef) -> WorkReportRef { - WorkReportRef(WorkReport.dummy(config: config)) - } -} diff --git a/Blockchain/Sources/Blockchain/Validator/GuaranteeingService.swift b/Blockchain/Sources/Blockchain/Validator/GuaranteeingService.swift index ebe21000..be647d5c 100644 --- a/Blockchain/Sources/Blockchain/Validator/GuaranteeingService.swift +++ b/Blockchain/Sources/Blockchain/Validator/GuaranteeingService.swift @@ -352,8 +352,8 @@ public final class GuaranteeingService: ServiceBase2, @unchecked Sendable, OnBef let currentTime = timeProvider.getTime() let timeslot = currentTime.timeToTimeslot(config: config) + 1 - logger.info("Generated work report", - metadata: ["reportHash": "\(workReportHash)", "timeslot": "\(timeslot)", "signatures": "\(sigs.count)"]) + logger.debug("Generated work report", + metadata: ["reportHash": "\(workReportHash)", "timeslot": "\(timeslot)", "signatures": "\(sigs.count)"]) // Distribute the guaranteed work-report to all current validators publish(RuntimeEvents.WorkReportGenerated( diff --git a/Database/Sources/Database/RocksDBBackend.swift b/Database/Sources/Database/RocksDBBackend.swift index 54396e37..baf70d56 100644 --- a/Database/Sources/Database/RocksDBBackend.swift +++ b/Database/Sources/Database/RocksDBBackend.swift @@ -72,6 +72,16 @@ public final class RocksDBBackend: Sendable { } extension RocksDBBackend: BlockchainDataProviderProtocol { + public func hasGuaranteedWorkReport(hash _: Data32) async throws -> Bool { + true + } + + public func getGuaranteedWorkReport(hash _: Data32) async throws -> GuaranteedWorkReportRef? { + nil + } + + public func add(guaranteedWorkReport _: GuaranteedWorkReportRef) async throws {} + public func getKeys(prefix: Data32, count: UInt32, startKey: Data32?, blockHash: Data32?) async throws -> [String] { logger.trace(""" getKeys() prefix: \(prefix), count: \(count), diff --git a/Node/Sources/Node/NetworkingProtocol/NetworkManager.swift b/Node/Sources/Node/NetworkingProtocol/NetworkManager.swift index 3eab44ea..58b42326 100644 --- a/Node/Sources/Node/NetworkingProtocol/NetworkManager.swift +++ b/Node/Sources/Node/NetworkingProtocol/NetworkManager.swift @@ -410,16 +410,15 @@ struct HandlerImpl: NetworkProtocolHandler { return [] case let .workReportRequest(message): blockchain.publish(event: RuntimeEvents.WorkReportRequestReceived(workReportHash: message.workReportHash)) -// let resp = try await blockchain.waitFor(RuntimeEvents.WorkReportRequestResponse.self) { event in -// message.workReportHash == event.workReportHash -// } -// switch resp.result { -// case let .success(workReport): -// return try [JamEncoder.encode(workReport)] -// case let .failure(error): -// throw error -// } - return [] + let resp = try await blockchain.waitFor(RuntimeEvents.WorkReportRequestResponse.self) { event in + message.workReportHash == event.workReportHash + } + switch resp.result { + case let .success(workReport): + return try [JamEncoder.encode(workReport)] + case let .failure(error): + throw error + } case let .shardDistribution(message): blockchain .publish(event: RuntimeEvents.ShardDistributionReceived(erasureRoot: message.erasureRoot, shardIndex: message.shardIndex)) diff --git a/Node/Tests/NodeTests/NetworkManagerTests.swift b/Node/Tests/NodeTests/NetworkManagerTests.swift index 6c848b77..786786e8 100644 --- a/Node/Tests/NodeTests/NetworkManagerTests.swift +++ b/Node/Tests/NodeTests/NetworkManagerTests.swift @@ -99,14 +99,12 @@ struct NetworkManagerTests { // Wait for event processing let events = await storeMiddleware.wait() - try await Task.sleep(for: .microseconds(100)) - // Verify network calls #expect( network.contain(calls: [ .init(function: "connect", parameters: ["address": devPeers.first!, "role": PeerRole.validator]), .init(function: "sendToPeer", parameters: [ - "peerId": PeerId(publicKey: key.ed25519.data.data, address: NetAddr(address: "127.0.0.1:5000")!), + "peerId": PeerId(publicKey: key.ed25519.data.data, address: devPeers.first!), "message": CERequest.workPackageSharing(.init( coreIndex: 1, segmentsRootMappings: segmentsRootMappings, @@ -116,8 +114,6 @@ struct NetworkManagerTests { ]), "network calls: \(network.calls)" ) - try await Task.sleep(for: .microseconds(200)) - let event = try #require(events.first { $0 is RuntimeEvents.WorkPackageBundleReceivedReply } as? RuntimeEvents .WorkPackageBundleReceivedReply) #expect(event.source == key.ed25519.data) From b187b979441b3f5efa50b7933e9cea4f2eee3c7f Mon Sep 17 00:00:00 2001 From: MacOMNI <414294494@qq.com> Date: Wed, 9 Apr 2025 15:56:43 +0800 Subject: [PATCH 11/54] update work report --- .../InMemoryDataProvider.swift | 14 +++++---- .../Types/GuaranteedWorkReport.swift | 2 -- .../Types/GuaranteedWorkReportRef.swift | 22 ++++++++++++++ .../BlockchainDataProviderTests.swift | 29 +++++++++++++++++++ .../Sources/Database/RocksDBBackend.swift | 16 ++++++---- Database/Sources/Database/Stores.swift | 3 ++ 6 files changed, 73 insertions(+), 13 deletions(-) create mode 100644 Blockchain/Sources/Blockchain/Types/GuaranteedWorkReportRef.swift diff --git a/Blockchain/Sources/Blockchain/BlockchainDataProvider/InMemoryDataProvider.swift b/Blockchain/Sources/Blockchain/BlockchainDataProvider/InMemoryDataProvider.swift index 10f45059..44f07143 100644 --- a/Blockchain/Sources/Blockchain/BlockchainDataProvider/InMemoryDataProvider.swift +++ b/Blockchain/Sources/Blockchain/BlockchainDataProvider/InMemoryDataProvider.swift @@ -9,6 +9,7 @@ public actor InMemoryDataProvider { private var blockByHash: [Data32: BlockRef] = [:] private var stateByBlockHash: [Data32: StateRef] = [:] private var hashByTimeslot: [TimeslotIndex: Set] = [:] + private var guaranteedWorkReports: [Data32: GuaranteedWorkReportRef] = [:] public let genesisBlockHash: Data32 public init(genesisState: StateRef, genesisBlock: BlockRef) async { @@ -22,15 +23,17 @@ public actor InMemoryDataProvider { } extension InMemoryDataProvider: BlockchainDataProviderProtocol { - public func hasGuaranteedWorkReport(hash _: Data32) async throws -> Bool { - true + public func hasGuaranteedWorkReport(hash: Data32) async throws -> Bool { + guaranteedWorkReports[hash] != nil } - public func getGuaranteedWorkReport(hash _: Data32) async throws -> GuaranteedWorkReportRef? { - nil + public func getGuaranteedWorkReport(hash: Data32) async throws -> GuaranteedWorkReportRef? { + guaranteedWorkReports[hash] } - public func add(guaranteedWorkReport _: GuaranteedWorkReportRef) async throws {} + public func add(guaranteedWorkReport: GuaranteedWorkReportRef) async throws { + guaranteedWorkReports[guaranteedWorkReport.value.workReport.hash()] = guaranteedWorkReport + } public func getKeys(prefix: Data32, count: UInt32, startKey: Data32?, blockHash: Data32?) async throws -> [String] { guard let stateRef = try getState(hash: blockHash ?? genesisBlockHash) else { @@ -130,6 +133,7 @@ extension InMemoryDataProvider: BlockchainDataProviderProtocol { let timeslot = blockByHash[hash]?.header.timeslot ?? stateByBlockHash[hash]?.value.timeslot stateByBlockHash.removeValue(forKey: hash) blockByHash.removeValue(forKey: hash) + guaranteedWorkReports.removeValue(forKey: hash) if let timeslot { hashByTimeslot[timeslot]?.remove(hash) diff --git a/Blockchain/Sources/Blockchain/Types/GuaranteedWorkReport.swift b/Blockchain/Sources/Blockchain/Types/GuaranteedWorkReport.swift index 2f4b8c72..7dc441c7 100644 --- a/Blockchain/Sources/Blockchain/Types/GuaranteedWorkReport.swift +++ b/Blockchain/Sources/Blockchain/Types/GuaranteedWorkReport.swift @@ -40,5 +40,3 @@ extension GuaranteedWorkReport { GuaranteedWorkReportRef(self) } } - -public typealias GuaranteedWorkReportRef = RefWithHash diff --git a/Blockchain/Sources/Blockchain/Types/GuaranteedWorkReportRef.swift b/Blockchain/Sources/Blockchain/Types/GuaranteedWorkReportRef.swift new file mode 100644 index 00000000..289f891e --- /dev/null +++ b/Blockchain/Sources/Blockchain/Types/GuaranteedWorkReportRef.swift @@ -0,0 +1,22 @@ +import Codec +import Foundation +import Utils + +public final class GuaranteedWorkReportRef: RefWithHash, @unchecked Sendable { + public var workReport: WorkReport { value.workReport } + public var slot: UInt32 { value.slot } + public var signatures: [ValidatorSignature] { value.signatures } + override public var description: String { + "GuaranteedWorkReport(hash: \(workReport.hash()), timeslot: \(slot))" + } +} + +extension GuaranteedWorkReportRef: Codable { + public convenience init(from decoder: Decoder) throws { + try self.init(.init(from: decoder)) + } + + public func encode(to encoder: Encoder) throws { + try value.encode(to: encoder) + } +} diff --git a/Blockchain/Tests/BlockchainTests/BlockchainDataProviderTests.swift b/Blockchain/Tests/BlockchainTests/BlockchainDataProviderTests.swift index 8b4320e0..8cc7f68e 100644 --- a/Blockchain/Tests/BlockchainTests/BlockchainDataProviderTests.swift +++ b/Blockchain/Tests/BlockchainTests/BlockchainDataProviderTests.swift @@ -185,4 +185,33 @@ struct BlockchainDataProviderTests { #expect(try await provider.hasBlock(hash: block.hash) == false) #expect(try await provider.hasState(hash: block.hash) == false) } + + @Test func guaranteedWorkReportOperations() async throws { + // Create a dummy work report and guaranteed work report + let workReport = WorkReport.dummy(config: config) + let guaranteedReport = GuaranteedWorkReport( + workReport: workReport, + slot: 1, + signatures: [] + ) + let reportRef = guaranteedReport.asRef() + + // Test adding and retrieving + try await provider.add(guaranteedWorkReport: reportRef) + + // Verify existence + #expect(try await provider.hasGuaranteedWorkReport(hash: reportRef.hash)) + + // Verify retrieval + let retrieved = try await provider.getGuaranteedWorkReport(hash: reportRef.hash) + #expect(retrieved?.hash == reportRef.hash) + } + + @Test func guaranteedWorkReportOperationsErrors() async throws { + let nonExistentHash = Data32.random() + // Test checking non-existent report + #expect(try await provider.hasGuaranteedWorkReport(hash: nonExistentHash) == false) + // Test getting non-existent report + #expect(try await provider.getGuaranteedWorkReport(hash: nonExistentHash) == nil) + } } diff --git a/Database/Sources/Database/RocksDBBackend.swift b/Database/Sources/Database/RocksDBBackend.swift index baf70d56..8761009c 100644 --- a/Database/Sources/Database/RocksDBBackend.swift +++ b/Database/Sources/Database/RocksDBBackend.swift @@ -24,6 +24,7 @@ public final class RocksDBBackend: Sendable { private let stateValue: Store> private let stateRefs: Store> private let stateRefsRaw: Store> + private let guaranteedWorkReports: Store> public let genesisBlockHash: Data32 @@ -40,7 +41,7 @@ public final class RocksDBBackend: Sendable { stateValue = Store(db: db, column: .state, coder: BinaryCoder(config: config, prefix: Data([1]))) stateRefs = Store(db: db, column: .stateRefs, coder: BinaryCoder(config: config, prefix: Data([0]))) stateRefsRaw = Store(db: db, column: .stateRefs, coder: BinaryCoder(config: config, prefix: Data([1]))) - + guaranteedWorkReports = Store(db: db, column: .guaranteedWorkReports, coder: JamCoder(config: config)) genesisBlockHash = genesisBlock.hash let genesis = try meta.get(key: MetaKey.genesisHash.key) @@ -72,15 +73,18 @@ public final class RocksDBBackend: Sendable { } extension RocksDBBackend: BlockchainDataProviderProtocol { - public func hasGuaranteedWorkReport(hash _: Data32) async throws -> Bool { - true + public func hasGuaranteedWorkReport(hash: Data32) async throws -> Bool { + try guaranteedWorkReports.exists(key: hash) } - public func getGuaranteedWorkReport(hash _: Data32) async throws -> GuaranteedWorkReportRef? { - nil + public func getGuaranteedWorkReport(hash: Data32) async throws -> GuaranteedWorkReportRef? { + try guaranteedWorkReports.get(key: hash) } - public func add(guaranteedWorkReport _: GuaranteedWorkReportRef) async throws {} + public func add(guaranteedWorkReport: GuaranteedWorkReportRef) async throws { + let hash = guaranteedWorkReport.hash + try guaranteedWorkReports.put(key: hash, value: guaranteedWorkReport) + } public func getKeys(prefix: Data32, count: UInt32, startKey: Data32?, blockHash: Data32?) async throws -> [String] { logger.trace(""" diff --git a/Database/Sources/Database/Stores.swift b/Database/Sources/Database/Stores.swift index 51c732c2..910234a2 100644 --- a/Database/Sources/Database/Stores.swift +++ b/Database/Sources/Database/Stores.swift @@ -23,6 +23,9 @@ enum StoreId: UInt8, ColumnFamilyKey { // 0x00 + node hash => ref count // 0x01 + value hash => ref count case stateRefs = 4 + // guaranteedWorkReports + // workReportHash => guaranteedWorkReport + case guaranteedWorkReports = 5 } enum MetaKey: UInt8 { From 8d6087c26cc979945f704de871e4e77e17a97a59 Mon Sep 17 00:00:00 2001 From: MacOMNI <414294494@qq.com> Date: Wed, 9 Apr 2025 16:58:48 +0800 Subject: [PATCH 12/54] update db --- Database/Sources/Database/RocksDBBackend.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Database/Sources/Database/RocksDBBackend.swift b/Database/Sources/Database/RocksDBBackend.swift index 8761009c..1cfc8752 100644 --- a/Database/Sources/Database/RocksDBBackend.swift +++ b/Database/Sources/Database/RocksDBBackend.swift @@ -225,7 +225,7 @@ extension RocksDBBackend: BlockchainDataProviderProtocol { // TODO: batch delete try blocks.delete(key: hash) - + try guaranteedWorkReports.delete(key: hash) if let block = try await getBlock(hash: hash) { try blockHashByTimeslot.delete(key: block.header.timeslot) } From 876bc86ee630a0eb23fcd6f1a737154b066d2b0a Mon Sep 17 00:00:00 2001 From: MacOMNI <414294494@qq.com> Date: Thu, 10 Apr 2025 17:00:00 +0800 Subject: [PATCH 13/54] update OnSyncCompleted --- .../RuntimeProtocols/RuntimeEvents.swift | 17 ----------------- .../Validator/DataAvailabilityService.swift | 13 ++++++++++++- .../Validator/GuaranteeingService.swift | 8 ++++++++ .../CommonEphemeral/CERequest.swift | 14 +++++++------- .../NetworkingProtocol/NetworkManager.swift | 18 ++++++------------ Node/Sources/Node/StreamKind.swift | 2 +- Node/Tests/NodeTests/NetworkManagerTests.swift | 17 ++++------------- 7 files changed, 38 insertions(+), 51 deletions(-) diff --git a/Blockchain/Sources/Blockchain/RuntimeProtocols/RuntimeEvents.swift b/Blockchain/Sources/Blockchain/RuntimeProtocols/RuntimeEvents.swift index 4429fbe8..a7e7b6f0 100644 --- a/Blockchain/Sources/Blockchain/RuntimeProtocols/RuntimeEvents.swift +++ b/Blockchain/Sources/Blockchain/RuntimeProtocols/RuntimeEvents.swift @@ -275,23 +275,6 @@ public enum RuntimeEvents { } } - // Response to work report request - public struct WorkReportRequestResponse: Event { - public var workReportHash: Data32 - - public let result: Result - - public init(workReportHash: Data32, workReport: WorkReport) { - self.workReportHash = workReportHash - result = .success(workReport) - } - - public init(workReportHash: Data32, error: Error) { - self.workReportHash = workReportHash - result = .failure(error) - } - } - public struct AuditShardRequestReceived: Event { public let erasureRoot: Data32 public let shardIndex: UInt32 diff --git a/Blockchain/Sources/Blockchain/Validator/DataAvailabilityService.swift b/Blockchain/Sources/Blockchain/Validator/DataAvailabilityService.swift index d90d571b..24f05aa1 100644 --- a/Blockchain/Sources/Blockchain/Validator/DataAvailabilityService.swift +++ b/Blockchain/Sources/Blockchain/Validator/DataAvailabilityService.swift @@ -16,9 +16,12 @@ public enum DataAvailabilityError: Error { case invalidSegmentsRoot case invalidDataLength case pagedProofsGenerationError + case invalidWorkReportSlot + case invalidWorkReport + case insufficientSignatures } -public final class DataAvailabilityService: ServiceBase2, @unchecked Sendable { +public final class DataAvailabilityService: ServiceBase2, @unchecked Sendable, OnSyncCompleted { private let dataProvider: BlockchainDataProvider private let dataStore: DataStore @@ -40,6 +43,14 @@ public final class DataAvailabilityService: ServiceBase2, @unchecked Sendable { } } + public func onSyncCompleted() async { + await subscribe(RuntimeEvents.WorkReportReceived.self, id: "DataAvailabilityService.WorkReportReceived") { [weak self] event in + await self?.handleWorkReportReceived(event) + } + } + + public func handleWorkReportReceived(_: RuntimeEvents.WorkReportReceived) async {} + /// Purge old data from the data availability stores /// - Parameter epoch: The current epoch index public func purge(epoch _: EpochIndex) async { diff --git a/Blockchain/Sources/Blockchain/Validator/GuaranteeingService.swift b/Blockchain/Sources/Blockchain/Validator/GuaranteeingService.swift index be647d5c..ef6566c2 100644 --- a/Blockchain/Sources/Blockchain/Validator/GuaranteeingService.swift +++ b/Blockchain/Sources/Blockchain/Validator/GuaranteeingService.swift @@ -355,6 +355,14 @@ public final class GuaranteeingService: ServiceBase2, @unchecked Sendable, OnBef logger.debug("Generated work report", metadata: ["reportHash": "\(workReportHash)", "timeslot": "\(timeslot)", "signatures": "\(sigs.count)"]) + // Save GuaranteedWorkReport to local db + try await dataProvider + .add(guaranteedWorkReport: + GuaranteedWorkReportRef(GuaranteedWorkReport( + workReport: workReport, + slot: timeslot, + signatures: sigs + ))) // Distribute the guaranteed work-report to all current validators publish(RuntimeEvents.WorkReportGenerated( workReport: workReport, diff --git a/Node/Sources/Node/NetworkingProtocol/CommonEphemeral/CERequest.swift b/Node/Sources/Node/NetworkingProtocol/CommonEphemeral/CERequest.swift index f8e4cfec..903247f8 100644 --- a/Node/Sources/Node/NetworkingProtocol/CommonEphemeral/CERequest.swift +++ b/Node/Sources/Node/NetworkingProtocol/CommonEphemeral/CERequest.swift @@ -15,7 +15,7 @@ public enum CERequest: Sendable, Equatable, Hashable { case safroleTicket2(SafroleTicketMessage) case workPackageSubmission(WorkPackageSubmissionMessage) case workPackageSharing(WorkPackageSharingMessage) - case workReportDistrubution(WorkReportDistributionMessage) + case workReportDistribution(WorkReportDistributionMessage) case workReportRequest(WorkReportRequestMessage) case shardDistribution(ShardDistributionMessage) case auditShardRequest(AuditShardRequestMessage) @@ -45,7 +45,7 @@ extension CERequest: RequestProtocol { try message.encode() case let .workPackageSharing(message): try message.encode() - case let .workReportDistrubution(message): + case let .workReportDistribution(message): try message.encode() case let .workReportRequest(message): try message.encode() @@ -84,8 +84,8 @@ extension CERequest: RequestProtocol { .workPackageSubmission case .workPackageSharing: .workPackageSharing - case .workReportDistrubution: - .workReportDistrubution + case .workReportDistribution: + .workReportDistribution case .workReportRequest: .workReportRequest case .shardDistribution: @@ -123,7 +123,7 @@ extension CERequest: RequestProtocol { WorkPackageSubmissionMessage.self case .workPackageSharing: WorkPackageSharingMessage.self - case .workReportDistrubution: + case .workReportDistribution: WorkReportDistributionMessage.self case .workReportRequest: WorkReportRequestMessage.self @@ -168,9 +168,9 @@ extension CERequest: RequestProtocol { case .workPackageSharing: guard let message = data as? WorkPackageSharingMessage else { return nil } return .workPackageSharing(message) - case .workReportDistrubution: + case .workReportDistribution: guard let message = data as? WorkReportDistributionMessage else { return nil } - return .workReportDistrubution(message) + return .workReportDistribution(message) case .workReportRequest: guard let message = data as? WorkReportRequestMessage else { return nil } return .workReportRequest(message) diff --git a/Node/Sources/Node/NetworkingProtocol/NetworkManager.swift b/Node/Sources/Node/NetworkingProtocol/NetworkManager.swift index 58b42326..1fb835d1 100644 --- a/Node/Sources/Node/NetworkingProtocol/NetworkManager.swift +++ b/Node/Sources/Node/NetworkingProtocol/NetworkManager.swift @@ -274,10 +274,9 @@ public final class NetworkManager: Sendable { logger.trace("sending guaranteed work-report", metadata: ["slot": "\(event.slot)", "signatures": "\(event.signatures.count)"]) - await broadcast( to: .currentValidators, - message: .workReportDistrubution(.init( + message: .workReportDistribution(.init( workReport: event.workReport, slot: event.slot, signatures: event.signatures @@ -397,7 +396,7 @@ struct HandlerImpl: NetworkProtocolHandler { } let (workReportHash, signature) = try resp.result.get() return try [JamEncoder.encode(workReportHash, signature)] - case let .workReportDistrubution(message): + case let .workReportDistribution(message): blockchain .publish( event: RuntimeEvents @@ -409,16 +408,11 @@ struct HandlerImpl: NetworkProtocolHandler { ) return [] case let .workReportRequest(message): - blockchain.publish(event: RuntimeEvents.WorkReportRequestReceived(workReportHash: message.workReportHash)) - let resp = try await blockchain.waitFor(RuntimeEvents.WorkReportRequestResponse.self) { event in - message.workReportHash == event.workReportHash - } - switch resp.result { - case let .success(workReport): - return try [JamEncoder.encode(workReport)] - case let .failure(error): - throw error + let workReportRef = try await blockchain.dataProvider.getGuaranteedWorkReport(hash: message.workReportHash) + if let workReport = workReportRef { + return try [JamEncoder.encode(workReport.value)] } + return [] case let .shardDistribution(message): blockchain .publish(event: RuntimeEvents.ShardDistributionReceived(erasureRoot: message.erasureRoot, shardIndex: message.shardIndex)) diff --git a/Node/Sources/Node/StreamKind.swift b/Node/Sources/Node/StreamKind.swift index 8121f735..85d64065 100644 --- a/Node/Sources/Node/StreamKind.swift +++ b/Node/Sources/Node/StreamKind.swift @@ -11,7 +11,7 @@ public enum CommonEphemeralStreamKind: UInt8, StreamKindProtocol { case safroleTicket2 = 132 case workPackageSubmission = 133 case workPackageSharing = 134 - case workReportDistrubution = 135 + case workReportDistribution = 135 case workReportRequest = 136 case shardDistribution = 137 case auditShardRequest = 138 diff --git a/Node/Tests/NodeTests/NetworkManagerTests.swift b/Node/Tests/NodeTests/NetworkManagerTests.swift index 786786e8..50aeaece 100644 --- a/Node/Tests/NodeTests/NetworkManagerTests.swift +++ b/Node/Tests/NodeTests/NetworkManagerTests.swift @@ -339,7 +339,7 @@ struct NetworkManagerTests { let slot: UInt32 = 123 let signatures = [ValidatorSignature(validatorIndex: 0, signature: Ed25519Signature(repeating: 20))] - let distributionMessage = CERequest.workReportDistrubution(WorkReportDistributionMessage( + let distributionMessage = CERequest.workReportDistribution(WorkReportDistributionMessage( workReport: workReport, slot: slot, signatures: signatures @@ -376,19 +376,10 @@ struct NetworkManagerTests { let message = try WorkReportRequestMessage.decode(data: requestMessage.encode(), config: services.config) #expect(workReportHash == message.workReportHash) - _ = try await network.handler.handle(ceRequest: requestMessage) - - let events = await storeMiddleware.wait() - - let receivedEvent = events.first { - if let event = $0 as? RuntimeEvents.WorkReportRequestReceived { - return event.workReportHash == workReportHash - } - return false - } as? RuntimeEvents.WorkReportRequestReceived + let data = try await network.handler.handle(ceRequest: requestMessage) - let event = try #require(receivedEvent) - #expect(event.workReportHash == workReportHash) + await storeMiddleware.wait() + #expect(data == []) } @Test From b50d929df44a549a879f6dd580f2762e3c186877 Mon Sep 17 00:00:00 2001 From: MacOMNI <414294494@qq.com> Date: Fri, 11 Apr 2025 15:43:11 +0800 Subject: [PATCH 14/54] update networkmanager --- .../Blockchain/BlockchainServices.swift | 28 +++++++++++ .../RuntimeProtocols/RuntimeEvents.swift | 15 ++++++ .../Validator/DataAvailabilityService.swift | 47 ++++++++++++++++++- .../NetworkingProtocol/NetworkManager.swift | 8 ++++ .../Tests/NodeTests/NetworkManagerTests.swift | 18 ++----- 5 files changed, 101 insertions(+), 15 deletions(-) diff --git a/Blockchain/Sources/Blockchain/BlockchainServices.swift b/Blockchain/Sources/Blockchain/BlockchainServices.swift index 82f5676a..f866c51b 100644 --- a/Blockchain/Sources/Blockchain/BlockchainServices.swift +++ b/Blockchain/Sources/Blockchain/BlockchainServices.swift @@ -23,6 +23,9 @@ public class BlockchainServices: @unchecked Sendable { private var _guaranteeingService: GuaranteeingService? private weak var _guaranteeingServiceRef: GuaranteeingService? + private var _dataAvailabilityService: DataAvailabilityService? + private weak var _dataAvailabilityServiceRef: DataAvailabilityService? + private let schedulerService: ServiceBase2 public init( @@ -63,6 +66,7 @@ public class BlockchainServices: @unchecked Sendable { _blockchain = nil _blockAuthor = nil _guaranteeingService = nil + _dataAvailabilityService = nil if let _blockchainRef { fatalError("BlockchainServices: blockchain still alive. retain count: \(_getRetainCount(_blockchainRef))") @@ -75,6 +79,30 @@ public class BlockchainServices: @unchecked Sendable { if let _guaranteeingServiceRef { fatalError("BlockchainServices: guaranteeingService still alive. retain count: \(_getRetainCount(_guaranteeingServiceRef))") } + + if let _dataAvailabilityServiceRef { + fatalError( + "BlockchainServices: dataAvailabilityService still alive. retain count: \(_getRetainCount(_dataAvailabilityServiceRef))" + ) + } + } + + public var dataAvailabilityService: DataAvailabilityService { + get async { + if let _dataAvailabilityService { + return _dataAvailabilityService + } + _dataAvailabilityService = await DataAvailabilityService( + config: config, + eventBus: eventBus, + scheduler: scheduler, + dataProvider: dataProvider, + dataStore: dataStore + ) + _dataAvailabilityServiceRef = _dataAvailabilityService + await _dataAvailabilityService!.onSyncCompleted() + return _dataAvailabilityService! + } } public var blockchain: Blockchain { diff --git a/Blockchain/Sources/Blockchain/RuntimeProtocols/RuntimeEvents.swift b/Blockchain/Sources/Blockchain/RuntimeProtocols/RuntimeEvents.swift index a7e7b6f0..25594416 100644 --- a/Blockchain/Sources/Blockchain/RuntimeProtocols/RuntimeEvents.swift +++ b/Blockchain/Sources/Blockchain/RuntimeProtocols/RuntimeEvents.swift @@ -236,6 +236,21 @@ public enum RuntimeEvents { } } + public struct WorkReportReceivedResponse: Event { + public let workReportHash: Data32 + public let result: Result + + public init(workReportHash: Data32) { + self.workReportHash = workReportHash + result = .success(()) + } + + public init(workReportHash: Data32, error: Error) { + self.workReportHash = workReportHash + result = .failure(error) + } + } + public struct WorkReportRequestReceived: Event { public let workReportHash: Data32 diff --git a/Blockchain/Sources/Blockchain/Validator/DataAvailabilityService.swift b/Blockchain/Sources/Blockchain/Validator/DataAvailabilityService.swift index 24f05aa1..56d7990a 100644 --- a/Blockchain/Sources/Blockchain/Validator/DataAvailabilityService.swift +++ b/Blockchain/Sources/Blockchain/Validator/DataAvailabilityService.swift @@ -49,7 +49,9 @@ public final class DataAvailabilityService: ServiceBase2, @unchecked Sendable, O } } - public func handleWorkReportReceived(_: RuntimeEvents.WorkReportReceived) async {} + public func handleWorkReportReceived(_ event: RuntimeEvents.WorkReportReceived) async { + await workReportDistribution(workReport: event.workReport, slot: event.slot, signatures: event.signatures) + } /// Purge old data from the data availability stores /// - Parameter epoch: The current epoch index @@ -191,6 +193,49 @@ public final class DataAvailabilityService: ServiceBase2, @unchecked Sendable, O true } + // MARK: - Work-report Distribution (CE 135) + + public func workReportDistribution( + workReport: WorkReport, + slot: UInt32, + signatures: [ValidatorSignature] + ) async { + let hash = workReport.hash() + + do { + // verify slot + if await isSlotValid(slot) { + throw DataAvailabilityError.invalidWorkReportSlot + } + // verify signatures + try await validate(signatures: signatures) + + // store guaranteedWorkReport + let report = GuaranteedWorkReport( + workReport: workReport, + slot: slot, + signatures: signatures + ) + try await dataProvider.add(guaranteedWorkReport: GuaranteedWorkReportRef(report)) + // response success result + publish(RuntimeEvents.WorkReportReceivedResponse(workReportHash: hash)) + } catch { + publish(RuntimeEvents.WorkReportReceivedResponse(workReportHash: hash, error: error)) + } + } + + private func isSlotValid(_ slot: UInt32) async -> Bool { + let currentSlot = await dataProvider.bestHead.timeslot + return slot + 5 >= currentSlot && slot <= currentSlot + 3 + } + + private func validate(signatures: [ValidatorSignature]) async throws { + guard signatures.count >= 3 else { + throw DataAvailabilityError.insufficientSignatures + } + // TODO: more validates + } + // MARK: - Shard Distribution (CE 137) /// Distribute shards to validators diff --git a/Node/Sources/Node/NetworkingProtocol/NetworkManager.swift b/Node/Sources/Node/NetworkingProtocol/NetworkManager.swift index 1fb835d1..da272a22 100644 --- a/Node/Sources/Node/NetworkingProtocol/NetworkManager.swift +++ b/Node/Sources/Node/NetworkingProtocol/NetworkManager.swift @@ -397,6 +397,7 @@ struct HandlerImpl: NetworkProtocolHandler { let (workReportHash, signature) = try resp.result.get() return try [JamEncoder.encode(workReportHash, signature)] case let .workReportDistribution(message): + let hash = message.workReport.hash() blockchain .publish( event: RuntimeEvents @@ -406,6 +407,13 @@ struct HandlerImpl: NetworkProtocolHandler { signatures: message.signatures ) ) + + let resp = try await blockchain.waitFor(RuntimeEvents.WorkReportReceivedResponse.self) { event in + hash == event.workReportHash + } + if case let .failure(error) = resp.result { + throw error // failed + } return [] case let .workReportRequest(message): let workReportRef = try await blockchain.dataProvider.getGuaranteedWorkReport(hash: message.workReportHash) diff --git a/Node/Tests/NodeTests/NetworkManagerTests.swift b/Node/Tests/NodeTests/NetworkManagerTests.swift index 50aeaece..36a7c9b0 100644 --- a/Node/Tests/NodeTests/NetworkManagerTests.swift +++ b/Node/Tests/NodeTests/NetworkManagerTests.swift @@ -348,21 +348,11 @@ struct NetworkManagerTests { let message = try WorkReportDistributionMessage.decode(data: distributionMessage.encode(), config: services.config) #expect(slot == message.slot) - _ = try await network.handler.handle(ceRequest: distributionMessage) - - let events = await storeMiddleware.wait() + _ = await services.dataAvailabilityService - let receivedEvent = events.first { - if let event = $0 as? RuntimeEvents.WorkReportReceived { - return event.workReport.hash() == workReport.hash() - } - return false - } as? RuntimeEvents.WorkReportReceived - - let event = try #require(receivedEvent) - #expect(event.workReport == workReport) - #expect(event.slot == slot) - #expect(event.signatures == signatures) + await #expect(throws: Error.self) { + _ = try await network.handler.handle(ceRequest: distributionMessage) + } } @Test From 3925ab0e0939ae0b6cdf995563ec0d104775aac4 Mon Sep 17 00:00:00 2001 From: MacOMNI <414294494@qq.com> Date: Mon, 14 Apr 2025 09:43:41 +0800 Subject: [PATCH 15/54] update block request --- Blockchain/Sources/Blockchain/Blockchain.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Blockchain/Sources/Blockchain/Blockchain.swift b/Blockchain/Sources/Blockchain/Blockchain.swift index d7e36c3a..42a8e019 100644 --- a/Blockchain/Sources/Blockchain/Blockchain.swift +++ b/Blockchain/Sources/Blockchain/Blockchain.swift @@ -33,7 +33,10 @@ public final class Blockchain: ServiceBase, @unchecked Sendable { logger.debug("block already imported", metadata: ["hash": "\(block.hash)"]) return } - + // TODO: if current block is light + // check if dataProvider.hasGuaranteedWorkReport + // send workReportDistribution waiting for response + // save to full block try await withSpan("importBlock") { span in span.attributes.blockHash = block.hash.description From 0212d1333929e732073711bef15c5eea022e2f35 Mon Sep 17 00:00:00 2001 From: MacOMNI <414294494@qq.com> Date: Mon, 14 Apr 2025 10:30:14 +0800 Subject: [PATCH 16/54] update more tests --- .../Tests/BlockchainTests/BlockchainDataProviderTests.swift | 4 ++-- Database/Sources/Database/RocksDBBackend.swift | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Blockchain/Tests/BlockchainTests/BlockchainDataProviderTests.swift b/Blockchain/Tests/BlockchainTests/BlockchainDataProviderTests.swift index 8cc7f68e..f326fffc 100644 --- a/Blockchain/Tests/BlockchainTests/BlockchainDataProviderTests.swift +++ b/Blockchain/Tests/BlockchainTests/BlockchainDataProviderTests.swift @@ -200,10 +200,10 @@ struct BlockchainDataProviderTests { try await provider.add(guaranteedWorkReport: reportRef) // Verify existence - #expect(try await provider.hasGuaranteedWorkReport(hash: reportRef.hash)) + #expect(try await provider.hasGuaranteedWorkReport(hash: workReport.hash())) // Verify retrieval - let retrieved = try await provider.getGuaranteedWorkReport(hash: reportRef.hash) + let retrieved = try await provider.getGuaranteedWorkReport(hash: workReport.hash()) #expect(retrieved?.hash == reportRef.hash) } diff --git a/Database/Sources/Database/RocksDBBackend.swift b/Database/Sources/Database/RocksDBBackend.swift index 1cfc8752..fd2b8392 100644 --- a/Database/Sources/Database/RocksDBBackend.swift +++ b/Database/Sources/Database/RocksDBBackend.swift @@ -82,7 +82,7 @@ extension RocksDBBackend: BlockchainDataProviderProtocol { } public func add(guaranteedWorkReport: GuaranteedWorkReportRef) async throws { - let hash = guaranteedWorkReport.hash + let hash = guaranteedWorkReport.workReport.hash() try guaranteedWorkReports.put(key: hash, value: guaranteedWorkReport) } From fa89824d93a4a6ca362643e6169c7e6b7ded1baa Mon Sep 17 00:00:00 2001 From: MacOMNI <414294494@qq.com> Date: Mon, 14 Apr 2025 14:25:18 +0800 Subject: [PATCH 17/54] update open rpc --- Tools/Sources/Tools/OpenRPC.swift | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Tools/Sources/Tools/OpenRPC.swift b/Tools/Sources/Tools/OpenRPC.swift index 7b84a8d3..a5ec0538 100644 --- a/Tools/Sources/Tools/OpenRPC.swift +++ b/Tools/Sources/Tools/OpenRPC.swift @@ -74,7 +74,7 @@ func createSpecContent(type: Any.Type, name: String?) -> SpecContent { summary: nil, description: nil, required: required, - schema: getSchema(type: type).definition + schema: getSchema(type: type).definition() ) } } @@ -104,7 +104,7 @@ func getSchema(type: Any.Type) -> any JSONSchemaComponent { JSONObject { for field in info.properties { JSONProperty(key: field.name) { - getSchema(type: field.type) + JSONComponents.AnyComponent(getSchema(type: field.type)) } } }.title(getName(type: type)) @@ -197,7 +197,7 @@ extension Array: TypeDescription { } static var schema: any JSONSchemaComponent { - JSONArray().items { getSchema(type: Element.self) } + JSONArray { JSONComponents.AnyComponent(getSchema(type: Element.self)) } } } @@ -217,7 +217,7 @@ extension Set: TypeDescription { } static var schema: any JSONSchemaComponent { - JSONArray().items { getSchema(type: Element.self) } + JSONArray { JSONComponents.AnyComponent(getSchema(type: Element.self)) } } } @@ -231,7 +231,7 @@ extension LimitedSizeArray: TypeDescription { } static var schema: any JSONSchemaComponent { - JSONArray().items { getSchema(type: T.self) } + JSONArray { JSONComponents.AnyComponent(getSchema(type: T.self)) } } } @@ -241,7 +241,7 @@ extension ConfigLimitedSizeArray: TypeDescription { } static var schema: any JSONSchemaComponent { - JSONArray().items { getSchema(type: T.self) } + JSONArray { JSONComponents.AnyComponent(getSchema(type: T.self)) } } } From 413d1070bcd6c341191a3dfc98fc4c0e935de293 Mon Sep 17 00:00:00 2001 From: MacOMNI <414294494@qq.com> Date: Mon, 14 Apr 2025 15:41:47 +0800 Subject: [PATCH 18/54] fix some unstable tests --- Node/Tests/NodeTests/Mocks/MockNetwork.swift | 2 +- Node/Tests/NodeTests/NetworkManagerTests.swift | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Node/Tests/NodeTests/Mocks/MockNetwork.swift b/Node/Tests/NodeTests/Mocks/MockNetwork.swift index 9aea0242..1394f5d3 100644 --- a/Node/Tests/NodeTests/Mocks/MockNetwork.swift +++ b/Node/Tests/NodeTests/Mocks/MockNetwork.swift @@ -127,7 +127,7 @@ final class MockNetwork: NetworkProtocol { idx += 1 } - return idx == toCheck.count + return idx >= toCheck.count } } diff --git a/Node/Tests/NodeTests/NetworkManagerTests.swift b/Node/Tests/NodeTests/NetworkManagerTests.swift index 36a7c9b0..97b35eee 100644 --- a/Node/Tests/NodeTests/NetworkManagerTests.swift +++ b/Node/Tests/NodeTests/NetworkManagerTests.swift @@ -98,6 +98,7 @@ struct NetworkManagerTests { )) // Wait for event processing + try await Task.sleep(for: .milliseconds(2000)) let events = await storeMiddleware.wait() // Verify network calls #expect( @@ -114,6 +115,7 @@ struct NetworkManagerTests { ]), "network calls: \(network.calls)" ) + try await Task.sleep(for: .milliseconds(500)) let event = try #require(events.first { $0 is RuntimeEvents.WorkPackageBundleReceivedReply } as? RuntimeEvents .WorkPackageBundleReceivedReply) #expect(event.source == key.ed25519.data) From bfb8164cd0680a81bd900634728bbd0980331926 Mon Sep 17 00:00:00 2001 From: MacOMNI <414294494@qq.com> Date: Mon, 14 Apr 2025 16:20:05 +0800 Subject: [PATCH 19/54] fix some issues --- Tools/Sources/Tools/OpenRPC.swift | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Tools/Sources/Tools/OpenRPC.swift b/Tools/Sources/Tools/OpenRPC.swift index a5ec0538..08b0d155 100644 --- a/Tools/Sources/Tools/OpenRPC.swift +++ b/Tools/Sources/Tools/OpenRPC.swift @@ -100,19 +100,19 @@ func getSchema(type: Any.Type) -> any JSONSchemaComponent { let info = try! typeInfo(of: type) switch info.kind { case .struct, .class: - return build { - JSONObject { - for field in info.properties { - JSONProperty(key: field.name) { - JSONComponents.AnyComponent(getSchema(type: field.type)) - } - } - }.title(getName(type: type)) + let properties = info.properties.map { field -> any JSONPropertyComponent in + JSONProperty(key: field.name) { + getSchema(type: field.type) + } } - default: - return build { - JSONObject().title(getName(type: type)) + + return JSONObject { + JSONComponents.Group(components: properties) } + .title(getName(type: type)) + + default: + return JSONObject().title(getName(type: type)) } } From 4ff9b78ab18c7cbf585b45d276bbca0fdc00b9aa Mon Sep 17 00:00:00 2001 From: MacOMNI <414294494@qq.com> Date: Mon, 14 Apr 2025 17:59:49 +0800 Subject: [PATCH 20/54] fix open rpc --- Tools/Sources/Tools/OpenRPC.swift | 75 +++++++++++++++---------------- 1 file changed, 35 insertions(+), 40 deletions(-) diff --git a/Tools/Sources/Tools/OpenRPC.swift b/Tools/Sources/Tools/OpenRPC.swift index 08b0d155..b2adbffe 100644 --- a/Tools/Sources/Tools/OpenRPC.swift +++ b/Tools/Sources/Tools/OpenRPC.swift @@ -60,8 +60,19 @@ func build(@JSONSchemaBuilder _ content: () -> any JSONSchemaComponent) -> any J content() } +func wrapSchema(_ schema: any JSONSchemaComponent) -> some JSONSchemaComponent { + JSONSchemaComponentContainer(component: schema) +} + +struct JSONSchemaComponentContainer: JSONSchemaComponent { + let component: any JSONSchemaComponent + + func definition() -> JSONSchema { + component.definition() + } +} + func createSpecContent(type: Any.Type, name: String?) -> SpecContent { - // if it is optional if let type = type as? OptionalProtocol.Type { return createSpecContentInner(type: type.wrappedType, required: false) } else { @@ -81,7 +92,6 @@ func createSpecContent(type: Any.Type, name: String?) -> SpecContent { protocol TypeDescription { static var name: String { get } - static var schema: any JSONSchemaComponent { get } } @@ -102,14 +112,13 @@ func getSchema(type: Any.Type) -> any JSONSchemaComponent { case .struct, .class: let properties = info.properties.map { field -> any JSONPropertyComponent in JSONProperty(key: field.name) { - getSchema(type: field.type) + wrapSchema(getSchema(type: field.type)) } } return JSONObject { JSONComponents.Group(components: properties) - } - .title(getName(type: type)) + }.title(getName(type: type)) default: return JSONObject().title(getName(type: type)) @@ -127,33 +136,18 @@ extension Optional: TypeDescription { } extension Bool: TypeDescription { - static var name: String { - "Bool" - } - - static var schema: any JSONSchemaComponent { - JSONBoolean() - } + static var name: String { "Bool" } + static var schema: any JSONSchemaComponent { JSONBoolean() } } extension String: TypeDescription { - static var name: String { - "String" - } - - static var schema: any JSONSchemaComponent { - JSONString() - } + static var name: String { "String" } + static var schema: any JSONSchemaComponent { JSONString() } } extension BinaryInteger where Self: TypeDescription { - static var name: String { - String(describing: Self.self) - } - - static var schema: any JSONSchemaComponent { - JSONInteger() - } + static var name: String { String(describing: Self.self) } + static var schema: any JSONSchemaComponent { JSONInteger() } } extension Int8: TypeDescription {} @@ -168,14 +162,9 @@ extension UInt64: TypeDescription {} extension UInt: TypeDescription {} extension Data: TypeDescription { - static var name: String { - "Data" - } - + static var name: String { "Data" } static var schema: any JSONSchemaComponent { - JSONString() - .title(name) - .pattern("^0x[0-9a-fA-F]*$") + JSONString().title(name).pattern("^0x[0-9a-fA-F]*$") } } @@ -185,9 +174,7 @@ extension FixedSizeData: TypeDescription { } static var schema: any JSONSchemaComponent { - JSONString() - .title(name) - .pattern("^0x[0-9a-fA-F]{\(T.value * 2)}$") + JSONString().title(name).pattern("^0x[0-9a-fA-F]{\(T.value * 2)}$") } } @@ -197,7 +184,9 @@ extension Array: TypeDescription { } static var schema: any JSONSchemaComponent { - JSONArray { JSONComponents.AnyComponent(getSchema(type: Element.self)) } + JSONArray { + wrapSchema(getSchema(type: Element.self)) + } } } @@ -217,7 +206,9 @@ extension Set: TypeDescription { } static var schema: any JSONSchemaComponent { - JSONArray { JSONComponents.AnyComponent(getSchema(type: Element.self)) } + JSONArray { + wrapSchema(getSchema(type: Element.self)) + } } } @@ -231,7 +222,9 @@ extension LimitedSizeArray: TypeDescription { } static var schema: any JSONSchemaComponent { - JSONArray { JSONComponents.AnyComponent(getSchema(type: T.self)) } + JSONArray { + wrapSchema(getSchema(type: T.self)) + } } } @@ -241,7 +234,9 @@ extension ConfigLimitedSizeArray: TypeDescription { } static var schema: any JSONSchemaComponent { - JSONArray { JSONComponents.AnyComponent(getSchema(type: T.self)) } + JSONArray { + wrapSchema(getSchema(type: T.self)) + } } } From 2694049ae935aa509079e105a3fcaf9d4d984f7b Mon Sep 17 00:00:00 2001 From: MacOMNI <414294494@qq.com> Date: Mon, 14 Apr 2025 18:24:29 +0800 Subject: [PATCH 21/54] update OpenRPC --- Tools/Sources/Tools/OpenRPC.swift | 64 +++++++++++++------------------ 1 file changed, 26 insertions(+), 38 deletions(-) diff --git a/Tools/Sources/Tools/OpenRPC.swift b/Tools/Sources/Tools/OpenRPC.swift index b2adbffe..2c13ccad 100644 --- a/Tools/Sources/Tools/OpenRPC.swift +++ b/Tools/Sources/Tools/OpenRPC.swift @@ -31,7 +31,9 @@ struct OpenRPC: AsyncParsableCommand { name: h.method, summary: h.summary, description: nil, - params: h.requestType.types.enumerated().map { createSpecContent(type: $1, name: h.requestNames[safe: $0]) }, + params: h.requestType.types.enumerated().map { + createSpecContent(type: $1, name: h.requestNames[safe: $0]) + }, result: createSpecContent(type: h.responseType, name: nil), examples: nil ) @@ -60,18 +62,6 @@ func build(@JSONSchemaBuilder _ content: () -> any JSONSchemaComponent) -> any J content() } -func wrapSchema(_ schema: any JSONSchemaComponent) -> some JSONSchemaComponent { - JSONSchemaComponentContainer(component: schema) -} - -struct JSONSchemaComponentContainer: JSONSchemaComponent { - let component: any JSONSchemaComponent - - func definition() -> JSONSchema { - component.definition() - } -} - func createSpecContent(type: Any.Type, name: String?) -> SpecContent { if let type = type as? OptionalProtocol.Type { return createSpecContentInner(type: type.wrappedType, required: false) @@ -110,16 +100,13 @@ func getSchema(type: Any.Type) -> any JSONSchemaComponent { let info = try! typeInfo(of: type) switch info.kind { case .struct, .class: - let properties = info.properties.map { field -> any JSONPropertyComponent in - JSONProperty(key: field.name) { - wrapSchema(getSchema(type: field.type)) - } - } - return JSONObject { - JSONComponents.Group(components: properties) + for field in info.properties { + JSONProperty(key: field.name) { + getSchema(type: field.type) + } + } }.title(getName(type: type)) - default: return JSONObject().title(getName(type: type)) } @@ -164,17 +151,18 @@ extension UInt: TypeDescription {} extension Data: TypeDescription { static var name: String { "Data" } static var schema: any JSONSchemaComponent { - JSONString().title(name).pattern("^0x[0-9a-fA-F]*$") + JSONString() + .title(name) + .pattern("^0x[0-9a-fA-F]*$") } } extension FixedSizeData: TypeDescription { - static var name: String { - "Data\(T.value)" - } - + static var name: String { "Data\(T.value)" } static var schema: any JSONSchemaComponent { - JSONString().title(name).pattern("^0x[0-9a-fA-F]{\(T.value * 2)}$") + JSONString() + .title(name) + .pattern("^0x[0-9a-fA-F]{\(T.value * 2)}$") } } @@ -185,30 +173,30 @@ extension Array: TypeDescription { static var schema: any JSONSchemaComponent { JSONArray { - wrapSchema(getSchema(type: Element.self)) + JSONComponents.AnyComponent(getSchema(type: Element.self)) } } } -extension Dictionary: TypeDescription { +extension Set: TypeDescription { static var name: String { - "Dictionary<\(getName(type: Key.self)), \(getName(type: Value.self))>" + "Set<\(getName(type: Element.self))>" } static var schema: any JSONSchemaComponent { - JSONObject().title(name) + JSONArray { + JSONComponents.AnyComponent(getSchema(type: Element.self)) + } } } -extension Set: TypeDescription { +extension Dictionary: TypeDescription { static var name: String { - "Set<\(getName(type: Element.self))>" + "Dictionary<\(getName(type: Key.self)), \(getName(type: Value.self))>" } static var schema: any JSONSchemaComponent { - JSONArray { - wrapSchema(getSchema(type: Element.self)) - } + JSONObject().title(name) } } @@ -223,7 +211,7 @@ extension LimitedSizeArray: TypeDescription { static var schema: any JSONSchemaComponent { JSONArray { - wrapSchema(getSchema(type: T.self)) + JSONComponents.AnyComponent(getSchema(type: T.self)) } } } @@ -235,7 +223,7 @@ extension ConfigLimitedSizeArray: TypeDescription { static var schema: any JSONSchemaComponent { JSONArray { - wrapSchema(getSchema(type: T.self)) + JSONComponents.AnyComponent(getSchema(type: T.self)) } } } From 96c096986f712a6c3b6313d3c035d5933b0b76c9 Mon Sep 17 00:00:00 2001 From: MacOMNI <414294494@qq.com> Date: Tue, 15 Apr 2025 07:42:44 +0800 Subject: [PATCH 22/54] update OpenRPC --- Tools/Sources/Tools/OpenRPC.swift | 92 +++++++++++++++++-------------- 1 file changed, 50 insertions(+), 42 deletions(-) diff --git a/Tools/Sources/Tools/OpenRPC.swift b/Tools/Sources/Tools/OpenRPC.swift index 2c13ccad..bbb459e2 100644 --- a/Tools/Sources/Tools/OpenRPC.swift +++ b/Tools/Sources/Tools/OpenRPC.swift @@ -48,6 +48,8 @@ struct OpenRPC: AsyncParsableCommand { } } +// MARK: - Schema Generation Utilities + private protocol OptionalProtocol { static var wrappedType: Any.Type { get } } @@ -58,10 +60,6 @@ extension Optional: OptionalProtocol { } } -func build(@JSONSchemaBuilder _ content: () -> any JSONSchemaComponent) -> any JSONSchemaComponent { - content() -} - func createSpecContent(type: Any.Type, name: String?) -> SpecContent { if let type = type as? OptionalProtocol.Type { return createSpecContentInner(type: type.wrappedType, required: false) @@ -100,28 +98,25 @@ func getSchema(type: Any.Type) -> any JSONSchemaComponent { let info = try! typeInfo(of: type) switch info.kind { case .struct, .class: - return JSONObject { - for field in info.properties { - JSONProperty(key: field.name) { - getSchema(type: field.type) - } - } - }.title(getName(type: type)) + return buildObjectSchema(type: type, properties: info.properties) default: return JSONObject().title(getName(type: type)) } } -extension Optional: TypeDescription { - static var name: String { - "Optional<\(getName(type: Wrapped.self))>" - } - - static var schema: any JSONSchemaComponent { - getSchema(type: Wrapped.self) +private func buildObjectSchema(type: Any.Type, properties: [PropertyInfo]) -> any JSONSchemaComponent { + JSONObject { + for field in properties { + JSONProperty(key: field.name) { + getSchema(type: field.type) + } + } } + .title(getName(type: type)) } +// MARK: - Primitive Types Conformance + extension Bool: TypeDescription { static var name: String { "Bool" } static var schema: any JSONSchemaComponent { JSONBoolean() } @@ -132,6 +127,8 @@ extension String: TypeDescription { static var schema: any JSONSchemaComponent { JSONString() } } +// MARK: - Numeric Types Conformance + extension BinaryInteger where Self: TypeDescription { static var name: String { String(describing: Self.self) } static var schema: any JSONSchemaComponent { JSONInteger() } @@ -148,6 +145,8 @@ extension UInt32: TypeDescription {} extension UInt64: TypeDescription {} extension UInt: TypeDescription {} +// MARK: - Data Types Conformance + extension Data: TypeDescription { static var name: String { "Data" } static var schema: any JSONSchemaComponent { @@ -166,27 +165,28 @@ extension FixedSizeData: TypeDescription { } } +// MARK: - Collection Types Conformance + extension Array: TypeDescription { - static var name: String { - "Array<\(getName(type: Element.self))>" - } + static var name: String { "Array<\(getName(type: Element.self))>" } static var schema: any JSONSchemaComponent { JSONArray { - JSONComponents.AnyComponent(getSchema(type: Element.self)) + getSchema(type: Element.self) } + .title(name) } } extension Set: TypeDescription { - static var name: String { - "Set<\(getName(type: Element.self))>" - } + static var name: String { "Set<\(getName(type: Element.self))>" } static var schema: any JSONSchemaComponent { JSONArray { - JSONComponents.AnyComponent(getSchema(type: Element.self)) + getSchema(type: Element.self) } + .title(name) + .uniqueItems() } } @@ -196,44 +196,52 @@ extension Dictionary: TypeDescription { } static var schema: any JSONSchemaComponent { - JSONObject().title(name) + JSONObject() + .title(name) + .additionalProperties(getSchema(type: Value.self)) } } +// MARK: - Special Array Types Conformance + extension LimitedSizeArray: TypeDescription { static var name: String { - if minLength == maxLength { - "Array\(minLength)<\(getName(type: T.self))>" - } else { - "Array<\(getName(type: T.self))>[\(minLength) ..< \(maxLength)]" - } + minLength == maxLength + ? "Array\(minLength)<\(getName(type: T.self))>" + : "Array<\(getName(type: T.self))>[\(minLength)..<\(maxLength)]" } static var schema: any JSONSchemaComponent { JSONArray { - JSONComponents.AnyComponent(getSchema(type: T.self)) + getSchema(type: T.self) } + .title(name) + .minItems(minLength) + .maxItems(maxLength) } } extension ConfigLimitedSizeArray: TypeDescription { static var name: String { - "Array<\(getName(type: T.self))>[\(getName(type: TMinLength.self)) ..< \(getName(type: TMaxLength.self))]" + "Array<\(getName(type: T.self))>[\(getName(type: TMinLength.self))..<\(getName(type: TMaxLength.self))]" } static var schema: any JSONSchemaComponent { JSONArray { - JSONComponents.AnyComponent(getSchema(type: T.self)) + getSchema(type: T.self) } + .title(name) } } -extension Ref: TypeDescription { - static var name: String { - getName(type: T.self) - } +// MARK: - Optional and Reference Types Conformance - static var schema: any JSONSchemaComponent { - getSchema(type: T.self) - } +extension Optional: TypeDescription { + static var name: String { "Optional<\(getName(type: Wrapped.self))>" } + static var schema: any JSONSchemaComponent { getSchema(type: Wrapped.self) } +} + +extension Ref: TypeDescription { + static var name: String { getName(type: T.self) } + static var schema: any JSONSchemaComponent { getSchema(type: T.self) } } From 6cba5efd77d50152b85d6e68907dd113ef5d7446 Mon Sep 17 00:00:00 2001 From: MacOMNI <414294494@qq.com> Date: Tue, 15 Apr 2025 11:49:35 +0800 Subject: [PATCH 23/54] update open rpc --- Tools/Sources/Tools/OpenRPC.swift | 176 +++++++++++++++++------------- 1 file changed, 103 insertions(+), 73 deletions(-) diff --git a/Tools/Sources/Tools/OpenRPC.swift b/Tools/Sources/Tools/OpenRPC.swift index bbb459e2..140d0ae5 100644 --- a/Tools/Sources/Tools/OpenRPC.swift +++ b/Tools/Sources/Tools/OpenRPC.swift @@ -31,9 +31,7 @@ struct OpenRPC: AsyncParsableCommand { name: h.method, summary: h.summary, description: nil, - params: h.requestType.types.enumerated().map { - createSpecContent(type: $1, name: h.requestNames[safe: $0]) - }, + params: h.requestType.types.enumerated().map { createSpecContent(type: $1, name: h.requestNames[safe: $0]) }, result: createSpecContent(type: h.responseType, name: nil), examples: nil ) @@ -48,8 +46,6 @@ struct OpenRPC: AsyncParsableCommand { } } -// MARK: - Schema Generation Utilities - private protocol OptionalProtocol { static var wrappedType: Any.Type { get } } @@ -60,7 +56,33 @@ extension Optional: OptionalProtocol { } } +struct AnyJSONSchemaComponent: JSONSchemaComponent, @unchecked Sendable { + private let _schemaValue: [KeywordIdentifier: JSONValue] + private let _parse: @Sendable (JSONValue) -> Parsed + + init(wrapped component: Component) where Component.Output: Sendable { + _schemaValue = component.schemaValue + _parse = { value in + component.parse(value).map { $0 as Any } + } + } + + var schemaValue: [KeywordIdentifier: JSONValue] { + get { _schemaValue } + set {} + } + + func parse(_ value: JSONValue) -> Parsed { + _parse(value) + } +} + +func build(@JSONSchemaBuilder _ content: () -> any JSONSchemaComponent) -> any JSONSchemaComponent { + content() +} + func createSpecContent(type: Any.Type, name: String?) -> SpecContent { + // if it is optional if let type = type as? OptionalProtocol.Type { return createSpecContentInner(type: type.wrappedType, required: false) } else { @@ -80,6 +102,7 @@ func createSpecContent(type: Any.Type, name: String?) -> SpecContent { protocol TypeDescription { static var name: String { get } + static var schema: any JSONSchemaComponent { get } } @@ -98,40 +121,60 @@ func getSchema(type: Any.Type) -> any JSONSchemaComponent { let info = try! typeInfo(of: type) switch info.kind { case .struct, .class: - return buildObjectSchema(type: type, properties: info.properties) + return build { + JSONObject { + for field in info.properties { + JSONProperty(key: field.name) { + AnyJSONSchemaComponent(getSchema(type: field.type)) + } + } + }.title(getName(type: type)) + } default: - return JSONObject().title(getName(type: type)) + return build { + JSONObject().title(getName(type: type)) + } } } -private func buildObjectSchema(type: Any.Type, properties: [PropertyInfo]) -> any JSONSchemaComponent { - JSONObject { - for field in properties { - JSONProperty(key: field.name) { - getSchema(type: field.type) - } - } +extension Optional: TypeDescription { + static var name: String { + "Optional<\(getName(type: Wrapped.self))>" } - .title(getName(type: type)) -} -// MARK: - Primitive Types Conformance + static var schema: any JSONSchemaComponent { + getSchema(type: Wrapped.self) + } +} extension Bool: TypeDescription { - static var name: String { "Bool" } - static var schema: any JSONSchemaComponent { JSONBoolean() } + static var name: String { + "Bool" + } + + static var schema: any JSONSchemaComponent { + JSONBoolean() + } } extension String: TypeDescription { - static var name: String { "String" } - static var schema: any JSONSchemaComponent { JSONString() } -} + static var name: String { + "String" + } -// MARK: - Numeric Types Conformance + static var schema: any JSONSchemaComponent { + JSONString() + } +} extension BinaryInteger where Self: TypeDescription { - static var name: String { String(describing: Self.self) } - static var schema: any JSONSchemaComponent { JSONInteger() } + static var name: String { + String(describing: Self.self) + } + + static var schema: any JSONSchemaComponent { + JSONInteger() + } } extension Int8: TypeDescription {} @@ -145,10 +188,11 @@ extension UInt32: TypeDescription {} extension UInt64: TypeDescription {} extension UInt: TypeDescription {} -// MARK: - Data Types Conformance - extension Data: TypeDescription { - static var name: String { "Data" } + static var name: String { + "Data" + } + static var schema: any JSONSchemaComponent { JSONString() .title(name) @@ -157,7 +201,10 @@ extension Data: TypeDescription { } extension FixedSizeData: TypeDescription { - static var name: String { "Data\(T.value)" } + static var name: String { + "Data\(T.value)" + } + static var schema: any JSONSchemaComponent { JSONString() .title(name) @@ -165,83 +212,66 @@ extension FixedSizeData: TypeDescription { } } -// MARK: - Collection Types Conformance - extension Array: TypeDescription { - static var name: String { "Array<\(getName(type: Element.self))>" } + static var name: String { + "Array<\(getName(type: Element.self))>" + } static var schema: any JSONSchemaComponent { - JSONArray { - getSchema(type: Element.self) - } - .title(name) + JSONArray { AnyJSONSchemaComponent(getSchema(type: Element.self)) } } } -extension Set: TypeDescription { - static var name: String { "Set<\(getName(type: Element.self))>" } +extension Dictionary: TypeDescription { + static var name: String { + "Dictionary<\(getName(type: Key.self)), \(getName(type: Value.self))>" + } static var schema: any JSONSchemaComponent { - JSONArray { - getSchema(type: Element.self) - } - .title(name) - .uniqueItems() + JSONObject().title(name) } } -extension Dictionary: TypeDescription { +extension Set: TypeDescription { static var name: String { - "Dictionary<\(getName(type: Key.self)), \(getName(type: Value.self))>" + "Set<\(getName(type: Element.self))>" } static var schema: any JSONSchemaComponent { - JSONObject() - .title(name) - .additionalProperties(getSchema(type: Value.self)) + JSONArray { AnyJSONSchemaComponent(getSchema(type: Element.self)) } } } -// MARK: - Special Array Types Conformance - extension LimitedSizeArray: TypeDescription { static var name: String { - minLength == maxLength - ? "Array\(minLength)<\(getName(type: T.self))>" - : "Array<\(getName(type: T.self))>[\(minLength)..<\(maxLength)]" + if minLength == maxLength { + "Array\(minLength)<\(getName(type: T.self))>" + } else { + "Array<\(getName(type: T.self))>[\(minLength) ..< \(maxLength)]" + } } static var schema: any JSONSchemaComponent { - JSONArray { - getSchema(type: T.self) - } - .title(name) - .minItems(minLength) - .maxItems(maxLength) + JSONArray { AnyJSONSchemaComponent(getSchema(type: T.self)) } } } extension ConfigLimitedSizeArray: TypeDescription { static var name: String { - "Array<\(getName(type: T.self))>[\(getName(type: TMinLength.self))..<\(getName(type: TMaxLength.self))]" + "Array<\(getName(type: T.self))>[\(getName(type: TMinLength.self)) ..< \(getName(type: TMaxLength.self))]" } static var schema: any JSONSchemaComponent { - JSONArray { - getSchema(type: T.self) - } - .title(name) + JSONArray { AnyJSONSchemaComponent(getSchema(type: T.self)) } } } -// MARK: - Optional and Reference Types Conformance - -extension Optional: TypeDescription { - static var name: String { "Optional<\(getName(type: Wrapped.self))>" } - static var schema: any JSONSchemaComponent { getSchema(type: Wrapped.self) } -} - extension Ref: TypeDescription { - static var name: String { getName(type: T.self) } - static var schema: any JSONSchemaComponent { getSchema(type: T.self) } + static var name: String { + getName(type: T.self) + } + + static var schema: any JSONSchemaComponent { + getSchema(type: T.self) + } } From 223b7e77f9714368e3fad7a8acb21d6def7579f7 Mon Sep 17 00:00:00 2001 From: MacOMNI <414294494@qq.com> Date: Tue, 15 Apr 2025 11:54:30 +0800 Subject: [PATCH 24/54] update swiftlint --- Tools/Sources/Tools/OpenRPC.swift | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Tools/Sources/Tools/OpenRPC.swift b/Tools/Sources/Tools/OpenRPC.swift index 140d0ae5..8295d90d 100644 --- a/Tools/Sources/Tools/OpenRPC.swift +++ b/Tools/Sources/Tools/OpenRPC.swift @@ -67,10 +67,7 @@ struct AnyJSONSchemaComponent: JSONSchemaComponent, @unchecked Sendable { } } - var schemaValue: [KeywordIdentifier: JSONValue] { - get { _schemaValue } - set {} - } + var schemaValue: [KeywordIdentifier: JSONValue] { _schemaValue } func parse(_ value: JSONValue) -> Parsed { _parse(value) From 2a6476b2ae6397bff07d6a5dbd0d09ccb1454077 Mon Sep 17 00:00:00 2001 From: MacOMNI <414294494@qq.com> Date: Tue, 15 Apr 2025 14:20:23 +0800 Subject: [PATCH 25/54] update OpenRPC --- Tools/Sources/Tools/OpenRPC.swift | 112 +++++++++++++----------------- 1 file changed, 50 insertions(+), 62 deletions(-) diff --git a/Tools/Sources/Tools/OpenRPC.swift b/Tools/Sources/Tools/OpenRPC.swift index 8295d90d..17960010 100644 --- a/Tools/Sources/Tools/OpenRPC.swift +++ b/Tools/Sources/Tools/OpenRPC.swift @@ -31,7 +31,9 @@ struct OpenRPC: AsyncParsableCommand { name: h.method, summary: h.summary, description: nil, - params: h.requestType.types.enumerated().map { createSpecContent(type: $1, name: h.requestNames[safe: $0]) }, + params: h.requestType.types.enumerated().map { + createSpecContent(type: $1, name: h.requestNames[safe: $0]) + }, result: createSpecContent(type: h.responseType, name: nil), examples: nil ) @@ -46,6 +48,8 @@ struct OpenRPC: AsyncParsableCommand { } } +// MARK: - Optional Type Check + private protocol OptionalProtocol { static var wrappedType: Any.Type { get } } @@ -56,32 +60,43 @@ extension Optional: OptionalProtocol { } } +// MARK: - Type Erasure Wrapper + struct AnyJSONSchemaComponent: JSONSchemaComponent, @unchecked Sendable { + typealias Output = Any + private let _schemaValue: [KeywordIdentifier: JSONValue] private let _parse: @Sendable (JSONValue) -> Parsed - init(wrapped component: Component) where Component.Output: Sendable { + init(wrapped component: some JSONSchemaComponent) { _schemaValue = component.schemaValue - _parse = { value in - component.parse(value).map { $0 as Any } - } + _parse = { value in component.parse(value).map { $0 as Any } } } - var schemaValue: [KeywordIdentifier: JSONValue] { _schemaValue } + var schemaValue: [KeywordIdentifier: JSONValue] { + get { _schemaValue } + set { fatalError("schemaValue is read-only") } + } func parse(_ value: JSONValue) -> Parsed { _parse(value) } } +// 👇 Wrap helper for nicer syntax +func wrap(_ schema: any JSONSchemaComponent) -> AnyJSONSchemaComponent { + .init(wrapped: schema) +} + +// MARK: - Builder helpers + func build(@JSONSchemaBuilder _ content: () -> any JSONSchemaComponent) -> any JSONSchemaComponent { content() } func createSpecContent(type: Any.Type, name: String?) -> SpecContent { - // if it is optional - if let type = type as? OptionalProtocol.Type { - return createSpecContentInner(type: type.wrappedType, required: false) + if let optionalType = type as? OptionalProtocol.Type { + return createSpecContentInner(type: optionalType.wrappedType, required: false) } else { return createSpecContentInner(type: type, required: true) } @@ -97,32 +112,34 @@ func createSpecContent(type: Any.Type, name: String?) -> SpecContent { } } +// MARK: - Type Descriptions + protocol TypeDescription { static var name: String { get } - static var schema: any JSONSchemaComponent { get } } func getName(type: Any.Type) -> String { - if let type = type as? TypeDescription.Type { - return type.name + if let t = type as? TypeDescription.Type { + return t.name } return String(describing: type) } func getSchema(type: Any.Type) -> any JSONSchemaComponent { - if let type = type as? TypeDescription.Type { - return type.schema + if let t = type as? TypeDescription.Type { + return t.schema } let info = try! typeInfo(of: type) + switch info.kind { case .struct, .class: return build { JSONObject { for field in info.properties { JSONProperty(key: field.name) { - AnyJSONSchemaComponent(getSchema(type: field.type)) + wrap(getSchema(type: field.type)) } } }.title(getName(type: type)) @@ -134,6 +151,8 @@ func getSchema(type: Any.Type) -> any JSONSchemaComponent { } } +// MARK: - Conformances + extension Optional: TypeDescription { static var name: String { "Optional<\(getName(type: Wrapped.self))>" @@ -145,33 +164,18 @@ extension Optional: TypeDescription { } extension Bool: TypeDescription { - static var name: String { - "Bool" - } - - static var schema: any JSONSchemaComponent { - JSONBoolean() - } + static var name: String { "Bool" } + static var schema: any JSONSchemaComponent { JSONBoolean() } } extension String: TypeDescription { - static var name: String { - "String" - } - - static var schema: any JSONSchemaComponent { - JSONString() - } + static var name: String { "String" } + static var schema: any JSONSchemaComponent { JSONString() } } extension BinaryInteger where Self: TypeDescription { - static var name: String { - String(describing: Self.self) - } - - static var schema: any JSONSchemaComponent { - JSONInteger() - } + static var name: String { String(describing: Self.self) } + static var schema: any JSONSchemaComponent { JSONInteger() } } extension Int8: TypeDescription {} @@ -186,36 +190,23 @@ extension UInt64: TypeDescription {} extension UInt: TypeDescription {} extension Data: TypeDescription { - static var name: String { - "Data" - } - + static var name: String { "Data" } static var schema: any JSONSchemaComponent { - JSONString() - .title(name) - .pattern("^0x[0-9a-fA-F]*$") + JSONString().title(name).pattern("^0x[0-9a-fA-F]*$") } } extension FixedSizeData: TypeDescription { - static var name: String { - "Data\(T.value)" - } - + static var name: String { "Data\(T.value)" } static var schema: any JSONSchemaComponent { - JSONString() - .title(name) - .pattern("^0x[0-9a-fA-F]{\(T.value * 2)}$") + JSONString().title(name).pattern("^0x[0-9a-fA-F]{\(T.value * 2)}$") } } extension Array: TypeDescription { - static var name: String { - "Array<\(getName(type: Element.self))>" - } - + static var name: String { "Array<\(getName(type: Element.self))>" } static var schema: any JSONSchemaComponent { - JSONArray { AnyJSONSchemaComponent(getSchema(type: Element.self)) } + JSONArray { wrap(getSchema(type: Element.self)) } } } @@ -235,7 +226,7 @@ extension Set: TypeDescription { } static var schema: any JSONSchemaComponent { - JSONArray { AnyJSONSchemaComponent(getSchema(type: Element.self)) } + JSONArray { wrap(getSchema(type: Element.self)) } } } @@ -249,7 +240,7 @@ extension LimitedSizeArray: TypeDescription { } static var schema: any JSONSchemaComponent { - JSONArray { AnyJSONSchemaComponent(getSchema(type: T.self)) } + JSONArray { wrap(getSchema(type: T.self)) } } } @@ -259,15 +250,12 @@ extension ConfigLimitedSizeArray: TypeDescription { } static var schema: any JSONSchemaComponent { - JSONArray { AnyJSONSchemaComponent(getSchema(type: T.self)) } + JSONArray { wrap(getSchema(type: T.self)) } } } extension Ref: TypeDescription { - static var name: String { - getName(type: T.self) - } - + static var name: String { getName(type: T.self) } static var schema: any JSONSchemaComponent { getSchema(type: T.self) } From d9c93bce943dd83177ee8481a406e099ee98a589 Mon Sep 17 00:00:00 2001 From: MacOMNI <414294494@qq.com> Date: Tue, 15 Apr 2025 14:30:04 +0800 Subject: [PATCH 26/54] update OpenRPC --- Tools/Sources/Tools/OpenRPC.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Tools/Sources/Tools/OpenRPC.swift b/Tools/Sources/Tools/OpenRPC.swift index 17960010..ec3a81d7 100644 --- a/Tools/Sources/Tools/OpenRPC.swift +++ b/Tools/Sources/Tools/OpenRPC.swift @@ -65,7 +65,7 @@ extension Optional: OptionalProtocol { struct AnyJSONSchemaComponent: JSONSchemaComponent, @unchecked Sendable { typealias Output = Any - private let _schemaValue: [KeywordIdentifier: JSONValue] + private var _schemaValue: [KeywordIdentifier: JSONValue] private let _parse: @Sendable (JSONValue) -> Parsed init(wrapped component: some JSONSchemaComponent) { @@ -75,7 +75,9 @@ struct AnyJSONSchemaComponent: JSONSchemaComponent, @unchecked Sendable { var schemaValue: [KeywordIdentifier: JSONValue] { get { _schemaValue } - set { fatalError("schemaValue is read-only") } + set { + _schemaValue = newValue + } } func parse(_ value: JSONValue) -> Parsed { From 81c2cd98ec9c86986c847cc0dfd09ee518d122df Mon Sep 17 00:00:00 2001 From: MacOMNI <414294494@qq.com> Date: Tue, 15 Apr 2025 15:07:00 +0800 Subject: [PATCH 27/54] update vapor --- RPC/Package.swift | 2 +- .../xcshareddata/swiftpm/Package.resolved | 33 +++++++------------ 2 files changed, 13 insertions(+), 22 deletions(-) diff --git a/RPC/Package.swift b/RPC/Package.swift index c55fd150..9ff0d2d5 100644 --- a/RPC/Package.swift +++ b/RPC/Package.swift @@ -18,7 +18,7 @@ let package = Package( dependencies: [ .package(path: "../Blockchain"), .package(path: "../Utils"), - .package(url: "https://github.com/vapor/vapor.git", from: "4.111.0"), + .package(url: "https://github.com/vapor/vapor.git", from: "4.106.0"), .package(url: "https://github.com/vapor/async-kit.git", from: "1.20.0"), .package(url: "https://github.com/apple/swift-testing.git", branch: "6.0.3"), diff --git a/boka.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/boka.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 7ab6c539..fe65a8a4 100644 --- a/boka.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/boka.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -1,5 +1,5 @@ { - "originHash" : "a665e9a8fd18c09063611f8c8d8375b6bc7fc9c3b56edf7c4923e3d0302506f0", + "originHash" : "020b2782bb26f1c964c6d3b6702f7a0fbff4acfdad3b8d68e0e2514fe32a5fef", "pins" : [ { "identity" : "async-channels", @@ -69,8 +69,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/vapor/multipart-kit.git", "state" : { - "revision" : "3498e60218e6003894ff95192d756e238c01f44e", - "version" : "4.7.1" + "revision" : "a31236f24bfd2ea2f520a74575881f6731d7ae68", + "version" : "4.7.0" } }, { @@ -172,22 +172,13 @@ "version" : "1.1.1" } }, - { - "identity" : "swift-http-structured-headers", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-http-structured-headers.git", - "state" : { - "revision" : "8e769facea6b7d46ea60e5e93635a384fd573480", - "version" : "1.2.1" - } - }, { "identity" : "swift-http-types", "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-http-types.git", + "location" : "https://github.com/apple/swift-http-types", "state" : { - "revision" : "a0a57e949a8903563aba4615869310c0ebf14c03", - "version" : "1.4.0" + "revision" : "ae67c8178eb46944fd85e4dc6dd970e1f3ed6ccd", + "version" : "1.3.0" } }, { @@ -231,8 +222,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-nio-extras.git", "state" : { - "revision" : "00f3f72d2f9942d0e2dc96057ab50a37ced150d4", - "version" : "1.25.0" + "revision" : "d1ead62745cc3269e482f1c51f27608057174379", + "version" : "1.24.0" } }, { @@ -240,8 +231,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-nio-http2.git", "state" : { - "revision" : "170f4ca06b6a9c57b811293cebcb96e81b661310", - "version" : "1.35.0" + "revision" : "b5f7062b60e4add1e8c343ba4eb8da2e324b3a94", + "version" : "1.34.0" } }, { @@ -249,8 +240,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-nio-ssl.git", "state" : { - "revision" : "0cc3528ff48129d64ab9cab0b1cd621634edfc6b", - "version" : "2.29.3" + "revision" : "7b84abbdcef69cc3be6573ac12440220789dcd69", + "version" : "2.27.2" } }, { From 438a454a332bc1ec11105dec9e3cace2c2e180bf Mon Sep 17 00:00:00 2001 From: MacOMNI <414294494@qq.com> Date: Tue, 15 Apr 2025 15:42:02 +0800 Subject: [PATCH 28/54] update vapor --- RPC/Package.swift | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/RPC/Package.swift b/RPC/Package.swift index 9ff0d2d5..cc338145 100644 --- a/RPC/Package.swift +++ b/RPC/Package.swift @@ -18,7 +18,7 @@ let package = Package( dependencies: [ .package(path: "../Blockchain"), .package(path: "../Utils"), - .package(url: "https://github.com/vapor/vapor.git", from: "4.106.0"), + .package(url: "https://github.com/vapor/vapor.git", from: "4.111.0"), .package(url: "https://github.com/vapor/async-kit.git", from: "1.20.0"), .package(url: "https://github.com/apple/swift-testing.git", branch: "6.0.3"), @@ -43,5 +43,6 @@ let package = Package( .product(name: "Testing", package: "swift-testing"), ] ), - ] + ], + swiftLanguageModes: [.version("6")] ) From c1a3f6ccfadc7f851a259e3b187d95aaff4a5a8b Mon Sep 17 00:00:00 2001 From: MacOMNI <414294494@qq.com> Date: Tue, 15 Apr 2025 20:10:14 +0800 Subject: [PATCH 29/54] fix unstable tests --- Node/Tests/NodeTests/NetworkManagerTests.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Node/Tests/NodeTests/NetworkManagerTests.swift b/Node/Tests/NodeTests/NetworkManagerTests.swift index 97b35eee..1f62cfa6 100644 --- a/Node/Tests/NodeTests/NetworkManagerTests.swift +++ b/Node/Tests/NodeTests/NetworkManagerTests.swift @@ -98,7 +98,10 @@ struct NetworkManagerTests { )) // Wait for event processing - try await Task.sleep(for: .milliseconds(2000)) + let startTime = Date() + while network.calls.count < 2, Date().timeIntervalSince(startTime) < 10.0 { + try await Task.sleep(for: .milliseconds(100)) + } let events = await storeMiddleware.wait() // Verify network calls #expect( @@ -115,7 +118,6 @@ struct NetworkManagerTests { ]), "network calls: \(network.calls)" ) - try await Task.sleep(for: .milliseconds(500)) let event = try #require(events.first { $0 is RuntimeEvents.WorkPackageBundleReceivedReply } as? RuntimeEvents .WorkPackageBundleReceivedReply) #expect(event.source == key.ed25519.data) From 8b8a7f516eed6f0f18fba9ed6032557756a2ddd0 Mon Sep 17 00:00:00 2001 From: MacOMNI <414294494@qq.com> Date: Tue, 15 Apr 2025 20:15:05 +0800 Subject: [PATCH 30/54] fix unstable tests --- Node/Tests/NodeTests/NetworkManagerTests.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Node/Tests/NodeTests/NetworkManagerTests.swift b/Node/Tests/NodeTests/NetworkManagerTests.swift index 1f62cfa6..54a90714 100644 --- a/Node/Tests/NodeTests/NetworkManagerTests.swift +++ b/Node/Tests/NodeTests/NetworkManagerTests.swift @@ -99,7 +99,7 @@ struct NetworkManagerTests { // Wait for event processing let startTime = Date() - while network.calls.count < 2, Date().timeIntervalSince(startTime) < 10.0 { + while network.calls.count < 3, Date().timeIntervalSince(startTime) < 10.0 { try await Task.sleep(for: .milliseconds(100)) } let events = await storeMiddleware.wait() From 812a01bf52a8008ac909c873df757812b1a97e78 Mon Sep 17 00:00:00 2001 From: MacOMNI <414294494@qq.com> Date: Wed, 16 Apr 2025 09:54:40 +0800 Subject: [PATCH 31/54] fix unstable tests --- Node/Tests/NodeTests/NetworkManagerTests.swift | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Node/Tests/NodeTests/NetworkManagerTests.swift b/Node/Tests/NodeTests/NetworkManagerTests.swift index 54a90714..44efe3c9 100644 --- a/Node/Tests/NodeTests/NetworkManagerTests.swift +++ b/Node/Tests/NodeTests/NetworkManagerTests.swift @@ -88,6 +88,8 @@ struct NetworkManagerTests { let expectedResp = try JamEncoder.encode(workReportHash, signature) network.state.write { $0.simulatedResponseData = [expectedResp] } + try await Task.sleep(for: .milliseconds(500)) + // Publish WorkPackagesReceived event await services.blockchain .publish(event: RuntimeEvents.WorkPackageBundleReady( @@ -98,10 +100,6 @@ struct NetworkManagerTests { )) // Wait for event processing - let startTime = Date() - while network.calls.count < 3, Date().timeIntervalSince(startTime) < 10.0 { - try await Task.sleep(for: .milliseconds(100)) - } let events = await storeMiddleware.wait() // Verify network calls #expect( From 6198b3e2cb8c267ca86c5b04b1a06f5cf90451da Mon Sep 17 00:00:00 2001 From: MacOMNI <414294494@qq.com> Date: Wed, 16 Apr 2025 16:28:26 +0800 Subject: [PATCH 32/54] update some issues --- .../Tests/NodeTests/NetworkManagerTests.swift | 32 ++++++------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/Node/Tests/NodeTests/NetworkManagerTests.swift b/Node/Tests/NodeTests/NetworkManagerTests.swift index 44efe3c9..084f5de3 100644 --- a/Node/Tests/NodeTests/NetworkManagerTests.swift +++ b/Node/Tests/NodeTests/NetworkManagerTests.swift @@ -86,10 +86,9 @@ struct NetworkManagerTests { let workReportHash = Data32(repeating: 2) let signature = Ed25519Signature(repeating: 3) let expectedResp = try JamEncoder.encode(workReportHash, signature) - network.state.write { $0.simulatedResponseData = [expectedResp] } - - try await Task.sleep(for: .milliseconds(500)) - + network.state.write { + $0.simulatedResponseData = [expectedResp] + } // Publish WorkPackagesReceived event await services.blockchain .publish(event: RuntimeEvents.WorkPackageBundleReady( @@ -98,26 +97,15 @@ struct NetworkManagerTests { bundle: bundle, segmentsRootMappings: segmentsRootMappings )) - // Wait for event processing let events = await storeMiddleware.wait() - // Verify network calls - #expect( - network.contain(calls: [ - .init(function: "connect", parameters: ["address": devPeers.first!, "role": PeerRole.validator]), - .init(function: "sendToPeer", parameters: [ - "peerId": PeerId(publicKey: key.ed25519.data.data, address: devPeers.first!), - "message": CERequest.workPackageSharing(.init( - coreIndex: 1, - segmentsRootMappings: segmentsRootMappings, - bundle: bundle - )), - ]), - ]), - "network calls: \(network.calls)" - ) - let event = try #require(events.first { $0 is RuntimeEvents.WorkPackageBundleReceivedReply } as? RuntimeEvents - .WorkPackageBundleReceivedReply) + var maxRetry = 20 + while network.calls.count < 3, maxRetry > 0 { + maxRetry -= 1 + try? await Task.sleep(for: .milliseconds(100)) + } + let event = events.first { $0 is RuntimeEvents.WorkPackageBundleReceivedReply } as! RuntimeEvents + .WorkPackageBundleReceivedReply #expect(event.source == key.ed25519.data) #expect(event.workReportHash == workReportHash) #expect(event.signature == signature) From de831e86b6fea1a0c0121441ba96a17d69450a88 Mon Sep 17 00:00:00 2001 From: MacOMNI <414294494@qq.com> Date: Wed, 16 Apr 2025 21:36:56 +0800 Subject: [PATCH 33/54] update networkmanager --- .../NetworkingProtocol/NetworkManager.swift | 3 +- .../Tests/NodeTests/NetworkManagerTests.swift | 84 ++++++++++--------- 2 files changed, 45 insertions(+), 42 deletions(-) diff --git a/Node/Sources/Node/NetworkingProtocol/NetworkManager.swift b/Node/Sources/Node/NetworkingProtocol/NetworkManager.swift index da272a22..af5abf3d 100644 --- a/Node/Sources/Node/NetworkingProtocol/NetworkManager.swift +++ b/Node/Sources/Node/NetworkingProtocol/NetworkManager.swift @@ -225,6 +225,7 @@ public final class NetworkManager: Sendable { private func on(workPackageBundleReady event: RuntimeEvents.WorkPackageBundleReady) async { await withSpan("NetworkManager.on(workPackageBundleReady)", logger: logger) { _ in let target = event.target + let resp = try await send(to: target, message: .workPackageSharing(.init( coreIndex: event.coreIndex, segmentsRootMappings: event.segmentsRootMappings, @@ -255,7 +256,7 @@ public final class NetworkManager: Sendable { let currentValidators = event.state.currentValidators let nextValidators = event.state.nextValidators let allValidators = Set([currentValidators.array, nextValidators.array].joined()) - + print("NetworkManager.onBeforeEpoch \(allValidators)") var peerIdByPublicKey: [Data32: PeerId] = [:] for validator in allValidators { if let addr = NetAddr(address: validator.metadataString) { diff --git a/Node/Tests/NodeTests/NetworkManagerTests.swift b/Node/Tests/NodeTests/NetworkManagerTests.swift index 084f5de3..9aa4cdec 100644 --- a/Node/Tests/NodeTests/NetworkManagerTests.swift +++ b/Node/Tests/NodeTests/NetworkManagerTests.swift @@ -86,8 +86,10 @@ struct NetworkManagerTests { let workReportHash = Data32(repeating: 2) let signature = Ed25519Signature(repeating: 3) let expectedResp = try JamEncoder.encode(workReportHash, signature) + await services.publishOnBeforeEpochEvent() network.state.write { $0.simulatedResponseData = [expectedResp] + $0.simulatedPeerRole = .validator } // Publish WorkPackagesReceived event await services.blockchain @@ -97,18 +99,18 @@ struct NetworkManagerTests { bundle: bundle, segmentsRootMappings: segmentsRootMappings )) + try? await Task.sleep(for: .milliseconds(1000)) + // Wait for event processing let events = await storeMiddleware.wait() - var maxRetry = 20 - while network.calls.count < 3, maxRetry > 0 { - maxRetry -= 1 - try? await Task.sleep(for: .milliseconds(100)) - } - let event = events.first { $0 is RuntimeEvents.WorkPackageBundleReceivedReply } as! RuntimeEvents + + #expect(network.calls.count == 3) + + let event = events.first { $0 is RuntimeEvents.WorkPackageBundleReceivedReply } as? RuntimeEvents .WorkPackageBundleReceivedReply - #expect(event.source == key.ed25519.data) - #expect(event.workReportHash == workReportHash) - #expect(event.signature == signature) + #expect(event?.source == key.ed25519.data) + #expect(event?.workReportHash == workReportHash) + #expect(event?.signature == signature) } @Test @@ -229,6 +231,38 @@ struct NetworkManagerTests { #expect(block.hash == services.genesisBlock.hash) } + @Test + func testWorkPackageBundleReadyInvalidResponse() async throws { + // Here, we configure the mock network to provide an empty response. + // That should trigger the "WorkPackageSharing response is invalid" path, + // preventing publication of a WorkPackageBundleReceivedReply event. + + network.state.write { $0.simulatedResponseData = [] } + + // Since the dev peer public key in the mock is all zeros, + // we'll use Data32(repeating: 0) for the target to avoid a peerNotFound error. + let target = Data32(repeating: 0) + let bundle = WorkPackageBundle.dummy(config: services.config) + let segmentsRootMappings = [SegmentsRootMapping( + workPackageHash: Data32(), + segmentsRoot: Data32() + )] + + await services.blockchain.publish(event: RuntimeEvents.WorkPackageBundleReady( + target: target, + coreIndex: 321, + bundle: bundle, + segmentsRootMappings: segmentsRootMappings + )) + + // Wait for async processing + let events = await storeMiddleware.wait() + let reply = events.first(where: { $0 is RuntimeEvents.WorkPackageBundleReceivedReply }) + + // Verify no event was published + #expect(reply == nil) + } + @Test func testHandleWorkPackageSubmission() async throws { // Create work package and extrinsics @@ -291,38 +325,6 @@ struct NetworkManagerTests { #expect(reply == nil) } - @Test - func testWorkPackageBundleReadyInvalidResponse() async throws { - // Here, we configure the mock network to provide an empty response. - // That should trigger the "WorkPackageSharing response is invalid" path, - // preventing publication of a WorkPackageBundleReceivedReply event. - - network.state.write { $0.simulatedResponseData = [] } - - // Since the dev peer public key in the mock is all zeros, - // we'll use Data32(repeating: 0) for the target to avoid a peerNotFound error. - let target = Data32(repeating: 0) - let bundle = WorkPackageBundle.dummy(config: services.config) - let segmentsRootMappings = [SegmentsRootMapping( - workPackageHash: Data32(), - segmentsRoot: Data32() - )] - - await services.blockchain.publish(event: RuntimeEvents.WorkPackageBundleReady( - target: target, - coreIndex: 321, - bundle: bundle, - segmentsRootMappings: segmentsRootMappings - )) - - // Wait for async processing - let events = await storeMiddleware.wait() - let reply = events.first(where: { $0 is RuntimeEvents.WorkPackageBundleReceivedReply }) - - // Verify no event was published - #expect(reply == nil) - } - @Test func testHandleWorkReportDistribution() async throws { let workReport = WorkReport.dummy(config: services.config) From 805bde6dfd5e786810a295cc35813e6c1c962a3c Mon Sep 17 00:00:00 2001 From: MacOMNI <414294494@qq.com> Date: Thu, 17 Apr 2025 07:06:51 +0800 Subject: [PATCH 34/54] update vapor --- RPC/Package.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RPC/Package.swift b/RPC/Package.swift index cc338145..6b8e87f8 100644 --- a/RPC/Package.swift +++ b/RPC/Package.swift @@ -18,7 +18,7 @@ let package = Package( dependencies: [ .package(path: "../Blockchain"), .package(path: "../Utils"), - .package(url: "https://github.com/vapor/vapor.git", from: "4.111.0"), + .package(url: "https://github.com/vapor/vapor.git", from: "4.106.0"), .package(url: "https://github.com/vapor/async-kit.git", from: "1.20.0"), .package(url: "https://github.com/apple/swift-testing.git", branch: "6.0.3"), From b4e1e6bbb490a062d4d2515c30c0f2ddd8dd23dd Mon Sep 17 00:00:00 2001 From: MacOMNI <414294494@qq.com> Date: Thu, 17 Apr 2025 09:30:55 +0800 Subject: [PATCH 35/54] update vapor --- RPC/Package.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RPC/Package.swift b/RPC/Package.swift index 6b8e87f8..8850b00b 100644 --- a/RPC/Package.swift +++ b/RPC/Package.swift @@ -18,7 +18,7 @@ let package = Package( dependencies: [ .package(path: "../Blockchain"), .package(path: "../Utils"), - .package(url: "https://github.com/vapor/vapor.git", from: "4.106.0"), + .package(url: "https://github.com/vapor/vapor.git", from: "4.114.1"), .package(url: "https://github.com/vapor/async-kit.git", from: "1.20.0"), .package(url: "https://github.com/apple/swift-testing.git", branch: "6.0.3"), From 245627277d788d9f6eecc567e4a767b271b230f9 Mon Sep 17 00:00:00 2001 From: MacOMNI <414294494@qq.com> Date: Thu, 17 Apr 2025 10:30:45 +0800 Subject: [PATCH 36/54] update rpc package --- RPC/Package.swift | 2 +- RPC/Tests/RPCTests/BuilderHandlersTests.swift | 2 +- RPC/Tests/RPCTests/ChainHandlesTests.swift | 12 ++++++------ RPC/Tests/RPCTests/KeystoreHandlersTests.swift | 6 +++--- RPC/Tests/RPCTests/StateHandlersTests.swift | 4 ++-- RPC/Tests/RPCTests/SystemHandlersTests.swift | 12 ++++++------ RPC/Tests/RPCTests/TelemetryHandlersTests.swift | 6 +++--- 7 files changed, 22 insertions(+), 22 deletions(-) diff --git a/RPC/Package.swift b/RPC/Package.swift index 8850b00b..6b8e87f8 100644 --- a/RPC/Package.swift +++ b/RPC/Package.swift @@ -18,7 +18,7 @@ let package = Package( dependencies: [ .package(path: "../Blockchain"), .package(path: "../Utils"), - .package(url: "https://github.com/vapor/vapor.git", from: "4.114.1"), + .package(url: "https://github.com/vapor/vapor.git", from: "4.106.0"), .package(url: "https://github.com/vapor/async-kit.git", from: "1.20.0"), .package(url: "https://github.com/apple/swift-testing.git", branch: "6.0.3"), diff --git a/RPC/Tests/RPCTests/BuilderHandlersTests.swift b/RPC/Tests/RPCTests/BuilderHandlersTests.swift index 91707a39..cc91dcfa 100644 --- a/RPC/Tests/RPCTests/BuilderHandlersTests.swift +++ b/RPC/Tests/RPCTests/BuilderHandlersTests.swift @@ -36,7 +36,7 @@ final class BuilderRPCControllerTests { let req = JSONRequest(jsonrpc: "2.0", method: "builder_submitWorkPackage", params: params, id: 0) var buffer = ByteBuffer() try buffer.writeJSONEncodable(req) - try await app.test(.POST, "/", headers: ["Content-Type": "application/json"], body: buffer) { res async in + try await app.testable().test(.POST, "/", headers: ["Content-Type": "application/json"], body: buffer) { res async in #expect(res.status == .ok) let resp = try? res.content.decode(JSONResponse.self, using: JSONDecoder()) #expect(resp?.result?.value as? JSON == .boolean(true)) diff --git a/RPC/Tests/RPCTests/ChainHandlesTests.swift b/RPC/Tests/RPCTests/ChainHandlesTests.swift index 85824b5b..e29173d0 100644 --- a/RPC/Tests/RPCTests/ChainHandlesTests.swift +++ b/RPC/Tests/RPCTests/ChainHandlesTests.swift @@ -72,10 +72,10 @@ final class ChainRPCControllerTests { let req = JSONRequest(jsonrpc: "2.0", method: "chain_getBlock", params: params, id: 1) var buffer = ByteBuffer() try buffer.writeJSONEncodable(req) - try await app.test(.POST, "/", headers: ["Content-Type": "application/json"], body: buffer) { res async in + try await app.testable().test(.POST, "/", headers: ["Content-Type": "application/json"], body: buffer) { res async in #expect(res.status == .ok) let resp = try! res.content.decode(JSONResponse.self, using: JSONDecoder()) - #expect(resp.result!.value != nil) + #expect(resp.result?.value != nil) } try await app.asyncShutdown() } @@ -87,10 +87,10 @@ final class ChainRPCControllerTests { let req = JSONRequest(jsonrpc: "2.0", method: "chain_getBlockHash", params: params, id: 2) var buffer = ByteBuffer() try buffer.writeJSONEncodable(req) - try await app.test(.POST, "/", headers: ["Content-Type": "application/json"], body: buffer) { res async in + try await app.testable().test(.POST, "/", headers: ["Content-Type": "application/json"], body: buffer) { res async in #expect(res.status == .ok) let resp = try! res.content.decode(JSONResponse.self, using: JSONDecoder()) - #expect(resp.result!.value != nil) + #expect(resp.result?.value != nil) } try await app.asyncShutdown() } @@ -100,7 +100,7 @@ final class ChainRPCControllerTests { let req = JSONRequest(jsonrpc: "2.0", method: "chain_getFinalizedHead", params: nil, id: 3) var buffer = ByteBuffer() try buffer.writeJSONEncodable(req) - try await app.test(.POST, "/", headers: ["Content-Type": "application/json"], body: buffer) { res async in + try await app.testable().test(.POST, "/", headers: ["Content-Type": "application/json"], body: buffer) { res async in #expect(res.status == .ok) let resp = try! res.content.decode(JSONResponse.self, using: JSONDecoder()) #expect(resp.result!.value != nil) @@ -115,7 +115,7 @@ final class ChainRPCControllerTests { let req = JSONRequest(jsonrpc: "2.0", method: "chain_getHeader", params: params, id: 4) var buffer = ByteBuffer() try buffer.writeJSONEncodable(req) - try await app.test(.POST, "/", headers: ["Content-Type": "application/json"], body: buffer) { res async in + try await app.testable().test(.POST, "/", headers: ["Content-Type": "application/json"], body: buffer) { res async in #expect(res.status == .ok) let resp = try! res.content.decode(JSONResponse.self, using: JSONDecoder()) #expect(resp.result!.value != nil) diff --git a/RPC/Tests/RPCTests/KeystoreHandlersTests.swift b/RPC/Tests/RPCTests/KeystoreHandlersTests.swift index ad35802b..17c85330 100644 --- a/RPC/Tests/RPCTests/KeystoreHandlersTests.swift +++ b/RPC/Tests/RPCTests/KeystoreHandlersTests.swift @@ -45,7 +45,7 @@ final class KeystoreHandlersTests { let req = JSONRequest(jsonrpc: "2.0", method: "keys_create", params: params, id: 0) var buffer = ByteBuffer() try buffer.writeJSONEncodable(req) - try await app.test(.POST, "/", headers: ["Content-Type": "application/json"], body: buffer) { res async in + try await app.testable().test(.POST, "/", headers: ["Content-Type": "application/json"], body: buffer) { res async in #expect(res.status == .ok) let resp = try? res.content.decode(JSONResponse.self, using: JSONDecoder()) #expect(resp?.result?.value is JSON) @@ -65,7 +65,7 @@ final class KeystoreHandlersTests { let req = JSONRequest(jsonrpc: "2.0", method: "keys_list", params: .array([]), id: 0) var buffer = ByteBuffer() try buffer.writeJSONEncodable(req) - try await app.test(.POST, "/", headers: ["Content-Type": "application/json"], body: buffer) { res async in + try await app.testable().test(.POST, "/", headers: ["Content-Type": "application/json"], body: buffer) { res async in #expect(res.status == .ok) let resp = try? res.content.decode(JSONResponse.self, using: JSONDecoder()) #expect((resp?.result?.value as! JSON).array!.count >= 2) @@ -81,7 +81,7 @@ final class KeystoreHandlersTests { let req = JSONRequest(jsonrpc: "2.0", method: "keys_hasKey", params: params, id: 0) var buffer = ByteBuffer() try buffer.writeJSONEncodable(req) - try await app.test(.POST, "/", headers: ["Content-Type": "application/json"], body: buffer) { res async in + try await app.testable().test(.POST, "/", headers: ["Content-Type": "application/json"], body: buffer) { res async in #expect(res.status == .ok) let resp = try? res.content.decode(JSONResponse.self, using: JSONDecoder()) #expect((resp?.result!.value as! JSON).bool == true) diff --git a/RPC/Tests/RPCTests/StateHandlersTests.swift b/RPC/Tests/RPCTests/StateHandlersTests.swift index 64c20ed5..9702a503 100644 --- a/RPC/Tests/RPCTests/StateHandlersTests.swift +++ b/RPC/Tests/RPCTests/StateHandlersTests.swift @@ -34,7 +34,7 @@ final class StateHandlersTests { let req = JSONRequest(jsonrpc: "2.0", method: "state_getKeys", params: params, id: 1) var buffer = ByteBuffer() try buffer.writeJSONEncodable(req) - try await app.test(.POST, "/", headers: ["Content-Type": "application/json"], body: buffer) { res async in + try await app.testable().test(.POST, "/", headers: ["Content-Type": "application/json"], body: buffer) { res async in #expect(res.status == .ok) let resp = try! res.content.decode(JSONResponse.self, using: JSONDecoder()) #expect(resp.result!.value != nil) @@ -49,7 +49,7 @@ final class StateHandlersTests { let req = JSONRequest(jsonrpc: "2.0", method: "state_getStorage", params: params, id: 2) var buffer = ByteBuffer() try buffer.writeJSONEncodable(req) - try await app.test(.POST, "/", headers: ["Content-Type": "application/json"], body: buffer) { res async in + try await app.testable().test(.POST, "/", headers: ["Content-Type": "application/json"], body: buffer) { res async in #expect(res.status == .ok) let resp = try! res.content.decode(JSONResponse.self, using: JSONDecoder()) #expect(resp.result!.value != nil) diff --git a/RPC/Tests/RPCTests/SystemHandlersTests.swift b/RPC/Tests/RPCTests/SystemHandlersTests.swift index 14baa069..628e57b4 100644 --- a/RPC/Tests/RPCTests/SystemHandlersTests.swift +++ b/RPC/Tests/RPCTests/SystemHandlersTests.swift @@ -53,7 +53,7 @@ final class SystemHandlersTests { let req = JSONRequest(jsonrpc: "2.0", method: "system_health", params: nil, id: 1) var buffer = ByteBuffer() try buffer.writeJSONEncodable(req) - try app.test(.POST, "/", headers: ["Content-Type": "application/json"], body: buffer) { res in + try app.testable().test(.POST, "/", headers: ["Content-Type": "application/json"], body: buffer) { res in #expect(res.status == .ok) let resp = try res.content.decode(JSONResponse.self, using: JSONDecoder()) #expect((resp.result!.value as! Utils.JSON).bool == true) @@ -64,7 +64,7 @@ final class SystemHandlersTests { let req = JSONRequest(jsonrpc: "2.0", method: "system_implementation", params: nil, id: 2) var buffer = ByteBuffer() try buffer.writeJSONEncodable(req) - try app.test(.POST, "/", headers: ["Content-Type": "application/json"], body: buffer) { res in + try app.testable().test(.POST, "/", headers: ["Content-Type": "application/json"], body: buffer) { res in #expect(res.status == .ok) let resp = try res.content.decode(JSONResponse.self, using: JSONDecoder()) #expect((resp.result!.value as! Utils.JSON).string == "Boka") @@ -75,7 +75,7 @@ final class SystemHandlersTests { let req = JSONRequest(jsonrpc: "2.0", method: "system_version", params: nil, id: 3) var buffer = ByteBuffer() try buffer.writeJSONEncodable(req) - try app.test(.POST, "/", headers: ["Content-Type": "application/json"], body: buffer) { res in + try app.testable().test(.POST, "/", headers: ["Content-Type": "application/json"], body: buffer) { res in #expect(res.status == .ok) let resp = try res.content.decode(JSONResponse.self, using: JSONDecoder()) #expect((resp.result!.value as! Utils.JSON).string == "0.0.1") @@ -86,7 +86,7 @@ final class SystemHandlersTests { let req = JSONRequest(jsonrpc: "2.0", method: "system_properties", params: nil, id: 4) var buffer = ByteBuffer() try buffer.writeJSONEncodable(req) - try app.test(.POST, "/", headers: ["Content-Type": "application/json"], body: buffer) { res in + try app.testable().test(.POST, "/", headers: ["Content-Type": "application/json"], body: buffer) { res in #expect(res.status == .ok) let resp = try res.content.decode(JSONResponse.self, using: JSONDecoder()) #expect(resp.result?.value != nil) @@ -97,7 +97,7 @@ final class SystemHandlersTests { let req = JSONRequest(jsonrpc: "2.0", method: "system_nodeRoles", params: nil, id: 5) var buffer = ByteBuffer() try buffer.writeJSONEncodable(req) - try app.test(.POST, "/", headers: ["Content-Type": "application/json"], body: buffer) { res in + try app.testable().test(.POST, "/", headers: ["Content-Type": "application/json"], body: buffer) { res in #expect(res.status == .ok) let resp = try res.content.decode(JSONResponse.self, using: JSONDecoder()) #expect((resp.result!.value as! Utils.JSON).array == []) @@ -108,7 +108,7 @@ final class SystemHandlersTests { let req = JSONRequest(jsonrpc: "2.0", method: "system_chain", params: nil, id: 6) var buffer = ByteBuffer() try buffer.writeJSONEncodable(req) - try app.test(.POST, "/", headers: ["Content-Type": "application/json"], body: buffer) { res in + try app.testable().test(.POST, "/", headers: ["Content-Type": "application/json"], body: buffer) { res in #expect(res.status == .ok) let resp = try res.content.decode(JSONResponse.self, using: JSONDecoder()) #expect((resp.result!.value as! Utils.JSON).string == "dev") diff --git a/RPC/Tests/RPCTests/TelemetryHandlersTests.swift b/RPC/Tests/RPCTests/TelemetryHandlersTests.swift index 195bae74..d7ea7b7e 100644 --- a/RPC/Tests/RPCTests/TelemetryHandlersTests.swift +++ b/RPC/Tests/RPCTests/TelemetryHandlersTests.swift @@ -41,7 +41,7 @@ final class TelemetryHandlersTests { let req = JSONRequest(jsonrpc: "2.0", method: "telemetry_name", params: nil, id: 1) var buffer = ByteBuffer() try buffer.writeJSONEncodable(req) - try app.test(.POST, "/", headers: ["Content-Type": "application/json"], body: buffer) { res in + try app.testable().test(.POST, "/", headers: ["Content-Type": "application/json"], body: buffer) { res in #expect(res.status == .ok) let resp = try res.content.decode(JSONResponse.self, using: JSONDecoder()) #expect((resp.result!.value as! Utils.JSON).string == "TestNode") @@ -52,7 +52,7 @@ final class TelemetryHandlersTests { let req = JSONRequest(jsonrpc: "2.0", method: "telemetry_peersCount", params: nil, id: 2) var buffer = ByteBuffer() try buffer.writeJSONEncodable(req) - try app.test(.POST, "/", headers: ["Content-Type": "application/json"], body: buffer) { res in + try app.testable().test(.POST, "/", headers: ["Content-Type": "application/json"], body: buffer) { res in #expect(res.status == .ok) let resp = try res.content.decode(JSONResponse.self, using: JSONDecoder()) #expect((resp.result!.value as! Utils.JSON).number == 42) @@ -63,7 +63,7 @@ final class TelemetryHandlersTests { let req = JSONRequest(jsonrpc: "2.0", method: "telemetry_networkKey", params: nil, id: 3) var buffer = ByteBuffer() try buffer.writeJSONEncodable(req) - try app.test(.POST, "/", headers: ["Content-Type": "application/json"], body: buffer) { res in + try app.testable().test(.POST, "/", headers: ["Content-Type": "application/json"], body: buffer) { res in #expect(res.status == .ok) let resp = try res.content.decode(JSONResponse.self, using: JSONDecoder()) #expect((resp.result!.value as! Utils.JSON).string == "Ed25519:TestKey") From 0ed4dbb606a1b000735aa1501a7668ee9a9a6b3e Mon Sep 17 00:00:00 2001 From: MacOMNI <414294494@qq.com> Date: Thu, 17 Apr 2025 11:17:47 +0800 Subject: [PATCH 37/54] update swift test --- Blockchain/Package.swift | 2 +- Boka/Package.swift | 2 +- Codec/Package.swift | 2 +- Database/Package.swift | 2 +- JAMTests/Package.swift | 2 +- Networking/Package.swift | 2 +- Node/Package.swift | 2 +- PolkaVM/Package.swift | 2 +- RPC/Package.swift | 3 +-- Utils/Package.resolved | 8 ++++---- Utils/Package.swift | 2 +- .../xcshareddata/swiftpm/Package.resolved | 8 ++++---- 12 files changed, 18 insertions(+), 19 deletions(-) diff --git a/Blockchain/Package.swift b/Blockchain/Package.swift index ee2f2f52..9f02304c 100644 --- a/Blockchain/Package.swift +++ b/Blockchain/Package.swift @@ -20,7 +20,7 @@ let package = Package( .package(path: "../Utils"), .package(path: "../TracingUtils"), .package(path: "../PolkaVM"), - .package(url: "https://github.com/apple/swift-testing.git", branch: "6.0.3"), + .package(url: "https://github.com/apple/swift-testing.git", branch: "0.10.0"), ], targets: [ // Targets are the basic building blocks of a package, defining a module or a test suite. diff --git a/Boka/Package.swift b/Boka/Package.swift index 59429639..35a89f20 100644 --- a/Boka/Package.swift +++ b/Boka/Package.swift @@ -14,7 +14,7 @@ let package = Package( .package(url: "https://github.com/slashmo/swift-otel.git", from: "0.9.0"), .package(url: "https://github.com/swift-server/swift-service-lifecycle.git", from: "2.6.0"), .package(url: "https://github.com/vapor/console-kit.git", from: "4.15.0"), - .package(url: "https://github.com/apple/swift-testing.git", branch: "6.0.3"), + .package(url: "https://github.com/apple/swift-testing.git", branch: "0.10.0"), .package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.5.0"), ], targets: [ diff --git a/Codec/Package.swift b/Codec/Package.swift index 1b3fcf01..c8cf459c 100644 --- a/Codec/Package.swift +++ b/Codec/Package.swift @@ -16,7 +16,7 @@ let package = Package( ), ], dependencies: [ - .package(url: "https://github.com/apple/swift-testing.git", branch: "6.0.3"), + .package(url: "https://github.com/apple/swift-testing.git", branch: "0.10.0"), ], targets: [ // Targets are the basic building blocks of a package, defining a module or a test suite. diff --git a/Database/Package.swift b/Database/Package.swift index 9d4d083f..e820ad24 100644 --- a/Database/Package.swift +++ b/Database/Package.swift @@ -19,7 +19,7 @@ let package = Package( .package(path: "../Blockchain"), .package(path: "../Codec"), .package(path: "../Utils"), - .package(url: "https://github.com/apple/swift-testing.git", branch: "6.0.3"), + .package(url: "https://github.com/apple/swift-testing.git", branch: "0.10.0"), ], targets: [ .target( diff --git a/JAMTests/Package.swift b/JAMTests/Package.swift index f1ea0cbc..99e636a5 100644 --- a/JAMTests/Package.swift +++ b/JAMTests/Package.swift @@ -21,7 +21,7 @@ let package = Package( .package(path: "../TracingUtils"), .package(path: "../Blockchain"), .package(path: "../PolkaVM"), - .package(url: "https://github.com/apple/swift-testing.git", branch: "6.0.3"), + .package(url: "https://github.com/apple/swift-testing.git", branch: "0.10.0"), ], targets: [ // Targets are the basic building blocks of a package, defining a module or a test suite. diff --git a/Networking/Package.swift b/Networking/Package.swift index b05f5221..ee9b929a 100644 --- a/Networking/Package.swift +++ b/Networking/Package.swift @@ -19,7 +19,7 @@ let package = Package( .package(path: "../Utils"), .package(url: "https://github.com/apple/swift-log.git", from: "1.6.0"), .package(url: "https://github.com/apple/swift-certificates.git", from: "1.5.0"), - .package(url: "https://github.com/apple/swift-testing.git", branch: "6.0.3"), + .package(url: "https://github.com/apple/swift-testing.git", branch: "0.10.0"), .package(url: "https://github.com/gh123man/Async-Channels.git", from: "1.0.2"), ], targets: [ diff --git a/Node/Package.swift b/Node/Package.swift index 9b22869b..a7a3e4d7 100644 --- a/Node/Package.swift +++ b/Node/Package.swift @@ -22,7 +22,7 @@ let package = Package( .package(path: "../TracingUtils"), .package(path: "../Utils"), .package(path: "../Database"), - .package(url: "https://github.com/apple/swift-testing.git", branch: "6.0.3"), + .package(url: "https://github.com/apple/swift-testing.git", branch: "0.10.0"), .package(url: "https://github.com/gh123man/Async-Channels.git", from: "1.0.2"), ], targets: [ diff --git a/PolkaVM/Package.swift b/PolkaVM/Package.swift index f3e61464..88e789e1 100644 --- a/PolkaVM/Package.swift +++ b/PolkaVM/Package.swift @@ -17,7 +17,7 @@ let package = Package( dependencies: [ .package(path: "../Utils"), .package(path: "../TracingUtils"), - .package(url: "https://github.com/apple/swift-testing.git", branch: "6.0.3"), + .package(url: "https://github.com/apple/swift-testing.git", branch: "0.10.0"), .package(url: "https://github.com/apple/swift-log.git", from: "1.6.0"), .package(url: "https://github.com/nicklockwood/LRUCache.git", from: "1.0.7"), ], diff --git a/RPC/Package.swift b/RPC/Package.swift index 6b8e87f8..2c07eed0 100644 --- a/RPC/Package.swift +++ b/RPC/Package.swift @@ -20,8 +20,7 @@ let package = Package( .package(path: "../Utils"), .package(url: "https://github.com/vapor/vapor.git", from: "4.106.0"), .package(url: "https://github.com/vapor/async-kit.git", from: "1.20.0"), - .package(url: "https://github.com/apple/swift-testing.git", branch: "6.0.3"), - + .package(url: "https://github.com/apple/swift-testing.git", branch: "0.10.0"), ], targets: [ // Targets are the basic building blocks of a package, defining a module or a test suite. diff --git a/Utils/Package.resolved b/Utils/Package.resolved index 1549cb9f..3cf0cc02 100644 --- a/Utils/Package.resolved +++ b/Utils/Package.resolved @@ -1,5 +1,5 @@ { - "originHash" : "0685a96f04661159428431b8747ce4f61898018d240efed51e5918b3894d1393", + "originHash" : "3af4fa15534a1d00e66459fc585003c2f7835023bebcf2a960f70e34d14438b2", "pins" : [ { "identity" : "blake2.swift", @@ -67,7 +67,7 @@ { "identity" : "swift-syntax", "kind" : "remoteSourceControl", - "location" : "https://github.com/swiftlang/swift-syntax.git", + "location" : "https://github.com/apple/swift-syntax.git", "state" : { "revision" : "0687f71944021d616d34d922343dcef086855920", "version" : "600.0.1" @@ -78,8 +78,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-testing.git", "state" : { - "branch" : "6.0.3", - "revision" : "18c42c19cac3fafd61cab1156d4088664b7424ae" + "branch" : "0.10.0", + "revision" : "69d59cfc76e5daf498ca61f5af409f594768eef9" } } ], diff --git a/Utils/Package.swift b/Utils/Package.swift index f58412a8..17386e22 100644 --- a/Utils/Package.swift +++ b/Utils/Package.swift @@ -20,7 +20,7 @@ let package = Package( .package(path: "../TracingUtils"), .package(url: "https://github.com/tesseract-one/Blake2.swift.git", from: "0.2.0"), .package(url: "https://github.com/apple/swift-crypto.git", "1.0.0" ..< "4.0.0"), - .package(url: "https://github.com/apple/swift-testing.git", branch: "6.0.3"), + .package(url: "https://github.com/apple/swift-testing.git", branch: "0.10.0"), .package(url: "https://github.com/apple/swift-numerics.git", branch: "main"), ], targets: [ diff --git a/boka.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/boka.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index fe65a8a4..d625cece 100644 --- a/boka.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/boka.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -1,5 +1,5 @@ { - "originHash" : "020b2782bb26f1c964c6d3b6702f7a0fbff4acfdad3b8d68e0e2514fe32a5fef", + "originHash" : "29f4f0920a303b91d3ab3d9a73e42e497b83eeafb0e20a02a020e5dbbc9bd47c", "pins" : [ { "identity" : "async-channels", @@ -301,7 +301,7 @@ { "identity" : "swift-syntax", "kind" : "remoteSourceControl", - "location" : "https://github.com/swiftlang/swift-syntax.git", + "location" : "https://github.com/apple/swift-syntax.git", "state" : { "revision" : "0687f71944021d616d34d922343dcef086855920", "version" : "600.0.1" @@ -321,8 +321,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-testing.git", "state" : { - "branch" : "6.0.3", - "revision" : "18c42c19cac3fafd61cab1156d4088664b7424ae" + "branch" : "0.10.0", + "revision" : "69d59cfc76e5daf498ca61f5af409f594768eef9" } }, { From c1f676982f9a19b4c2948ef67446c4416a86107c Mon Sep 17 00:00:00 2001 From: MacOMNI <414294494@qq.com> Date: Thu, 17 Apr 2025 12:38:59 +0800 Subject: [PATCH 38/54] update swift pm --- Blockchain/Package.swift | 2 +- Boka/Package.swift | 2 +- Codec/Package.swift | 2 +- Database/Package.swift | 2 +- JAMTests/Package.swift | 2 +- Networking/Package.swift | 2 +- Node/Package.swift | 2 +- PolkaVM/Package.swift | 2 +- RPC/Package.swift | 4 ++-- RPC/Tests/RPCTests/StateHandlersTests.swift | 4 ++-- Utils/Package.swift | 2 +- 11 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Blockchain/Package.swift b/Blockchain/Package.swift index 9f02304c..a5d3344b 100644 --- a/Blockchain/Package.swift +++ b/Blockchain/Package.swift @@ -20,7 +20,7 @@ let package = Package( .package(path: "../Utils"), .package(path: "../TracingUtils"), .package(path: "../PolkaVM"), - .package(url: "https://github.com/apple/swift-testing.git", branch: "0.10.0"), + .package(url: "https://github.com/apple/swift-testing.git", branch: "6.1"), ], targets: [ // Targets are the basic building blocks of a package, defining a module or a test suite. diff --git a/Boka/Package.swift b/Boka/Package.swift index 35a89f20..e46b3cc0 100644 --- a/Boka/Package.swift +++ b/Boka/Package.swift @@ -14,7 +14,7 @@ let package = Package( .package(url: "https://github.com/slashmo/swift-otel.git", from: "0.9.0"), .package(url: "https://github.com/swift-server/swift-service-lifecycle.git", from: "2.6.0"), .package(url: "https://github.com/vapor/console-kit.git", from: "4.15.0"), - .package(url: "https://github.com/apple/swift-testing.git", branch: "0.10.0"), + .package(url: "https://github.com/apple/swift-testing.git", branch: "6.1"), .package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.5.0"), ], targets: [ diff --git a/Codec/Package.swift b/Codec/Package.swift index c8cf459c..8ed78eca 100644 --- a/Codec/Package.swift +++ b/Codec/Package.swift @@ -16,7 +16,7 @@ let package = Package( ), ], dependencies: [ - .package(url: "https://github.com/apple/swift-testing.git", branch: "0.10.0"), + .package(url: "https://github.com/apple/swift-testing.git", branch: "6.1"), ], targets: [ // Targets are the basic building blocks of a package, defining a module or a test suite. diff --git a/Database/Package.swift b/Database/Package.swift index e820ad24..f549c362 100644 --- a/Database/Package.swift +++ b/Database/Package.swift @@ -19,7 +19,7 @@ let package = Package( .package(path: "../Blockchain"), .package(path: "../Codec"), .package(path: "../Utils"), - .package(url: "https://github.com/apple/swift-testing.git", branch: "0.10.0"), + .package(url: "https://github.com/apple/swift-testing.git", branch: "6.1"), ], targets: [ .target( diff --git a/JAMTests/Package.swift b/JAMTests/Package.swift index 99e636a5..3b74fb72 100644 --- a/JAMTests/Package.swift +++ b/JAMTests/Package.swift @@ -21,7 +21,7 @@ let package = Package( .package(path: "../TracingUtils"), .package(path: "../Blockchain"), .package(path: "../PolkaVM"), - .package(url: "https://github.com/apple/swift-testing.git", branch: "0.10.0"), + .package(url: "https://github.com/apple/swift-testing.git", branch: "6.1"), ], targets: [ // Targets are the basic building blocks of a package, defining a module or a test suite. diff --git a/Networking/Package.swift b/Networking/Package.swift index ee9b929a..aa4e2679 100644 --- a/Networking/Package.swift +++ b/Networking/Package.swift @@ -19,7 +19,7 @@ let package = Package( .package(path: "../Utils"), .package(url: "https://github.com/apple/swift-log.git", from: "1.6.0"), .package(url: "https://github.com/apple/swift-certificates.git", from: "1.5.0"), - .package(url: "https://github.com/apple/swift-testing.git", branch: "0.10.0"), + .package(url: "https://github.com/apple/swift-testing.git", branch: "6.1"), .package(url: "https://github.com/gh123man/Async-Channels.git", from: "1.0.2"), ], targets: [ diff --git a/Node/Package.swift b/Node/Package.swift index a7a3e4d7..753b8355 100644 --- a/Node/Package.swift +++ b/Node/Package.swift @@ -22,7 +22,7 @@ let package = Package( .package(path: "../TracingUtils"), .package(path: "../Utils"), .package(path: "../Database"), - .package(url: "https://github.com/apple/swift-testing.git", branch: "0.10.0"), + .package(url: "https://github.com/apple/swift-testing.git", branch: "6.1"), .package(url: "https://github.com/gh123man/Async-Channels.git", from: "1.0.2"), ], targets: [ diff --git a/PolkaVM/Package.swift b/PolkaVM/Package.swift index 88e789e1..aaf50561 100644 --- a/PolkaVM/Package.swift +++ b/PolkaVM/Package.swift @@ -17,7 +17,7 @@ let package = Package( dependencies: [ .package(path: "../Utils"), .package(path: "../TracingUtils"), - .package(url: "https://github.com/apple/swift-testing.git", branch: "0.10.0"), + .package(url: "https://github.com/apple/swift-testing.git", branch: "6.1"), .package(url: "https://github.com/apple/swift-log.git", from: "1.6.0"), .package(url: "https://github.com/nicklockwood/LRUCache.git", from: "1.0.7"), ], diff --git a/RPC/Package.swift b/RPC/Package.swift index 2c07eed0..16e3cf17 100644 --- a/RPC/Package.swift +++ b/RPC/Package.swift @@ -18,9 +18,9 @@ let package = Package( dependencies: [ .package(path: "../Blockchain"), .package(path: "../Utils"), - .package(url: "https://github.com/vapor/vapor.git", from: "4.106.0"), + .package(url: "https://github.com/vapor/vapor.git", from: "4.114.1"), .package(url: "https://github.com/vapor/async-kit.git", from: "1.20.0"), - .package(url: "https://github.com/apple/swift-testing.git", branch: "0.10.0"), + .package(url: "https://github.com/apple/swift-testing.git", branch: "6.1"), ], targets: [ // Targets are the basic building blocks of a package, defining a module or a test suite. diff --git a/RPC/Tests/RPCTests/StateHandlersTests.swift b/RPC/Tests/RPCTests/StateHandlersTests.swift index 9702a503..e691f677 100644 --- a/RPC/Tests/RPCTests/StateHandlersTests.swift +++ b/RPC/Tests/RPCTests/StateHandlersTests.swift @@ -37,7 +37,7 @@ final class StateHandlersTests { try await app.testable().test(.POST, "/", headers: ["Content-Type": "application/json"], body: buffer) { res async in #expect(res.status == .ok) let resp = try! res.content.decode(JSONResponse.self, using: JSONDecoder()) - #expect(resp.result!.value != nil) + #expect(resp.result?.value != nil) } try await app.asyncShutdown() } @@ -52,7 +52,7 @@ final class StateHandlersTests { try await app.testable().test(.POST, "/", headers: ["Content-Type": "application/json"], body: buffer) { res async in #expect(res.status == .ok) let resp = try! res.content.decode(JSONResponse.self, using: JSONDecoder()) - #expect(resp.result!.value != nil) + #expect(resp.result?.value != nil) } try await app.asyncShutdown() } diff --git a/Utils/Package.swift b/Utils/Package.swift index 17386e22..2179554b 100644 --- a/Utils/Package.swift +++ b/Utils/Package.swift @@ -20,7 +20,7 @@ let package = Package( .package(path: "../TracingUtils"), .package(url: "https://github.com/tesseract-one/Blake2.swift.git", from: "0.2.0"), .package(url: "https://github.com/apple/swift-crypto.git", "1.0.0" ..< "4.0.0"), - .package(url: "https://github.com/apple/swift-testing.git", branch: "0.10.0"), + .package(url: "https://github.com/apple/swift-testing.git", branch: "6.1"), .package(url: "https://github.com/apple/swift-numerics.git", branch: "main"), ], targets: [ From b32f842583e9e39299db14e5cdb9a00249bb4f3c Mon Sep 17 00:00:00 2001 From: MacOMNI <414294494@qq.com> Date: Thu, 17 Apr 2025 13:10:04 +0800 Subject: [PATCH 39/54] update package --- RPC/Package.swift | 2 +- Utils/Package.resolved | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/RPC/Package.swift b/RPC/Package.swift index 16e3cf17..2560eb89 100644 --- a/RPC/Package.swift +++ b/RPC/Package.swift @@ -18,7 +18,7 @@ let package = Package( dependencies: [ .package(path: "../Blockchain"), .package(path: "../Utils"), - .package(url: "https://github.com/vapor/vapor.git", from: "4.114.1"), + .package(url: "https://github.com/vapor/vapor.git", branch: "4.113.0"), .package(url: "https://github.com/vapor/async-kit.git", from: "1.20.0"), .package(url: "https://github.com/apple/swift-testing.git", branch: "6.1"), ], diff --git a/Utils/Package.resolved b/Utils/Package.resolved index 3cf0cc02..d1be45e0 100644 --- a/Utils/Package.resolved +++ b/Utils/Package.resolved @@ -1,5 +1,5 @@ { - "originHash" : "3af4fa15534a1d00e66459fc585003c2f7835023bebcf2a960f70e34d14438b2", + "originHash" : "58cf105575b46ad7fba6c2a1e8924751af596842a801a9c8d41493126bb7ca1a", "pins" : [ { "identity" : "blake2.swift", @@ -67,10 +67,10 @@ { "identity" : "swift-syntax", "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-syntax.git", + "location" : "https://github.com/swiftlang/swift-syntax.git", "state" : { - "revision" : "0687f71944021d616d34d922343dcef086855920", - "version" : "600.0.1" + "revision" : "f99ae8aa18f0cf0d53481901f88a0991dc3bd4a2", + "version" : "601.0.1" } }, { @@ -78,8 +78,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-testing.git", "state" : { - "branch" : "0.10.0", - "revision" : "69d59cfc76e5daf498ca61f5af409f594768eef9" + "branch" : "6.1", + "revision" : "43b6f88e2f2712e0f2a97e6acc75b55f22234299" } } ], From 54be47198f98709c77060c3401ce583e349bf2e9 Mon Sep 17 00:00:00 2001 From: MacOMNI <414294494@qq.com> Date: Thu, 17 Apr 2025 14:56:11 +0800 Subject: [PATCH 40/54] update swift testing --- Blockchain/Package.resolved | 4 ++-- Blockchain/Package.swift | 2 +- Boka/Package.swift | 2 +- Codec/Package.swift | 2 +- Database/Package.swift | 2 +- JAMTests/Package.swift | 2 +- Networking/Package.swift | 2 +- Node/Package.swift | 2 +- PolkaVM/Package.swift | 2 +- RPC/Package.swift | 4 ++-- Utils/Package.resolved | 10 +++++----- Utils/Package.swift | 2 +- 12 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Blockchain/Package.resolved b/Blockchain/Package.resolved index d93d6f5d..2a4fb336 100644 --- a/Blockchain/Package.resolved +++ b/Blockchain/Package.resolved @@ -1,5 +1,5 @@ { - "originHash" : "653eff92c0b101b13d9ec17170dd383380bf31cf51922af0915e8046af171eb5", + "originHash" : "70f026b0b2979b5824592ab2cbdf4ae1a235fd69ecef967a7fbc6585ba704548", "pins" : [ { "identity" : "blake2.swift", @@ -87,7 +87,7 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-testing.git", "state" : { - "branch" : "6.0.3", + "branch" : "release/6.0", "revision" : "18c42c19cac3fafd61cab1156d4088664b7424ae" } } diff --git a/Blockchain/Package.swift b/Blockchain/Package.swift index a5d3344b..d6eecdea 100644 --- a/Blockchain/Package.swift +++ b/Blockchain/Package.swift @@ -20,7 +20,7 @@ let package = Package( .package(path: "../Utils"), .package(path: "../TracingUtils"), .package(path: "../PolkaVM"), - .package(url: "https://github.com/apple/swift-testing.git", branch: "6.1"), + .package(url: "https://github.com/apple/swift-testing.git", branch: "release/6.0"), ], targets: [ // Targets are the basic building blocks of a package, defining a module or a test suite. diff --git a/Boka/Package.swift b/Boka/Package.swift index e46b3cc0..35a89f20 100644 --- a/Boka/Package.swift +++ b/Boka/Package.swift @@ -14,7 +14,7 @@ let package = Package( .package(url: "https://github.com/slashmo/swift-otel.git", from: "0.9.0"), .package(url: "https://github.com/swift-server/swift-service-lifecycle.git", from: "2.6.0"), .package(url: "https://github.com/vapor/console-kit.git", from: "4.15.0"), - .package(url: "https://github.com/apple/swift-testing.git", branch: "6.1"), + .package(url: "https://github.com/apple/swift-testing.git", branch: "0.10.0"), .package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.5.0"), ], targets: [ diff --git a/Codec/Package.swift b/Codec/Package.swift index 8ed78eca..a2a95da9 100644 --- a/Codec/Package.swift +++ b/Codec/Package.swift @@ -16,7 +16,7 @@ let package = Package( ), ], dependencies: [ - .package(url: "https://github.com/apple/swift-testing.git", branch: "6.1"), + .package(url: "https://github.com/apple/swift-testing.git", branch: "release/6.0"), ], targets: [ // Targets are the basic building blocks of a package, defining a module or a test suite. diff --git a/Database/Package.swift b/Database/Package.swift index f549c362..e820ad24 100644 --- a/Database/Package.swift +++ b/Database/Package.swift @@ -19,7 +19,7 @@ let package = Package( .package(path: "../Blockchain"), .package(path: "../Codec"), .package(path: "../Utils"), - .package(url: "https://github.com/apple/swift-testing.git", branch: "6.1"), + .package(url: "https://github.com/apple/swift-testing.git", branch: "0.10.0"), ], targets: [ .target( diff --git a/JAMTests/Package.swift b/JAMTests/Package.swift index 3b74fb72..99e636a5 100644 --- a/JAMTests/Package.swift +++ b/JAMTests/Package.swift @@ -21,7 +21,7 @@ let package = Package( .package(path: "../TracingUtils"), .package(path: "../Blockchain"), .package(path: "../PolkaVM"), - .package(url: "https://github.com/apple/swift-testing.git", branch: "6.1"), + .package(url: "https://github.com/apple/swift-testing.git", branch: "0.10.0"), ], targets: [ // Targets are the basic building blocks of a package, defining a module or a test suite. diff --git a/Networking/Package.swift b/Networking/Package.swift index aa4e2679..ee9b929a 100644 --- a/Networking/Package.swift +++ b/Networking/Package.swift @@ -19,7 +19,7 @@ let package = Package( .package(path: "../Utils"), .package(url: "https://github.com/apple/swift-log.git", from: "1.6.0"), .package(url: "https://github.com/apple/swift-certificates.git", from: "1.5.0"), - .package(url: "https://github.com/apple/swift-testing.git", branch: "6.1"), + .package(url: "https://github.com/apple/swift-testing.git", branch: "0.10.0"), .package(url: "https://github.com/gh123man/Async-Channels.git", from: "1.0.2"), ], targets: [ diff --git a/Node/Package.swift b/Node/Package.swift index 753b8355..a7a3e4d7 100644 --- a/Node/Package.swift +++ b/Node/Package.swift @@ -22,7 +22,7 @@ let package = Package( .package(path: "../TracingUtils"), .package(path: "../Utils"), .package(path: "../Database"), - .package(url: "https://github.com/apple/swift-testing.git", branch: "6.1"), + .package(url: "https://github.com/apple/swift-testing.git", branch: "0.10.0"), .package(url: "https://github.com/gh123man/Async-Channels.git", from: "1.0.2"), ], targets: [ diff --git a/PolkaVM/Package.swift b/PolkaVM/Package.swift index aaf50561..44fb3c8d 100644 --- a/PolkaVM/Package.swift +++ b/PolkaVM/Package.swift @@ -17,7 +17,7 @@ let package = Package( dependencies: [ .package(path: "../Utils"), .package(path: "../TracingUtils"), - .package(url: "https://github.com/apple/swift-testing.git", branch: "6.1"), + .package(url: "https://github.com/apple/swift-testing.git", branch: "release/6.0"), .package(url: "https://github.com/apple/swift-log.git", from: "1.6.0"), .package(url: "https://github.com/nicklockwood/LRUCache.git", from: "1.0.7"), ], diff --git a/RPC/Package.swift b/RPC/Package.swift index 2560eb89..52dd2da2 100644 --- a/RPC/Package.swift +++ b/RPC/Package.swift @@ -18,9 +18,9 @@ let package = Package( dependencies: [ .package(path: "../Blockchain"), .package(path: "../Utils"), - .package(url: "https://github.com/vapor/vapor.git", branch: "4.113.0"), + .package(url: "https://github.com/vapor/vapor.git", branch: "4.107.0"), .package(url: "https://github.com/vapor/async-kit.git", from: "1.20.0"), - .package(url: "https://github.com/apple/swift-testing.git", branch: "6.1"), + .package(url: "https://github.com/apple/swift-testing.git", branch: "6.0.0"), ], targets: [ // Targets are the basic building blocks of a package, defining a module or a test suite. diff --git a/Utils/Package.resolved b/Utils/Package.resolved index d1be45e0..06816716 100644 --- a/Utils/Package.resolved +++ b/Utils/Package.resolved @@ -1,5 +1,5 @@ { - "originHash" : "58cf105575b46ad7fba6c2a1e8924751af596842a801a9c8d41493126bb7ca1a", + "originHash" : "3847f043e8fc69c774b86676c165ce04729f02b98bdfdfe1c869bf7e3be10c62", "pins" : [ { "identity" : "blake2.swift", @@ -69,8 +69,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/swiftlang/swift-syntax.git", "state" : { - "revision" : "f99ae8aa18f0cf0d53481901f88a0991dc3bd4a2", - "version" : "601.0.1" + "revision" : "0687f71944021d616d34d922343dcef086855920", + "version" : "600.0.1" } }, { @@ -78,8 +78,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-testing.git", "state" : { - "branch" : "6.1", - "revision" : "43b6f88e2f2712e0f2a97e6acc75b55f22234299" + "branch" : "release/6.0", + "revision" : "18c42c19cac3fafd61cab1156d4088664b7424ae" } } ], diff --git a/Utils/Package.swift b/Utils/Package.swift index 2179554b..3e42360e 100644 --- a/Utils/Package.swift +++ b/Utils/Package.swift @@ -20,7 +20,7 @@ let package = Package( .package(path: "../TracingUtils"), .package(url: "https://github.com/tesseract-one/Blake2.swift.git", from: "0.2.0"), .package(url: "https://github.com/apple/swift-crypto.git", "1.0.0" ..< "4.0.0"), - .package(url: "https://github.com/apple/swift-testing.git", branch: "6.1"), + .package(url: "https://github.com/apple/swift-testing.git", branch: "release/6.0"), .package(url: "https://github.com/apple/swift-numerics.git", branch: "main"), ], targets: [ From 38f70dff80350f3f022ff0f7e467bbb36f0a822a Mon Sep 17 00:00:00 2001 From: MacOMNI <414294494@qq.com> Date: Fri, 18 Apr 2025 11:14:02 +0800 Subject: [PATCH 41/54] update more tests --- .../Validator/GuaranteeingService.swift | 3 --- Node/Package.swift | 2 +- .../Tests/NodeTests/NetworkManagerTests.swift | 22 ++++++++++++++++++- Node/Tests/NodeTests/NodeTests.swift | 5 +++++ 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/Blockchain/Sources/Blockchain/Validator/GuaranteeingService.swift b/Blockchain/Sources/Blockchain/Validator/GuaranteeingService.swift index ef6566c2..3b7c8fa5 100644 --- a/Blockchain/Sources/Blockchain/Validator/GuaranteeingService.swift +++ b/Blockchain/Sources/Blockchain/Validator/GuaranteeingService.swift @@ -352,9 +352,6 @@ public final class GuaranteeingService: ServiceBase2, @unchecked Sendable, OnBef let currentTime = timeProvider.getTime() let timeslot = currentTime.timeToTimeslot(config: config) + 1 - logger.debug("Generated work report", - metadata: ["reportHash": "\(workReportHash)", "timeslot": "\(timeslot)", "signatures": "\(sigs.count)"]) - // Save GuaranteedWorkReport to local db try await dataProvider .add(guaranteedWorkReport: diff --git a/Node/Package.swift b/Node/Package.swift index a7a3e4d7..9b22869b 100644 --- a/Node/Package.swift +++ b/Node/Package.swift @@ -22,7 +22,7 @@ let package = Package( .package(path: "../TracingUtils"), .package(path: "../Utils"), .package(path: "../Database"), - .package(url: "https://github.com/apple/swift-testing.git", branch: "0.10.0"), + .package(url: "https://github.com/apple/swift-testing.git", branch: "6.0.3"), .package(url: "https://github.com/gh123man/Async-Channels.git", from: "1.0.2"), ], targets: [ diff --git a/Node/Tests/NodeTests/NetworkManagerTests.swift b/Node/Tests/NodeTests/NetworkManagerTests.swift index 9aa4cdec..0a73d343 100644 --- a/Node/Tests/NodeTests/NetworkManagerTests.swift +++ b/Node/Tests/NodeTests/NetworkManagerTests.swift @@ -329,8 +329,28 @@ struct NetworkManagerTests { func testHandleWorkReportDistribution() async throws { let workReport = WorkReport.dummy(config: services.config) let slot: UInt32 = 123 - let signatures = [ValidatorSignature(validatorIndex: 0, signature: Ed25519Signature(repeating: 20))] + let signature = ValidatorSignature(validatorIndex: 0, signature: Ed25519Signature(repeating: 20)) + let signatures = [signature, signature, signature] + let distributionMessage = CERequest.workReportDistribution(WorkReportDistributionMessage( + workReport: workReport, + slot: slot, + signatures: signatures + )) + + let message = try WorkReportDistributionMessage.decode(data: distributionMessage.encode(), config: services.config) + #expect(slot == message.slot) + _ = await services.dataAvailabilityService + let data = try await network.handler.handle(ceRequest: distributionMessage) + await storeMiddleware.wait() + #expect(data == []) + } + + @Test + func testHandleInvalidWorkReportDistribution() async throws { + let workReport = WorkReport.dummy(config: services.config) + let slot: UInt32 = 123 + let signatures = [ValidatorSignature(validatorIndex: 0, signature: Ed25519Signature(repeating: 20))] let distributionMessage = CERequest.workReportDistribution(WorkReportDistributionMessage( workReport: workReport, slot: slot, diff --git a/Node/Tests/NodeTests/NodeTests.swift b/Node/Tests/NodeTests/NodeTests.swift index 010f21e9..36d18162 100644 --- a/Node/Tests/NodeTests/NodeTests.swift +++ b/Node/Tests/NodeTests/NodeTests.swift @@ -85,6 +85,11 @@ final class NodeTests { await #expect(throws: StateBackendError.self) { _ = try await validatorNode.blockchain.dataProvider.getStorage(key: Data32.random(), blockHash: nil) } + let guaranteedWorkReport = GuaranteedWorkReport.dummy(config: .dev) + let hash = guaranteedWorkReport.workReport.hash() + try await validatorNode.blockchain.dataProvider.add(guaranteedWorkReport: GuaranteedWorkReportRef(guaranteedWorkReport)) + #expect(try await (validatorNode.blockchain.dataProvider.getGuaranteedWorkReport(hash: hash)) != nil) + #expect(try await validatorNode.blockchain.dataProvider.hasGuaranteedWorkReport(hash: hash) == true) } @Test func sync() async throws { From d3d277abcc797a6448347851a9f4eb47e8ec4ee3 Mon Sep 17 00:00:00 2001 From: MacOMNI <414294494@qq.com> Date: Mon, 21 Apr 2025 14:59:54 +0800 Subject: [PATCH 42/54] update swift testing --- Blockchain/Package.swift | 2 +- Boka/Package.swift | 2 +- Codec/Package.swift | 2 +- Database/Package.swift | 2 +- JAMTests/Package.swift | 2 +- Networking/Package.swift | 2 +- PolkaVM/Package.swift | 2 +- Utils/Package.swift | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Blockchain/Package.swift b/Blockchain/Package.swift index d6eecdea..9976fd04 100644 --- a/Blockchain/Package.swift +++ b/Blockchain/Package.swift @@ -20,7 +20,7 @@ let package = Package( .package(path: "../Utils"), .package(path: "../TracingUtils"), .package(path: "../PolkaVM"), - .package(url: "https://github.com/apple/swift-testing.git", branch: "release/6.0"), + .package(url: "https://github.com/apple/swift-testing.git", branch: "6.0.0"), ], targets: [ // Targets are the basic building blocks of a package, defining a module or a test suite. diff --git a/Boka/Package.swift b/Boka/Package.swift index 35a89f20..ca126167 100644 --- a/Boka/Package.swift +++ b/Boka/Package.swift @@ -14,7 +14,7 @@ let package = Package( .package(url: "https://github.com/slashmo/swift-otel.git", from: "0.9.0"), .package(url: "https://github.com/swift-server/swift-service-lifecycle.git", from: "2.6.0"), .package(url: "https://github.com/vapor/console-kit.git", from: "4.15.0"), - .package(url: "https://github.com/apple/swift-testing.git", branch: "0.10.0"), + .package(url: "https://github.com/apple/swift-testing.git", branch: "6.0.0"), .package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.5.0"), ], targets: [ diff --git a/Codec/Package.swift b/Codec/Package.swift index a2a95da9..6a0307fe 100644 --- a/Codec/Package.swift +++ b/Codec/Package.swift @@ -16,7 +16,7 @@ let package = Package( ), ], dependencies: [ - .package(url: "https://github.com/apple/swift-testing.git", branch: "release/6.0"), + .package(url: "https://github.com/apple/swift-testing.git", branch: "6.0.0"), ], targets: [ // Targets are the basic building blocks of a package, defining a module or a test suite. diff --git a/Database/Package.swift b/Database/Package.swift index e820ad24..ca635b23 100644 --- a/Database/Package.swift +++ b/Database/Package.swift @@ -19,7 +19,7 @@ let package = Package( .package(path: "../Blockchain"), .package(path: "../Codec"), .package(path: "../Utils"), - .package(url: "https://github.com/apple/swift-testing.git", branch: "0.10.0"), + .package(url: "https://github.com/apple/swift-testing.git", branch: "6.0.0"), ], targets: [ .target( diff --git a/JAMTests/Package.swift b/JAMTests/Package.swift index 99e636a5..8aff67c0 100644 --- a/JAMTests/Package.swift +++ b/JAMTests/Package.swift @@ -21,7 +21,7 @@ let package = Package( .package(path: "../TracingUtils"), .package(path: "../Blockchain"), .package(path: "../PolkaVM"), - .package(url: "https://github.com/apple/swift-testing.git", branch: "0.10.0"), + .package(url: "https://github.com/apple/swift-testing.git", branch: "6.0.0"), ], targets: [ // Targets are the basic building blocks of a package, defining a module or a test suite. diff --git a/Networking/Package.swift b/Networking/Package.swift index ee9b929a..87038171 100644 --- a/Networking/Package.swift +++ b/Networking/Package.swift @@ -19,7 +19,7 @@ let package = Package( .package(path: "../Utils"), .package(url: "https://github.com/apple/swift-log.git", from: "1.6.0"), .package(url: "https://github.com/apple/swift-certificates.git", from: "1.5.0"), - .package(url: "https://github.com/apple/swift-testing.git", branch: "0.10.0"), + .package(url: "https://github.com/apple/swift-testing.git", branch: "6.0.0"), .package(url: "https://github.com/gh123man/Async-Channels.git", from: "1.0.2"), ], targets: [ diff --git a/PolkaVM/Package.swift b/PolkaVM/Package.swift index 44fb3c8d..30ebea01 100644 --- a/PolkaVM/Package.swift +++ b/PolkaVM/Package.swift @@ -17,7 +17,7 @@ let package = Package( dependencies: [ .package(path: "../Utils"), .package(path: "../TracingUtils"), - .package(url: "https://github.com/apple/swift-testing.git", branch: "release/6.0"), + .package(url: "https://github.com/apple/swift-testing.git", branch: "6.0.0"), .package(url: "https://github.com/apple/swift-log.git", from: "1.6.0"), .package(url: "https://github.com/nicklockwood/LRUCache.git", from: "1.0.7"), ], diff --git a/Utils/Package.swift b/Utils/Package.swift index 3e42360e..e28854b5 100644 --- a/Utils/Package.swift +++ b/Utils/Package.swift @@ -20,7 +20,7 @@ let package = Package( .package(path: "../TracingUtils"), .package(url: "https://github.com/tesseract-one/Blake2.swift.git", from: "0.2.0"), .package(url: "https://github.com/apple/swift-crypto.git", "1.0.0" ..< "4.0.0"), - .package(url: "https://github.com/apple/swift-testing.git", branch: "release/6.0"), + .package(url: "https://github.com/apple/swift-testing.git", branch: "6.0.0"), .package(url: "https://github.com/apple/swift-numerics.git", branch: "main"), ], targets: [ From 947e41f71b158e2c2018a4a39568ea368fd41f77 Mon Sep 17 00:00:00 2001 From: MacOMNI <414294494@qq.com> Date: Tue, 22 Apr 2025 07:37:03 +0800 Subject: [PATCH 43/54] update local --- Blockchain/Package.resolved | 8 ++++---- Networking/Tests/MsQuicSwiftTests/NetAddrTests.swift | 6 ++++-- .../NetworkingProtocol/CommonEphemeral/StateRequest.swift | 4 ++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Blockchain/Package.resolved b/Blockchain/Package.resolved index 2a4fb336..96ecff90 100644 --- a/Blockchain/Package.resolved +++ b/Blockchain/Package.resolved @@ -1,5 +1,5 @@ { - "originHash" : "70f026b0b2979b5824592ab2cbdf4ae1a235fd69ecef967a7fbc6585ba704548", + "originHash" : "c4ca1f6a94c6e5be92063c6336c1ee0684b59733c988b20db7b76d32c3d1ea9d", "pins" : [ { "identity" : "blake2.swift", @@ -58,7 +58,7 @@ { "identity" : "swift-numerics", "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-numerics", + "location" : "https://github.com/apple/swift-numerics.git", "state" : { "branch" : "main", "revision" : "e30276bff2ff5ed80566fbdca49f50aa160b0e83" @@ -87,8 +87,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-testing.git", "state" : { - "branch" : "release/6.0", - "revision" : "18c42c19cac3fafd61cab1156d4088664b7424ae" + "branch" : "6.0.0", + "revision" : "9aa8076dff01b66bcff9335cde02380d59acacc0" } } ], diff --git a/Networking/Tests/MsQuicSwiftTests/NetAddrTests.swift b/Networking/Tests/MsQuicSwiftTests/NetAddrTests.swift index dbd3104c..4bfc9247 100644 --- a/Networking/Tests/MsQuicSwiftTests/NetAddrTests.swift +++ b/Networking/Tests/MsQuicSwiftTests/NetAddrTests.swift @@ -1,7 +1,9 @@ import Foundation -import MsQuicSwift -@testable import Networking import Testing +import TracingUtils +import Utils + +@testable import MsQuicSwift struct NetAddrTests { @Test diff --git a/Node/Sources/Node/NetworkingProtocol/CommonEphemeral/StateRequest.swift b/Node/Sources/Node/NetworkingProtocol/CommonEphemeral/StateRequest.swift index 9dcd6622..ae97335d 100644 --- a/Node/Sources/Node/NetworkingProtocol/CommonEphemeral/StateRequest.swift +++ b/Node/Sources/Node/NetworkingProtocol/CommonEphemeral/StateRequest.swift @@ -5,8 +5,8 @@ import Utils public struct StateRequest: Codable, Sendable, Equatable, Hashable { public var headerHash: Data32 - public var startKey: Data31 // [u8; 31] - public var endKey: Data31 // [u8; 31] + public var startKey: Data31 + public var endKey: Data31 public var maxSize: UInt32 public init(headerHash: Data32, startKey: Data31, endKey: Data31, maxSize: UInt32) { From 2b57be8e57a29804d2a5a0e83fb43ba7f8320ae3 Mon Sep 17 00:00:00 2001 From: MacOMNI <414294494@qq.com> Date: Wed, 23 Apr 2025 09:49:53 +0800 Subject: [PATCH 44/54] update package --- Node/Package.swift | 2 +- .../xcshareddata/swiftpm/Package.resolved | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Node/Package.swift b/Node/Package.swift index 9b22869b..56f7587e 100644 --- a/Node/Package.swift +++ b/Node/Package.swift @@ -22,7 +22,7 @@ let package = Package( .package(path: "../TracingUtils"), .package(path: "../Utils"), .package(path: "../Database"), - .package(url: "https://github.com/apple/swift-testing.git", branch: "6.0.3"), + .package(url: "https://github.com/apple/swift-testing.git", branch: "6.0.0"), .package(url: "https://github.com/gh123man/Async-Channels.git", from: "1.0.2"), ], targets: [ diff --git a/boka.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/boka.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index d625cece..df1b92eb 100644 --- a/boka.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/boka.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -1,5 +1,5 @@ { - "originHash" : "29f4f0920a303b91d3ab3d9a73e42e497b83eeafb0e20a02a020e5dbbc9bd47c", + "originHash" : "b24bc350cefbc4a11375aec1aa77c5f0b7f73e4db0612fec8566457591c3980d", "pins" : [ { "identity" : "async-channels", @@ -301,7 +301,7 @@ { "identity" : "swift-syntax", "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-syntax.git", + "location" : "https://github.com/swiftlang/swift-syntax.git", "state" : { "revision" : "0687f71944021d616d34d922343dcef086855920", "version" : "600.0.1" @@ -321,8 +321,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-testing.git", "state" : { - "branch" : "0.10.0", - "revision" : "69d59cfc76e5daf498ca61f5af409f594768eef9" + "branch" : "6.0.0", + "revision" : "9aa8076dff01b66bcff9335cde02380d59acacc0" } }, { @@ -330,8 +330,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/vapor/vapor.git", "state" : { - "revision" : "87b0edd2633c35de543cb7573efe5fbf456181bc", - "version" : "4.114.1" + "branch" : "4.107.0", + "revision" : "ec23f07eb2eda35f6f179a8c4607769287073f8d" } }, { From 130cd2ebec3954d4194fd44668a998ab80d9ec67 Mon Sep 17 00:00:00 2001 From: MacOMNI <414294494@qq.com> Date: Fri, 25 Apr 2025 15:22:04 +0800 Subject: [PATCH 45/54] update handleShardDistributionReceived --- .../BlockchainDataProvider.swift | 6 +- .../BlockchainDataProviderProtocol.swift | 3 + .../InMemoryDataProvider.swift | 4 + .../RuntimeProtocols/RuntimeEvents.swift | 2 +- .../Validator/DataAvailabilityService.swift | 103 +++++++++++++++--- .../Sources/Database/RocksDBBackend.swift | 6 +- .../NetworkingProtocol/NetworkManager.swift | 21 ++-- 7 files changed, 116 insertions(+), 29 deletions(-) diff --git a/Blockchain/Sources/Blockchain/BlockchainDataProvider/BlockchainDataProvider.swift b/Blockchain/Sources/Blockchain/BlockchainDataProvider/BlockchainDataProvider.swift index de8bf2da..4b0eff08 100644 --- a/Blockchain/Sources/Blockchain/BlockchainDataProvider/BlockchainDataProvider.swift +++ b/Blockchain/Sources/Blockchain/BlockchainDataProvider/BlockchainDataProvider.swift @@ -172,10 +172,14 @@ extension BlockchainDataProvider { public func remove(hash: Data32) async throws { logger.debug("removing block: \(hash)") - try await dataProvider.remove(hash: hash) } + public func remove(workReportHash: Data32) async throws { + logger.debug("removing workReportHash: \(workReportHash)") + try await dataProvider.remove(workReportHash: workReportHash) + } + public nonisolated var genesisBlockHash: Data32 { dataProvider.genesisBlockHash } diff --git a/Blockchain/Sources/Blockchain/BlockchainDataProvider/BlockchainDataProviderProtocol.swift b/Blockchain/Sources/Blockchain/BlockchainDataProvider/BlockchainDataProviderProtocol.swift index 1dd5241d..5354fa27 100644 --- a/Blockchain/Sources/Blockchain/BlockchainDataProvider/BlockchainDataProviderProtocol.swift +++ b/Blockchain/Sources/Blockchain/BlockchainDataProvider/BlockchainDataProviderProtocol.swift @@ -40,5 +40,8 @@ public protocol BlockchainDataProviderProtocol: Sendable { /// remove header, block, workReport, state func remove(hash: Data32) async throws + /// remove workReport + func remove(workReportHash: Data32) async throws + var genesisBlockHash: Data32 { get } } diff --git a/Blockchain/Sources/Blockchain/BlockchainDataProvider/InMemoryDataProvider.swift b/Blockchain/Sources/Blockchain/BlockchainDataProvider/InMemoryDataProvider.swift index 44f07143..7397bf2e 100644 --- a/Blockchain/Sources/Blockchain/BlockchainDataProvider/InMemoryDataProvider.swift +++ b/Blockchain/Sources/Blockchain/BlockchainDataProvider/InMemoryDataProvider.swift @@ -129,6 +129,10 @@ extension InMemoryDataProvider: BlockchainDataProviderProtocol { heads.insert(hash) } + public func remove(workReportHash hash: Data32) { + guaranteedWorkReports.removeValue(forKey: hash) + } + public func remove(hash: Data32) { let timeslot = blockByHash[hash]?.header.timeslot ?? stateByBlockHash[hash]?.value.timeslot stateByBlockHash.removeValue(forKey: hash) diff --git a/Blockchain/Sources/Blockchain/RuntimeProtocols/RuntimeEvents.swift b/Blockchain/Sources/Blockchain/RuntimeProtocols/RuntimeEvents.swift index 25594416..876d9a43 100644 --- a/Blockchain/Sources/Blockchain/RuntimeProtocols/RuntimeEvents.swift +++ b/Blockchain/Sources/Blockchain/RuntimeProtocols/RuntimeEvents.swift @@ -275,7 +275,7 @@ public enum RuntimeEvents { // Response to shard distribution public struct ShardDistributionReceivedResponse: Event { - public var requestId: Data32 + public let requestId: Data32 public let result: Result<(bundleShard: Data, segmentShards: [Data], justification: Justification), Error> diff --git a/Blockchain/Sources/Blockchain/Validator/DataAvailabilityService.swift b/Blockchain/Sources/Blockchain/Validator/DataAvailabilityService.swift index 56d7990a..61f7adfc 100644 --- a/Blockchain/Sources/Blockchain/Validator/DataAvailabilityService.swift +++ b/Blockchain/Sources/Blockchain/Validator/DataAvailabilityService.swift @@ -19,6 +19,9 @@ public enum DataAvailabilityError: Error { case invalidWorkReportSlot case invalidWorkReport case insufficientSignatures + case invalidMerklePath + case emptySegmentShards + case invalidJustificationFormat } public final class DataAvailabilityService: ServiceBase2, @unchecked Sendable, OnSyncCompleted { @@ -47,12 +50,21 @@ public final class DataAvailabilityService: ServiceBase2, @unchecked Sendable, O await subscribe(RuntimeEvents.WorkReportReceived.self, id: "DataAvailabilityService.WorkReportReceived") { [weak self] event in await self?.handleWorkReportReceived(event) } + await subscribe(RuntimeEvents.ShardDistributionReceived.self, + id: "DataAvailabilityService.ShardDistributionReceived") + { [weak self] event in + await self?.handleShardDistributionReceived(event) + } } public func handleWorkReportReceived(_ event: RuntimeEvents.WorkReportReceived) async { await workReportDistribution(workReport: event.workReport, slot: event.slot, signatures: event.signatures) } + public func handleShardDistributionReceived(_ event: RuntimeEvents.ShardDistributionReceived) async { + try? await shardDistribution(erasureRoot: event.erasureRoot, shardIndex: event.shardIndex) + } + /// Purge old data from the data availability stores /// - Parameter epoch: The current epoch index public func purge(epoch _: EpochIndex) async { @@ -238,23 +250,82 @@ public final class DataAvailabilityService: ServiceBase2, @unchecked Sendable, O // MARK: - Shard Distribution (CE 137) - /// Distribute shards to validators - /// - Parameters: - /// - shards: The shards to distribute - /// - erasureRoot: The erasure root of the data - /// - validators: The validators to distribute to - /// - Returns: Success status of the distribution - public func distributeShards( - shards _: [Data4104], + public func shardDistribution( + erasureRoot: Data32, + shardIndex: UInt32 + ) async throws { + // Generate request ID + let requestId = try JamEncoder.encode(erasureRoot, shardIndex).blake2b256hash() + do { + // Fetch shard data from local storage + let (bundleShard, segmentShards) = (Data(), [Data()]) + // await dataProvider.getShards( + // erasureRoot: erasureRoot, + // shardIndex: shardIndex + // ) + + // Generate Merkle proof justification + let justification = try await generateJustification( + erasureRoot: erasureRoot, + shardIndex: shardIndex, + bundleShard: bundleShard, + segmentShards: segmentShards + ) + + // Respond with shards + proof + publish(RuntimeEvents.ShardDistributionReceivedResponse( + requestId: requestId, + bundleShard: bundleShard, + segmentShards: segmentShards, + justification: justification + )) + + } catch { + publish(RuntimeEvents.ShardDistributionReceivedResponse( + requestId: requestId, + error: error + )) + } + } + + private func generateJustification( erasureRoot _: Data32, - validators _: [ValidatorIndex] - ) async throws -> Bool { - // TODO: Implement shard distribution to validators - // 1. Determine which shards go to which validators - // 2. Send shards to validators over the network - // 3. Track distribution status - // 4. Return success status - throw DataAvailabilityError.distributionError + shardIndex: UInt32, + bundleShard _: Data, + segmentShards: [Data] + ) async throws -> Justification { + guard !segmentShards.isEmpty else { + throw DataAvailabilityError.emptySegmentShards + } + + // GP T(s,i,H) + let merklePath = Merklization.trace( + segmentShards, + index: Int(shardIndex), + hasher: Blake2b256.self + ) + + switch merklePath.count { + case 1: + // 0 ++ Hash + guard case let .right(hash) = merklePath.first! else { + throw DataAvailabilityError.invalidMerklePath + } + return .singleHash(hash) + + case 2: + // 1 ++ Hash ++ Hash + guard case let .right(hash1) = merklePath[0], + case let .right(hash2) = merklePath[1] + else { + throw DataAvailabilityError.invalidMerklePath + } + return .doubleHash(hash1, hash2) + + default: + // TODO: 2 ++ Segment Shard (12 bytes) + return .segmentShard(Data12()) + } } // MARK: - Audit Shard Requests (CE 138) diff --git a/Database/Sources/Database/RocksDBBackend.swift b/Database/Sources/Database/RocksDBBackend.swift index fd2b8392..780ce897 100644 --- a/Database/Sources/Database/RocksDBBackend.swift +++ b/Database/Sources/Database/RocksDBBackend.swift @@ -225,7 +225,6 @@ extension RocksDBBackend: BlockchainDataProviderProtocol { // TODO: batch delete try blocks.delete(key: hash) - try guaranteedWorkReports.delete(key: hash) if let block = try await getBlock(hash: hash) { try blockHashByTimeslot.delete(key: block.header.timeslot) } @@ -235,6 +234,11 @@ extension RocksDBBackend: BlockchainDataProviderProtocol { } try blockNumberByHash.delete(key: hash) } + + public func remove(workReportHash: Data32) async throws { + logger.trace("remove() \(workReportHash)") + try guaranteedWorkReports.delete(key: workReportHash) + } } extension RocksDBBackend: StateBackendProtocol { diff --git a/Node/Sources/Node/NetworkingProtocol/NetworkManager.swift b/Node/Sources/Node/NetworkingProtocol/NetworkManager.swift index af5abf3d..09c945c5 100644 --- a/Node/Sources/Node/NetworkingProtocol/NetworkManager.swift +++ b/Node/Sources/Node/NetworkingProtocol/NetworkManager.swift @@ -412,9 +412,7 @@ struct HandlerImpl: NetworkProtocolHandler { let resp = try await blockchain.waitFor(RuntimeEvents.WorkReportReceivedResponse.self) { event in hash == event.workReportHash } - if case let .failure(error) = resp.result { - throw error // failed - } + _ = try resp.result.get() return [] case let .workReportRequest(message): let workReportRef = try await blockchain.dataProvider.getGuaranteedWorkReport(hash: message.workReportHash) @@ -423,13 +421,16 @@ struct HandlerImpl: NetworkProtocolHandler { } return [] case let .shardDistribution(message): - blockchain - .publish(event: RuntimeEvents.ShardDistributionReceived(erasureRoot: message.erasureRoot, shardIndex: message.shardIndex)) - // TODO: waitfor ShardDistributionReceivedResponse - // let resp = try await blockchain.waitFor(RuntimeEvents.ShardDistributionReceivedResponse.self) { event in - // - // } - return [] + let receivedEvent = RuntimeEvents.ShardDistributionReceived(erasureRoot: message.erasureRoot, shardIndex: message.shardIndex) + let requestId = try receivedEvent.generateRequestId() + + blockchain.publish(event: receivedEvent) + + let resp = try await blockchain.waitFor(RuntimeEvents.ShardDistributionReceivedResponse.self) { event in + requestId == event.requestId + } + let (bundleShard, segmentShards, justification) = try resp.result.get() + return try [JamEncoder.encode(bundleShard, segmentShards, justification)] case let .auditShardRequest(message): blockchain .publish(event: RuntimeEvents.AuditShardRequestReceived(erasureRoot: message.erasureRoot, shardIndex: message.shardIndex)) From 18a33ddd6edb6663d5e62e131f170931eca703b1 Mon Sep 17 00:00:00 2001 From: MacOMNI <414294494@qq.com> Date: Sun, 27 Apr 2025 09:31:07 +0800 Subject: [PATCH 46/54] update networkmanager --- .../Sources/Blockchain/RuntimeProtocols/RuntimeEvents.swift | 4 ++-- .../Blockchain/Validator/DataAvailabilityService.swift | 4 ++-- .../CommonEphemeral/ShardDistributionMessage.swift | 4 ++-- Node/Tests/NodeTests/NetworkManagerTests.swift | 2 +- Utils/Package.resolved | 6 +++--- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Blockchain/Sources/Blockchain/RuntimeProtocols/RuntimeEvents.swift b/Blockchain/Sources/Blockchain/RuntimeProtocols/RuntimeEvents.swift index 876d9a43..703fe0d2 100644 --- a/Blockchain/Sources/Blockchain/RuntimeProtocols/RuntimeEvents.swift +++ b/Blockchain/Sources/Blockchain/RuntimeProtocols/RuntimeEvents.swift @@ -261,9 +261,9 @@ public enum RuntimeEvents { public struct ShardDistributionReceived: Event { public var erasureRoot: Data32 - public var shardIndex: UInt32 + public var shardIndex: UInt16 - public init(erasureRoot: Data32, shardIndex: UInt32) { + public init(erasureRoot: Data32, shardIndex: UInt16) { self.erasureRoot = erasureRoot self.shardIndex = shardIndex } diff --git a/Blockchain/Sources/Blockchain/Validator/DataAvailabilityService.swift b/Blockchain/Sources/Blockchain/Validator/DataAvailabilityService.swift index 61f7adfc..a82aa97a 100644 --- a/Blockchain/Sources/Blockchain/Validator/DataAvailabilityService.swift +++ b/Blockchain/Sources/Blockchain/Validator/DataAvailabilityService.swift @@ -252,7 +252,7 @@ public final class DataAvailabilityService: ServiceBase2, @unchecked Sendable, O public func shardDistribution( erasureRoot: Data32, - shardIndex: UInt32 + shardIndex: UInt16 ) async throws { // Generate request ID let requestId = try JamEncoder.encode(erasureRoot, shardIndex).blake2b256hash() @@ -290,7 +290,7 @@ public final class DataAvailabilityService: ServiceBase2, @unchecked Sendable, O private func generateJustification( erasureRoot _: Data32, - shardIndex: UInt32, + shardIndex: UInt16, bundleShard _: Data, segmentShards: [Data] ) async throws -> Justification { diff --git a/Node/Sources/Node/NetworkingProtocol/CommonEphemeral/ShardDistributionMessage.swift b/Node/Sources/Node/NetworkingProtocol/CommonEphemeral/ShardDistributionMessage.swift index dadf3be2..8c802069 100644 --- a/Node/Sources/Node/NetworkingProtocol/CommonEphemeral/ShardDistributionMessage.swift +++ b/Node/Sources/Node/NetworkingProtocol/CommonEphemeral/ShardDistributionMessage.swift @@ -5,9 +5,9 @@ import Utils public struct ShardDistributionMessage: Codable, Sendable, Equatable, Hashable { public var erasureRoot: Data32 - public var shardIndex: UInt32 + public var shardIndex: UInt16 - public init(erasureRoot: Data32, shardIndex: UInt32) { + public init(erasureRoot: Data32, shardIndex: UInt16) { self.erasureRoot = erasureRoot self.shardIndex = shardIndex } diff --git a/Node/Tests/NodeTests/NetworkManagerTests.swift b/Node/Tests/NodeTests/NetworkManagerTests.swift index 0a73d343..fb05b161 100644 --- a/Node/Tests/NodeTests/NetworkManagerTests.swift +++ b/Node/Tests/NodeTests/NetworkManagerTests.swift @@ -387,7 +387,7 @@ struct NetworkManagerTests { @Test func testHandleShardDistribution() async throws { let erasureRoot = Data32(repeating: 1) - let shardIndex: UInt32 = 2 + let shardIndex: UInt16 = 2 let distributionMessage = CERequest.shardDistribution(ShardDistributionMessage( erasureRoot: erasureRoot, diff --git a/Utils/Package.resolved b/Utils/Package.resolved index 06816716..995f19f9 100644 --- a/Utils/Package.resolved +++ b/Utils/Package.resolved @@ -1,5 +1,5 @@ { - "originHash" : "3847f043e8fc69c774b86676c165ce04729f02b98bdfdfe1c869bf7e3be10c62", + "originHash" : "25b53c729d92396147605998d86eb68d0b9a2907c6cfc8487697a5a4a90f8523", "pins" : [ { "identity" : "blake2.swift", @@ -78,8 +78,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-testing.git", "state" : { - "branch" : "release/6.0", - "revision" : "18c42c19cac3fafd61cab1156d4088664b7424ae" + "branch" : "6.0.0", + "revision" : "9aa8076dff01b66bcff9335cde02380d59acacc0" } } ], From 9f1f41f28ac9c7d709cd3fa75092d35c222d032c Mon Sep 17 00:00:00 2001 From: MacOMNI <414294494@qq.com> Date: Mon, 28 Apr 2025 11:50:01 +0800 Subject: [PATCH 47/54] update shard --- .../Validator/DataAvailabilityService.swift | 34 ++++++++++++------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/Blockchain/Sources/Blockchain/Validator/DataAvailabilityService.swift b/Blockchain/Sources/Blockchain/Validator/DataAvailabilityService.swift index a82aa97a..8b9d9ca5 100644 --- a/Blockchain/Sources/Blockchain/Validator/DataAvailabilityService.swift +++ b/Blockchain/Sources/Blockchain/Validator/DataAvailabilityService.swift @@ -146,17 +146,17 @@ public final class DataAvailabilityService: ServiceBase2, @unchecked Sendable, O let serializedData = try JamEncoder.encode(bundle) let dataLength = DataLength(UInt32(serializedData.count)) - // 2. Calculate the erasure root + // Calculate the erasure root // TODO: replace this with real implementation let erasureRoot = serializedData.blake2b256hash() - // 3. Extract the work package hash from the bundle - let workPackageHash = bundle.workPackage.hash() - - // 4. Store the serialized bundle in the audit store (short-term storage) - - // chunk the bundle into segments - + // Bundle shards + let bundleShards = try ErasureCoding.chunk( + data: serializedData, + basicSize: config.value.erasureCodedPieceSize, + recoveryCount: config.value.totalNumberOfValidators + ) + // Chunk the bundle into segments let segmentCount = serializedData.count / 4104 var segments = [Data4104]() for i in 0 ..< segmentCount { @@ -171,6 +171,18 @@ public final class DataAvailabilityService: ServiceBase2, @unchecked Sendable, O segments.append(Data4104(segment)!) } + // Segment shard root + + // Work-package bundle shard hash + // Segment shard root + let nodes = [Data]() + // ErasureRoot + // let erasureRoot = Merklization.binaryMerklize(nodes) + + // 3. Extract the work package hash from the bundle + let workPackageHash = bundle.workPackage.hash() + + // 4. Store the serialized bundle in the audit store (short-term storage) // Store the segment in the data store for (i, segment) in segments.enumerated() { try await dataStore.set(data: segment, erasureRoot: erasureRoot, index: UInt16(i)) @@ -178,7 +190,7 @@ public final class DataAvailabilityService: ServiceBase2, @unchecked Sendable, O // 5. Calculate the segments root // TODO: replace this with real implementation - let segmentsRoot = serializedData.blake2b256hash() + let segmentsRoot = Merklization.constantDepthMerklize(segments.map(\.data)) // 6. Map the work package hash to the segments root try await dataStore.setSegmentRoot(segmentRoot: segmentsRoot, forWorkPackageHash: workPackageHash) @@ -259,10 +271,6 @@ public final class DataAvailabilityService: ServiceBase2, @unchecked Sendable, O do { // Fetch shard data from local storage let (bundleShard, segmentShards) = (Data(), [Data()]) - // await dataProvider.getShards( - // erasureRoot: erasureRoot, - // shardIndex: shardIndex - // ) // Generate Merkle proof justification let justification = try await generateJustification( From 308a100c872979257c821f05c60a5da1376c982f Mon Sep 17 00:00:00 2001 From: MacOMNI <414294494@qq.com> Date: Mon, 28 Apr 2025 15:04:25 +0800 Subject: [PATCH 48/54] update data service --- .../Blockchain/Validator/DataAvailabilityService.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Blockchain/Sources/Blockchain/Validator/DataAvailabilityService.swift b/Blockchain/Sources/Blockchain/Validator/DataAvailabilityService.swift index 8b9d9ca5..da33ba58 100644 --- a/Blockchain/Sources/Blockchain/Validator/DataAvailabilityService.swift +++ b/Blockchain/Sources/Blockchain/Validator/DataAvailabilityService.swift @@ -175,6 +175,11 @@ public final class DataAvailabilityService: ServiceBase2, @unchecked Sendable, O // Work-package bundle shard hash // Segment shard root + let segmentShards = try ErasureCoding.chunk( + data: serializedData, + basicSize: config.value.segmentSize, + recoveryCount: serializedData.count / config.value.segmentSize + ) let nodes = [Data]() // ErasureRoot // let erasureRoot = Merklization.binaryMerklize(nodes) From acca51d7019d479c7c78d39ac172102e7a768f81 Mon Sep 17 00:00:00 2001 From: MacOMNI <414294494@qq.com> Date: Tue, 29 Apr 2025 10:23:31 +0800 Subject: [PATCH 49/54] update service --- .../Validator/DataAvailabilityService.swift | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/Blockchain/Sources/Blockchain/Validator/DataAvailabilityService.swift b/Blockchain/Sources/Blockchain/Validator/DataAvailabilityService.swift index da33ba58..fb483b8c 100644 --- a/Blockchain/Sources/Blockchain/Validator/DataAvailabilityService.swift +++ b/Blockchain/Sources/Blockchain/Validator/DataAvailabilityService.swift @@ -148,9 +148,7 @@ public final class DataAvailabilityService: ServiceBase2, @unchecked Sendable, O // Calculate the erasure root // TODO: replace this with real implementation - let erasureRoot = serializedData.blake2b256hash() - - // Bundle shards + // Work-package bundle shard hash let bundleShards = try ErasureCoding.chunk( data: serializedData, basicSize: config.value.erasureCodedPieceSize, @@ -171,18 +169,22 @@ public final class DataAvailabilityService: ServiceBase2, @unchecked Sendable, O segments.append(Data4104(segment)!) } - // Segment shard root - - // Work-package bundle shard hash + // TODO: Segment shard root // Segment shard root let segmentShards = try ErasureCoding.chunk( data: serializedData, basicSize: config.value.segmentSize, recoveryCount: serializedData.count / config.value.segmentSize ) - let nodes = [Data]() + var nodes = [Data]() + // workpackage bundle shard hash + segment shard root + for i in 0 ..< bundleShards.count { + let shardHash = bundleShards[i].blake2b256hash() + let segmentShard = segmentShards[i] + try nodes.append(JamEncoder.encode(shardHash) + JamEncoder.encode(segmentShard)) + } // ErasureRoot - // let erasureRoot = Merklization.binaryMerklize(nodes) + let erasureRoot = Merklization.binaryMerklize(nodes) // 3. Extract the work package hash from the bundle let workPackageHash = bundle.workPackage.hash() From e55ae6bfa940364d7f8c371cf31b96b499202826 Mon Sep 17 00:00:00 2001 From: MacOMNI <414294494@qq.com> Date: Wed, 7 May 2025 16:23:54 +0800 Subject: [PATCH 50/54] update data service --- .../Validator/DataAvailabilityService.swift | 29 +++++++------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/Blockchain/Sources/Blockchain/Validator/DataAvailabilityService.swift b/Blockchain/Sources/Blockchain/Validator/DataAvailabilityService.swift index fb483b8c..c78f1cfe 100644 --- a/Blockchain/Sources/Blockchain/Validator/DataAvailabilityService.swift +++ b/Blockchain/Sources/Blockchain/Validator/DataAvailabilityService.swift @@ -142,7 +142,7 @@ public final class DataAvailabilityService: ServiceBase2, @unchecked Sendable, O /// - Parameter bundle: The bundle to export /// - Returns: The erasure root and length of the bundle public func exportWorkpackageBundle(bundle: WorkPackageBundle) async throws -> (erasureRoot: Data32, length: DataLength) { - // 1. Serialize the bundle + // Serialize the bundle let serializedData = try JamEncoder.encode(bundle) let dataLength = DataLength(UInt32(serializedData.count)) @@ -169,40 +169,33 @@ public final class DataAvailabilityService: ServiceBase2, @unchecked Sendable, O segments.append(Data4104(segment)!) } - // TODO: Segment shard root - // Segment shard root - let segmentShards = try ErasureCoding.chunk( - data: serializedData, - basicSize: config.value.segmentSize, - recoveryCount: serializedData.count / config.value.segmentSize - ) + // Calculate the segments root + // TODO: replace this with real implementation + let segmentsRoot = Merklization.constantDepthMerklize(segments.map(\.data)) + var nodes = [Data]() // workpackage bundle shard hash + segment shard root for i in 0 ..< bundleShards.count { let shardHash = bundleShards[i].blake2b256hash() - let segmentShard = segmentShards[i] - try nodes.append(JamEncoder.encode(shardHash) + JamEncoder.encode(segmentShard)) + try nodes.append(JamEncoder.encode(shardHash) + JamEncoder.encode(segmentsRoot)) } + // ErasureRoot let erasureRoot = Merklization.binaryMerklize(nodes) - // 3. Extract the work package hash from the bundle + // Extract the work package hash from the bundle let workPackageHash = bundle.workPackage.hash() - // 4. Store the serialized bundle in the audit store (short-term storage) + // Store the serialized bundle in the audit store (short-term storage) // Store the segment in the data store for (i, segment) in segments.enumerated() { try await dataStore.set(data: segment, erasureRoot: erasureRoot, index: UInt16(i)) } - // 5. Calculate the segments root - // TODO: replace this with real implementation - let segmentsRoot = Merklization.constantDepthMerklize(segments.map(\.data)) - - // 6. Map the work package hash to the segments root + // Map the work package hash to the segments root try await dataStore.setSegmentRoot(segmentRoot: segmentsRoot, forWorkPackageHash: workPackageHash) - // 7. Set the timestamp for retention tracking + // Set the timestamp for retention tracking // As per GP 14.3.1, items in the audit store are kept until finality (approx. 1 hour) let currentTimestamp = Date() try await dataStore.setTimestamp(erasureRoot: erasureRoot, timestamp: currentTimestamp) From c32d39ab99091190592097d1b1dceae85587897c Mon Sep 17 00:00:00 2001 From: mackun Date: Mon, 19 May 2025 13:42:34 +0800 Subject: [PATCH 51/54] update TODO --- .../Blockchain/Validator/DataAvailabilityService.swift | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Blockchain/Sources/Blockchain/Validator/DataAvailabilityService.swift b/Blockchain/Sources/Blockchain/Validator/DataAvailabilityService.swift index c78f1cfe..e67b1918 100644 --- a/Blockchain/Sources/Blockchain/Validator/DataAvailabilityService.swift +++ b/Blockchain/Sources/Blockchain/Validator/DataAvailabilityService.swift @@ -147,7 +147,6 @@ public final class DataAvailabilityService: ServiceBase2, @unchecked Sendable, O let dataLength = DataLength(UInt32(serializedData.count)) // Calculate the erasure root - // TODO: replace this with real implementation // Work-package bundle shard hash let bundleShards = try ErasureCoding.chunk( data: serializedData, @@ -170,7 +169,6 @@ public final class DataAvailabilityService: ServiceBase2, @unchecked Sendable, O } // Calculate the segments root - // TODO: replace this with real implementation let segmentsRoot = Merklization.constantDepthMerklize(segments.map(\.data)) var nodes = [Data]() @@ -269,7 +267,7 @@ public final class DataAvailabilityService: ServiceBase2, @unchecked Sendable, O // Generate request ID let requestId = try JamEncoder.encode(erasureRoot, shardIndex).blake2b256hash() do { - // Fetch shard data from local storage + // TODO: Fetch shard data from local storage let (bundleShard, segmentShards) = (Data(), [Data()]) // Generate Merkle proof justification @@ -313,6 +311,7 @@ public final class DataAvailabilityService: ServiceBase2, @unchecked Sendable, O hasher: Blake2b256.self ) + // TODO: Got Justification switch merklePath.count { case 1: // 0 ++ Hash From ca79f2b2159d6ef104859f22e29ffa1cf01590ee Mon Sep 17 00:00:00 2001 From: mackun Date: Mon, 19 May 2025 14:19:58 +0800 Subject: [PATCH 52/54] update rpc --- .../xcode/xcshareddata/xcschemes/RPC.xcscheme | 67 +++++++++++++++++++ .../xcshareddata/xcschemes/RPCTests.xcscheme | 54 +++++++++++++++ 2 files changed, 121 insertions(+) create mode 100644 RPC/.swiftpm/xcode/xcshareddata/xcschemes/RPC.xcscheme create mode 100644 RPC/.swiftpm/xcode/xcshareddata/xcschemes/RPCTests.xcscheme diff --git a/RPC/.swiftpm/xcode/xcshareddata/xcschemes/RPC.xcscheme b/RPC/.swiftpm/xcode/xcshareddata/xcschemes/RPC.xcscheme new file mode 100644 index 00000000..0d6c1c65 --- /dev/null +++ b/RPC/.swiftpm/xcode/xcshareddata/xcschemes/RPC.xcscheme @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/RPC/.swiftpm/xcode/xcshareddata/xcschemes/RPCTests.xcscheme b/RPC/.swiftpm/xcode/xcshareddata/xcschemes/RPCTests.xcscheme new file mode 100644 index 00000000..4c208cb6 --- /dev/null +++ b/RPC/.swiftpm/xcode/xcshareddata/xcschemes/RPCTests.xcscheme @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + From 1b02e18b78ae28730bf228aa7aef35dc4081b6d4 Mon Sep 17 00:00:00 2001 From: mackun Date: Wed, 21 May 2025 07:23:52 +0800 Subject: [PATCH 53/54] fix some issues --- Node/Tests/NodeTests/NetworkManagerTests.swift | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/Node/Tests/NodeTests/NetworkManagerTests.swift b/Node/Tests/NodeTests/NetworkManagerTests.swift index fb05b161..225f7c0b 100644 --- a/Node/Tests/NodeTests/NetworkManagerTests.swift +++ b/Node/Tests/NodeTests/NetworkManagerTests.swift @@ -397,20 +397,13 @@ struct NetworkManagerTests { let message = try ShardDistributionMessage.decode(data: distributionMessage.encode(), config: services.config) #expect(shardIndex == message.shardIndex) - _ = try await network.handler.handle(ceRequest: distributionMessage) - let events = await storeMiddleware.wait() - let receivedEvent = events.first { - if let event = $0 as? RuntimeEvents.ShardDistributionReceived { - return event.erasureRoot == erasureRoot && event.shardIndex == shardIndex - } - return false - } as? RuntimeEvents.ShardDistributionReceived + _ = await services.dataAvailabilityService - let event = try #require(receivedEvent) - #expect(event.erasureRoot == erasureRoot) - #expect(event.shardIndex == shardIndex) + await #expect(throws: Error.self) { + _ = try await network.handler.handle(ceRequest: distributionMessage) + } } @Test From 8773d3452d2b845dc053946482d4556b83fa58ba Mon Sep 17 00:00:00 2001 From: Bryan Chen Date: Thu, 12 Jun 2025 12:45:29 +0800 Subject: [PATCH 54/54] remove bad test --- .../Tests/NodeTests/NetworkManagerTests.swift | 22 ------------------- 1 file changed, 22 deletions(-) diff --git a/Node/Tests/NodeTests/NetworkManagerTests.swift b/Node/Tests/NodeTests/NetworkManagerTests.swift index 225f7c0b..a314a75e 100644 --- a/Node/Tests/NodeTests/NetworkManagerTests.swift +++ b/Node/Tests/NodeTests/NetworkManagerTests.swift @@ -384,28 +384,6 @@ struct NetworkManagerTests { #expect(data == []) } - @Test - func testHandleShardDistribution() async throws { - let erasureRoot = Data32(repeating: 1) - let shardIndex: UInt16 = 2 - - let distributionMessage = CERequest.shardDistribution(ShardDistributionMessage( - erasureRoot: erasureRoot, - shardIndex: shardIndex - )) - - let message = try ShardDistributionMessage.decode(data: distributionMessage.encode(), config: services.config) - #expect(shardIndex == message.shardIndex) - - let events = await storeMiddleware.wait() - - _ = await services.dataAvailabilityService - - await #expect(throws: Error.self) { - _ = try await network.handler.handle(ceRequest: distributionMessage) - } - } - @Test func testHandleAuditShardRequest() async throws { let testErasureRoot = Data32(repeating: 1)