Skip to content

Commit

Permalink
Bumping fuel-vm to v0.40.0
Browse files Browse the repository at this point in the history
  • Loading branch information
xgreenx committed Oct 31, 2023
1 parent 5971c83 commit 836f5e0
Show file tree
Hide file tree
Showing 10 changed files with 72 additions and 44 deletions.
32 changes: 16 additions & 16 deletions 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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ fuel-core-tests = { version = "0.0.0", path = "./tests" }
fuel-core-xtask = { version = "0.0.0", path = "./xtask" }

# Fuel dependencies
fuel-vm-private = { version = "0.39.0", package = "fuel-vm", default-features = false }
fuel-vm-private = { version = "0.40.0", package = "fuel-vm", default-features = false }

# Common dependencies
anyhow = "1.0"
Expand Down
11 changes: 8 additions & 3 deletions crates/client/assets/schema.sdl
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,8 @@ type GasCosts {
scwq: DependentCost!
smo: DependentCost!
srwq: DependentCost!
contractRoot: DependentCost!
stateRoot: DependentCost!
swwq: DependentCost!
}

Expand Down Expand Up @@ -903,10 +905,11 @@ scalar TransactionId
union TransactionStatus = SubmittedStatus | SuccessStatus | SqueezedOutStatus | FailureStatus

type TxParameters {
maxInputs: U64!
maxOutputs: U64!
maxWitnesses: U64!
maxInputs: U8!
maxOutputs: U8!
maxWitnesses: U32!
maxGasPerTx: U64!
maxSize: U64!
}

scalar TxPointer
Expand All @@ -915,6 +918,8 @@ scalar U32

scalar U64

scalar U8

scalar UtxoId

type VariableOutput {
Expand Down
14 changes: 11 additions & 3 deletions crates/client/src/client/schema/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ use crate::client::schema::{
block::Block,
schema,
AssetId,
U32,
U64,
U8,
};

#[derive(cynic::QueryFragment, Debug)]
Expand All @@ -21,10 +23,11 @@ pub struct ConsensusParameters {
#[derive(cynic::QueryFragment, Debug)]
#[cynic(schema_path = "./assets/schema.sdl")]
pub struct TxParameters {
pub max_inputs: U64,
pub max_outputs: U64,
pub max_witnesses: U64,
pub max_inputs: U8,
pub max_outputs: U8,
pub max_witnesses: U32,
pub max_gas_per_tx: U64,
pub max_size: U64,
}

impl From<TxParameters> for fuel_core_types::fuel_tx::TxParameters {
Expand All @@ -34,6 +37,7 @@ impl From<TxParameters> for fuel_core_types::fuel_tx::TxParameters {
max_outputs: params.max_outputs.into(),
max_witnesses: params.max_witnesses.into(),
max_gas_per_tx: params.max_gas_per_tx.into(),
max_size: params.max_size.into(),
}
}
}
Expand Down Expand Up @@ -236,6 +240,10 @@ include_from_impls_and_cynic! {
pub smo: DependentCost,
pub srwq: DependentCost,
pub swwq: DependentCost,

// Non-opcodes prices
pub contract_root: DependentCost,
pub state_root: DependentCost,
}
}

Expand Down
1 change: 1 addition & 0 deletions crates/client/src/client/schema/primitives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ macro_rules! number_scalar {

number_scalar!(U64, u64);
number_scalar!(U32, u32);
number_scalar!(U8, u8);

impl TryFrom<U64> for PanicInstruction {
type Error = ConversionError;
Expand Down
5 changes: 5 additions & 0 deletions crates/client/src/client/types/gas_costs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ include_from_impls! {
pub smo: DependentCost,
pub srwq: DependentCost,
pub swwq: DependentCost,

// Non-opcode prices

pub state_root: DependentCost,
pub contract_root: DependentCost,
}
}

Expand Down
10 changes: 4 additions & 6 deletions crates/fuel-core/src/database/vm_database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ impl InterpreterStorage for VmDatabase {
&self,
contract_id: &ContractId,
start_key: &Bytes32,
range: Word,
range: usize,
) -> Result<Vec<Option<Cow<Bytes32>>>, Self::DataError> {
// TODO: Optimization: Iterate only over `range` elements.
let mut iterator = self.database.iter_all_filtered::<Vec<u8>, Bytes32, _, _>(
Expand All @@ -234,8 +234,6 @@ impl InterpreterStorage for VmDatabase {
Some(ContractsStateKey::new(contract_id, start_key)),
Some(IterDirection::Forward),
);
let range = usize::try_from(range)
.expect("Corresponding PR in `fuel-vm` https://github.com/FuelLabs/fuel-vm/pull/619 will use `usize`");

let mut expected_key = U256::from_big_endian(start_key.as_ref());
let mut results = vec![];
Expand Down Expand Up @@ -313,7 +311,7 @@ impl InterpreterStorage for VmDatabase {
&mut self,
contract_id: &ContractId,
start_key: &Bytes32,
range: Word,
range: usize,
) -> Result<Option<()>, Self::DataError> {
let mut found_unset = false;

Expand Down Expand Up @@ -417,7 +415,7 @@ mod tests {
fn read_sequential_range(
prefilled_slots: &[([u8; 32], [u8; 32])],
start_key: [u8; 32],
range: u64,
range: usize,
) -> Result<Vec<Option<[u8; 32]>>, ()> {
let mut db = VmDatabase::default();

Expand Down Expand Up @@ -583,7 +581,7 @@ mod tests {
fn remove_range(
prefilled_slots: &[([u8; 32], [u8; 32])],
start_key: [u8; 32],
remove_count: Word,
remove_count: usize,
) -> (Vec<[u8; 32]>, bool) {
let mut db = VmDatabase::default();

Expand Down
18 changes: 6 additions & 12 deletions crates/fuel-core/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1798,7 +1798,6 @@ mod tests {
Outputs,
Script as ScriptField,
},
Chargeable,
CheckError,
ConsensusParameters,
Create,
Expand Down Expand Up @@ -2032,7 +2031,6 @@ mod tests {
// state transition between blocks.
let price = 1;
let limit = 0;
let gas_used_by_predicates = 0;
let gas_price_factor = 1;
let script = TxBuilder::new(1u64)
.gas_limit(limit)
Expand Down Expand Up @@ -2067,12 +2065,10 @@ mod tests {

let producer = Executor::test(database.clone(), config);

let expected_fee_amount_1 = TransactionFee::checked_from_values(
let expected_fee_amount_1 = TransactionFee::checked_from_tx(
producer.config.consensus_parameters.gas_costs(),
producer.config.consensus_parameters.fee_params(),
script.metered_bytes_size() as Word,
gas_used_by_predicates,
limit,
price,
&script,
)
.unwrap()
.max_fee();
Expand Down Expand Up @@ -2138,12 +2134,10 @@ mod tests {
.transaction()
.clone();

let expected_fee_amount_2 = TransactionFee::checked_from_values(
let expected_fee_amount_2 = TransactionFee::checked_from_tx(
producer.config.consensus_parameters.gas_costs(),
producer.config.consensus_parameters.fee_params(),
script.metered_bytes_size() as Word,
gas_used_by_predicates,
limit,
price,
&script,
)
.unwrap()
.max_fee();
Expand Down
22 changes: 19 additions & 3 deletions crates/fuel-core/src/schema/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ use crate::{
block::Block,
scalars::{
AssetId,
U32,
U64,
U8,
},
},
};
Expand Down Expand Up @@ -113,21 +115,25 @@ impl ConsensusParameters {

#[Object]
impl TxParameters {
async fn max_inputs(&self) -> U64 {
async fn max_inputs(&self) -> U8 {
self.0.max_inputs.into()
}

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

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

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

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

#[Object]
Expand Down Expand Up @@ -604,6 +610,16 @@ impl GasCosts {
self.0.srwq.into()
}

// Non-opcode prices

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

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

async fn swwq(&self) -> DependentCost {
self.0.swwq.into()
}
Expand Down
1 change: 1 addition & 0 deletions crates/fuel-core/src/schema/scalars.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ macro_rules! number_scalar {

number_scalar!(U64, u64, "U64");
number_scalar!(U32, u32, "U32");
number_scalar!(U8, u8, "U8");

impl From<BlockHeight> for U32 {
fn from(h: BlockHeight) -> Self {
Expand Down

0 comments on commit 836f5e0

Please sign in to comment.