Skip to content

Commit

Permalink
Merge branch 'master' into bvrooman/chore/simplify-interpreter-storage
Browse files Browse the repository at this point in the history
  • Loading branch information
Brandon Vrooman authored Feb 22, 2024
2 parents 3a2254c + 77f44f8 commit a0bc1a4
Show file tree
Hide file tree
Showing 54 changed files with 635 additions and 508 deletions.
14 changes: 12 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,24 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

### Changed
#### Breaking

- [#672](https://github.com/FuelLabs/fuel-vm/pull/672): Remove `GasPrice` policy
- [#672](https://github.com/FuelLabs/fuel-vm/pull/672): Add `gas_price` field to transaction execution

## [Version 0.46.0]

### Changed
#### Breaking

- [#679](https://github.com/FuelLabs/fuel-vm/pull/679): Require less restricted constraint on `MerkleRootStorage` trait. Now it requires `StorageInspect` instead of the `StorageMutate`.
- [#1632](https://github.com/FuelLabs/fuel-core/pull/1632): Removed `ContractsInfo` table. Contract salts and roots are no longer stored in on-chain data.
- [#1632](https://github.com/FuelLabs/fuel-core/pull/1632): Opcode `CROO` now calculates the given contract's root on demand. `CROO` has therefore been changed to a `DependentCost` gas cost.
- [#673](https://github.com/FuelLabs/fuel-vm/pull/673): Removed `ContractsInfo` table. Contract salts and roots are no longer stored in on-chain data.
- [#673](https://github.com/FuelLabs/fuel-vm/pull/673): Opcode `CROO` now calculates the given contract's root on demand. `CROO` has therefore been changed to a `DependentCost` gas cost.

### Changed

- [#672](https://github.com/FuelLabs/fuel-vm/pull/672): Add `Tip` policy

## [Version 0.45.0]

Expand Down
4 changes: 2 additions & 2 deletions fuel-asm/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ crate::enum_try_from! {
PolicyTypes = 0x500,

/// Set `$rA` to `tx.policies[0x00].gasPrice`
PolicyGasPrice = 0x501,
PolicyTip = 0x501,

/// Set `$rA` to `tx.policies[count_ones(0b11 & tx.policyTypes) - 1].witnessLimit`
PolicyWitnessLimit = 0x502,
Expand Down Expand Up @@ -362,7 +362,7 @@ fn encode_gtf_args() {
GTFArgs::WitnessDataLength,
GTFArgs::WitnessData,
GTFArgs::PolicyTypes,
GTFArgs::PolicyGasPrice,
GTFArgs::PolicyTip,
GTFArgs::PolicyWitnessLimit,
GTFArgs::PolicyMaturity,
GTFArgs::PolicyMaxFee,
Expand Down
11 changes: 5 additions & 6 deletions fuel-tx/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use crate::{
field::{
BytecodeLength,
BytecodeWitnessIndex,
GasPrice,
Maturity,
Tip,
Witnesses,
},
Chargeable,
Expand Down Expand Up @@ -119,7 +119,7 @@ impl TransactionBuilder<Script> {
script_gas_limit: Default::default(),
script,
script_data,
policies: Policies::new().with_gas_price(0),
policies: Policies::new(),
inputs: Default::default(),
outputs: Default::default(),
witnesses: Default::default(),
Expand Down Expand Up @@ -148,7 +148,7 @@ impl TransactionBuilder<Create> {
bytecode_witness_index: Default::default(),
salt,
storage_slots,
policies: Policies::new().with_gas_price(0),
policies: Policies::new(),
inputs: Default::default(),
outputs: Default::default(),
witnesses: Default::default(),
Expand Down Expand Up @@ -293,9 +293,8 @@ impl<Tx: Buildable> TransactionBuilder<Tx> {
self.sign_keys.keys()
}

pub fn gas_price(&mut self, gas_price: Word) -> &mut Self {
self.tx.set_gas_price(gas_price);

pub fn tip(&mut self, tip: Word) -> &mut Self {
self.tx.set_tip(tip);
self
}

Expand Down
10 changes: 2 additions & 8 deletions fuel-tx/src/tests/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,6 @@ fn transaction() {
fn create_input_data_offset() {
let rng = &mut StdRng::seed_from_u64(8586);

let gas_price = 100;
let maturity = 10.into();
let bytecode_witness_index = 0x00;
let salt = rng.gen();
Expand Down Expand Up @@ -476,9 +475,7 @@ fn create_input_data_offset() {

let tx = Transaction::create(
bytecode_witness_index,
Policies::new()
.with_maturity(maturity)
.with_gas_price(gas_price),
Policies::new().with_maturity(maturity),
salt,
storage_slot.clone(),
inputs,
Expand Down Expand Up @@ -529,7 +526,6 @@ fn create_input_data_offset() {
fn script_input_coin_data_offset() {
let rng = &mut StdRng::seed_from_u64(8586);

let gas_price = 100;
let gas_limit = 1000;
let maturity = 10.into();

Expand Down Expand Up @@ -598,9 +594,7 @@ fn script_input_coin_data_offset() {
gas_limit,
script.clone(),
script_data.clone(),
Policies::new()
.with_maturity(maturity)
.with_gas_price(gas_price),
Policies::new().with_maturity(maturity),
inputs,
outputs.clone(),
witnesses.clone(),
Expand Down
45 changes: 39 additions & 6 deletions fuel-tx/src/tests/valid_cases/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ fn input_coin_message_signature() {
#[test]
fn coin_signed() {
let rng = &mut StdRng::seed_from_u64(8586);
let arb_gas_price = 1;

let mut tx = Script::default();

Expand All @@ -157,7 +158,11 @@ fn coin_signed() {

let block_height = rng.gen();
let err = tx
.check(block_height, &ConsensusParameters::standard())
.check(
block_height,
&ConsensusParameters::standard(),
arb_gas_price,
)
.expect_err("Expected failure");

assert_eq!(ValidityError::InputWitnessIndexBounds { index: 0 }, err);
Expand Down Expand Up @@ -333,6 +338,7 @@ fn contract() {
#[test]
fn message_metadata() {
let rng = &mut StdRng::seed_from_u64(8586);
let arb_gas_price = 1;

let txhash: Bytes32 = rng.gen();

Expand Down Expand Up @@ -370,7 +376,11 @@ fn message_metadata() {

let block_height = rng.gen();
let err = tx
.check(block_height, &ConsensusParameters::standard())
.check(
block_height,
&ConsensusParameters::standard(),
arb_gas_price,
)
.expect_err("Expected failure");

assert_eq!(ValidityError::InputWitnessIndexBounds { index: 0 }, err,);
Expand Down Expand Up @@ -471,6 +481,8 @@ fn message_metadata() {
fn message_message_coin() {
let rng = &mut StdRng::seed_from_u64(8586);

let arb_gas_price = 1;

let txhash: Bytes32 = rng.gen();

let predicate = generate_nonempty_padded_bytes(rng);
Expand All @@ -495,7 +507,11 @@ fn message_message_coin() {

let block_height = rng.gen();
let err = tx
.check(block_height, &ConsensusParameters::standard())
.check(
block_height,
&ConsensusParameters::standard(),
arb_gas_price,
)
.expect_err("Expected failure");

assert_eq!(ValidityError::InputWitnessIndexBounds { index: 0 }, err,);
Expand Down Expand Up @@ -556,6 +572,7 @@ fn message_message_coin() {
fn transaction_with_duplicate_coin_inputs_is_invalid() {
let rng = &mut StdRng::seed_from_u64(8586);
let utxo_id = rng.gen();
let arb_gas_price = 1;

let a = Input::coin_signed(
utxo_id,
Expand All @@ -581,7 +598,11 @@ fn transaction_with_duplicate_coin_inputs_is_invalid() {
.add_input(b)
.add_witness(rng.gen())
.finalize()
.check_without_signatures(Default::default(), &ConsensusParameters::standard())
.check_without_signatures(
Default::default(),
&ConsensusParameters::standard(),
arb_gas_price,
)
.expect_err("Expected checkable failure");

assert_eq!(err, ValidityError::DuplicateInputUtxoId { utxo_id });
Expand All @@ -590,6 +611,7 @@ fn transaction_with_duplicate_coin_inputs_is_invalid() {
#[test]
fn transaction_with_duplicate_message_inputs_is_invalid() {
let rng = &mut StdRng::seed_from_u64(8586);
let arb_gas_price = 1;
let message_input = Input::message_data_signed(
rng.gen(),
rng.gen(),
Expand Down Expand Up @@ -619,6 +641,7 @@ fn transaction_with_duplicate_message_inputs_is_invalid() {
.check_without_signatures(
Default::default(),
&ConsensusParameters::standard(),
arb_gas_price,
)
.expect_err("Expected checkable failure");

Expand All @@ -628,6 +651,7 @@ fn transaction_with_duplicate_message_inputs_is_invalid() {
#[test]
fn transaction_with_duplicate_contract_inputs_is_invalid() {
let rng = &mut StdRng::seed_from_u64(8586);
let arb_gas_price = 1;
let contract_id = rng.gen();
let fee = Input::coin_signed(
rng.gen(),
Expand All @@ -652,7 +676,11 @@ fn transaction_with_duplicate_contract_inputs_is_invalid() {
.add_output(o)
.add_output(p)
.finalize()
.check_without_signatures(Default::default(), &ConsensusParameters::standard())
.check_without_signatures(
Default::default(),
&ConsensusParameters::standard(),
arb_gas_price,
)
.expect_err("Expected checkable failure");

assert_eq!(err, ValidityError::DuplicateInputContractId { contract_id });
Expand All @@ -662,6 +690,7 @@ fn transaction_with_duplicate_contract_inputs_is_invalid() {
fn transaction_with_duplicate_contract_utxo_id_is_valid() {
let rng = &mut StdRng::seed_from_u64(8586);
let input_utxo_id: UtxoId = rng.gen();
let arb_gas_price = 1;

let a = Input::contract(input_utxo_id, rng.gen(), rng.gen(), rng.gen(), rng.gen());
let b = Input::contract(input_utxo_id, rng.gen(), rng.gen(), rng.gen(), rng.gen());
Expand All @@ -686,6 +715,10 @@ fn transaction_with_duplicate_contract_utxo_id_is_valid() {
.add_output(p)
.add_witness(rng.gen())
.finalize()
.check_without_signatures(Default::default(), &ConsensusParameters::standard())
.check_without_signatures(
Default::default(),
&ConsensusParameters::standard(),
arb_gas_price,
)
.expect("Duplicated UTXO id is valid for contract input");
}
Loading

0 comments on commit a0bc1a4

Please sign in to comment.