Skip to content

Commit

Permalink
Blob tx support and fuel-vm 0.56.0 (#1988)
Browse files Browse the repository at this point in the history
Work towards FuelLabs/fuel-specs#589. Spec PR
FuelLabs/fuel-specs#592.

Adds support for Blob transactions, which are inserted into the onchain
database column called `Blobs`.
Also updates fuel-vm to 0.56.0, which introduces the new tx type.

Work-in-progress, still needs:
- [x] Regenesis support
- [x] Tests

## Checklist
- [x] Breaking changes are clearly marked as such in the PR description
and changelog
- [x] New behavior is reflected in tests

### Before requesting review
- [x] I have reviewed the code myself
- [x] I have created follow-up issues caused by this PR and linked them
here

### After merging, notify other teams

- [ ] [Rust SDK](https://github.com/FuelLabs/fuels-rs/)
- [ ] [Sway compiler](https://github.com/FuelLabs/sway/)
- [ ] [Platform
documentation](https://github.com/FuelLabs/devrel-requests/issues/new?assignees=&labels=new+request&projects=&template=NEW-REQUEST.yml&title=%5BRequest%5D%3A+)
(for out-of-organization contributors, the person merging the PR will do
this)

---------

Co-authored-by: Ahmed Sagdati <37515857+segfault-magnet@users.noreply.github.com>
Co-authored-by: segfault-magnet <ahmed.sagdati.ets@gmail.com>
  • Loading branch information
3 people committed Aug 1, 2024
1 parent a204300 commit c2f5a3a
Show file tree
Hide file tree
Showing 51 changed files with 803 additions and 168 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- [1983](https://github.com/FuelLabs/fuel-core/pull/1983): Add adapters for gas price service for accessing database values

### Breaking
- [#1988](https://github.com/FuelLabs/fuel-core/pull/1988): Updated `fuel-vm` to `0.56.0` ([release notes](https://github.com/FuelLabs/fuel-vm/releases/tag/v0.55.0)). Adds Blob transaction support.
- [2025](https://github.com/FuelLabs/fuel-core/pull/2025): Add new V0 algorithm for gas price to services.
This change includes new flags for the CLI:
- "starting-gas-price" - the starting gas price for the gas price algorithm
Expand Down
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 @@ -85,7 +85,7 @@ fuel-core-xtask = { version = "0.0.0", path = "./xtask" }
fuel-gas-price-algorithm = { version = "0.31.0", path = "crates/fuel-gas-price-algorithm" }

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

# Common dependencies
anyhow = "1.0"
Expand Down
2 changes: 1 addition & 1 deletion benches/benches-outputs/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use fuel_core_types::fuel_tx::{
consensus_parameters::gas::GasCostsValuesV3,
consensus_parameters::gas::GasCostsValuesV4,
DependentCost,
GasCostsValues,
};
Expand Down
2 changes: 1 addition & 1 deletion benches/benches/block_target_gas_set/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ pub fn run_contract(group: &mut BenchmarkGroup<WallTime>) {
let mut instructions = setup_instructions();
instructions.extend(vec![
op::movi(0x13, size),
op::ldc(CONTRACT_ID_REGISTER, RegId::ZERO, 0x13),
op::ldc(CONTRACT_ID_REGISTER, RegId::ZERO, 0x13, 0),
op::jmpb(RegId::ZERO, 0),
]);
let id = format!("contract/ldc {:?}", size);
Expand Down
71 changes: 37 additions & 34 deletions benches/benches/block_target_gas_set/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,43 +97,46 @@ pub fn run_crypto(group: &mut BenchmarkGroup<WallTime>) {
.collect(),
);

let message = Message::new(b"foo");
let ed19_secret = ed25519_dalek::SigningKey::generate(&mut rand::rngs::OsRng {});
let ed19_signature = ed19_secret.sign(&*message);

run(
"crypto/ed19 opcode",
group,
vec![
op::gtf_args(0x20, 0x00, GTFArgs::ScriptData),
op::addi(
0x21,
0x20,
ed19_secret
.verifying_key()
.as_ref()
.len()
.try_into()
.unwrap(),
),
op::addi(
0x22,
0x21,
ed19_signature.to_bytes().len().try_into().unwrap(),
),
op::addi(0x22, 0x21, message.as_ref().len().try_into().unwrap()),
op::ed19(0x20, 0x21, 0x22),
op::jmpb(RegId::ZERO, 0),
],
ed19_secret
.verifying_key()
.to_bytes()
.iter()
.copied()
.chain(ed19_signature.to_bytes())
.chain(message.as_ref().iter().copied())
.collect(),
);
for i in arb_dependent_cost_values() {
let id = format!("crypto/ed19 opcode {:?}", i);
let message = vec![1u8; i as usize];
run(
&id,
group,
vec![
op::gtf_args(0x20, 0x00, GTFArgs::ScriptData),
op::addi(
0x21,
0x20,
ed19_secret
.verifying_key()
.as_ref()
.len()
.try_into()
.unwrap(),
),
op::addi(
0x22,
0x21,
ed19_signature.to_bytes().len().try_into().unwrap(),
),
op::movi(0x23, message.len().try_into().unwrap()),
op::ed19(0x20, 0x21, 0x22, 0x23),
op::jmpb(RegId::ZERO, 0),
],
ed19_secret
.verifying_key()
.to_bytes()
.iter()
.copied()
.chain(ed19_signature.to_bytes())
.chain(message.iter().copied())
.collect(),
);
}

for i in arb_dependent_cost_values() {
let id = format!("crypto/s256 opcode {:?}", i);
Expand Down
2 changes: 1 addition & 1 deletion benches/benches/vm_set/blockchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ pub fn run(c: &mut Criterion) {
run_group_ref(
&mut ldc,
format!("{i}"),
VmBench::new(op::ldc(0x10, RegId::ZERO, 0x13))
VmBench::new(op::ldc(0x10, RegId::ZERO, 0x13, 0))
.with_contract_code(code)
.with_data(data)
.with_prepare_script(prepare_script),
Expand Down
67 changes: 37 additions & 30 deletions benches/benches/vm_set/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,37 +114,44 @@ pub fn run(c: &mut Criterion) {
let ed19_secret = ed25519_dalek::SigningKey::generate(&mut rand::rngs::OsRng {});
let ed19_signature = ed19_secret.sign(&*message);

run_group_ref(
&mut c.benchmark_group("ed19"),
"ed19",
VmBench::new(op::ed19(0x20, 0x21, 0x22))
.with_prepare_script(vec![
op::gtf_args(0x20, 0x00, GTFArgs::ScriptData),
op::addi(
0x21,
0x20,
let mut bench_ed19 = c.benchmark_group("ed19");
for i in &linear {
bench_ed19.throughput(Throughput::Bytes(*i as u64));
run_group_ref(
&mut bench_ed19,
format!("{i}"),
VmBench::new(op::ed19(0x20, 0x21, RegId::ZERO, 0x10))
.with_prepare_script(vec![
op::gtf_args(0x20, 0x00, GTFArgs::ScriptData),
op::addi(
0x21,
0x20,
ed19_secret
.verifying_key()
.as_bytes()
.len()
.try_into()
.unwrap(),
),
op::addi(
0x22,
0x21,
ed19_signature.to_bytes().len().try_into().unwrap(),
),
op::movi(0x10, *i),
op::cfe(0x10),
])
.with_data(
ed19_secret
.verifying_key()
.as_bytes()
.len()
.try_into()
.unwrap(),
),
op::addi(
0x22,
0x21,
ed19_signature.to_bytes().len().try_into().unwrap(),
.to_bytes()
.iter()
.chain(ed19_signature.to_bytes().iter())
.chain(message.iter())
.copied()
.collect(),
),
])
.with_data(
ed19_secret
.verifying_key()
.to_bytes()
.iter()
.chain(ed19_signature.to_bytes().iter())
.chain(message.iter())
.copied()
.collect(),
),
);
);
}
bench_ed19.finish();
}
6 changes: 3 additions & 3 deletions benches/src/bin/collect.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use clap::Parser;
use fuel_core_types::fuel_tx::{
consensus_parameters::gas::GasCostsValuesV3,
consensus_parameters::gas::GasCostsValuesV4,
ConsensusParameters,
GasCosts,
};
Expand Down Expand Up @@ -371,7 +371,7 @@ pub const GIT: &str = ""#,
r#"";"#,
r##"
pub fn default_gas_costs() -> GasCostsValues {
GasCostsValuesV3 {"##,
GasCostsValuesV4 {"##,
r##" }.into()
}
"##,
Expand Down Expand Up @@ -495,7 +495,7 @@ impl State {
)
}

fn to_gas_costs(&self) -> GasCostsValuesV3 {
fn to_gas_costs(&self) -> GasCostsValuesV4 {
serde_yaml::from_value(self.to_yaml()).unwrap()
}

Expand Down
17 changes: 14 additions & 3 deletions benches/src/default_gas_costs.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::*;
use fuel_core_types::fuel_tx::consensus_parameters::gas::GasCostsValuesV3;
use fuel_core_types::fuel_tx::consensus_parameters::gas::GasCostsValuesV4;
pub fn default_gas_costs() -> GasCostsValues {
GasCostsValuesV3 {
GasCostsValuesV4 {
add: 2,
addi: 2,
and: 2,
Expand All @@ -16,7 +16,6 @@ pub fn default_gas_costs() -> GasCostsValues {
divi: 2,
eck1: 1907,
ecr1: 26135,
ed19: 1893,
eq: 2,
exp: 2,
expi: 2,
Expand Down Expand Up @@ -95,6 +94,14 @@ pub fn default_gas_costs() -> GasCostsValues {
base: 2,
units_per_gas: 15,
},
bldd: DependentCost::LightOperation {
base: 15,
units_per_gas: 272,
},
bsiz: DependentCost::LightOperation {
base: 17,
units_per_gas: 790,
},
cfe: DependentCost::LightOperation {
base: 10,
units_per_gas: 1818181,
Expand All @@ -119,6 +126,10 @@ pub fn default_gas_costs() -> GasCostsValues {
base: 31,
units_per_gas: 438,
},
ed19: DependentCost::LightOperation {
base: 3000,
units_per_gas: 214,
},
k256: DependentCost::LightOperation {
base: 27,
units_per_gas: 5,
Expand Down
Loading

0 comments on commit c2f5a3a

Please sign in to comment.