Skip to content

Commit

Permalink
Tracing (#54)
Browse files Browse the repository at this point in the history
* setup tracing utils

* setup tracing
  • Loading branch information
xlc authored Aug 6, 2024
1 parent 34a8f2c commit aae43bb
Show file tree
Hide file tree
Showing 21 changed files with 960 additions and 11 deletions.
155 changes: 154 additions & 1 deletion Blockchain/Package.resolved
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"originHash" : "b411c6a0bd87c7eb9917abe3f20455e142ffe77b06622bdfbf0cf5a8c002daf8",
"originHash" : "a6bbe74d9b5891b7b3286ff9db782962187c36afbc7f0261e2d03479b2b04bf5",
"pins" : [
{
"identity" : "blake2.swift",
Expand All @@ -10,6 +10,15 @@
"version" : "0.2.0"
}
},
{
"identity" : "grpc-swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/grpc/grpc-swift.git",
"state" : {
"revision" : "6a90b7e77e29f9bda6c2b3a4165a40d6c02cfda1",
"version" : "1.23.0"
}
},
{
"identity" : "scalecodec.swift",
"kind" : "remoteSourceControl",
Expand All @@ -19,6 +28,15 @@
"revision" : "dac3e7161de34c60c82794d031de0231b5a5746e"
}
},
{
"identity" : "swift-async-algorithms",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-async-algorithms.git",
"state" : {
"revision" : "6ae9a051f76b81cc668305ceed5b0e0a7fd93d20",
"version" : "1.0.1"
}
},
{
"identity" : "swift-atomics",
"kind" : "remoteSourceControl",
Expand All @@ -28,6 +46,15 @@
"version" : "1.2.0"
}
},
{
"identity" : "swift-collections",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-collections.git",
"state" : {
"revision" : "3d2dc41a01f9e49d84f0a3925fb858bed64f702d",
"version" : "1.1.2"
}
},
{
"identity" : "swift-crypto",
"kind" : "remoteSourceControl",
Expand All @@ -37,6 +64,123 @@
"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" : "05c36b57453d23ea63785d58a7dbc7b70ba1745e",
"version" : "1.23.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-otel",
"kind" : "remoteSourceControl",
"location" : "https://github.com/slashmo/swift-otel.git",
"state" : {
"revision" : "8c271c7fed34a39f29c728598b3358fbdddf8ff4",
"version" : "0.9.0"
}
},
{
"identity" : "swift-protobuf",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-protobuf.git",
"state" : {
"revision" : "e17d61f26df0f0e06f58f6977ba05a097a720106",
"version" : "1.27.1"
}
},
{
"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",
Expand All @@ -46,6 +190,15 @@
"version" : "600.0.0-prerelease-2024-06-12"
}
},
{
"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",
Expand Down
2 changes: 2 additions & 0 deletions Blockchain/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ let package = Package(
],
dependencies: [
.package(path: "../Utils"),
.package(path: "../TracingUtils"),
.package(url: "https://github.com/AcalaNetwork/ScaleCodec.swift.git", branch: "main"),
.package(url: "https://github.com/apple/swift-testing.git", branch: "0.10.0"),
],
Expand All @@ -27,6 +28,7 @@ let package = Package(
name: "Blockchain",
dependencies: [
"Utils",
"TracingUtils",
.product(name: "ScaleCodec", package: "ScaleCodec.swift"),
]
),
Expand Down
13 changes: 9 additions & 4 deletions Blockchain/Sources/Blockchain/Blockchain.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Foundation
import TracingUtils
import Utils

/// Holds the state of the blockchain.
Expand All @@ -15,10 +16,14 @@ public class Blockchain {
}

public func importBlock(_ block: BlockRef) async throws {
let runtime = Runtime(config: config)
let parent = try await dataProvider.getState(hash: block.header.parentHash)
let state = try runtime.apply(block: block, state: parent)
try await dataProvider.add(state: state)
try await withSpan("importBlock") { span in
span.attributes["hash"] = block.hash.description

let runtime = Runtime(config: config)
let parent = try await dataProvider.getState(hash: block.header.parentHash)
let state = try runtime.apply(block: block, state: parent)
try await dataProvider.add(state: state)
}
}

public func finalize(hash: Data32) async throws {
Expand Down
Loading

0 comments on commit aae43bb

Please sign in to comment.