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

Refactor fuel-core to use version of StorageRead::read with offset #2438

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
afbfef2
Refactor fuel-core to use version of StorageRead::read with offset
acerone85 Nov 14, 2024
2b6e689
Merge branch 'master' into use-storage-read-with-offset
acerone85 Nov 14, 2024
8c27f1f
Changelog
acerone85 Nov 14, 2024
ba070e2
Merge branch 'master' into use-storage-read-with-offset
acerone85 Dec 4, 2024
83d9641
Update fuel-vm to 0.59.0
acerone85 Dec 4, 2024
5ca045e
Add missing todo
acerone85 Dec 4, 2024
bfe28fe
Fix snapshot
acerone85 Dec 4, 2024
ba9f641
Add block height and fix gas version
AurelienFT Dec 4, 2024
71a2be2
Remove old todo
AurelienFT Dec 4, 2024
f538a65
Fix compil
AurelienFT Dec 4, 2024
759110b
Add value new policy
AurelienFT Dec 4, 2024
7f4bd85
Add safety checks
acerone85 Dec 4, 2024
5356264
Use master and fix derivative error.
AurelienFT Dec 9, 2024
c80881e
Fix lint toml
AurelienFT Dec 9, 2024
b1565f8
format prettier toml
AurelienFT Dec 9, 2024
59b4fc9
Lint toml.
AurelienFT Dec 9, 2024
0a27919
Merge branch 'master' into use-storage-read-with-offset
AurelienFT Dec 9, 2024
ef013b9
Merge branch 'master' into use-storage-read-with-offset
AurelienFT Dec 10, 2024
c668c15
Remove old serialization json version
AurelienFT Dec 10, 2024
e41ede9
fix tx json
AurelienFT Dec 10, 2024
7d60ea7
Update config files
AurelienFT Dec 11, 2024
15f404f
Update more config file with the new opcode
AurelienFT Dec 11, 2024
5b5ac86
Rust FMT
AurelienFT Dec 11, 2024
9d9deca
Fix nulleable gas costs.
AurelienFT Dec 11, 2024
e9ade9a
Update snapshot query graphql with new opcodes
AurelienFT Dec 11, 2024
d68995b
fix local chain config
AurelienFT Dec 11, 2024
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Changed
- [2295](https://github.com/FuelLabs/fuel-core/pull/2295): `CombinedDb::from_config` now respects `state_rewind_policy` with tmp RocksDB.
- [2378](https://github.com/FuelLabs/fuel-core/pull/2378): Use cached hash of the topic instead of calculating it on each publishing gossip message.
- [2438](https://github.com/FuelLabs/fuel-core/pull/2438): Refactored service to use new implementation of `StorageRead::read` that takes an offset in input.
- [2429](https://github.com/FuelLabs/fuel-core/pull/2429): Introduce custom enum for representing result of running service tasks
- [2377](https://github.com/FuelLabs/fuel-core/pull/2377): Add more errors that can be returned as responses when using protocol `/fuel/req_res/0.0.2`. The errors supported are `ProtocolV1EmptyResponse` (status code `0`) for converting empty responses sent via protocol `/fuel/req_res/0.0.1`, `RequestedRangeTooLarge`(status code `1`) if the client requests a range of objects such as sealed block headers or transactions too large, `Timeout` (status code `2`) if the remote peer takes too long to fulfill a request, or `SyncProcessorOutOfCapacity` if the remote peer is fulfilling too many requests concurrently.
- [2233](https://github.com/FuelLabs/fuel-core/pull/2233): Introduce a new column `modification_history_v2` for storing the modification history in the historical rocksDB. Keys in this column are stored in big endian order. Changed the behaviour of the historical rocksDB to write changes for new block heights to the new column, and to perform lookup of values from the `modification_history_v2` table first, and then from the `modification_history` table, performing a migration upon access if necessary.
Expand Down
89 changes: 53 additions & 36 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 @@ -87,7 +87,7 @@ fuel-core-xtask = { version = "0.0.0", path = "./xtask" }
fuel-gas-price-algorithm = { version = "0.40.0", path = "crates/fuel-gas-price-algorithm" }

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

# Common dependencies
anyhow = "1.0"
Expand Down
3 changes: 2 additions & 1 deletion benches/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,8 @@ impl TryFrom<VmBench> for VmBenchPrepared {
}
let storage_diff = vm.storage_diff();
let mut vm = vm.remove_recording();
let mut diff = start_vm.diff(&vm);
// TODO: Check if this is the intended use of rollback_to.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xgreenx please check that this is how we intend to use the new rollback_to funciton, in which case we can remove the TODO

let mut diff = start_vm.rollback_to(&vm);
diff += storage_diff;
let diff: diff::Diff<diff::InitialVmState> = diff.into();
vm.reset_vm_state(&diff);
Expand Down
9 changes: 7 additions & 2 deletions crates/fuel-core/src/graphql_api/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,13 @@ impl StorageSize<BlobData> for ReadView {
}

impl StorageRead<BlobData> for ReadView {
fn read(&self, key: &BlobId, buf: &mut [u8]) -> Result<Option<usize>, Self::Error> {
StorageRead::<BlobData>::read(self.on_chain.as_ref(), key, buf)
fn read(
&self,
key: &BlobId,
offset: usize,
buf: &mut [u8],
) -> Result<Option<usize>, Self::Error> {
StorageRead::<BlobData>::read(self.on_chain.as_ref(), key, offset, buf)
}

fn read_alloc(&self, key: &BlobId) -> Result<Option<Vec<u8>>, Self::Error> {
Expand Down
4 changes: 3 additions & 1 deletion crates/fuel-core/src/schema/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,9 @@ impl GasCosts {
GasCostsValues::V1(_)
| GasCostsValues::V2(_)
| GasCostsValues::V3(_)
| GasCostsValues::V4(_) => GasCostsVersion::V1,
| GasCostsValues::V4(_)
//TODO: Handle new GasCostsValues variant properly
| GasCostsValues::V5(_) => GasCostsVersion::V1,
AurelienFT marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down
6 changes: 3 additions & 3 deletions crates/fuel-core/src/schema/dap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ impl ConcreteStorage {
let fee_params = params.fee_params();

let ready_tx = checked_tx
.into_ready(GAS_PRICE, gas_costs, fee_params)
.into_ready(GAS_PRICE, gas_costs, fee_params, None)
AurelienFT marked this conversation as resolved.
Show resolved Hide resolved
.map_err(|e| {
anyhow!("Failed to apply dynamic values to checked tx: {:?}", e)
})?;
Expand Down Expand Up @@ -176,7 +176,7 @@ impl ConcreteStorage {
let fee_params = params.fee_params();

let ready_tx = checked_tx
.into_ready(GAS_PRICE, gas_costs, fee_params)
.into_ready(GAS_PRICE, gas_costs, fee_params, None)
AurelienFT marked this conversation as resolved.
Show resolved Hide resolved
.map_err(|e| {
anyhow!("Failed to apply dynamic values to checked tx: {:?}", e)
})?;
Expand Down Expand Up @@ -456,7 +456,7 @@ impl DapMutation {
match checked_tx {
CheckedTransaction::Script(script) => {
let ready_tx = script
.into_ready(GAS_PRICE, gas_costs, fee_params)
.into_ready(GAS_PRICE, gas_costs, fee_params, None)
AurelienFT marked this conversation as resolved.
Show resolved Hide resolved
.map_err(|e| {
anyhow!("Failed to apply dynamic values to checked tx: {:?}", e)
})?;
Expand Down
3 changes: 2 additions & 1 deletion crates/fuel-core/src/state/data_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,10 @@ where
&self,
key: &[u8],
column: Self::Column,
offset: usize,
buf: &mut [u8],
) -> StorageResult<Option<usize>> {
self.data.read(key, column, buf)
self.data.read(key, column, offset, buf)
}
}

Expand Down
12 changes: 9 additions & 3 deletions crates/fuel-core/src/state/generic_database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,13 @@ where
M: Mappable,
StructuredStorage<Storage>: StorageRead<M, Error = StorageError>,
{
fn read(&self, key: &M::Key, buf: &mut [u8]) -> Result<Option<usize>, Self::Error> {
self.storage.storage::<M>().read(key, buf)
fn read(
&self,
key: &M::Key,
offset: usize,
buf: &mut [u8],
) -> Result<Option<usize>, Self::Error> {
self.storage.storage::<M>().read(key, offset, buf)
}

fn read_alloc(&self, key: &M::Key) -> Result<Option<Vec<u8>>, Self::Error> {
Expand Down Expand Up @@ -124,9 +129,10 @@ where
&self,
key: &[u8],
column: Self::Column,
offset: usize,
buf: &mut [u8],
) -> StorageResult<Option<usize>> {
KeyValueInspect::read(&self.storage, key, column, buf)
KeyValueInspect::read(&self.storage, key, column, offset, buf)
}
}

Expand Down
4 changes: 3 additions & 1 deletion crates/fuel-core/src/state/historical_rocksdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -534,9 +534,11 @@ where
&self,
key: &[u8],
column: Self::Column,
offset: usize,
buf: &mut [u8],
) -> StorageResult<Option<usize>> {
self.db.read(key, Column::OriginalColumn(column), buf)
self.db
.read(key, Column::OriginalColumn(column), offset, buf)
}
}

Expand Down
3 changes: 2 additions & 1 deletion crates/fuel-core/src/state/iterable_key_value_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,10 @@ where
&self,
key: &[u8],
column: Self::Column,
offset: usize,
buf: &mut [u8],
) -> StorageResult<Option<usize>> {
self.0.read(key, column, buf)
self.0.read(key, column, offset, buf)
}
}

Expand Down
3 changes: 2 additions & 1 deletion crates/fuel-core/src/state/key_value_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ where
&self,
key: &[u8],
column: Self::Column,
offset: usize,
buf: &mut [u8],
) -> StorageResult<Option<usize>> {
self.0.read(key, column, buf)
self.0.read(key, column, offset, buf)
}
}
Loading
Loading