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 15 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
22 changes: 20 additions & 2 deletions Cargo.lock

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

15 changes: 13 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,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 @@ -112,7 +113,9 @@ tracing-subscriber = { version = "0.3.18", features = ["json"] }
url = "2.5.2"

#misc
rust-bls-bn254 = { git = "https://github.com/Layr-Labs/rust-bls-bn254", rev = "ce3313f" ,features = ["std"] }
rust-bls-bn254 = { git = "https://github.com/Layr-Labs/rust-bls-bn254", rev = "ce3313f", features = [
"std",
] }
uuid = { version = "1.11.0", features = ["v4"] }


Expand Down Expand Up @@ -145,7 +148,15 @@ alloy-transport-http = { version = "0.5.3", features = [
], default-features = false }
alloy-transport-ipc = { version = "0.5.3", default-features = false }
alloy-transport-ws = { version = "0.5.3", default-features = false }
alloy = { version = "0.5.3", features = ["sol-types", "contract","full","signer-aws"] }
alloy = { version = "0.5.3", features = [
"sol-types",
"contract",
"full",
"signer-aws",
] }

anvil-utils = { path = "examples/anvil-utils" }
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 @@ -310,6 +386,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 @@ -335,6 +422,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 @@ -366,6 +464,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 @@ -412,6 +521,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 @@ -438,6 +558,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 @@ -473,6 +604,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 @@ -545,6 +687,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