Skip to content

Commit

Permalink
Update fuel-vm and breaking changes
Browse files Browse the repository at this point in the history
  • Loading branch information
bvrooman committed Feb 26, 2024
1 parent 793b8c7 commit 15d06b5
Show file tree
Hide file tree
Showing 17 changed files with 81 additions and 38 deletions.
16 changes: 16 additions & 0 deletions Cargo.lock

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

4 changes: 0 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,3 @@ itertools = "0.10"
insta = "1.8"
tempfile = "3.4"
tikv-jemallocator = "0.5"

[patch.crates-io]
fuel-vm-private = { path = "../fuel-vm/fuel-vm", package = "fuel-vm" }
#fuel-vm-private = { git = 'https://github.com/FuelLabs/fuel-vm', package = "fuel-vm", branch = "bvrooman/feat/versionable-contract-info" }
6 changes: 5 additions & 1 deletion benches/src/default_gas_costs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ pub fn default_gas_costs() -> GasCostsValues {
cb: 2,
cfei: 2,
cfsi: 2,
croo: 40,
div: 2,
divi: 2,
eck1: 3347,
Expand Down Expand Up @@ -101,6 +100,11 @@ pub fn default_gas_costs() -> GasCostsValues {
base: 59,
units_per_gas: 20,
},
// TODO: Update CROO values based on benchmarks: https://github.com/FuelLabs/fuel-core/issues/1660
croo: DependentCost::LightOperation {
base: 1,
units_per_gas: 1,
},
csiz: DependentCost::LightOperation {
base: 59,
units_per_gas: 195,
Expand Down
18 changes: 6 additions & 12 deletions benches/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ impl From<Vec<u8>> for ContractCode {

Self {
contract,
salt,
id,
root,
storage_root,
salt,
slots,
}
}
Expand Down Expand Up @@ -162,7 +162,7 @@ impl VmBench {

let program = Witness::from(program);

let salt = rng.gen();
// let salt = rng.gen();

let contract = Contract::from(program.as_ref());
let state_root = Contract::default_state_root();
Expand All @@ -175,7 +175,7 @@ impl VmBench {
let input = Input::contract(utxo_id, balance_root, state_root, tx_pointer, id);
let output = Output::contract(0, rng.gen(), rng.gen());

db.deploy_contract_with_id(&salt, &[], &contract, &id)?;
db.deploy_contract_with_id(&[], &contract, &id)?;

let data = id
.iter()
Expand Down Expand Up @@ -374,12 +374,11 @@ impl TryFrom<VmBench> for VmBenchPrepared {
tx.add_input(input);
tx.add_output(output);

db.deploy_contract_with_id(&VmBench::SALT, &[], &code, &contract)?;
db.deploy_contract_with_id(&[], &code, &contract)?;
}

if let Some(ContractCode {
contract,
salt,
id,
slots,
storage_root,
Expand All @@ -400,7 +399,7 @@ impl TryFrom<VmBench> for VmBenchPrepared {
tx.add_input(input);
tx.add_output(output);

db.deploy_contract_with_id(&salt, &slots, &contract, &id)?;
db.deploy_contract_with_id(&slots, &contract, &id)?;
}

for contract_id in empty_contracts {
Expand All @@ -418,12 +417,7 @@ impl TryFrom<VmBench> for VmBenchPrepared {
tx.add_input(input);
tx.add_output(output);

db.deploy_contract_with_id(
&VmBench::SALT,
&[],
&Contract::default(),
&contract_id,
)?;
db.deploy_contract_with_id(&[], &Contract::default(), &contract_id)?;
}

inputs.into_iter().for_each(|i| {
Expand Down
2 changes: 1 addition & 1 deletion crates/client/assets/schema.sdl
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,6 @@ type GasCosts {
cb: U64!
cfei: U64!
cfsi: U64!
croo: U64!
div: U64!
divi: U64!
ecr1: U64!
Expand Down Expand Up @@ -397,6 +396,7 @@ type GasCosts {
xori: U64!
call: DependentCost!
ccp: DependentCost!
croo: DependentCost!
csiz: DependentCost!
k256: DependentCost!
ldc: DependentCost!
Expand Down
2 changes: 1 addition & 1 deletion crates/client/src/client/schema/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ include_from_impls_and_cynic! {
pub cb: U64,
pub cfei: U64,
pub cfsi: U64,
pub croo: U64,
pub div: U64,
pub divi: U64,
pub eck1: U64,
Expand Down Expand Up @@ -225,6 +224,7 @@ include_from_impls_and_cynic! {

pub call: DependentCost,
pub ccp: DependentCost,
pub croo: DependentCost,
pub csiz: DependentCost,
pub k256: DependentCost,
pub ldc: DependentCost,
Expand Down
1 change: 1 addition & 0 deletions crates/client/src/client/schema/tx/transparent_tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ impl TryFrom<Transaction> for fuel_tx::Transaction {
ConversionError::MissingField("mint_asset_id".to_string())
})?
.into(),
0,
);
mint.into()
};
Expand Down
2 changes: 1 addition & 1 deletion crates/client/src/client/types/gas_costs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ include_from_impls! {
pub cb: u64,
pub cfei: u64,
pub cfsi: u64,
pub croo: u64,
pub div: u64,
pub divi: u64,
pub eck1: u64,
Expand Down Expand Up @@ -125,6 +124,7 @@ include_from_impls! {
pub call: DependentCost,
pub ccp: DependentCost,
pub csiz: DependentCost,
pub croo: DependentCost,
pub k256: DependentCost,
pub ldc: DependentCost,
pub logd: DependentCost,
Expand Down
5 changes: 5 additions & 0 deletions crates/fuel-core/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,7 @@ mod tests {
Default::default(),
Default::default(),
Default::default(),
Default::default(),
);

let mut block = Block::default();
Expand Down Expand Up @@ -787,6 +788,7 @@ mod tests {
Default::default(),
Default::default(),
Default::default(),
Default::default(),
);
let tx = Transaction::default_test_tx();

Expand Down Expand Up @@ -823,6 +825,7 @@ mod tests {
Default::default(),
Default::default(),
Default::default(),
Default::default(),
);

let mut block = Block::default();
Expand Down Expand Up @@ -850,6 +853,7 @@ mod tests {
Default::default(),
Default::default(),
Default::default(),
Default::default(),
);

let mut block = Block::default();
Expand Down Expand Up @@ -879,6 +883,7 @@ mod tests {
Default::default(),
123,
Default::default(),
Default::default(),
);

let mut block = Block::default();
Expand Down
8 changes: 4 additions & 4 deletions crates/fuel-core/src/schema/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,6 @@ impl GasCosts {
self.0.cfsi.into()
}

async fn croo(&self) -> U64 {
self.0.croo.into()
}

async fn div(&self) -> U64 {
self.0.div.into()
}
Expand Down Expand Up @@ -580,6 +576,10 @@ impl GasCosts {
self.0.ccp.into()
}

async fn croo(&self) -> DependentCost {
self.0.croo.into()
}

async fn csiz(&self) -> DependentCost {
self.0.csiz.into()
}
Expand Down
8 changes: 5 additions & 3 deletions crates/fuel-core/src/service/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use fuel_core_storage::{
tables::{
Coins,
ContractsInfo,
ContractsInfoType,
ContractsLatestUtxo,
ContractsRawCode,
Messages,
Expand Down Expand Up @@ -43,7 +42,10 @@ use fuel_core_types::{
},
entities::{
coins::coin::Coin,
contract::ContractUtxoInfo,
contract::{
ContractUtxoInfo,
ContractsInfoType,
},
message::Message,
},
fuel_merkle::binary,
Expand Down Expand Up @@ -250,7 +252,7 @@ fn init_contracts(
// insert contract salt
if db
.storage::<ContractsInfo>()
.insert(&contract_id, &ContractsInfoType::V1(salt))?
.insert(&contract_id, &ContractsInfoType::V1(salt.into()))?
.is_some()
{
return Err(anyhow!("Contract info should not exist"))
Expand Down
1 change: 1 addition & 0 deletions crates/services/executor/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,7 @@ where
},
amount_to_mint,
self.config.consensus_parameters.base_asset_id,
0, // TODO:
);

execute_transaction(
Expand Down
1 change: 1 addition & 0 deletions crates/services/executor/src/ports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ pub trait ExecutorDatabaseTrait<D>:
+ StorageMutate<SpentMessages, Error = StorageError>
+ StorageMutate<ContractsLatestUtxo, Error = StorageError>
+ StorageMutate<ContractsRawCode, Error = StorageError>
+ StorageMutate<ContractsAssets, Error = StorageError>
+ StorageRead<ContractsRawCode>
+ StorageMutate<ContractsInfo, Error = StorageError>
+ MerkleRootStorage<ContractId, ContractsState, Error = StorageError>
Expand Down
1 change: 1 addition & 0 deletions crates/services/txpool/src/service/tests_p2p.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ async fn test_gossipped_mint_rejected() {
Default::default(),
1,
AssetId::BASE,
0,
)
.finalize_as_transaction();
// setup p2p mock - with tx incoming from p2p
Expand Down
10 changes: 7 additions & 3 deletions crates/storage/src/structured_storage/contracts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ use crate::{
},
StorageRead,
};
use core::ops::Deref;
use fuel_core_types::fuel_tx::ContractId;

use core::ops::Deref;

// # Dev-note: The value of the `ContractsRawCode` has a unique implementation of serialization
// and deserialization and uses `Raw` codec. Because the value is a contract byte code represented
// by bytes, we don't use `serde::Deserialization` and `serde::Serialization` for `Vec`,
Expand Down Expand Up @@ -76,7 +77,10 @@ impl TableWithBlueprint for ContractsLatestUtxo {
#[cfg(test)]
mod test {
use super::*;
use crate::tables::ContractsInfoType;
use fuel_core_types::{
entities::contract::ContractsInfoType,
fuel_tx::Salt,
};

crate::basic_storage_tests!(
ContractsRawCode,
Expand All @@ -88,7 +92,7 @@ mod test {
crate::basic_storage_tests!(
ContractsInfo,
<ContractsInfo as crate::Mappable>::Key::from([1u8; 32]),
ContractsInfoType::V1([2u8; 32].into())
ContractsInfoType::V1(Salt::new([2u8; 32]).into())
);

crate::basic_storage_tests!(
Expand Down
Loading

0 comments on commit 15d06b5

Please sign in to comment.