Skip to content

Commit

Permalink
chore(iota-graphql-rpc,move-vm-profiler,iota-node): Allow `unexpected…
Browse files Browse the repository at this point in the history
…_cfgs` and rework some macros (#4831)

* chore(iota-graphql-rpc): Allow `unexpected_cfgs`

* chore(move-vm-profiler,iota-node): Rework `gas_profiler_feature_enabled` to avoid compilation warnings

* One more check for disabled

---------

Co-authored-by: Thibault Martinez <[email protected]>
  • Loading branch information
DaughterOfMars and thibault-martinez authored Jan 22, 2025
1 parent d50a71b commit da3fb8a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
2 changes: 2 additions & 0 deletions crates/iota-graphql-rpc/src/data/pg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ impl QueryExecutor for PgExecutor {
let max_cost = self.limits.max_db_query_cost;
let instant = Instant::now();
let pool = self.inner.get_pool();
#[allow(unexpected_cfgs)]
let result = run_query_async!(&pool, move |conn| txn(&mut PgConnection { max_cost, conn }));
self.metrics
.observe_db_data(instant.elapsed(), result.is_ok());
Expand All @@ -84,6 +85,7 @@ impl QueryExecutor for PgExecutor {
let max_cost = self.limits.max_db_query_cost;
let instant = Instant::now();
let pool = self.inner.get_pool();
#[allow(unexpected_cfgs)]
let result = run_query_repeatable_async!(&pool, move |conn| txn(&mut PgConnection {
max_cost,
conn
Expand Down
2 changes: 1 addition & 1 deletion crates/iota-node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ fn main() {
// figure out how to eliminate crashes in prod because of this.
// ProtocolConfig::poison_get_for_min_version();

move_vm_profiler::gas_profiler_feature_enabled! {
if move_vm_profiler::is_gas_profiler_feature_enabled() {
panic!("Cannot run the iota-node binary with gas-profiler feature enabled");
}

Expand Down
2 changes: 1 addition & 1 deletion crates/iota/src/client_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ impl IotaClientCommands {
tx_digest,
profile_output,
} => {
move_vm_profiler::gas_profiler_feature_disabled! {
if !move_vm_profiler::is_gas_profiler_feature_enabled() {
bail!(
"gas-profiler feature is not enabled, rebuild or reinstall with \
--features gas-profiler"
Expand Down
19 changes: 13 additions & 6 deletions external-crates/move/crates/move-vm-profiler/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,7 @@ macro_rules! profile_dump_file {
#[macro_export]
macro_rules! gas_profiler_feature_enabled {
($($tt:tt)*) => {
if cfg!(feature = "gas-profiler") {
$($tt)*
}
$($tt)*
};
}

Expand All @@ -372,9 +370,7 @@ macro_rules! gas_profiler_feature_enabled {
#[macro_export]
macro_rules! gas_profiler_feature_disabled {
($($tt:tt)*) => {
if !cfg!(feature = "gas-profiler") {
$($tt)*
}
$($tt)*
};
}

Expand All @@ -383,3 +379,14 @@ macro_rules! gas_profiler_feature_disabled {
macro_rules! gas_profiler_feature_disabled {
( $( $tt:tt )* ) => {};
}

pub const fn is_gas_profiler_feature_enabled() -> bool {
#[cfg(feature = "gas-profiler")]
{
true
}
#[cfg(not(feature = "gas-profiler"))]
{
false
}
}

0 comments on commit da3fb8a

Please sign in to comment.