Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Telemetry with Posthog #147

Draft
wants to merge 23 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
21b6b61
initial work for Telemetry
pablodeymo Oct 18, 2024
e04d6e2
TelemetryConfig with capture_event
pablodeymo Oct 21, 2024
74ec9a3
Telemetry in OnceCell
pablodeymo Oct 22, 2024
a784c80
Reordering in a new file
pablodeymo Oct 22, 2024
45f64f6
adding telemetry call in get_operators_stake_in_quorums_at_block
pablodeymo Oct 22, 2024
8f3eaf4
Rename method new to set_config
pablodeymo Oct 22, 2024
a2fd71e
explanation of telemetry in README
pablodeymo Oct 22, 2024
2f2b820
README of eigen-telemetry improved
pablodeymo Oct 23, 2024
6190410
telemetry in other methods
pablodeymo Oct 25, 2024
0f7760e
Run telemetry in sync context
pablodeymo Oct 25, 2024
ab5029a
fixing await error
pablodeymo Oct 25, 2024
c1b3c28
Merge branch 'main' into telemetry
pablodeymo Nov 13, 2024
a169749
Cargo.lock updated
pablodeymo Nov 13, 2024
708a5ea
fake_backend fixed
pablodeymo Nov 13, 2024
f8ebd5a
telemetry calls in all the methods of avsregistry and elcontracts
pablodeymo Nov 15, 2024
0c5c6ea
Merge branch 'main' into telemetry
pablodeymo Dec 17, 2024
55de6b6
Fixing Cargo.toml in crates/chainio/clients/elcontracts
pablodeymo Dec 17, 2024
93a11f1
compilation fixes with telemetry feature
pablodeymo Dec 17, 2024
94b42ea
fix methods new
pablodeymo Dec 17, 2024
5148504
Fix ELChainReader::new and ELChainWriter::new
pablodeymo Dec 18, 2024
b68ce8e
Fix in get_operator_info.rs and register_operator_in_quorum_with_avs_…
pablodeymo Dec 18, 2024
6bfb9aa
Merge branch 'main' into telemetry
pablodeymo Dec 19, 2024
083a49e
cargo.toml
pablodeymo Dec 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 4 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ clippy.question_mark = "warn"
clippy.implicit_return = "allow"

[workspace.dependencies]
#misc
ark-bn254 = "0.5.0"
ark-ec = "0.5.0"
ark-ff = "0.5.0"
Expand All @@ -81,6 +82,7 @@ eigen-services-blsaggregation = { path = "crates/services/bls_aggregation" }
eigen-services-operatorsinfo = { path = "crates/services/operatorsinfo" }
eigen-signer = { path = "crates/signer/" }
eigen-testing-utils = { path = "testing/testing-utils" }
eigen-telemetry = { path = "crates/telemetry/" }
eigen-types = { path = "crates/types/" }
eigen-utils = { path = "crates/utils/" }
eigen-nodeapi = { path = "crates/nodeapi/" }
Expand Down Expand Up @@ -116,13 +118,8 @@ tokio = { version = "1.41", features = ["test-util", "full", "sync"] }
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["json"] }
url = "2.5"

#misc
rust-bls-bn254 = { version = "0.2.1", features = ["std"] }
uuid = { version = "1.11", features = ["v4"] }


#misc
parking_lot = "0.12"


Expand Down Expand Up @@ -160,6 +157,7 @@ alloy-transport-http = { version = "0.7", features = [
], default-features = false }
alloy-transport-ipc = { version = "0.7.0", default-features = false }
alloy-transport-ws = { version = "0.7.0", default-features = false }

avsregistry-read = { path = "examples/avsregistry-read" }
avsregistry-write = { path = "examples/avsregistry-write" }

posthog-rs = "0.2.0"
9 changes: 7 additions & 2 deletions crates/chainio/clients/avsregistry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,17 @@ alloy.workspace = true
alloy-primitives.workspace = true
alloy-signer.workspace = true
alloy-signer-local.workspace = true
ark-ff.workspace = true
async-trait.workspace = true
num-bigint = "0.4.4"
eigen-types.workspace = true
eigen-crypto-bls.workspace = true
ark-ff.workspace = true
eigen-telemetry = { workspace = true, optional = true }
eigen-client-elcontracts.workspace = true
eigen-utils.workspace = true
eigen-logging.workspace = true
num-bigint = "0.4.4"
thiserror.workspace = true
tokio = { workspace = true, optional = true }
tracing.workspace = true


Expand All @@ -34,3 +36,6 @@ eigen-testing-utils.workspace = true
hex = "0.4.3"
once_cell.workspace = true
tokio = { version = "1.37.0", features = ["test-util", "full", "sync"] }

[features]
telemetry = ["dep:eigen-telemetry", "dep:tokio"]
5 changes: 5 additions & 0 deletions crates/chainio/clients/avsregistry/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,14 @@ pub enum AvsRegistryError {
/// Invalid Signature
#[error("Invalid signature")]
InvalidSignature,

/// Parse BigInt
#[error("big int error")]
ParseBigIntError,

/// Telemetry error
#[error("Telemetry error")]
TelemetryError(String),
}

impl From<ElContractsError> for AvsRegistryError {
Expand Down
153 changes: 153 additions & 0 deletions crates/chainio/clients/avsregistry/src/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,17 @@ impl AvsRegistryReader for AvsRegistryChainReader {
.map_err(|_| AvsRegistryError::GetOperatorState)?;

let OperatorStateRetriever::getOperatorState_0Return { _0: quorum } = operator_state;

#[cfg(feature = "telemetry")]
{
let _ = tokio::task::spawn_blocking(move || {
let _ = eigen_telemetry::telemetry::Telemetry::capture_event(
"get_operators_stake_in_quorums_at_block",
)
.map_err(|e| AvsRegistryError::TelemetryError(e.to_string()));
})
.await;
}
Ok(quorum)
}

Expand All @@ -114,6 +125,17 @@ impl AvsRegistryReader for AvsRegistryChainReader {
quorum_numbers: Vec<u8>,
non_signer_operator_ids: Vec<FixedBytes<32>>,
) -> Result<OperatorStateRetriever::CheckSignaturesIndices, AvsRegistryError> {
#[cfg(feature = "telemetry")]
{
let _ = tokio::task::spawn_blocking(move || {
let _ = eigen_telemetry::telemetry::Telemetry::capture_event(
"avsregistryreader.get_check_signatures_indices",
)
.map_err(|e| AvsRegistryError::TelemetryError(e.to_string()));
})
.await;
}

let provider = get_provider(&self.provider);

let contract_operator_state_retriever =
Expand All @@ -137,6 +159,17 @@ impl AvsRegistryReader for AvsRegistryChainReader {
&self,
operator_id: [u8; 32],
) -> Result<Address, AvsRegistryError> {
#[cfg(feature = "telemetry")]
{
let _ = tokio::task::spawn_blocking(move || {
let _ = eigen_telemetry::telemetry::Telemetry::capture_event(
"avsregistryreader.get_operator_from_id",
)
.map_err(|e| AvsRegistryError::TelemetryError(e.to_string()));
})
.await;
}

let provider = get_provider(&self.provider);

let contract_registry_coordinator =
Expand Down Expand Up @@ -169,6 +202,16 @@ impl AvsRegistryChainReader {
operator_state_retriever_addr: Address,
http_provider_url: String,
) -> Result<AvsRegistryChainReader, AvsRegistryError> {
#[cfg(feature = "telemetry")]
{
let _ = tokio::task::spawn_blocking(move || {
let _ =
eigen_telemetry::telemetry::Telemetry::capture_event("avsregistryreader.new")
.map_err(|e| AvsRegistryError::TelemetryError(e.to_string()));
})
.await;
}

let provider = get_provider(&http_provider_url);

let contract_registry_coordinator =
Expand Down Expand Up @@ -209,6 +252,17 @@ impl AvsRegistryChainReader {
///
/// The total quorum count read from the RegistryCoordinator.
pub async fn get_quorum_count(&self) -> Result<u8, AvsRegistryError> {
#[cfg(feature = "telemetry")]
{
let _ = tokio::task::spawn_blocking(move || {
let _ = eigen_telemetry::telemetry::Telemetry::capture_event(
"avsregistryreader.get_quorum_count",
)
.map_err(|e| AvsRegistryError::TelemetryError(e.to_string()));
})
.await;
}

let provider = get_provider(&self.provider);

let contract_registry_coordinator =
Expand Down Expand Up @@ -241,6 +295,17 @@ impl AvsRegistryChainReader {
block_number: u32,
operator_id: B256,
) -> Result<(U256, Vec<Vec<OperatorStateRetriever::Operator>>), AvsRegistryError> {
#[cfg(feature = "telemetry")]
{
let _ = tokio::task::spawn_blocking(move || {
let _ = eigen_telemetry::telemetry::Telemetry::capture_event(
"avsregistryreader.get_operators_stake_in_quorums_at_block_operator_id",
)
.map_err(|e| AvsRegistryError::TelemetryError(e.to_string()));
})
.await;
}

let provider = get_provider(&self.provider);

let contract_operator_state_retriever =
Expand Down Expand Up @@ -276,6 +341,17 @@ impl AvsRegistryChainReader {
&self,
quorum_numbers: Bytes,
) -> Result<Vec<Vec<OperatorStateRetriever::Operator>>, AvsRegistryError> {
#[cfg(feature = "telemetry")]
{
let _ = tokio::task::spawn_blocking(move || {
let _ = eigen_telemetry::telemetry::Telemetry::capture_event(
"avsregistryreader.get_operators_stake_in_quorums_at_current_block",
)
.map_err(|e| AvsRegistryError::TelemetryError(e.to_string()));
})
.await;
}

let provider = get_provider(&self.provider);

let current_block_number = provider
Expand Down Expand Up @@ -309,6 +385,17 @@ impl AvsRegistryChainReader {
operator_id: B256,
block_number: u32,
) -> Result<(Vec<u8>, Vec<Vec<OperatorStateRetriever::Operator>>), AvsRegistryError> {
#[cfg(feature = "telemetry")]
{
let _ = tokio::task::spawn_blocking(move || {
let _ = eigen_telemetry::telemetry::Telemetry::capture_event(
"avsregistryreader.get_operators_stake_in_quorums_of_operator_at_block",
)
.map_err(|e| AvsRegistryError::TelemetryError(e.to_string()));
})
.await;
}

let (quorum_bitmaps, operator_stakes) = self
.get_operators_stake_in_quorums_at_block_operator_id(block_number, operator_id)
.await
Expand All @@ -334,6 +421,17 @@ impl AvsRegistryChainReader {
&self,
operator_id: B256,
) -> Result<(Vec<u8>, Vec<Vec<OperatorStateRetriever::Operator>>), AvsRegistryError> {
#[cfg(feature = "telemetry")]
{
let _ = tokio::task::spawn_blocking(move || {
let _ = eigen_telemetry::telemetry::Telemetry::capture_event(
"avsregistryreader.get_operators_stake_in_quorums_of_operator_at_current_block",
)
.map_err(|e| AvsRegistryError::TelemetryError(e.to_string()));
})
.await;
}

let provider = get_provider(&self.provider);

let current_block_number = provider.get_block_number().await.map_err(|e| {
Expand Down Expand Up @@ -365,6 +463,17 @@ impl AvsRegistryChainReader {
&self,
operator_id: B256,
) -> Result<HashMap<u8, BigInt>, AvsRegistryError> {
#[cfg(feature = "telemetry")]
{
let _ = tokio::task::spawn_blocking(move || {
let _ = eigen_telemetry::telemetry::Telemetry::capture_event(
"avsregistryreader.get_operator_stake_in_quorums_of_operator_at_current_block",
)
.map_err(|e| AvsRegistryError::TelemetryError(e.to_string()));
})
.await;
}

let provider = get_provider(&self.provider);

let registry_coordinator =
Expand Down Expand Up @@ -449,6 +558,17 @@ impl AvsRegistryChainReader {
&self,
operator_address: Address,
) -> Result<FixedBytes<32>, AvsRegistryError> {
#[cfg(feature = "telemetry")]
{
let _ = tokio::task::spawn_blocking(move || {
let _ = eigen_telemetry::telemetry::Telemetry::capture_event(
"avsregistryreader.get_operator_id",
)
.map_err(|e| AvsRegistryError::TelemetryError(e.to_string()));
})
.await;
}

let provider = get_provider(&self.provider);

let contract_registry_coordinator =
Expand All @@ -475,6 +595,17 @@ impl AvsRegistryChainReader {
&self,
operator_address: Address,
) -> Result<bool, AvsRegistryError> {
#[cfg(feature = "telemetry")]
{
let _ = tokio::task::spawn_blocking(move || {
let _ = eigen_telemetry::telemetry::Telemetry::capture_event(
"avsregistryreader.is_operator_registered",
)
.map_err(|e| AvsRegistryError::TelemetryError(e.to_string()));
})
.await;
}

let provider = get_provider(&self.provider);

let contract_registry_coordinator =
Expand Down Expand Up @@ -510,6 +641,17 @@ impl AvsRegistryChainReader {
mut stop_block: u64,
ws_url: String,
) -> Result<(Vec<Address>, Vec<OperatorPubKeys>), AvsRegistryError> {
#[cfg(feature = "telemetry")]
{
let _ = tokio::task::spawn_blocking(move || {
let _ = eigen_telemetry::telemetry::Telemetry::capture_event(
"avsregistryreader.query_existing_registered_operator_pub_keys",
)
.map_err(|e| AvsRegistryError::TelemetryError(e.to_string()));
})
.await;
}

let provider = get_ws_provider(&ws_url).await.map_err(|e| {
AvsRegistryError::AlloyContractError(alloy::contract::Error::TransportError(e))
})?;
Expand Down Expand Up @@ -582,6 +724,17 @@ impl AvsRegistryChainReader {
start_block: u64,
stop_block: u64,
) -> Result<HashMap<FixedBytes<32>, String>, AvsRegistryError> {
#[cfg(feature = "telemetry")]
{
let _ = tokio::task::spawn_blocking(move || {
let _ = eigen_telemetry::telemetry::Telemetry::capture_event(
"avsregistryreader.query_existing_registered_operator_sockets",
)
.map_err(|e| AvsRegistryError::TelemetryError(e.to_string()));
})
.await;
}

let provider = get_provider(&self.provider);

let mut operator_id_to_socket = HashMap::new();
Expand Down
Loading
Loading