Ver Fonte

runtime::{smt, merkle}: add missing call_idx to db_roots data

zero há 2 anos atrás
pai
commit
98fb3af981
2 ficheiros alterados com 2 adições e 8 exclusões
  1. 1 4
      src/runtime/import/merkle.rs
  2. 1 4
      src/runtime/import/smt.rs

+ 1 - 4
src/runtime/import/merkle.rs

@@ -271,12 +271,9 @@ pub(crate) fn merkle_add(mut ctx: FunctionEnvMut<Env>, ptr: WasmPtr<u8>, len: u3
     let latest_root_data = serialize(latest_root);
     assert_eq!(latest_root_data.len(), 32);
 
-    // This is hardcoded but should not be
-    let call_idx: u16 = 0;
-
     let mut value_data = Vec::with_capacity(32 + 2);
     env.tx_hash.inner().encode(&mut value_data).expect("Unable to serialize tx_hash");
-    call_idx.encode(&mut value_data).expect("Unable to serialize call_idx");
+    (env.call_idx as u16).encode(&mut value_data).expect("Unable to serialize call_idx");
     assert_eq!(value_data.len(), 32 + 2);
 
     if overlay.insert(&db_roots.tree, &latest_root_data, &value_data).is_err() {

+ 1 - 4
src/runtime/import/smt.rs

@@ -245,12 +245,9 @@ pub(crate) fn sparse_merkle_insert_batch(
     let latest_root_data = serialize(&latest_root);
     assert_eq!(latest_root_data.len(), 32);
 
-    // This is hardcoded but should not be
-    let call_idx: u16 = 0;
-
     let mut value_data = Vec::with_capacity(32 + 2);
     env.tx_hash.inner().encode(&mut value_data).expect("Unable to serialize tx_hash");
-    call_idx.encode(&mut value_data).expect("Unable to serialize call_idx");
+    (env.call_idx as u16).encode(&mut value_data).expect("Unable to serialize call_idx");
     assert_eq!(value_data.len(), 32 + 2);
 
     if overlay.insert(&db_roots.tree, &latest_root_data, &value_data).is_err() {