Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Use in-memory binary Merkle tree #459

Merged
merged 1 commit into from
Jul 4, 2022
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
19 changes: 18 additions & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion fuel-core-interfaces/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ chrono = { version = "0.4" }
derive_more = { version = "0.99" }
fuel-asm = "0.5"
fuel-crypto = { version = "0.5", default-features = false, features = [ "random" ] }
fuel-merkle = { version = "0.2" }
fuel-merkle = { version = "0.3" }
fuel-storage = "0.1"
fuel-tx = { version = "0.13", default-features = false }
fuel-types = { version = "0.5", default-features = false }
Expand Down
14 changes: 4 additions & 10 deletions fuel-core/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use chrono::Utc;
use fuel_core_interfaces::{
common::{
fuel_asm::Word,
fuel_merkle::{binary::MerkleTree, common::StorageMap},
fuel_merkle::binary::in_memory::MerkleTree,
fuel_storage::Storage,
fuel_tx::{
Address, AssetId, Bytes32, Input, Output, Receipt, Transaction, TxId, UtxoId,
Expand Down Expand Up @@ -85,8 +85,7 @@ impl Executor {
};

let mut block_db_transaction = self.database.transaction();
let mut storage = StorageMap::new();
let mut txs_merkle = MerkleTree::new(&mut storage);
let mut txs_merkle = MerkleTree::new();
let mut tx_status = vec![];
let mut coinbase = 0u64;

Expand Down Expand Up @@ -160,9 +159,7 @@ impl Executor {
// possible atm because the change output values are set on the tx instance in the vm
// and not also on the in-memory representation of the tx.
let tx_bytes = vm_result.tx().clone().to_bytes();
txs_merkle
.push(&tx_bytes)
.expect("In-memory impl should be infallible");
txs_merkle.push(&tx_bytes);

match mode {
ExecutionMode::Validation => {
Expand Down Expand Up @@ -239,10 +236,7 @@ impl Executor {
}

// check or set transaction commitment
let txs_root = txs_merkle
.root()
.expect("In-memory impl should be infallible")
.into();
let txs_root = txs_merkle.root().into();
match mode {
ExecutionMode::Production => {
block.header.transactions_root = txs_root;
Expand Down