Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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
555 changes: 555 additions & 0 deletions .github/ts-tasks/package-lock.json

Large diffs are not rendered by default.

368 changes: 208 additions & 160 deletions Cargo.lock

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -684,9 +684,9 @@ percent-encoding = "2.1.0"
petgraph = "0.6.5"
pin-project = "1.0.10"
plotters = { version = "0.3.5", default-features = false }
poem = { version = "3.1.3", features = ["anyhow", "compression", "rustls"] }
poem-openapi = { version = "5.1.2", features = ["swagger-ui", "url"] }
poem-openapi-derive = "5.1.1"
poem = { version = "3.1.9", features = ["anyhow", "compression", "rustls"] }
poem-openapi = { version = "5.1.12", features = ["swagger-ui", "url"] }
poem-openapi-derive = "5.1.12"
poseidon-ark = { git = "https://github.com/arnaucube/poseidon-ark.git", rev = "6d2487aa1308d9d3860a2b724c485d73095c1c68" }
pprof = { version = "0.11", features = ["flamegraph", "protobuf-codec"] }
pretty = "0.10.0"
Expand Down Expand Up @@ -748,7 +748,7 @@ siphasher = "0.3.10"
serde = { version = "1.0.193", features = ["derive", "rc"] }
serde-big-array = "0.5.1"
serde_bytes = "0.11.6"
serde_json = { version = "1.0.81", features = [
serde_json = { version = "1.0.140", features = [
"preserve_order",
"arbitrary_precision",
] } # Note: arbitrary_precision is required to parse u256 in JSON
Expand Down Expand Up @@ -824,7 +824,8 @@ wasm-bindgen = "0.2.95"
wasm-bindgen-futures = "0.4.42"
which = "4.2.5"
whoami = "1.5.0"
x25519-dalek = "1.2.0"
x25519-dalek = { git = "https://github.com/aptos-labs/x25519-dalek", branch = "zeroize_v1" }
zeroize = "1.6.0"
z3tracer = "0.8.0"

# MOVE DEPENDENCIES
Expand Down Expand Up @@ -906,7 +907,7 @@ debug = true
[patch.crates-io]
serde-reflection = { git = "https://github.com/aptos-labs/serde-reflection", rev = "73b6bbf748334b71ff6d7d09d06a29e3062ca075" }
merlin = { git = "https://github.com/aptos-labs/merlin" }
x25519-dalek = { git = "https://github.com/aptos-labs/x25519-dalek", rev = "b9cdbaf36bf2a83438d9f660e5a708c82ed60d8e" }
x25519-dalek = { git = "https://github.com/aptos-labs/x25519-dalek", branch = "zeroize_v1" }
futures = { git = "https://github.com/aptos-labs/futures-rs", branch = "backport" }
futures-channel = { git = "https://github.com/aptos-labs/futures-rs", branch = "backport" }
futures-executor = { git = "https://github.com/aptos-labs/futures-rs", branch = "backport" }
Expand Down
1 change: 1 addition & 0 deletions api/src/bcs_payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ impl ApiResponse for Bcs {
responses: vec![MetaResponse {
description: "BCS: Binary Canonical Serialization",
status: Some(200),
status_range: None,
content: vec![MetaMediaType {
content_type: Self::CONTENT_TYPE,
schema: Self::schema_ref(),
Expand Down
3 changes: 3 additions & 0 deletions aptos-move/aptos-vm-logging/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ aptos-types = { workspace = true }
arc-swap = { workspace = true }
once_cell = { workspace = true }
serde = { workspace = true }

[features]
metrics = []
16 changes: 10 additions & 6 deletions aptos-move/aptos-vm-logging/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
// Copyright © Aptos Foundation
// SPDX-License-Identifier: Apache-2.0

#[cfg(feature = "metrics")]
pub mod counters;
pub mod log_schema;

pub mod prelude {
#[cfg(feature = "metrics")]
pub use crate::counters::CRITICAL_ERRORS;
pub use crate::{
alert, counters::CRITICAL_ERRORS, disable_speculative_logging, speculative_debug,
speculative_error, speculative_info, speculative_log, speculative_trace, speculative_warn,
alert, disable_speculative_logging, speculative_debug, speculative_error, speculative_info,
speculative_log, speculative_trace, speculative_warn,
};
}

use crate::{
counters::{CRITICAL_ERRORS, SPECULATIVE_LOGGING_ERRORS},
log_schema::AdapterLogSchema,
};
#[cfg(feature = "metrics")]
use crate::counters::{CRITICAL_ERRORS, SPECULATIVE_LOGGING_ERRORS};
use crate::log_schema::AdapterLogSchema;
use aptos_logger::{prelude::*, Level};
use aptos_speculative_state_helper::{SpeculativeEvent, SpeculativeEvents};
use arc_swap::ArcSwapOption;
Expand Down Expand Up @@ -163,6 +165,7 @@ pub fn clear_speculative_txn_logs(txn_idx: usize) {
macro_rules! alert {
($($args:tt)+) => {
error!($($args)+);
#[cfg(feature = "metrics")]
CRITICAL_ERRORS.inc();
};
}
Expand All @@ -171,6 +174,7 @@ macro_rules! alert {
macro_rules! speculative_alert {
($($args:tt)+) => {
warn!($($args)+);
#[cfg(feature = "metrics")]
SPECULATIVE_LOGGING_ERRORS.inc();
};
}
Expand Down
3 changes: 2 additions & 1 deletion aptos-move/aptos-vm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ aptos-block-partitioner = { workspace = true }
aptos-crypto = { workspace = true }
aptos-crypto-derive = { workspace = true }
aptos-experimental-runtimes = { workspace = true }
aptos-framework = { workspace = true }
aptos-framework = { workspace = true }
aptos-gas-algebra = { workspace = true }
aptos-gas-meter = { workspace = true }
aptos-gas-schedule = { workspace = true }
Expand Down Expand Up @@ -76,3 +76,4 @@ default = []
fuzzing = ["move-core-types/fuzzing", "move-binary-format/fuzzing", "move-vm-types/fuzzing", "aptos-framework/fuzzing", "aptos-types/fuzzing"]
failpoints = ["fail/failpoints", "move-vm-runtime/failpoints"]
testing = ["move-unit-test", "aptos-framework/testing"]
metrics = []
27 changes: 22 additions & 5 deletions aptos-move/aptos-vm/src/aptos_vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@
// Parts of the project are originally copyright © Meta Platforms, Inc.
// SPDX-License-Identifier: Apache-2.0

#[cfg(feature = "metrics")]
use crate::counters::{
BLOCK_TRANSACTION_COUNT, SYSTEM_TRANSACTIONS_EXECUTED, TRANSACTIONS_VALIDATED, TXN_GAS_USAGE,
TXN_TOTAL_SECONDS, TXN_VALIDATION_SECONDS, USER_TRANSACTIONS_EXECUTED,
};
use crate::{
block_executor::{AptosTransactionOutput, AptosVMBlockExecutorWrapper},
counters::*,
data_cache::{AsMoveResolver, StorageAdapter},
errors::{discarded_output, expect_only_successful_execution},
gas::{check_gas, make_prod_gas_meter, ProdGasMeter},
Expand Down Expand Up @@ -844,10 +848,12 @@ impl AptosVM {
let module_id = traversal_context
.referenced_module_ids
.alloc(entry_fn.module().clone());
check_dependencies_and_charge_gas(module_storage, gas_meter, traversal_context, [(
module_id.address(),
module_id.name(),
)])?;
check_dependencies_and_charge_gas(
module_storage,
gas_meter,
traversal_context,
[(module_id.address(), module_id.name())],
)?;
}

if self.gas_feature_version() >= RELEASE_V1_27 {
Expand Down Expand Up @@ -1825,6 +1831,7 @@ impl AptosVM {
.max_gas_amount()
.checked_sub(gas_meter.balance())
.expect("Balance should always be less than or equal to max gas amount set");
#[cfg(feature = "metrics")]
TXN_GAS_USAGE.observe(u64::from(gas_usage) as f64);

let (vm_status, output) = result.unwrap_or_else(|err| {
Expand Down Expand Up @@ -2102,6 +2109,7 @@ impl AptosVM {
)
.map_err(|e| e.finish(Location::Undefined).into_vm_status())?;

#[cfg(feature = "metrics")]
SYSTEM_TRANSACTIONS_EXECUTED.inc();

let output = VMOutput::new(
Expand Down Expand Up @@ -2149,6 +2157,7 @@ impl AptosVM {
.or_else(|e| {
expect_only_successful_execution(e, BLOCK_PROLOGUE.as_str(), log_context)
})?;
#[cfg(feature = "metrics")]
SYSTEM_TRANSACTIONS_EXECUTED.inc();

let output = get_system_transaction_output(
Expand Down Expand Up @@ -2231,6 +2240,7 @@ impl AptosVM {
.or_else(|e| {
expect_only_successful_execution(e, BLOCK_PROLOGUE_EXT.as_str(), log_context)
})?;
#[cfg(feature = "metrics")]
SYSTEM_TRANSACTIONS_EXECUTED.inc();

let output = get_system_transaction_output(
Expand Down Expand Up @@ -2485,6 +2495,7 @@ impl AptosVM {
},
Transaction::UserTransaction(txn) => {
fail_point!("aptos_vm::execution::user_transaction");
#[cfg(feature = "metrics")]
let _timer = TXN_TOTAL_SECONDS.start_timer();
let (vm_status, output) =
self.execute_user_transaction(resolver, code_storage, txn, log_context);
Expand Down Expand Up @@ -2548,11 +2559,13 @@ impl AptosVM {
}

// Increment the counter for user transactions executed.
#[cfg(feature = "metrics")]
let counter_label = match output.status() {
TransactionStatus::Keep(_) => Some("success"),
TransactionStatus::Discard(_) => Some("discarded"),
TransactionStatus::Retry => None,
};
#[cfg(feature = "metrics")]
if let Some(label) = counter_label {
USER_TRANSACTIONS_EXECUTED.with_label_values(&[label]).inc();
}
Expand Down Expand Up @@ -2632,6 +2645,7 @@ impl AptosVMBlockExecutor {
);
if result.is_ok() {
// Record the histogram count for transactions per block.
#[cfg(feature = "metrics")]
BLOCK_TRANSACTION_COUNT.observe(num_txns as f64);
}
result
Expand Down Expand Up @@ -2686,6 +2700,7 @@ impl VMBlockExecutor for AptosVMBlockExecutor {
);
if ret.is_ok() {
// Record the histogram count for transactions per block.
#[cfg(feature = "metrics")]
BLOCK_TRANSACTION_COUNT.observe(count as f64);
}
ret
Expand All @@ -2710,6 +2725,7 @@ impl VMValidator for AptosVM {
state_view: &impl StateView,
module_storage: &impl ModuleStorage,
) -> VMValidatorResult {
#[cfg(feature = "metrics")]
let _timer = TXN_VALIDATION_SECONDS.start_timer();
let log_context = AdapterLogSchema::new(state_view.id(), 0);

Expand Down Expand Up @@ -2819,6 +2835,7 @@ impl VMValidator for AptosVM {
),
};

#[cfg(feature = "metrics")]
TRANSACTIONS_VALIDATED
.with_label_values(&[counter_label])
.inc();
Expand Down
3 changes: 3 additions & 0 deletions aptos-move/aptos-vm/src/block_executor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

pub(crate) mod vm_wrapper;

#[cfg(feature = "metrics")]
use crate::counters::{BLOCK_EXECUTOR_CONCURRENCY, BLOCK_EXECUTOR_EXECUTE_BLOCK_SECONDS};
use aptos_aggregator::{
delayed_change::DelayedChange, delta_change_set::DeltaOp, resolver::TAggregatorV1View,
Expand Down Expand Up @@ -420,6 +421,7 @@ impl<
transaction_slice_metadata: TransactionSliceMetadata,
transaction_commit_listener: Option<L>,
) -> Result<BlockOutput<TransactionOutput>, VMStatus> {
#[cfg(feature = "metrics")]
let _timer = BLOCK_EXECUTOR_EXECUTE_BLOCK_SECONDS.start_timer();

let num_txns = signature_verified_block.num_txns();
Expand All @@ -429,6 +431,7 @@ impl<
init_speculative_logs(num_txns);
}

#[cfg(feature = "metrics")]
BLOCK_EXECUTOR_CONCURRENCY.set(config.local.concurrency_level as i64);

let mut module_cache_manager_guard = module_cache_manager.try_lock(
Expand Down
2 changes: 1 addition & 1 deletion aptos-move/aptos-vm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
//! +-----------------------------+
//! ```

#[macro_use]
#[cfg(feature = "metrics")]
pub mod counters;
pub mod data_cache;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// Copyright © Aptos Foundation
// SPDX-License-Identifier: Apache-2.0

#[cfg(feature = "metrics")]
use crate::counters::WAIT_FOR_SHARDED_OUTPUT_SECONDS;
use crate::sharded_block_executor::{
coordinator_client::CoordinatorClient,
counters::WAIT_FOR_SHARDED_OUTPUT_SECONDS,
cross_shard_client::CrossShardClient,
executor_client::{ExecutorClient, ShardedExecutionOutput},
global_executor::GlobalExecutor,
Expand Down Expand Up @@ -162,6 +163,7 @@ impl<S: StateView + Sync + Send + 'static> LocalExecutorClient<S> {
}

fn get_output_from_shards(&self) -> Result<Vec<Vec<Vec<TransactionOutput>>>, VMStatus> {
#[cfg(feature = "metrics")]
let _timer = WAIT_FOR_SHARDED_OUTPUT_SECONDS.start_timer();
trace!("LocalExecutorClient Waiting for results");
let mut results = vec![];
Expand Down
15 changes: 9 additions & 6 deletions aptos-move/aptos-vm/src/sharded_block_executor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
// Parts of the project are originally copyright © Meta Platforms, Inc.
// SPDX-License-Identifier: Apache-2.0

use crate::sharded_block_executor::{
counters::{
NUM_EXECUTOR_SHARDS, SHARDED_BLOCK_EXECUTION_SECONDS,
SHARDED_EXECUTION_RESULT_AGGREGATION_SECONDS,
},
executor_client::ExecutorClient,
#[cfg(feature = "metrics")]
use crate::counters::{
NUM_EXECUTOR_SHARDS, SHARDED_BLOCK_EXECUTION_SECONDS,
SHARDED_EXECUTION_RESULT_AGGREGATION_SECONDS,
};
use crate::sharded_block_executor::executor_client::ExecutorClient;
use aptos_logger::info;
use aptos_types::{
block_executor::{
Expand All @@ -23,6 +22,7 @@ use std::{marker::PhantomData, sync::Arc};

pub mod aggr_overridden_state_view;
pub mod coordinator_client;
#[cfg(feature = "metrics")]
mod counters;
pub mod cross_shard_client;
mod cross_shard_state_view;
Expand Down Expand Up @@ -75,8 +75,10 @@ impl<S: StateView + Sync + Send + 'static, C: ExecutorClient<S>> ShardedBlockExe
concurrency_level_per_shard: usize,
onchain_config: BlockExecutorConfigFromOnchain,
) -> Result<Vec<TransactionOutput>, VMStatus> {
#[cfg(feature = "metrics")]
let _timer = SHARDED_BLOCK_EXECUTION_SECONDS.start_timer();
let num_executor_shards = self.executor_client.num_shards();
#[cfg(feature = "metrics")]
NUM_EXECUTOR_SHARDS.set(num_executor_shards as i64);
assert_eq!(
num_executor_shards,
Expand All @@ -95,6 +97,7 @@ impl<S: StateView + Sync + Send + 'static, C: ExecutorClient<S>> ShardedBlockExe
.into_inner();
// wait for all remote executors to send the result back and append them in order by shard id
info!("ShardedBlockExecutor Received all results");
#[cfg(feature = "metrics")]
let _aggregation_timer = SHARDED_EXECUTION_RESULT_AGGREGATION_SECONDS.start_timer();
let num_rounds = sharded_output[0].len();
let mut aggregated_results = vec![];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
// Copyright © Aptos Foundation
// SPDX-License-Identifier: Apache-2.0

#[cfg(feature = "metrics")]
use crate::counters::{
SHARDED_BLOCK_EXECUTION_BY_ROUNDS_SECONDS, SHARDED_BLOCK_EXECUTOR_TXN_COUNT,
SHARDED_EXECUTOR_SERVICE_SECONDS,
};
use crate::{
block_executor::AptosVMBlockExecutorWrapper,
sharded_block_executor::{
aggr_overridden_state_view::{AggregatorOverriddenStateView, TOTAL_SUPPLY_AGGR_BASE_VAL},
coordinator_client::CoordinatorClient,
counters::{
SHARDED_BLOCK_EXECUTION_BY_ROUNDS_SECONDS, SHARDED_BLOCK_EXECUTOR_TXN_COUNT,
SHARDED_EXECUTOR_SERVICE_SECONDS,
},
cross_shard_client::{CrossShardClient, CrossShardCommitReceiver, CrossShardCommitSender},
cross_shard_state_view::CrossShardStateView,
messages::CrossShardMsg,
Expand Down Expand Up @@ -188,9 +189,11 @@ impl<S: StateView + Sync + Send + 'static> ShardedExecutorService<S> {
) -> Result<Vec<Vec<TransactionOutput>>, VMStatus> {
let mut result = vec![];
for (round, sub_block) in transactions.into_sub_blocks().into_iter().enumerate() {
#[cfg(feature = "metrics")]
let _timer = SHARDED_BLOCK_EXECUTION_BY_ROUNDS_SECONDS
.with_label_values(&[&self.shard_id.to_string(), &round.to_string()])
.start_timer();
#[cfg(feature = "metrics")]
SHARDED_BLOCK_EXECUTOR_TXN_COUNT
.with_label_values(&[&self.shard_id.to_string(), &round.to_string()])
.observe(sub_block.transactions.len() as f64);
Expand Down Expand Up @@ -232,6 +235,7 @@ impl<S: StateView + Sync + Send + 'static> ShardedExecutorService<S> {
self.shard_id,
num_txns
);
#[cfg(feature = "metrics")]
let exe_timer = SHARDED_EXECUTOR_SERVICE_SECONDS
.with_label_values(&[&self.shard_id.to_string(), "execute_block"])
.start_timer();
Expand All @@ -246,8 +250,10 @@ impl<S: StateView + Sync + Send + 'static> ShardedExecutorService<S> {
},
);
drop(state_view);
#[cfg(feature = "metrics")]
drop(exe_timer);

#[cfg(feature = "metrics")]
let _result_tx_timer = SHARDED_EXECUTOR_SERVICE_SECONDS
.with_label_values(&[&self.shard_id.to_string(), "result_tx"])
.start_timer();
Expand All @@ -258,10 +264,12 @@ impl<S: StateView + Sync + Send + 'static> ShardedExecutorService<S> {
},
}
}
#[cfg(feature = "metrics")]
let exe_time = SHARDED_EXECUTOR_SERVICE_SECONDS
.get_metric_with_label_values(&[&self.shard_id.to_string(), "execute_block"])
.unwrap()
.get_sample_sum();
#[cfg(feature = "metrics")]
info!(
"Shard {} is shutting down; On shard execution tps {} txns/s ({} txns / {} s)",
self.shard_id,
Expand Down
Loading
Loading