Skip to content

Commit

Permalink
Split out effects from messages.rs (#11479)
Browse files Browse the repository at this point in the history
messages.rs is growing too much. Split out TransactionEffects and
related structures.
There are a few more that I would want to split out latter.

---------

Co-authored-by: ade <[email protected]>
  • Loading branch information
lxfind and oxade authored Apr 29, 2023
1 parent 47cdc59 commit 09b2081
Show file tree
Hide file tree
Showing 76 changed files with 867 additions and 670 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

20 changes: 10 additions & 10 deletions crates/sui-adapter/src/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ use std::{collections::BTreeMap, sync::Arc};

use anyhow::Result;
use move_binary_format::{access::ModuleAccess, file_format::CompiledModule};
use move_bytecode_verifier::{verify_module_with_config, VerifierConfig};
use move_bytecode_verifier::meter::Meter;
use move_bytecode_verifier::{verify_module_with_config_metered, VerifierConfig};
use move_core_types::{account_address::AccountAddress, vm_status::StatusCode};
pub use move_vm_runtime::move_vm::MoveVM;
use move_vm_runtime::{
Expand All @@ -25,7 +26,7 @@ use sui_types::{
object::Owner,
storage::ChildObjectResolver,
};
use sui_verifier::verifier::verify_module;
use sui_verifier::verifier::sui_verify_module_metered;

sui_macros::checked_arithmetic! {

Expand Down Expand Up @@ -166,6 +167,8 @@ pub fn missing_unwrapped_msg(id: &ObjectID) -> String {
pub fn run_metered_move_bytecode_verifier(
module_bytes: &[Vec<u8>],
protocol_config: &ProtocolConfig,
metered_verifier_config: &VerifierConfig,
meter: &mut impl Meter
) -> Result<(), SuiError> {
let modules_stat = module_bytes
.iter()
Expand All @@ -185,21 +188,18 @@ pub fn run_metered_move_bytecode_verifier(
return Ok(());
};

// We use a custom config with metering enabled
let metered_verifier_config =
default_verifier_config(protocol_config, true /* enable metering */);

run_metered_move_bytecode_verifier_impl(&modules, protocol_config, &metered_verifier_config)
run_metered_move_bytecode_verifier_impl(&modules, protocol_config, metered_verifier_config, meter)
}

pub fn run_metered_move_bytecode_verifier_impl(
modules: &[CompiledModule],
protocol_config: &ProtocolConfig,
verifier_config: &VerifierConfig
verifier_config: &VerifierConfig,
meter: &mut impl Meter
) -> Result<(), SuiError> {
// run the Move verifier
for module in modules.iter() {
if let Err(e) = verify_module_with_config(verifier_config, module) {
if let Err(e) = verify_module_with_config_metered(verifier_config, module, meter) {
// Check that the status indicates mtering timeout
// TODO: currently the Move verifier emits `CONSTRAINT_NOT_SATISFIED` for various failures including metering timeout
// We need to change the VM error code to be more specific when timedout for metering
Expand All @@ -213,7 +213,7 @@ pub fn run_metered_move_bytecode_verifier_impl(
error: "Verification timedout".to_string(),
});
};
verify_module(protocol_config, verifier_config, module, &BTreeMap::new())?
sui_verify_module_metered(protocol_config, module, &BTreeMap::new(), meter)?
}
}
Ok(())
Expand Down
3 changes: 2 additions & 1 deletion crates/sui-adapter/src/execution_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use sui_macros::checked_arithmetic;
use sui_protocol_config::{check_limit_by_meter, LimitThresholdCrossed, ProtocolConfig};
use sui_types::clock::{CLOCK_MODULE_NAME, CONSENSUS_COMMIT_PROLOGUE_FUNCTION_NAME};
use sui_types::committee::EpochId;
use sui_types::effects::TransactionEffects;
use sui_types::epoch_data::EpochData;
use sui_types::error::{ExecutionError, ExecutionErrorKind};
use sui_types::execution_status::ExecutionStatus;
Expand All @@ -41,7 +42,7 @@ use sui_types::temporary_store::TemporaryStore;
use sui_types::{
base_types::{ObjectRef, SuiAddress, TransactionDigest, TxContext},
gas::SuiGasStatus,
messages::{CallArg, ChangeEpoch, TransactionEffects},
messages::{CallArg, ChangeEpoch},
object::Object,
storage::BackingPackageStore,
sui_system_state::{ADVANCE_EPOCH_FUNCTION_NAME, SUI_SYSTEM_MODULE_NAME},
Expand Down
9 changes: 2 additions & 7 deletions crates/sui-adapter/src/programmable_transactions/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,7 @@ use sui_verifier::{
INIT_FN_NAME,
};

use crate::{
adapter::{default_verifier_config, substitute_package_id},
execution_mode::ExecutionMode,
};
use crate::{adapter::substitute_package_id, execution_mode::ExecutionMode};

use super::{context::*, types::*};

Expand Down Expand Up @@ -854,12 +851,10 @@ fn publish_and_verify_modules<S: StorageView>(
.map_err(|e| context.convert_vm_error(e))?;

// run the Sui verifier
let verifier_config =
default_verifier_config(context.protocol_config, false /* disable metering during execution */);
for module in modules {
// Run Sui bytecode verifier, which runs some additional checks that assume the Move
// bytecode verifier has passed.
sui_verifier::verifier::verify_module(context.protocol_config, &verifier_config, module, &BTreeMap::new())?;
sui_verifier::verifier::sui_verify_module_unmetered(context.protocol_config, module, &BTreeMap::new())?;
}

Ok(())
Expand Down
7 changes: 2 additions & 5 deletions crates/sui-benchmark/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ use sui_json_rpc_types::{
};
use sui_network::{DEFAULT_CONNECT_TIMEOUT_SEC, DEFAULT_REQUEST_TIMEOUT_SEC};
use sui_sdk::{SuiClient, SuiClientBuilder};
use sui_types::effects::{CertifiedTransactionEffects, TransactionEffectsAPI, TransactionEvents};
use sui_types::messages::CallArg;
use sui_types::messages::ObjectArg;
use sui_types::messages::TransactionEvents;
use sui_types::programmable_transaction_builder::ProgrammableTransactionBuilder;
use sui_types::sui_system_state::sui_system_state_summary::SuiSystemStateSummary;
use sui_types::{
Expand All @@ -43,10 +43,7 @@ use sui_types::{
AuthoritySignature,
},
message_envelope::Envelope,
messages::{
CertifiedTransaction, CertifiedTransactionEffects, HandleCertificateResponse, Transaction,
TransactionEffectsAPI, TransactionStatus,
},
messages::{CertifiedTransaction, HandleCertificateResponse, Transaction, TransactionStatus},
object::Object,
};
use sui_types::{base_types::ObjectRef, crypto::AuthorityStrongQuorumSignInfo, object::Owner};
Expand Down
5 changes: 3 additions & 2 deletions crates/sui-benchmark/src/workloads/adversarial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ use std::sync::Arc;
use strum::{EnumCount, IntoEnumIterator};
use strum_macros::{EnumCount as EnumCountMacro, EnumIter};
use sui_protocol_config::ProtocolConfig;
use sui_types::effects::TransactionEffectsAPI;
use sui_types::messages::Command;
use sui_types::messages::{CallArg, ObjectArg, TransactionEffectsAPI};
use sui_types::messages::{CallArg, ObjectArg};
use sui_types::{base_types::ObjectID, object::Owner};
use sui_types::{base_types::SuiAddress, crypto::get_key_pair, messages::VerifiedTransaction};
use sui_types::{
Expand Down Expand Up @@ -100,7 +101,7 @@ impl FromStr for AdversarialPayloadType {

impl Distribution<AdversarialPayloadType> for Standard {
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> AdversarialPayloadType {
// Excluse the "Random" variant
// Exclude the "Random" variant
let n = rng.gen_range(1..AdversarialPayloadType::COUNT);
AdversarialPayloadType::iter().nth(n).unwrap()
}
Expand Down
6 changes: 2 additions & 4 deletions crates/sui-config/src/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,14 @@ use sui_types::crypto::{
AuthorityKeyPair, AuthorityPublicKeyBytes, AuthoritySignInfo, AuthoritySignature,
SuiAuthoritySignature, ToFromBytes,
};
use sui_types::effects::{TransactionEffects, TransactionEvents};
use sui_types::epoch_data::EpochData;
use sui_types::gas::SuiGasStatus;
use sui_types::gas_coin::{GasCoin, TOTAL_SUPPLY_MIST};
use sui_types::governance::StakedSui;
use sui_types::in_memory_storage::InMemoryStorage;
use sui_types::message_envelope::Message;
use sui_types::messages::{
CallArg, Command, InputObjectKind, InputObjects, Transaction, TransactionEffects,
TransactionEvents,
};
use sui_types::messages::{CallArg, Command, InputObjectKind, InputObjects, Transaction};
use sui_types::messages_checkpoint::{
CertifiedCheckpointSummary, CheckpointContents, CheckpointSummary, VerifiedCheckpoint,
};
Expand Down
1 change: 1 addition & 0 deletions crates/sui-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ url = "2.3.1"

fastcrypto.workspace = true
move-binary-format.workspace = true
move-bytecode-verifier.workspace = true
move-bytecode-utils.workspace = true
move-core-types.workspace = true
move-package.workspace = true
Expand Down
5 changes: 5 additions & 0 deletions crates/sui-core/src/authority.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ mod batch_verification_tests;
#[cfg(feature = "test-utils")]
pub mod authority_test_utils;
use once_cell::sync::OnceCell;
use sui_types::effects::{
SignedTransactionEffects, TransactionEffects, TransactionEffectsAPI, TransactionEvents,
VerifiedCertifiedTransactionEffects, VerifiedSignedTransactionEffects,
};

pub mod authority_per_epoch_store;
pub mod authority_per_epoch_store_pruner;

Expand Down
3 changes: 2 additions & 1 deletion crates/sui-core/src/authority/authority_notify_read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ use std::collections::HashMap;
use std::sync::Arc;
use std::time::Instant;
use sui_types::base_types::{TransactionDigest, TransactionEffectsDigest};
use sui_types::effects::TransactionEffects;
use sui_types::effects::TransactionEffectsAPI;
use sui_types::error::SuiResult;
use sui_types::messages::{TransactionEffects, TransactionEffectsAPI};
use tracing::trace;

#[async_trait]
Expand Down
5 changes: 3 additions & 2 deletions crates/sui-core/src/authority/authority_per_epoch_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ use sui_types::error::{SuiError, SuiResult};
use sui_types::messages::{
AuthorityCapabilities, CertifiedTransaction, ConsensusTransaction, ConsensusTransactionKey,
ConsensusTransactionKind, SenderSignedData, SharedInputObject, TransactionData,
TransactionDataAPI, TransactionEffects, TransactionEffectsAPI, TrustedExecutableTransaction,
VerifiedCertificate, VerifiedExecutableTransaction, VerifiedSignedTransaction,
TransactionDataAPI, TrustedExecutableTransaction, VerifiedCertificate,
VerifiedExecutableTransaction, VerifiedSignedTransaction,
};
use sui_types::signature::GenericSignature;
use tracing::{debug, error, info, trace, warn};
Expand Down Expand Up @@ -60,6 +60,7 @@ use sui_adapter::adapter;
use sui_macros::fail_point;
use sui_protocol_config::{ProtocolConfig, ProtocolVersion};
use sui_storage::mutex_table::{MutexGuard, MutexTable};
use sui_types::effects::{TransactionEffects, TransactionEffectsAPI};
use sui_types::message_envelope::TrustedEnvelope;
use sui_types::messages_checkpoint::{
CheckpointContents, CheckpointSequenceNumber, CheckpointSignatureMessage, CheckpointSummary,
Expand Down
1 change: 1 addition & 0 deletions crates/sui-core/src/authority/authority_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ use super::authority_store_tables::LiveObject;
use super::{authority_store_tables::AuthorityPerpetualTables, *};
use mysten_common::sync::notify_read::NotifyRead;
use sui_storage::package_object_cache::PackageObjectCache;
use sui_types::effects::{TransactionEffects, TransactionEvents};
use sui_types::gas_coin::TOTAL_SUPPLY_MIST;
use typed_store::rocks::util::is_ref_count_value;

Expand Down
6 changes: 4 additions & 2 deletions crates/sui-core/src/authority/authority_store_pruner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ use std::{sync::Arc, time::Duration};
use sui_config::node::AuthorityStorePruningConfig;
use sui_storage::mutex_table::RwLockTable;
use sui_types::base_types::SequenceNumber;
use sui_types::messages::{TransactionEffects, TransactionEffectsAPI};
use sui_types::effects::TransactionEffects;
use sui_types::effects::TransactionEffectsAPI;
use sui_types::messages_checkpoint::CheckpointSequenceNumber;
use sui_types::{
base_types::{ObjectID, VersionNumber},
Expand Down Expand Up @@ -324,7 +325,8 @@ mod tests {
use prometheus::Registry;
use sui_storage::mutex_table::RwLockTable;
use sui_types::base_types::{ObjectDigest, VersionNumber};
use sui_types::messages::{TransactionEffects, TransactionEffectsAPI};
use sui_types::effects::TransactionEffects;
use sui_types::effects::TransactionEffectsAPI;
use sui_types::{
base_types::{ObjectID, SequenceNumber},
object::Object,
Expand Down
1 change: 1 addition & 0 deletions crates/sui-core/src/authority/authority_store_tables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use std::path::Path;
use sui_types::accumulator::Accumulator;
use sui_types::base_types::SequenceNumber;
use sui_types::digests::TransactionEventsDigest;
use sui_types::effects::TransactionEffects;
use sui_types::storage::ObjectStore;
use typed_store::metrics::SamplingInterval;
use typed_store::rocks::util::{empty_compaction_filter, reference_count_merge_operator};
Expand Down
4 changes: 4 additions & 0 deletions crates/sui-core/src/authority_aggregator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ use std::string::ToString;
use std::sync::Arc;
use std::time::Duration;
use sui_types::committee::{CommitteeWithNetworkMetadata, StakeUnit};
use sui_types::effects::{
CertifiedTransactionEffects, SignedTransactionEffects, TransactionEffects, TransactionEvents,
VerifiedCertifiedTransactionEffects,
};
use tap::TapFallible;
use tokio::time::{sleep, timeout};

Expand Down
3 changes: 2 additions & 1 deletion crates/sui-core/src/authority_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use sui_network::{
api::{Validator, ValidatorServer},
tonic,
};
use sui_types::effects::{TransactionEffectsAPI, TransactionEvents};
use sui_types::multiaddr::Multiaddr;
use sui_types::sui_system_state::SuiSystemState;
use sui_types::{error::*, messages::*};
Expand Down Expand Up @@ -318,7 +319,7 @@ impl ValidatorService {
Arc::clone(&consensus_adapter),
transaction.data(),
)?;
let _handel_tx_metrics_guard = metrics.handle_transaction_latency.start_timer();
let _handle_tx_metrics_guard = metrics.handle_transaction_latency.start_timer();

let tx_verif_metrics_guard = metrics.tx_verification_latency.start_timer();
let transaction = epoch_store
Expand Down
4 changes: 3 additions & 1 deletion crates/sui-core/src/checkpoints/casual_order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

use std::collections::{BTreeMap, BTreeSet, HashMap};
use sui_types::base_types::TransactionDigest;
use sui_types::messages::{TransactionEffects, TransactionEffectsAPI};
use sui_types::effects::TransactionEffects;
use sui_types::effects::TransactionEffectsAPI;
use sui_types::storage::ObjectKey;
use tracing::trace;

Expand Down Expand Up @@ -196,6 +197,7 @@ mod tests {
use super::*;
use sui_types::base_types::ObjectDigest;
use sui_types::base_types::{ObjectID, SequenceNumber};
use sui_types::effects::TransactionEffects;

#[test]
pub fn test_casual_order() {
Expand Down
3 changes: 2 additions & 1 deletion crates/sui-core/src/checkpoints/checkpoint_executor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@ use mysten_metrics::{spawn_monitored_task, MonitoredFutureExt};
use prometheus::Registry;
use sui_config::node::CheckpointExecutorConfig;
use sui_macros::{fail_point, fail_point_async};
use sui_types::effects::{TransactionEffects, TransactionEffectsAPI};
use sui_types::message_envelope::Message;
use sui_types::messages::VerifiedExecutableTransaction;
use sui_types::{
base_types::{ExecutionDigests, TransactionDigest, TransactionEffectsDigest},
messages::{TransactionEffects, TransactionEffectsAPI, VerifiedTransaction},
messages::VerifiedTransaction,
messages_checkpoint::{CheckpointSequenceNumber, VerifiedCheckpoint},
};
use sui_types::{error::SuiResult, messages::TransactionDataAPI};
Expand Down
7 changes: 3 additions & 4 deletions crates/sui-core/src/checkpoints/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,11 @@ use sui_protocol_config::ProtocolVersion;
use sui_types::base_types::{EpochId, TransactionDigest};
use sui_types::crypto::{AuthoritySignInfo, AuthorityStrongQuorumSignInfo};
use sui_types::digests::{CheckpointContentsDigest, CheckpointDigest};
use sui_types::effects::{TransactionEffects, TransactionEffectsAPI};
use sui_types::error::{SuiError, SuiResult};
use sui_types::gas::GasCostSummary;
use sui_types::message_envelope::Message;
use sui_types::messages::{
ConsensusTransactionKey, TransactionDataAPI, TransactionEffects, TransactionEffectsAPI,
TransactionKind,
};
use sui_types::messages::{ConsensusTransactionKey, TransactionDataAPI, TransactionKind};
use sui_types::messages_checkpoint::SignedCheckpointSummary;
use sui_types::messages_checkpoint::{
CertifiedCheckpointSummary, CheckpointContents, CheckpointSequenceNumber,
Expand Down Expand Up @@ -1386,6 +1384,7 @@ mod tests {
use std::ops::Deref;
use sui_types::base_types::{ObjectID, SequenceNumber, TransactionEffectsDigest};
use sui_types::crypto::Signature;
use sui_types::effects::TransactionEffects;
use sui_types::messages::{GenesisObject, VerifiedTransaction};
use sui_types::messages_checkpoint::SignedCheckpointSummary;
use sui_types::move_package::MovePackage;
Expand Down
3 changes: 2 additions & 1 deletion crates/sui-core/src/quorum_driver/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ use std::time::Duration;
use sui_types::base_types::SuiAddress;
use sui_types::base_types::TransactionDigest;
use sui_types::crypto::{deterministic_random_account_key, get_key_pair, AccountKeyPair};
use sui_types::messages::{TransactionEffectsAPI, VerifiedTransaction};
use sui_types::effects::TransactionEffectsAPI;
use sui_types::messages::VerifiedTransaction;
use sui_types::object::{generate_test_gas_objects, Object};
use sui_types::quorum_driver_types::{QuorumDriverError, QuorumDriverResponse, QuorumDriverResult};

Expand Down
1 change: 1 addition & 0 deletions crates/sui-core/src/safe_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use prometheus::{
use std::collections::HashSet;
use std::sync::Arc;
use sui_types::crypto::AuthorityPublicKeyBytes;
use sui_types::effects::{SignedTransactionEffects, TransactionEffectsAPI};
use sui_types::messages_checkpoint::{
CertifiedCheckpointSummary, CheckpointRequest, CheckpointResponse, CheckpointSequenceNumber,
};
Expand Down
3 changes: 2 additions & 1 deletion crates/sui-core/src/state_accumulator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ use std::sync::Arc;

use fastcrypto::hash::MultisetHash;
use sui_types::accumulator::Accumulator;
use sui_types::effects::TransactionEffects;
use sui_types::effects::TransactionEffectsAPI;
use sui_types::error::SuiResult;
use sui_types::messages::{TransactionEffects, TransactionEffectsAPI};
use sui_types::messages_checkpoint::{CheckpointSequenceNumber, ECMHLiveObjectSetDigest};
use typed_store::rocks::TypedStoreError;

Expand Down
2 changes: 1 addition & 1 deletion crates/sui-core/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use sui_types::base_types::TransactionDigest;
use sui_types::committee::Committee;
use sui_types::committee::EpochId;
use sui_types::digests::{TransactionEffectsDigest, TransactionEventsDigest};
use sui_types::effects::{TransactionEffects, TransactionEvents};
use sui_types::messages::VerifiedTransaction;
use sui_types::messages::{TransactionEffects, TransactionEvents};
use sui_types::messages_checkpoint::CheckpointContentsDigest;
use sui_types::messages_checkpoint::CheckpointDigest;
use sui_types::messages_checkpoint::CheckpointSequenceNumber;
Expand Down
Loading

0 comments on commit 09b2081

Please sign in to comment.