这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 8 additions & 0 deletions Cargo.lock

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

Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,21 @@
},
"type": "write_resource"
},
{
"address": "0x1",
"state_key_hash": "",
"data": {
"type": "0x1::randomness::PerBlockRandomness",
"data": {
"epoch": "1",
"round": "1",
"seed": {
"vec": []
}
}
},
"type": "write_resource"
},
{
"address": "0x1",
"state_key_hash": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,21 @@
},
"type": "write_resource"
},
{
"address": "0x1",
"state_key_hash": "",
"data": {
"type": "0x1::randomness::PerBlockRandomness",
"data": {
"epoch": "1",
"round": "1",
"seed": {
"vec": []
}
}
},
"type": "write_resource"
},
{
"state_key_hash": "",
"handle": "0x38ff67f17cf7998cd41ed5267b52cff7af37d06a22e8b390ce44b69680fc0e97",
Expand Down Expand Up @@ -420,6 +435,21 @@
},
"type": "write_resource"
},
{
"address": "0x1",
"state_key_hash": "",
"data": {
"type": "0x1::randomness::PerBlockRandomness",
"data": {
"epoch": "1",
"round": "1",
"seed": {
"vec": []
}
}
},
"type": "write_resource"
},
{
"state_key_hash": "",
"handle": "0x38ff67f17cf7998cd41ed5267b52cff7af37d06a22e8b390ce44b69680fc0e97",
Expand Down Expand Up @@ -741,6 +771,21 @@
},
"type": "write_resource"
},
{
"address": "0x1",
"state_key_hash": "",
"data": {
"type": "0x1::randomness::PerBlockRandomness",
"data": {
"epoch": "1",
"round": "1",
"seed": {
"vec": []
}
}
},
"type": "write_resource"
},
{
"state_key_hash": "",
"handle": "0x38ff67f17cf7998cd41ed5267b52cff7af37d06a22e8b390ce44b69680fc0e97",
Expand Down Expand Up @@ -1062,6 +1107,21 @@
},
"type": "write_resource"
},
{
"address": "0x1",
"state_key_hash": "",
"data": {
"type": "0x1::randomness::PerBlockRandomness",
"data": {
"epoch": "1",
"round": "1",
"seed": {
"vec": []
}
}
},
"type": "write_resource"
},
{
"state_key_hash": "",
"handle": "0x38ff67f17cf7998cd41ed5267b52cff7af37d06a22e8b390ce44b69680fc0e97",
Expand Down Expand Up @@ -1383,6 +1443,21 @@
},
"type": "write_resource"
},
{
"address": "0x1",
"state_key_hash": "",
"data": {
"type": "0x1::randomness::PerBlockRandomness",
"data": {
"epoch": "1",
"round": "1",
"seed": {
"vec": []
}
}
},
"type": "write_resource"
},
{
"state_key_hash": "",
"handle": "0x38ff67f17cf7998cd41ed5267b52cff7af37d06a22e8b390ce44b69680fc0e97",
Expand Down Expand Up @@ -1704,6 +1779,21 @@
},
"type": "write_resource"
},
{
"address": "0x1",
"state_key_hash": "",
"data": {
"type": "0x1::randomness::PerBlockRandomness",
"data": {
"epoch": "1",
"round": "1",
"seed": {
"vec": []
}
}
},
"type": "write_resource"
},
{
"state_key_hash": "",
"handle": "0x38ff67f17cf7998cd41ed5267b52cff7af37d06a22e8b390ce44b69680fc0e97",
Expand Down Expand Up @@ -2025,6 +2115,21 @@
},
"type": "write_resource"
},
{
"address": "0x1",
"state_key_hash": "",
"data": {
"type": "0x1::randomness::PerBlockRandomness",
"data": {
"epoch": "1",
"round": "1",
"seed": {
"vec": []
}
}
},
"type": "write_resource"
},
{
"state_key_hash": "",
"handle": "0x38ff67f17cf7998cd41ed5267b52cff7af37d06a22e8b390ce44b69680fc0e97",
Expand Down Expand Up @@ -2346,6 +2451,21 @@
},
"type": "write_resource"
},
{
"address": "0x1",
"state_key_hash": "",
"data": {
"type": "0x1::randomness::PerBlockRandomness",
"data": {
"epoch": "1",
"round": "1",
"seed": {
"vec": []
}
}
},
"type": "write_resource"
},
{
"state_key_hash": "",
"handle": "0x38ff67f17cf7998cd41ed5267b52cff7af37d06a22e8b390ce44b69680fc0e97",
Expand Down
4 changes: 3 additions & 1 deletion api/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,9 @@ impl Context {
.into_iter()
.map(|t| {
// Update the timestamp if the next block occurs
if let Some(txn) = t.transaction.try_as_block_metadata() {
if let Some(txn) = t.transaction.try_as_block_metadata_ext() {
timestamp = txn.timestamp_usecs();
} else if let Some(txn) = t.transaction.try_as_block_metadata() {
timestamp = txn.timestamp_usecs();
}
let txn = converter.try_into_onchain_transaction(timestamp, t)?;
Expand Down
17 changes: 16 additions & 1 deletion aptos-move/aptos-vm/src/aptos_vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ use crate::{
use anyhow::anyhow;
use aptos_block_executor::txn_commit_hook::NoOpTransactionCommitHook;
use aptos_crypto::HashValue;
use aptos_framework::{natives::code::PublishRequest, RuntimeModuleMetadataV1};
use aptos_framework::{
natives::{code::PublishRequest, transaction_context::NativeTransactionContext},
RuntimeModuleMetadataV1,
};
use aptos_gas_algebra::{Gas, GasQuantity, Octa};
use aptos_gas_meter::{AptosGasMeter, GasAlgebra, StandardGasAlgebra, StandardGasMeter};
use aptos_gas_schedule::{AptosGasParameters, VMGasParameters};
Expand Down Expand Up @@ -677,6 +680,18 @@ impl AptosVM {
senders: Vec<AccountAddress>,
entry_fn: &EntryFunction,
) -> Result<SerializedReturnValues, VMStatus> {
let is_friend_or_private = session.load_function_def_is_friend_or_private(
entry_fn.module(),
entry_fn.function(),
entry_fn.ty_args(),
)?;
if is_friend_or_private {
let txn_context = session
.get_native_extensions()
.get_mut::<NativeTransactionContext>();
txn_context.set_is_friend_or_private_entry_func();
}

let function =
session.load_function(entry_fn.module(), entry_fn.function(), entry_fn.ty_args())?;
let args = verifier::transaction_arg_validation::validate_combine_signer_and_txn_args(
Expand Down
2 changes: 2 additions & 0 deletions aptos-move/aptos-vm/src/move_vm_ext/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use aptos_framework::natives::{
code::NativeCodeContext,
cryptography::{algebra::AlgebraContext, ristretto255_point::NativeRistrettoPointContext},
event::NativeEventContext,
randomness::RandomnessContext,
state_storage::NativeStateStorageContext,
transaction_context::NativeTransactionContext,
};
Expand Down Expand Up @@ -201,6 +202,7 @@ impl MoveVmExt {
extensions.add(NativeRistrettoPointContext::new());
extensions.add(AlgebraContext::new());
extensions.add(NativeAggregatorContext::new(txn_hash, resolver, resolver));
extensions.add(RandomnessContext::new());
extensions.add(NativeTransactionContext::new(
txn_hash.to_vec(),
session_id.into_script_hash(),
Expand Down
11 changes: 6 additions & 5 deletions aptos-move/aptos-vm/src/natives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ use aptos_aggregator::{
#[cfg(feature = "testing")]
use aptos_aggregator::{resolver::TDelayedFieldView, types::DelayedFieldValue};
#[cfg(feature = "testing")]
use aptos_framework::natives::randomness::RandomnessContext;
#[cfg(feature = "testing")]
use aptos_framework::natives::{cryptography::algebra::AlgebraContext, event::NativeEventContext};
use aptos_gas_schedule::{MiscGasParameters, NativeGasParameters, LATEST_GAS_FEATURE_VERSION};
use aptos_native_interface::SafeNativeBuilder;
Expand Down Expand Up @@ -225,11 +227,9 @@ fn unit_test_extensions_hook(exts: &mut NativeContextExtensions) {

exts.add(NativeTableContext::new([0u8; 32], &*DUMMY_RESOLVER));
exts.add(NativeCodeContext::default());
exts.add(NativeTransactionContext::new(
vec![1],
vec![1],
ChainId::test().id(),
)); // We use the testing environment chain ID here
let mut txn_context = NativeTransactionContext::new(vec![1], vec![1], ChainId::test().id());
txn_context.set_is_friend_or_private_entry_func();
exts.add(txn_context); // We use the testing environment chain ID here
exts.add(NativeAggregatorContext::new(
[0; 32],
&*DUMMY_RESOLVER,
Expand All @@ -238,4 +238,5 @@ fn unit_test_extensions_hook(exts: &mut NativeContextExtensions) {
exts.add(NativeRistrettoPointContext::new());
exts.add(AlgebraContext::new());
exts.add(NativeEventContext::default());
exts.add(RandomnessContext::new());
}
9 changes: 6 additions & 3 deletions aptos-move/aptos-vm/src/validator_txns/dkg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use aptos_types::{
dkg::{DKGState, DKGTrait, DKGTranscript, DefaultDKG},
fee_statement::FeeStatement,
move_utils::as_move_value::AsMoveValue,
on_chain_config::OnChainConfig,
on_chain_config::{ConfigurationResource, OnChainConfig},
transaction::{ExecutionStatus, TransactionStatus},
};
use aptos_vm_logging::log_schema::AdapterLogSchema;
Expand All @@ -27,6 +27,7 @@ use move_core_types::{
};
use move_vm_types::gas::UnmeteredGasMeter;

#[derive(Debug)]
enum ExpectedFailure {
// Move equivalent: `errors::invalid_argument(*)`
EpochNotCurrent = 0x10001,
Expand All @@ -36,6 +37,7 @@ enum ExpectedFailure {
// Move equivalent: `errors::invalid_state(*)`
MissingResourceDKGState = 0x30001,
MissingResourceInprogressDKGSession = 0x30002,
MissingResourceConfiguration = 0x30003,
}

enum ExecutionFailure {
Expand Down Expand Up @@ -73,13 +75,14 @@ impl AptosVM {
) -> Result<(VMStatus, VMOutput), ExecutionFailure> {
let dkg_state = OnChainConfig::fetch_config(resolver)
.ok_or_else(|| Expected(MissingResourceDKGState))?;

let config_resource = ConfigurationResource::fetch_config(resolver)
.ok_or_else(|| Expected(MissingResourceConfiguration))?;
let DKGState { in_progress, .. } = dkg_state;
let in_progress_session_state =
in_progress.ok_or_else(|| Expected(MissingResourceInprogressDKGSession))?;

// Check epoch number.
if dkg_node.metadata.epoch != in_progress_session_state.metadata.dealer_epoch {
if dkg_node.metadata.epoch != config_resource.epoch() {
return Err(Expected(EpochNotCurrent));
}

Expand Down
Loading