diff --git a/Blockchain/Sources/Blockchain/Config/ProtocolConfig.swift b/Blockchain/Sources/Blockchain/Config/ProtocolConfig.swift index 21d61277..f2b68cbc 100644 --- a/Blockchain/Sources/Blockchain/Config/ProtocolConfig.swift +++ b/Blockchain/Sources/Blockchain/Config/ProtocolConfig.swift @@ -2,7 +2,7 @@ import PolkaVM import Utils // constants defined in the graypaper -public struct ProtocolConfig: Sendable { +public struct ProtocolConfig: Sendable, Codable { // A = 8: The period, in seconds, between audit tranches. public var auditTranchePeriod: Int @@ -191,6 +191,168 @@ extension Ref: @retroactive PvmConfig where T == ProtocolConfig { public var pvmProgramInitSegmentSize: Int { value.pvmProgramInitSegmentSize } } +extension ProtocolConfig { + public func merged(with other: ProtocolConfig) -> ProtocolConfig { + ProtocolConfig( + auditTranchePeriod: other.auditTranchePeriod != 0 + ? other.auditTranchePeriod : auditTranchePeriod, + additionalMinBalancePerStateItem: other.additionalMinBalancePerStateItem != 0 + ? other.additionalMinBalancePerStateItem : additionalMinBalancePerStateItem, + additionalMinBalancePerStateByte: other.additionalMinBalancePerStateByte != 0 + ? other.additionalMinBalancePerStateByte : additionalMinBalancePerStateByte, + serviceMinBalance: other.serviceMinBalance != 0 + ? other.serviceMinBalance : serviceMinBalance, + totalNumberOfCores: other.totalNumberOfCores != 0 + ? other.totalNumberOfCores : totalNumberOfCores, + preimagePurgePeriod: other.preimagePurgePeriod != 0 + ? other.preimagePurgePeriod : preimagePurgePeriod, + epochLength: other.epochLength != 0 ? other.epochLength : epochLength, + auditBiasFactor: other.auditBiasFactor != 0 + ? other.auditBiasFactor : auditBiasFactor, + coreAccumulationGas: other.coreAccumulationGas.value != 0 + ? other.coreAccumulationGas : coreAccumulationGas, + workPackageAuthorizerGas: other.workPackageAuthorizerGas.value != 0 + ? other.workPackageAuthorizerGas : workPackageAuthorizerGas, + workPackageRefineGas: other.workPackageRefineGas.value != 0 + ? other.workPackageRefineGas : workPackageRefineGas, + recentHistorySize: other.recentHistorySize != 0 + ? other.recentHistorySize : recentHistorySize, + maxWorkItems: other.maxWorkItems != 0 ? other.maxWorkItems : maxWorkItems, + maxTicketsPerExtrinsic: other.maxTicketsPerExtrinsic != 0 + ? other.maxTicketsPerExtrinsic : maxTicketsPerExtrinsic, + maxLookupAnchorAge: other.maxLookupAnchorAge != 0 + ? other.maxLookupAnchorAge : maxLookupAnchorAge, + transferMemoSize: other.transferMemoSize != 0 + ? other.transferMemoSize : transferMemoSize, + ticketEntriesPerValidator: other.ticketEntriesPerValidator != 0 + ? other.ticketEntriesPerValidator : ticketEntriesPerValidator, + maxAuthorizationsPoolItems: other.maxAuthorizationsPoolItems != 0 + ? other.maxAuthorizationsPoolItems : maxAuthorizationsPoolItems, + slotPeriodSeconds: other.slotPeriodSeconds != 0 + ? other.slotPeriodSeconds : slotPeriodSeconds, + maxAuthorizationsQueueItems: other.maxAuthorizationsQueueItems != 0 + ? other.maxAuthorizationsQueueItems : maxAuthorizationsQueueItems, + coreAssignmentRotationPeriod: other.coreAssignmentRotationPeriod != 0 + ? other.coreAssignmentRotationPeriod : coreAssignmentRotationPeriod, + maxServiceCodeSize: other.maxServiceCodeSize != 0 + ? other.maxServiceCodeSize : maxServiceCodeSize, + preimageReplacementPeriod: other.preimageReplacementPeriod != 0 + ? other.preimageReplacementPeriod : preimageReplacementPeriod, + totalNumberOfValidators: other.totalNumberOfValidators != 0 + ? other.totalNumberOfValidators : totalNumberOfValidators, + erasureCodedPieceSize: other.erasureCodedPieceSize != 0 + ? other.erasureCodedPieceSize : erasureCodedPieceSize, + maxWorkPackageManifestEntries: other.maxWorkPackageManifestEntries != 0 + ? other.maxWorkPackageManifestEntries : maxWorkPackageManifestEntries, + maxEncodedWorkPackageSize: other.maxEncodedWorkPackageSize != 0 + ? other.maxEncodedWorkPackageSize : maxEncodedWorkPackageSize, + maxEncodedWorkReportSize: other.maxEncodedWorkReportSize != 0 + ? other.maxEncodedWorkReportSize : maxEncodedWorkReportSize, + erasureCodedSegmentSize: other.erasureCodedSegmentSize != 0 + ? other.erasureCodedSegmentSize : erasureCodedSegmentSize, + ticketSubmissionEndSlot: other.ticketSubmissionEndSlot != 0 + ? other.ticketSubmissionEndSlot : ticketSubmissionEndSlot, + pvmDynamicAddressAlignmentFactor: other.pvmDynamicAddressAlignmentFactor != 0 + ? other.pvmDynamicAddressAlignmentFactor : pvmDynamicAddressAlignmentFactor, + pvmProgramInitInputDataSize: other.pvmProgramInitInputDataSize != 0 + ? other.pvmProgramInitInputDataSize : pvmProgramInitInputDataSize, + pvmProgramInitPageSize: other.pvmProgramInitPageSize != 0 + ? other.pvmProgramInitPageSize : pvmProgramInitPageSize, + pvmProgramInitSegmentSize: other.pvmProgramInitSegmentSize != 0 + ? other.pvmProgramInitSegmentSize : pvmProgramInitSegmentSize + ) + } + + public init(from decoder: Decoder, _ required: Bool = false) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + func decode(_ key: CodingKeys, defaultValue: T, required: Bool) throws -> T { + if required { + try container.decode(T.self, forKey: key) + } else { + try container.decodeIfPresent(T.self, forKey: key) ?? defaultValue + } + } + + auditTranchePeriod = try decode(.auditTranchePeriod, defaultValue: 0, required: required) + additionalMinBalancePerStateItem = try decode( + .additionalMinBalancePerStateItem, defaultValue: 0, required: required + ) + additionalMinBalancePerStateByte = try decode( + .additionalMinBalancePerStateByte, defaultValue: 0, required: required + ) + serviceMinBalance = try decode(.serviceMinBalance, defaultValue: 0, required: required) + totalNumberOfCores = try decode(.totalNumberOfCores, defaultValue: 0, required: required) + preimagePurgePeriod = try decode(.preimagePurgePeriod, defaultValue: 0, required: required) + epochLength = try decode(.epochLength, defaultValue: 0, required: required) + auditBiasFactor = try decode(.auditBiasFactor, defaultValue: 0, required: required) + coreAccumulationGas = try decode( + .coreAccumulationGas, defaultValue: Gas(0), required: required + ) + workPackageAuthorizerGas = try decode( + .workPackageAuthorizerGas, defaultValue: Gas(0), required: required + ) + workPackageRefineGas = try decode( + .workPackageRefineGas, defaultValue: Gas(0), required: required + ) + recentHistorySize = try decode(.recentHistorySize, defaultValue: 0, required: required) + maxWorkItems = try decode(.maxWorkItems, defaultValue: 0, required: required) + maxTicketsPerExtrinsic = try decode( + .maxTicketsPerExtrinsic, defaultValue: 0, required: required + ) + maxLookupAnchorAge = try decode(.maxLookupAnchorAge, defaultValue: 0, required: required) + transferMemoSize = try decode(.transferMemoSize, defaultValue: 0, required: required) + ticketEntriesPerValidator = try decode( + .ticketEntriesPerValidator, defaultValue: 0, required: required + ) + maxAuthorizationsPoolItems = try decode( + .maxAuthorizationsPoolItems, defaultValue: 0, required: required + ) + slotPeriodSeconds = try decode(.slotPeriodSeconds, defaultValue: 0, required: required) + maxAuthorizationsQueueItems = try decode( + .maxAuthorizationsQueueItems, defaultValue: 0, required: required + ) + coreAssignmentRotationPeriod = try decode( + .coreAssignmentRotationPeriod, defaultValue: 0, required: required + ) + maxServiceCodeSize = try decode(.maxServiceCodeSize, defaultValue: 0, required: required) + preimageReplacementPeriod = try decode( + .preimageReplacementPeriod, defaultValue: 0, required: required + ) + totalNumberOfValidators = try decode( + .totalNumberOfValidators, defaultValue: 0, required: required + ) + erasureCodedPieceSize = try decode(.erasureCodedPieceSize, defaultValue: 0, required: required) + maxWorkPackageManifestEntries = try decode( + .maxWorkPackageManifestEntries, defaultValue: 0, required: required + ) + maxEncodedWorkPackageSize = try decode( + .maxEncodedWorkPackageSize, defaultValue: 0, required: required + ) + maxEncodedWorkReportSize = try decode( + .maxEncodedWorkReportSize, defaultValue: 0, required: required + ) + erasureCodedSegmentSize = try decode( + .erasureCodedSegmentSize, defaultValue: 0, required: required + ) + ticketSubmissionEndSlot = try decode( + .ticketSubmissionEndSlot, defaultValue: 0, required: required + ) + pvmDynamicAddressAlignmentFactor = try decode( + .pvmDynamicAddressAlignmentFactor, defaultValue: 0, required: required + ) + pvmProgramInitInputDataSize = try decode( + .pvmProgramInitInputDataSize, defaultValue: 0, required: required + ) + pvmProgramInitPageSize = try decode( + .pvmProgramInitPageSize, defaultValue: 0, required: required + ) + pvmProgramInitSegmentSize = try decode( + .pvmProgramInitSegmentSize, defaultValue: 0, required: required + ) + } +} + extension ProtocolConfig { public enum AuditTranchePeriod: ReadInt { public typealias TConfig = ProtocolConfigRef diff --git a/Blockchain/Sources/Blockchain/Types/State+Genesis.swift b/Blockchain/Sources/Blockchain/Types/State+Genesis.swift index df08f188..a3979a00 100644 --- a/Blockchain/Sources/Blockchain/Types/State+Genesis.swift +++ b/Blockchain/Sources/Blockchain/Types/State+Genesis.swift @@ -34,4 +34,6 @@ extension State { return state } + // TODO: add file genesis + // public static func fileGenesis(config: ProtocolConfigRef) throws -> State } diff --git a/Boka/.swiftpm/xcode/xcshareddata/xcschemes/Boka.xcscheme b/Boka/.swiftpm/xcode/xcshareddata/xcschemes/Boka.xcscheme index ed43f72f..ae134e00 100644 --- a/Boka/.swiftpm/xcode/xcshareddata/xcschemes/Boka.xcscheme +++ b/Boka/.swiftpm/xcode/xcshareddata/xcschemes/Boka.xcscheme @@ -29,6 +29,18 @@ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" shouldUseLaunchSchemeArgsEnv = "YES" shouldAutocreateTestPlan = "YES"> + + + + + + URL? { + let bundle = Bundle.module + return bundle.url(forResource: name, withExtension: nil, subdirectory: "chainfiles") + } +} + +final class BokaTests { + var console: Terminal + var boka: Boka + init() { + console = Terminal() + boka = Boka() + } + + @Test func missCommand() async throws { + let sepc = ResourceLoader.loadResource(named: "devnet_allconfig_spec.json")!.path() + let input = CommandInput(arguments: ["Boka", "-m", sepc]) + await #expect(throws: Error.self) { + try await console.run(boka, input: input) + } + } + + @Test func commandWithWrongFilePath() async throws { + let sepc = "/path/to/wrong/file.json" + let input = CommandInput(arguments: ["Boka", "--config-file", sepc]) + await #expect(throws: Error.self) { + try await console.run(boka, input: input) + } + } + + @Test func commandWithAllConfig() async throws { + let sepc = ResourceLoader.loadResource(named: "devnet_allconfig_spec.json")!.path() + let genesis: Genesis = .file(path: sepc) + let (_, protocolConfig) = try await genesis.load() + #expect(protocolConfig.value.maxWorkItems == 2) + #expect(protocolConfig.value.serviceMinBalance == 100) + } + + @Test func commandWithSomeConfig() async throws { + let sepc = ResourceLoader.loadResource(named: "mainnet_someconfig_spec.json")!.path() + let genesis: Genesis = .file(path: sepc) + let config = ProtocolConfigRef.mainnet.value + let (_, protocolConfig) = try await genesis.load() + #expect(protocolConfig.value.auditTranchePeriod == 100) + #expect(protocolConfig.value.pvmProgramInitSegmentSize == config.pvmProgramInitSegmentSize) + } - // Defining Test Cases and Test Methods - // https://developer.apple.com/documentation/xctest/defining_test_cases_and_test_methods + @Test func commandWithNoConfig() async throws { + let sepc = ResourceLoader.loadResource(named: "devnet_noconfig_spec.json")!.path() + let genesis: Genesis = .file(path: sepc) + let config = ProtocolConfigRef.dev.value + let (_, protocolConfig) = try await genesis.load() + #expect(protocolConfig.value.maxWorkItems == config.maxWorkItems) + #expect(protocolConfig.value.serviceMinBalance == config.serviceMinBalance) } } diff --git a/Boka/Tests/BokaTests/chainfiles/devnet_allconfig_spec.json b/Boka/Tests/BokaTests/chainfiles/devnet_allconfig_spec.json new file mode 100644 index 00000000..7613c9a8 --- /dev/null +++ b/Boka/Tests/BokaTests/chainfiles/devnet_allconfig_spec.json @@ -0,0 +1,42 @@ +{ + "name": "Devnet", + "id": "devnet-1", + "bootnodes": ["127.0.0.1:9955"], + "config": { + "auditTranchePeriod": 10, + "additionalMinBalancePerStateItem": 1, + "additionalMinBalancePerStateByte": 1, + "serviceMinBalance": 100, + "totalNumberOfCores": 1, + "preimagePurgePeriod": 100, + "epochLength": 1000, + "auditBiasFactor": 1, + "coreAccumulationGas": 10, + "workPackageAuthorizerGas": 5, + "workPackageRefineGas": 2, + "recentHistorySize": 10, + "maxWorkItems": 2, + "maxTicketsPerExtrinsic": 1, + "maxLookupAnchorAge": 10, + "transferMemoSize": 64, + "ticketEntriesPerValidator": 1, + "maxAuthorizationsPoolItems": 10, + "slotPeriodSeconds": 1, + "maxAuthorizationsQueueItems": 5, + "coreAssignmentRotationPeriod": 100, + "maxServiceCodeSize": 256, + "preimageReplacementPeriod": 100, + "totalNumberOfValidators": 5, + "erasureCodedPieceSize": 128, + "maxWorkPackageManifestEntries": 2, + "maxEncodedWorkPackageSize": 512, + "maxEncodedWorkReportSize": 256, + "erasureCodedSegmentSize": 1024, + "ticketSubmissionEndSlot": 10, + "pvmDynamicAddressAlignmentFactor": 2, + "pvmProgramInitInputDataSize": 64, + "pvmProgramInitPageSize": 1024, + "pvmProgramInitSegmentSize": 2048 + }, + "state": "0x789abc" +} diff --git a/Boka/Tests/BokaTests/chainfiles/devnet_noconfig_spec.json b/Boka/Tests/BokaTests/chainfiles/devnet_noconfig_spec.json new file mode 100644 index 00000000..92f107cc --- /dev/null +++ b/Boka/Tests/BokaTests/chainfiles/devnet_noconfig_spec.json @@ -0,0 +1,11 @@ +{ + "name": "MainNet", + "id": "mainnet-456", + "bootnodes": [ + "node1.mainnet.com", + "node2.mainnet.com" + ], + "preset": "dev", + "state": "0x1234567890abcdef" + } + \ No newline at end of file diff --git a/Boka/Tests/BokaTests/chainfiles/mainnet_someconfig_spec.json b/Boka/Tests/BokaTests/chainfiles/mainnet_someconfig_spec.json new file mode 100644 index 00000000..5bc02817 --- /dev/null +++ b/Boka/Tests/BokaTests/chainfiles/mainnet_someconfig_spec.json @@ -0,0 +1,26 @@ +{ + "name": "Mainnet", + "id": "mainnet-1", + "bootnodes": [ + "127.0.0.1:9955" + ], + "preset": "mainnet", + "config": { + "auditTranchePeriod": 100, + "additionalMinBalancePerStateItem": 10, + "additionalMinBalancePerStateByte": 1, + "serviceMinBalance": 1000, + "totalNumberOfCores": 4, + "preimagePurgePeriod": 1000, + "epochLength": 10000, + "auditBiasFactor": 5, + "coreAccumulationGas": 100, + "workPackageAuthorizerGas": 50, + "workPackageRefineGas": 20, + "recentHistorySize": 100, + "maxWorkItems": 10, + "maxTicketsPerExtrinsic": 5, + "maxLookupAnchorAge": 100 + }, + "state": "0xabcdef" +} diff --git a/Networking/.swiftpm/xcode/xcshareddata/xcschemes/Networking.xcscheme b/Networking/.swiftpm/xcode/xcshareddata/xcschemes/Networking.xcscheme index 943c06eb..7cdbd250 100644 --- a/Networking/.swiftpm/xcode/xcshareddata/xcschemes/Networking.xcscheme +++ b/Networking/.swiftpm/xcode/xcshareddata/xcschemes/Networking.xcscheme @@ -40,6 +40,16 @@ ReferencedContainer = "container:"> + + + + (StateRef, ProtocolConfigRef) { switch self { - case .file: - fatalError("TODO: not implemented") case .dev: let config = ProtocolConfigRef.dev let state = try State.devGenesis(config: config) - return (StateRef(state), config) + case let .file(path): + let genesis = try readAndValidateGenesis(from: path) + var config: ProtocolConfig + let preset = genesis.preset?.lowercased() + switch preset { + case "dev", "mainnet": + config = + (preset == "dev" + ? ProtocolConfigRef.dev.value : ProtocolConfigRef.mainnet.value) + if let genesisConfig = genesis.config { + config = config.merged(with: genesisConfig) + } + default: + // In this case, genesis.config has been verified to be non-nil + config = genesis.config! + } + let configRef = Ref(config) + let state = try State.devGenesis(config: configRef) + return (StateRef(state), configRef) + } + } + + private func validate(_ genesis: GenesisData) throws { + // Validate required fields + if genesis.name.isEmpty { + throw GenesisError.invalidFormat("Invalid or missing 'name'") + } + if genesis.id.isEmpty { + throw GenesisError.invalidFormat("Invalid or missing 'id'") + } + if genesis.bootnodes.isEmpty { + throw GenesisError.invalidFormat("Invalid or missing 'bootnodes'") + } + if genesis.state.isEmpty { + throw GenesisError.invalidFormat("Invalid or missing 'state'") + } + let preset = genesis.preset?.lowercased() + if preset != nil, !["dev", "mainnet"].contains(preset!) { + throw GenesisError.invalidFormat("Invalid preset value. Must be 'dev' or 'mainnet'.") + } + } + + func readAndValidateGenesis(from filePath: String) throws -> GenesisData { + do { + let fileContents = try String(contentsOfFile: filePath, encoding: .utf8) + let data = fileContents.data(using: .utf8)! + let decoder = JSONDecoder() + let genesis = try decoder.decode(GenesisData.self, from: data) + try validate(genesis) + return genesis + } catch let error as GenesisError { + throw error + } catch { + throw GenesisError.fileReadError(error) + } + } +} + +extension KeyedDecodingContainer { + func decode(_: ProtocolConfig.Type, forKey key: K, required: Bool = true) throws -> ProtocolConfig { + let nestedDecoder = try superDecoder(forKey: key) + return try ProtocolConfig(from: nestedDecoder, required) + } + + func decodeIfPresent(_: ProtocolConfig.Type, forKey key: K, required: Bool = false) throws -> ProtocolConfig? { + guard contains(key) else { return nil } + let nestedDecoder = try superDecoder(forKey: key) + return try ProtocolConfig(from: nestedDecoder, required) + } +} + +struct GenesisData: Sendable, Codable { + var name: String + var id: String + var bootnodes: [String] + var preset: String? + var config: ProtocolConfig? + // TODO: check & deal with state + var state: String + + init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + name = try container.decode(String.self, forKey: .name) + id = try container.decode(String.self, forKey: .id) + bootnodes = try container.decode([String].self, forKey: .bootnodes) + preset = try container.decodeIfPresent(String.self, forKey: .preset) + if preset == nil || !["dev", "mainnet"].contains(preset) { + config = try container.decode(ProtocolConfig.self, forKey: .config, required: true) + } else { + config = try container.decodeIfPresent(ProtocolConfig.self, forKey: .config, required: false) } + state = try container.decode(String.self, forKey: .state) } } diff --git a/RPC/Package.resolved b/RPC/Package.resolved index cb3923e3..8dce31cb 100644 --- a/RPC/Package.resolved +++ b/RPC/Package.resolved @@ -1,13 +1,13 @@ { - "originHash" : "b321ce09e4e6d9d71a2e200de7c83616493e740a9be4805f0d13a7caba7a8086", + "originHash" : "7b96cffee59bcf3ffc3dd86f84561500dff49efc82bcdd615bb1d37430c8c096", "pins" : [ { "identity" : "async-http-client", "kind" : "remoteSourceControl", "location" : "https://github.com/swift-server/async-http-client.git", "state" : { - "revision" : "0ae99db85b2b9d1e79b362bd31fd1ffe492f7c47", - "version" : "1.21.2" + "revision" : "64abc77edf1ef81e69bd90a2ac386de615c8e8ea", + "version" : "1.23.0" } }, { @@ -15,8 +15,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/vapor/async-kit.git", "state" : { - "revision" : "15b3fb7b2437f9db11f6ddcf365c5b5db8c3a346", - "version" : "1.19.1" + "revision" : "e048c8ee94967e8d8a1c2ec0e1156d6f7fa34d31", + "version" : "1.20.0" } }, { @@ -33,8 +33,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/vapor/console-kit.git", "state" : { - "revision" : "9f7932f22ab6f64aafadc14491e694179b7d0f6f", - "version" : "4.14.3" + "revision" : "78c0dd739df8cb9ee14a8bbbf770facc4fc3402a", + "version" : "4.15.0" } }, { @@ -78,8 +78,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-collections.git", "state" : { - "revision" : "3d2dc41a01f9e49d84f0a3925fb858bed64f702d", - "version" : "1.1.2" + "revision" : "671108c96644956dddcd89dd59c203dcdb36cec7", + "version" : "1.1.4" } }, { @@ -87,8 +87,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-crypto.git", "state" : { - "revision" : "46072478ca365fe48370993833cb22de9b41567f", - "version" : "3.5.2" + "revision" : "ffca28be3c9c6a86a579949d23f68818a4b9b5d8", + "version" : "3.8.0" } }, { @@ -96,8 +96,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-distributed-tracing.git", "state" : { - "revision" : "11c756c5c4d7de0eeed8595695cadd7fa107aa19", - "version" : "1.1.1" + "revision" : "6483d340853a944c96dbcc28b27dd10b6c581703", + "version" : "1.1.2" } }, { @@ -132,8 +132,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-nio.git", "state" : { - "revision" : "fc79798d5a150d61361a27ce0c51169b889e23de", - "version" : "2.68.0" + "revision" : "665206000b8307cab5ac51203d29b0f232d7e31b", + "version" : "2.74.0" } }, { @@ -141,8 +141,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-nio-extras.git", "state" : { - "revision" : "05c36b57453d23ea63785d58a7dbc7b70ba1745e", - "version" : "1.23.0" + "revision" : "d1ead62745cc3269e482f1c51f27608057174379", + "version" : "1.24.0" } }, { @@ -150,8 +150,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-nio-http2.git", "state" : { - "revision" : "a0224f3d20438635dd59c9fcc593520d80d131d0", - "version" : "1.33.0" + "revision" : "eaa71bb6ae082eee5a07407b1ad0cbd8f48f9dca", + "version" : "1.34.1" } }, { @@ -159,8 +159,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-nio-ssl.git", "state" : { - "revision" : "2b09805797f21c380f7dc9bedaab3157c5508efb", - "version" : "2.27.0" + "revision" : "7b84abbdcef69cc3be6573ac12440220789dcd69", + "version" : "2.27.2" } }, { @@ -168,8 +168,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-nio-transport-services.git", "state" : { - "revision" : "38ac8221dd20674682148d6451367f89c2652980", - "version" : "1.21.0" + "revision" : "dbace16f126fdcd80d58dc54526c561ca17327d7", + "version" : "1.22.0" } }, { @@ -195,8 +195,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-syntax.git", "state" : { - "revision" : "06b5cdc432e93b60e3bdf53aff2857c6b312991a", - "version" : "600.0.0-prerelease-2024-07-30" + "revision" : "0687f71944021d616d34d922343dcef086855920", + "version" : "600.0.1" } }, { @@ -204,8 +204,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-system.git", "state" : { - "revision" : "6a9e38e7bd22a3b8ba80bddf395623cf68f57807", - "version" : "1.3.1" + "revision" : "d2ba781702a1d8285419c15ee62fd734a9437ff5", + "version" : "1.3.2" } }, { @@ -222,8 +222,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/vapor/vapor.git", "state" : { - "revision" : "a823735db57b46100b0c61cdfc5a08525b1e7cad", - "version" : "4.102.1" + "revision" : "1466c50e4ad39072143e2fcdf13b4ba11be375a0", + "version" : "4.106.0" } }, { diff --git a/RPC/Package.swift b/RPC/Package.swift index 83db47f3..f175b3f3 100644 --- a/RPC/Package.swift +++ b/RPC/Package.swift @@ -18,9 +18,10 @@ let package = Package( dependencies: [ .package(path: "../Blockchain"), .package(path: "../Utils"), - .package(url: "https://github.com/vapor/vapor.git", from: "4.102.1"), - .package(url: "https://github.com/vapor/async-kit.git", from: "1.19.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: "0.10.0"), + ], targets: [ // Targets are the basic building blocks of a package, defining a module or a test suite. diff --git a/RPC/Sources/RPC/Server.swift b/RPC/Sources/RPC/Server.swift index bcf29b64..5540be93 100644 --- a/RPC/Sources/RPC/Server.swift +++ b/RPC/Sources/RPC/Server.swift @@ -23,8 +23,8 @@ public class Server { public init(config: Config, source: DataSource) throws { self.config = config self.source = source - - let env = try Environment.detect() + // TODO: add env to arguments + let env = try Environment.detect(arguments: ["--env"]) app = Application(env) var handlers: [String: JSONRPCHandler] = SystemHandler.getHandlers() diff --git a/boka.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/boka.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 1da8d5a1..3db802d8 100644 --- a/boka.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/boka.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -33,8 +33,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/vapor/console-kit.git", "state" : { - "revision" : "9f7932f22ab6f64aafadc14491e694179b7d0f6f", - "version" : "4.14.3" + "revision" : "78c0dd739df8cb9ee14a8bbbf770facc4fc3402a", + "version" : "4.15.0" } }, { @@ -73,15 +73,6 @@ "version" : "1.2.0" } }, - { - "identity" : "swift-argument-parser", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-argument-parser.git", - "state" : { - "revision" : "0fbc8848e389af3bb55c182bc19ca9d5dc2f255b", - "version" : "1.4.0" - } - }, { "identity" : "swift-asn1", "kind" : "remoteSourceControl", @@ -186,8 +177,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-nio-extras.git", "state" : { - "revision" : "05c36b57453d23ea63785d58a7dbc7b70ba1745e", - "version" : "1.23.0" + "revision" : "d1ead62745cc3269e482f1c51f27608057174379", + "version" : "1.24.0" } }, { @@ -220,7 +211,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" @@ -294,8 +285,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/vapor/vapor.git", "state" : { - "revision" : "a823735db57b46100b0c61cdfc5a08525b1e7cad", - "version" : "4.102.1" + "revision" : "1466c50e4ad39072143e2fcdf13b4ba11be375a0", + "version" : "4.106.0" } }, {