Skip to content

Commit

Permalink
[AptosFramework] update cores modules name to get rid of Diem prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
zekun000 authored and aptos-bot committed Mar 11, 2022
1 parent 167db88 commit eda9789
Show file tree
Hide file tree
Showing 623 changed files with 14,006 additions and 32,327 deletions.
72 changes: 36 additions & 36 deletions api/src/tests/accounts_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,20 +183,20 @@ async fn test_get_module_aptos_config() {
let address = "0x1";

let resp = context.get(&account_modules(address)).await;
let res = find_value(&resp, |v| v["abi"]["name"] == "DiemConfig");
let res = find_value(&resp, |v| v["abi"]["name"] == "Reconfiguration");
assert_json(
res["abi"].clone(),
json!({
"address": "0x1",
"name": "DiemConfig",
"name": "Reconfiguration",
"friends": [
"0x1::DiemConsensusConfig",
"0x1::DiemSystem",
"0x1::DiemTransactionPublishingOption",
"0x1::DiemVMConfig",
"0x1::DiemVersion",
"0x1::ConsensusConfig",
"0x1::ParallelExecutionConfig",
"0x1::RegisteredCurrencies"
"0x1::RegisteredCurrencies",
"0x1::TransactionPublishingOption",
"0x1::VMConfig",
"0x1::ValidatorSystem",
"0x1::Version",
],
"exposed_functions": [
{
Expand Down Expand Up @@ -260,7 +260,7 @@ async fn test_get_module_aptos_config() {
"T0"
],
"return": [
"0x1::DiemConfig::ModifyConfigCapability<T0>"
"0x1::Reconfiguration::ModifyConfigCapability<T0>"
]
},
{
Expand Down Expand Up @@ -303,7 +303,7 @@ async fn test_get_module_aptos_config() {
}
],
"params": [
"&0x1::DiemConfig::ModifyConfigCapability<T0>",
"&0x1::Reconfiguration::ModifyConfigCapability<T0>",
"T0"
],
"return": []
Expand All @@ -328,31 +328,7 @@ async fn test_get_module_aptos_config() {
},
{
"name": "events",
"type": "0x1::Event::EventHandle<0x1::DiemConfig::NewEpochEvent>"
}
]
},
{
"name": "DiemConfig",
"is_native": false,
"abilities": [
"store",
"key"
],
"generic_type_params": [
{
"constraints": [
"copy",
"drop",
"store"
],
"is_phantom": false
}
],
"fields": [
{
"name": "payload",
"type": "T0"
"type": "0x1::Event::EventHandle<0x1::Reconfiguration::NewEpochEvent>"
}
]
},
Expand Down Expand Up @@ -404,7 +380,31 @@ async fn test_get_module_aptos_config() {
"type": "u64"
}
]
}
},
{
"name": "Reconfiguration",
"is_native": false,
"abilities": [
"store",
"key"
],
"generic_type_params": [
{
"constraints": [
"copy",
"drop",
"store"
],
"is_phantom": false
}
],
"fields": [
{
"name": "payload",
"type": "T0"
}
]
},
]
}),
);
Expand Down
6 changes: 3 additions & 3 deletions api/src/tests/test_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use aptos_types::{
on_chain_config::VMPublishingOption,
transaction::{Transaction, TransactionStatus},
};
use aptos_vm::DiemVM;
use aptos_vm::AptosVM;
use aptosdb::AptosDB;
use bytes::Bytes;
use executor::db_bootstrapper;
Expand Down Expand Up @@ -63,7 +63,7 @@ pub fn new_test_context() -> TestContext {

let (db, db_rw) = DbReaderWriter::wrap(AptosDB::new_for_test(&tmp_dir));
let ret =
db_bootstrapper::maybe_bootstrap::<DiemVM>(&db_rw, &genesis, genesis_waypoint).unwrap();
db_bootstrapper::maybe_bootstrap::<AptosVM>(&db_rw, &genesis, genesis_waypoint).unwrap();
assert!(ret);

let mempool = MockSharedMempool::new_in_runtime(&db_rw, VMValidator::new(db.clone()));
Expand All @@ -79,7 +79,7 @@ pub fn new_test_context() -> TestContext {
rng,
root_keys,
validator_owner,
Box::new(BlockExecutor::<DiemVM>::new(db_rw)),
Box::new(BlockExecutor::<AptosVM>::new(db_rw)),
mempool,
db,
)
Expand Down
4 changes: 2 additions & 2 deletions aptos-move/aptos-transaction-benchmarks/src/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use aptos_types::{
on_chain_config::{OnChainConfig, ValidatorSet},
transaction::Transaction,
};
use aptos_vm::{DiemVM, VMExecutor};
use aptos_vm::{AptosVM, VMExecutor};
use criterion::{measurement::Measurement, BatchSize, Bencher};
use language_e2e_tests::{
account_universe::{log_balance_strategy, AUTransactionGen, AccountUniverseGen},
Expand Down Expand Up @@ -164,7 +164,7 @@ impl TransactionBenchState {
fn execute(self) {
// The output is ignored here since we're just testing transaction performance, not trying
// to assert correctness.
DiemVM::execute_block(self.transactions, self.executor.get_state_view())
AptosVM::execute_block(self.transactions, self.executor.get_state_view())
.expect("VM should not fail to start");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use aptos_types::{
},
vm_status::KeptVMStatus,
};
use aptos_vm::DiemVM;
use aptos_vm::AptosVM;
use language_e2e_tests::data_store::{FakeDataStore, GENESIS_CHANGE_SET_FRESH};
use move_binary_format::file_format::{CompiledModule, CompiledScript};
use move_compiler::{
Expand Down Expand Up @@ -546,7 +546,7 @@ impl<'a> DiemTestAdapter<'a> {
/// Should error if the transaction ends up being discarded, or having a status other than
/// EXECUTED.
fn run_transaction(&mut self, txn: Transaction) -> Result<TransactionOutput> {
let mut outputs = DiemVM::execute_block_and_keep_vm_status(vec![txn], &self.storage)?;
let mut outputs = AptosVM::execute_block_and_keep_vm_status(vec![txn], &self.storage)?;

assert_eq!(outputs.len(), 1);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ Events:
{
key: 11000000000000000000000000000000000000000a550c18
seq_num: 0
type: 0x1::DiemBlock::NewBlockEvent
type: 0x1::Block::NewBlockEvent
data: "0000000000000000c5e34b925cf6875fec02d4b77adbd2d6006400000000000000"
}
58 changes: 26 additions & 32 deletions aptos-move/aptos-vm/src/aptos_vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::{
},
aptos_vm_impl::{
charge_global_write_gas_usage, convert_changeset_and_events, get_currency_info,
get_gas_currency_code, get_transaction_output, DiemVMImpl, DiemVMInternals,
get_gas_currency_code, get_transaction_output, AptosVMImpl, AptosVMInternals,
},
counters::*,
data_cache::{RemoteStorage, StateViewCache},
Expand All @@ -27,7 +27,7 @@ use aptos_types::{
account_config,
block_metadata::BlockMetadata,
on_chain_config::{
DiemVersion, OnChainConfig, ParallelExecutionConfig, VMConfig, VMPublishingOption,
OnChainConfig, ParallelExecutionConfig, VMConfig, VMPublishingOption, Version,
DIEM_VERSION_2, DIEM_VERSION_3,
},
transaction::{
Expand Down Expand Up @@ -57,11 +57,11 @@ use std::{
};

#[derive(Clone)]
pub struct DiemVM(pub(crate) DiemVMImpl);
pub struct AptosVM(pub(crate) AptosVMImpl);

impl DiemVM {
impl AptosVM {
pub fn new<S: StateView>(state: &S) -> Self {
Self(DiemVMImpl::new(state))
Self(AptosVMImpl::new(state))
}

pub fn new_for_validation<S: StateView>(state: &S) -> Self {
Expand All @@ -73,19 +73,19 @@ impl DiemVM {
}

pub fn init_with_config(
version: DiemVersion,
version: Version,
on_chain_config: VMConfig,
publishing_option: VMPublishingOption,
) -> Self {
info!("Adapter restarted for Validation");
DiemVM(DiemVMImpl::init_with_config(
AptosVM(AptosVMImpl::init_with_config(
version,
on_chain_config,
publishing_option,
))
}
pub fn internals(&self) -> DiemVMInternals {
DiemVMInternals::new(&self.0)
pub fn internals(&self) -> AptosVMInternals {
AptosVMInternals::new(&self.0)
}

/// Load a module into its internal MoveVM's code cache.
Expand Down Expand Up @@ -212,7 +212,7 @@ impl DiemVM {

match payload {
TransactionPayload::Script(script) => {
let aptos_version = self.0.get_diem_version()?;
let aptos_version = self.0.get_version()?;
let remapped_script =
if aptos_version < aptos_types::on_chain_config::DIEM_VERSION_2 {
None
Expand Down Expand Up @@ -244,7 +244,7 @@ impl DiemVM {
}
}
TransactionPayload::ScriptFunction(script_fn) => {
let aptos_version = self.0.get_diem_version()?;
let aptos_version = self.0.get_version()?;
let mut senders = vec![txn_data.sender()];
if aptos_version >= DIEM_VERSION_3 {
senders.extend(txn_data.secondary_signers());
Expand Down Expand Up @@ -423,7 +423,7 @@ impl DiemVM {
WriteSetPayload::Direct(change_set) => change_set.clone(),
WriteSetPayload::Script { script, execute_as } => {
let mut tmp_session = self.0.new_session(storage);
let aptos_version = self.0.get_diem_version().map_err(Err)?;
let aptos_version = self.0.get_version().map_err(Err)?;
let senders = match txn_sender {
None => vec![*execute_as],
Some(sender) => vec![sender, *execute_as],
Expand Down Expand Up @@ -530,13 +530,7 @@ impl DiemVM {
MoveValue::Address(proposer),
]);
session
.execute_function(
&DIEM_BLOCK_MODULE,
BLOCK_PROLOGUE,
vec![],
args,
&mut gas_status,
)
.execute_function(&BLOCK_MODULE, BLOCK_PROLOGUE, vec![], args, &mut gas_status)
.map(|_return_vals| ())
.or_else(|e| {
expect_only_successful_execution(e, BLOCK_PROLOGUE.as_str(), log_context)
Expand Down Expand Up @@ -706,7 +700,7 @@ impl DiemVM {
) -> Result<Vec<(VMStatus, TransactionOutput)>, VMStatus> {
let mut state_view_cache = StateViewCache::new(state_view);
let count = transactions.len();
let vm = DiemVM::new(&state_view_cache);
let vm = AptosVM::new(&state_view_cache);
let res = adapter_common::execute_block_impl(&vm, transactions, &mut state_view_cache)?;
// Record the histogram count for transactions per block.
BLOCK_TRANSACTION_COUNT.observe(count as f64);
Expand All @@ -715,7 +709,7 @@ impl DiemVM {
}

// Executor external API
impl VMExecutor for DiemVM {
impl VMExecutor for AptosVM {
/// Execute a block of `transactions`. The output vector will have the exact same length as the
/// input vector. The discarded transactions will be marked as `TransactionStatus::Discard` and
/// have an empty `WriteSet`. Also `state_view` is immutable, and does not have interior
Expand All @@ -740,7 +734,7 @@ impl VMExecutor for DiemVM {
// Note that writeset transactions will be executed sequentially as it won't be inferred
// by the read write set analysis and thus fall into the sequential path.
let (result, _) =
crate::parallel_executor::ParallelDiemVM::execute_block(transactions, state_view)?;
crate::parallel_executor::ParallelAptosVM::execute_block(transactions, state_view)?;
Ok(result)
} else {
let output = Self::execute_block_and_keep_vm_status(transactions, state_view)?;
Expand All @@ -753,14 +747,14 @@ impl VMExecutor for DiemVM {
}

// VMValidator external API
impl VMValidator for DiemVM {
impl VMValidator for AptosVM {
/// Determine if a transaction is valid. Will return `None` if the transaction is accepted,
/// `Some(Err)` if the VM rejects it, with `Err` as an error code. Verification performs the
/// following steps:
/// 1. The signature on the `SignedTransaction` matches the public key included in the
/// transaction
/// 2. The script to be executed is under given specific configuration.
/// 3. Invokes `DiemAccount.prologue`, which checks properties such as the transaction has the
/// 3. Invokes `Account.prologue`, which checks properties such as the transaction has the
/// right sequence number and the sender has enough balance to pay for the gas.
/// TBD:
/// 1. Transaction arguments matches the main function's type signature.
Expand All @@ -774,7 +768,7 @@ impl VMValidator for DiemVM {
}
}

impl VMAdapter for DiemVM {
impl VMAdapter for AptosVM {
fn new_session<'r, R: MoveResolver>(&self, remote: &'r R) -> Session<'r, '_, R> {
self.0.new_session(remote)
}
Expand All @@ -784,7 +778,7 @@ impl VMAdapter for DiemVM {
}

fn check_transaction_format(&self, txn: &SignedTransaction) -> Result<(), VMStatus> {
if txn.is_multi_agent() && self.0.get_diem_version()? < DIEM_VERSION_3 {
if txn.is_multi_agent() && self.0.get_version()? < DIEM_VERSION_3 {
// Multi agent is not allowed
return Err(VMStatus::Error(StatusCode::FEATURE_UNDER_GATING));
}
Expand Down Expand Up @@ -833,8 +827,8 @@ impl VMAdapter for DiemVM {
.run_script_prologue(session, &txn_data, &currency_code, log_context)
}
TransactionPayload::ScriptFunction(_) => {
// gate the behavior until the Diem version is ready
if self.0.get_diem_version()? < DIEM_VERSION_2 {
// gate the behavior until the version is ready
if self.0.get_version()? < DIEM_VERSION_2 {
return Err(VMStatus::Error(StatusCode::FEATURE_UNDER_GATING));
}
// NOTE: Script and ScriptFunction shares the same prologue
Expand Down Expand Up @@ -919,14 +913,14 @@ impl VMAdapter for DiemVM {
}
}

impl AsRef<DiemVMImpl> for DiemVM {
fn as_ref(&self) -> &DiemVMImpl {
impl AsRef<AptosVMImpl> for AptosVM {
fn as_ref(&self) -> &AptosVMImpl {
&self.0
}
}

impl AsMut<DiemVMImpl> for DiemVM {
fn as_mut(&mut self) -> &mut DiemVMImpl {
impl AsMut<AptosVMImpl> for AptosVM {
fn as_mut(&mut self) -> &mut AptosVMImpl {
&mut self.0
}
}
Loading

0 comments on commit eda9789

Please sign in to comment.