Skip to content

Commit

Permalink
apply merged version
Browse files Browse the repository at this point in the history
  • Loading branch information
sh-cha committed Oct 30, 2024
1 parent 34c4c8d commit bf1b2c6
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 40 deletions.
44 changes: 22 additions & 22 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -118,28 +118,28 @@ pretty_assertions = "1.2.1"
# Note: the BEGIN and END comments below are required for external tooling. Do not remove.
# BEGIN MOVE DEPENDENCIES

move-binary-format = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "7131086965eb19c1c7f35b2003d2a5637691f108" }
move-bytecode-verifier = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "7131086965eb19c1c7f35b2003d2a5637691f108" }
move-bytecode-utils = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "7131086965eb19c1c7f35b2003d2a5637691f108" }
move-cli = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "7131086965eb19c1c7f35b2003d2a5637691f108" }
move-command-line-common = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "7131086965eb19c1c7f35b2003d2a5637691f108" }
move-compiler = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "7131086965eb19c1c7f35b2003d2a5637691f108" }
move-coverage = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "7131086965eb19c1c7f35b2003d2a5637691f108" }
move-core-types = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "7131086965eb19c1c7f35b2003d2a5637691f108" }
move-docgen = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "7131086965eb19c1c7f35b2003d2a5637691f108" }
move-model = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "7131086965eb19c1c7f35b2003d2a5637691f108" }
move-package = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "7131086965eb19c1c7f35b2003d2a5637691f108" }
move-prover = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "7131086965eb19c1c7f35b2003d2a5637691f108" }
move-prover-boogie-backend = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "7131086965eb19c1c7f35b2003d2a5637691f108" }
move-prover-bytecode-pipeline = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "7131086965eb19c1c7f35b2003d2a5637691f108" }
move-resource-viewer = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "7131086965eb19c1c7f35b2003d2a5637691f108" }
move-stackless-bytecode = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "7131086965eb19c1c7f35b2003d2a5637691f108" }
move-stdlib = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "7131086965eb19c1c7f35b2003d2a5637691f108" }
move-symbol-pool = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "7131086965eb19c1c7f35b2003d2a5637691f108" }
move-unit-test = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "7131086965eb19c1c7f35b2003d2a5637691f108" }
move-vm-runtime = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "7131086965eb19c1c7f35b2003d2a5637691f108" }
move-vm-test-utils = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "7131086965eb19c1c7f35b2003d2a5637691f108" }
move-vm-types = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "7131086965eb19c1c7f35b2003d2a5637691f108" }
move-binary-format = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "751c9a34969e54dd18452d41f3c996fc2e971eb7" }
move-bytecode-verifier = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "751c9a34969e54dd18452d41f3c996fc2e971eb7" }
move-bytecode-utils = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "751c9a34969e54dd18452d41f3c996fc2e971eb7" }
move-cli = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "751c9a34969e54dd18452d41f3c996fc2e971eb7" }
move-command-line-common = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "751c9a34969e54dd18452d41f3c996fc2e971eb7" }
move-compiler = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "751c9a34969e54dd18452d41f3c996fc2e971eb7" }
move-coverage = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "751c9a34969e54dd18452d41f3c996fc2e971eb7" }
move-core-types = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "751c9a34969e54dd18452d41f3c996fc2e971eb7" }
move-docgen = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "751c9a34969e54dd18452d41f3c996fc2e971eb7" }
move-model = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "751c9a34969e54dd18452d41f3c996fc2e971eb7" }
move-package = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "751c9a34969e54dd18452d41f3c996fc2e971eb7" }
move-prover = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "751c9a34969e54dd18452d41f3c996fc2e971eb7" }
move-prover-boogie-backend = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "751c9a34969e54dd18452d41f3c996fc2e971eb7" }
move-prover-bytecode-pipeline = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "751c9a34969e54dd18452d41f3c996fc2e971eb7" }
move-resource-viewer = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "751c9a34969e54dd18452d41f3c996fc2e971eb7" }
move-stackless-bytecode = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "751c9a34969e54dd18452d41f3c996fc2e971eb7" }
move-stdlib = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "751c9a34969e54dd18452d41f3c996fc2e971eb7" }
move-symbol-pool = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "751c9a34969e54dd18452d41f3c996fc2e971eb7" }
move-unit-test = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "751c9a34969e54dd18452d41f3c996fc2e971eb7" }
move-vm-runtime = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "751c9a34969e54dd18452d41f3c996fc2e971eb7" }
move-vm-test-utils = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "751c9a34969e54dd18452d41f3c996fc2e971eb7" }
move-vm-types = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "751c9a34969e54dd18452d41f3c996fc2e971eb7" }

# END MOVE DEPENDENCIES

Expand Down
6 changes: 3 additions & 3 deletions crates/storage/src/code_scale.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ mod test {
use move_core_types::account_address::AccountAddress;
use move_core_types::identifier::Identifier;
use move_core_types::language_storage::ModuleId;
use move_vm_runtime::{compute_code_hash, CodeStorage, ModuleStorage, RuntimeEnvironment};
use move_vm_types::code::{Code, ModuleCode, WithBytes, WithHash};
use move_vm_runtime::{CodeStorage, ModuleStorage, RuntimeEnvironment};
use move_vm_types::{code::{Code, ModuleCode, WithBytes, WithHash}, sha3_256};

use crate::code_storage::test::make_script;
use crate::code_storage::AsInitiaCodeStorage;
Expand Down Expand Up @@ -284,7 +284,7 @@ mod test {
);

let serialized_script = make_script(vec!["a"]);
compute_code_hash(&serialized_script);
sha3_256(&serialized_script);
code_storage.deserialize_and_cache_script(&serialized_script).unwrap();
let script = code_storage.verify_and_cache_script(&serialized_script).unwrap();

Expand Down
16 changes: 9 additions & 7 deletions crates/storage/src/code_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ use bytes::Bytes;
use move_binary_format::{errors::VMResult, file_format::CompiledScript, CompiledModule};
use move_core_types::{account_address::AccountAddress, identifier::IdentStr, metadata::Metadata};
use move_vm_runtime::{
ambassador_impl_ModuleStorage, ambassador_impl_WithRuntimeEnvironment, compute_code_hash,
ambassador_impl_ModuleStorage, ambassador_impl_WithRuntimeEnvironment,
logging::expect_no_verification_errors, CodeStorage, Module, ModuleStorage, RuntimeEnvironment,
Script, WithRuntimeEnvironment,
};
use move_vm_types::{
code::{Code, ModuleBytesStorage},
module_linker_error,
sha3_256
};
use std::sync::Arc;

Expand Down Expand Up @@ -96,7 +97,7 @@ impl<M: ModuleStorage> CodeStorage for InitiaCodeStorage<M> {
&self,
serialized_script: &[u8],
) -> VMResult<Arc<CompiledScript>> {
let hash = compute_code_hash(serialized_script);
let hash = sha3_256(serialized_script);
Ok(match self.script_cache.get_script(&hash) {
Some(script) => script.deserialized().clone(),
None => {
Expand All @@ -112,7 +113,7 @@ impl<M: ModuleStorage> CodeStorage for InitiaCodeStorage<M> {
fn verify_and_cache_script(&self, serialized_script: &[u8]) -> VMResult<Arc<Script>> {
use Code::*;

let hash = compute_code_hash(serialized_script);
let hash = sha3_256(serialized_script);
let deserialized_script = match self.script_cache.get_script(&hash) {
Some(Verified(script)) => return Ok(script),
Some(Deserialized(deserialized_script)) => deserialized_script,
Expand Down Expand Up @@ -180,7 +181,8 @@ pub(crate) mod test {
use move_core_types::{
account_address::AccountAddress, identifier::Identifier, language_storage::ModuleId,
};
use move_vm_runtime::{compute_code_hash, CodeStorage, RuntimeEnvironment};
use move_vm_runtime::{CodeStorage, RuntimeEnvironment};
use move_vm_types::sha3_256;

use crate::{
code_storage::AsInitiaCodeStorage,
Expand Down Expand Up @@ -217,11 +219,11 @@ pub(crate) mod test {
);

let serialized_script = make_script(vec!["a"]);
let hash_1 = compute_code_hash(&serialized_script);
let hash_1 = sha3_256(&serialized_script);
assert_ok!(code_storage.deserialize_and_cache_script(&serialized_script));

let serialized_script = make_script(vec!["b"]);
let hash_2 = compute_code_hash(&serialized_script);
let hash_2 = sha3_256(&serialized_script);
assert_ok!(code_storage.deserialize_and_cache_script(&serialized_script));

code_storage.assert_cached_state(vec![&hash_1, &hash_2], vec![]);
Expand Down Expand Up @@ -249,7 +251,7 @@ pub(crate) mod test {
);

let serialized_script = make_script(vec!["a"]);
let hash = compute_code_hash(&serialized_script);
let hash = sha3_256(&serialized_script);
assert_ok!(code_storage.deserialize_and_cache_script(&serialized_script));

// Nothing gets loaded into module cache.
Expand Down
8 changes: 4 additions & 4 deletions crates/storage/src/memory_module_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ use move_core_types::{
value::MoveTypeLayout,
vm_status::StatusCode,
};
use move_vm_runtime::compute_code_hash;
use move_vm_types::{
code::ModuleBytesStorage,
resolver::{resource_size, ModuleResolver, ResourceResolver},
sha3_256
};
use std::{
collections::{btree_map, BTreeMap},
Expand Down Expand Up @@ -193,8 +193,8 @@ impl InMemoryAccountStorage {
(
k,
match v {
Op::New(bytes) => Op::New(compute_code_hash(&bytes)),
Op::Modify(bytes) => Op::Modify(compute_code_hash(&bytes)),
Op::New(bytes) => Op::New(sha3_256(&bytes)),
Op::Modify(bytes) => Op::Modify(sha3_256(&bytes)),
Op::Delete => Op::Delete,
},
)
Expand Down Expand Up @@ -246,7 +246,7 @@ impl InMemoryStorage {
module_name: &IdentStr,
bytes: Bytes,
) -> Checksum {
let checksum = compute_code_hash(&bytes);
let checksum = sha3_256(&bytes);

let account = get_or_insert(&mut self.accounts, *address, || {
InMemoryAccountStorage::new()
Expand Down
2 changes: 1 addition & 1 deletion crates/storage/src/move_core_type/file_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ pub struct U256(PrimitiveU256);

impl GetSize for U256 {
fn get_size(&self) -> usize {
4
32
}
}
impl fmt::Display for U256 {
Expand Down
6 changes: 3 additions & 3 deletions crates/vm/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ use move_core_types::{
value::{MoveFieldLayout, MoveStructLayout, MoveTypeLayout},
vm_status::StatusCode,
};
use move_vm_runtime::{compute_code_hash, session::Session, ModuleStorage};
use move_vm_types::loaded_data::runtime_types::{StructLayout, StructNameIndex, StructType, Type};
use move_vm_runtime::{session::Session, ModuleStorage};
use move_vm_types::{loaded_data::runtime_types::{StructLayout, StructNameIndex, StructType, Type}, sha3_256};

/// Maximal depth of a value in terms of type depth.
pub const VALUE_DEPTH_MAX: u64 = 128;
Expand Down Expand Up @@ -123,7 +123,7 @@ impl<'r, 'l> SessionExt<'r, 'l> {
module_write_set.insert(
ap,
op.map(|v| {
let checksum = compute_code_hash(&v);
let checksum = sha3_256(&v);
checksum.into()
}),
);
Expand Down

0 comments on commit bf1b2c6

Please sign in to comment.