Skip to content

Commit

Permalink
Merge branch 'main' into docs/readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Trantorian1 committed Nov 28, 2024
2 parents 70d36de + de271ba commit 8b51655
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 20 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Next release

- fix(tracing): RUST_LOG filtering support
- fix(fgw): fetch class
- feat: possibility of starting madara & kakarot-rpc in docker
- feat(debug): service cancelling and profiling build
- feat(endpoint): added extra admin rpc endpoint for sensitive rpc calls
Expand Down
35 changes: 30 additions & 5 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -238,3 +238,5 @@ tracing-opentelemetry = "0.26.0"
[patch.crates-io]
# wait for PR https://github.com/starknet-io/types-rs/pull/76 to be merged
starknet-types-core = { git = "https://github.com/kasarlabs/types-rs.git", branch = "feat-deserialize-v0.1.7" }

starknet-core = { git = "https://github.com/kasarlabs/starknet-rs.git", branch = "fork" }
14 changes: 5 additions & 9 deletions crates/client/analytics/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,27 @@ use tracing::Level;
use tracing_opentelemetry::OpenTelemetryLayer;
use tracing_subscriber::layer::SubscriberExt as _;
use tracing_subscriber::util::SubscriberInitExt as _;
use tracing_subscriber::EnvFilter;
use url::Url;

pub struct Analytics {
meter_provider: Option<SdkMeterProvider>,
service_name: String,
log_level: Level,
collection_endpoint: Option<Url>,
}

impl Analytics {
pub fn new(
service_name: String,
log_level: tracing::Level,
collection_endpoint: Option<Url>,
) -> anyhow::Result<Self> {
Ok(Self { meter_provider: None, service_name, log_level, collection_endpoint })
pub fn new(service_name: String, collection_endpoint: Option<Url>) -> anyhow::Result<Self> {
Ok(Self { meter_provider: None, service_name, collection_endpoint })
}

pub fn setup(&mut self) -> anyhow::Result<()> {
let local_offset = UtcOffset::current_local_offset().unwrap_or(UtcOffset::UTC);
let custom_formatter = CustomFormatter { local_offset };

let tracing_subscriber = tracing_subscriber::registry()
.with(tracing_subscriber::filter::LevelFilter::from_level(self.log_level))
.with(tracing_subscriber::fmt::layer().event_format(custom_formatter));
.with(tracing_subscriber::fmt::layer().event_format(custom_formatter))
.with(EnvFilter::from_default_env());

if self.collection_endpoint.is_none() {
tracing_subscriber.init();
Expand Down
11 changes: 11 additions & 0 deletions crates/client/gateway/client/src/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ mod tests {

const CLASS_BLOCK_0: &str = "0x010455c752b86932ce552f2b0fe81a880746649b9aee7e0d842bf3f52378f9f8";

const CLASS_NO_ABI: &str = "0x371b5f7c5517d84205365a87f02dcef230efa7b4dd91a9e4ba7e04c5b69d69b";

const CLASS_ACCOUNT: &str = "0x07595b4f7d50010ceb00230d8b5656e3c3dd201b6df35d805d3f2988c69a1432";
const CLASS_ACCOUNT_BLOCK: u64 = 1342;

Expand Down Expand Up @@ -408,6 +410,15 @@ mod tests {
assert_eq!(class, class_compressed_reference.into());
}

#[rstest]
#[tokio::test]
async fn get_class_by_hash_legacy_without_abi(client_mainnet_fixture: GatewayProvider) {
let _ = client_mainnet_fixture
.get_class_by_hash(Felt::from_hex_unchecked(CLASS_NO_ABI), BlockId::Number(20734))
.await
.unwrap_or_else(|_| panic!("Getting class {CLASS_NO_ABI} at block number 0"));
}

#[rstest]
#[tokio::test]
async fn get_class_by_hash_account(client_mainnet_fixture: GatewayProvider) {
Expand Down
5 changes: 0 additions & 5 deletions crates/node/src/cli/analytics.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use clap::Args;
use mp_utils::parsers::parse_url;
use tracing::Level;
use url::Url;

/// Parameters used to config analytics.
Expand All @@ -10,10 +9,6 @@ pub struct AnalyticsParams {
#[arg(env = "MADARA_ANALYTICS_SERVICE_NAME", long, alias = "analytics", default_value = "madara_analytics")]
pub analytics_service_name: String,

/// Log level of the service.
#[arg(env = "RUST_LOG", long, default_value = "info")]
pub analytics_log_level: Level,

/// Endpoint of the analytics server.
#[arg(env = "OTEL_EXPORTER_OTLP_ENDPOINT", long, value_parser = parse_url, default_value = None)]
pub analytics_collection_endpoint: Option<Url>,
Expand Down
1 change: 0 additions & 1 deletion crates/node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ async fn main() -> anyhow::Result<()> {

let mut analytics = Analytics::new(
run_cmd.analytics_params.analytics_service_name.clone(),
run_cmd.analytics_params.analytics_log_level,
run_cmd.analytics_params.analytics_collection_endpoint.clone(),
)
.context("Initializing analytics service")?;
Expand Down

0 comments on commit 8b51655

Please sign in to comment.