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

Use AtomicView in all services #1612

Merged
merged 68 commits into from
Jan 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
df6e1ae
Move storage traits implementation to the `fuel-core-storage` crate
xgreenx Dec 24, 2023
de82e25
Added comments to all newly added stuff. Made self-review and applied…
xgreenx Dec 26, 2023
7ccc722
Merge branch 'master' into feature/move-storage-implementation-to-own…
xgreenx Dec 26, 2023
33661bc
Updated CHANGELOG.md
xgreenx Dec 26, 2023
1b8295a
Merge remote-tracking branch 'origin/feature/move-storage-implementat…
xgreenx Dec 26, 2023
82df7e2
Moved insertion of the blocks into the `BlockImporter` instead of the…
xgreenx Dec 29, 2023
d4a4d0a
Update CHANGELOG.md
xgreenx Dec 29, 2023
5033d8c
Cleanup
xgreenx Dec 29, 2023
ab88c67
Moved insertion of the whole block with transactions
xgreenx Dec 29, 2023
a49d96d
Use `store_block` as a name instead of `block`
xgreenx Dec 30, 2023
c6fb1fe
Merge branch 'master' into feature/move-blocks-to-importer
xgreenx Jan 2, 2024
f5c38f2
Move `ChainId` to `fuel_core_importer::Config`
xgreenx Jan 5, 2024
4c3f18c
Apply suggestions from the PR
xgreenx Jan 5, 2024
0eaab98
Merge branch 'master' into feature/move-storage-implementation-to-own…
xgreenx Jan 5, 2024
c1ee5f8
Apply suggestions from the PR
xgreenx Jan 5, 2024
c594d45
Extract off chain logic from the executor
xgreenx Jan 4, 2024
bd60793
Added comments and linked todos
xgreenx Jan 5, 2024
8221443
Updated CHANGELOG.md
xgreenx Jan 5, 2024
810edee
Merge branch 'master' into feature/move-offchain-logic-from-executor
xgreenx Jan 5, 2024
4a580ed
Merge branch 'master' into feature/move-offchain-logic-from-executor
xgreenx Jan 6, 2024
0cea5bb
Merge branch 'master' into feature/move-storage-implementation-to-own…
xgreenx Jan 6, 2024
c9977a4
Merge branch 'master' into feature/move-storage-implementation-to-own…
xgreenx Jan 6, 2024
b0ed3e9
Fixed compilation
xgreenx Jan 6, 2024
541527e
Merge branch 'master' into feature/move-storage-implementation-to-own…
xgreenx Jan 6, 2024
c5a7b71
Merge branch 'master' into feature/move-offchain-logic-from-executor
xgreenx Jan 6, 2024
d2b5504
Use `BlockHeight` as a primary key for the `FuelsBlock` table
xgreenx Jan 6, 2024
1013f0e
Merge branch 'feature/move-storage-implementation-to-own-crate' into …
xgreenx Jan 6, 2024
359192e
Updated CHANGELOG.md
xgreenx Jan 6, 2024
34b5e6a
Merge remote-tracking branch 'origin/feature/block-height-as-primary-…
xgreenx Jan 6, 2024
e27996a
Fix compilation
xgreenx Jan 6, 2024
f3515d8
Merge branch 'master' into feature/move-offchain-logic-from-executor
xgreenx Jan 7, 2024
1be054c
Use `AtomicView` in the `TxPool`
xgreenx Jan 8, 2024
ea69532
Update CHANGELOG.md
xgreenx Jan 8, 2024
452418c
Merge remote-tracking branch 'origin/feature/move-storage-implementat…
xgreenx Jan 19, 2024
1fbc318
Merge branch 'master' into feature/move-storage-implementation-to-own…
xgreenx Jan 19, 2024
c5956a8
Use "blueprint" instead of "structure"
xgreenx Jan 19, 2024
cc9966c
Fix documents
xgreenx Jan 19, 2024
0bbeea1
Merge branch 'feature/move-storage-implementation-to-own-crate' into …
xgreenx Jan 19, 2024
2d3e471
Merge latest modifications from move storage PR
xgreenx Jan 19, 2024
f0df4f0
Merge branch 'master' into feature/block-height-as-primary-key
xgreenx Jan 19, 2024
688a24b
Merge branch 'master' into feature/move-offchain-logic-from-executor
xgreenx Jan 19, 2024
c7bce20
Fix conflicts
xgreenx Jan 19, 2024
0850b03
Merge branch 'feature/move-offchain-logic-from-executor' into feature…
xgreenx Jan 19, 2024
f607007
Merge branch 'feature/move-offchain-logic-from-executor' into feature…
xgreenx Jan 19, 2024
55424cb
Merge remote-tracking branch 'origin/feature/use-view-in-txpool' into…
xgreenx Jan 19, 2024
2b95d4e
Merge branch 'master' into feature/use-view-in-txpool
xgreenx Jan 19, 2024
993aa84
Merge branch 'master' into feature/block-height-as-primary-key
xgreenx Jan 19, 2024
36445b7
Merged master
xgreenx Jan 19, 2024
0e2abad
Merge branch 'master' into feature/block-height-as-primary-key
xgreenx Jan 19, 2024
6a503b9
Apply comments
xgreenx Jan 19, 2024
02a45a8
Merge branch 'master' into feature/use-view-in-txpool
xgreenx Jan 19, 2024
50f2ff0
Merge branch 'feature/block-height-as-primary-key' into feature/use-v…
xgreenx Jan 19, 2024
067792b
Apply comments
xgreenx Jan 19, 2024
6cead2b
Merge branch 'master' into feature/use-view-in-txpool
xgreenx Jan 19, 2024
8369cd5
Move arc wrapper into its own module
xgreenx Jan 19, 2024
4b79c3f
Merge branch 'master' into feature/atomic-view-everywhere
xgreenx Jan 21, 2024
c540f4d
Use `AtomicView` in all services
xgreenx Jan 21, 2024
7e7ff6d
Update CHANGELOG.md
xgreenx Jan 21, 2024
fa5d52d
Fix compilation
xgreenx Jan 21, 2024
9c35ab7
Merge branch 'master' into feature/atomic-view-everywhere
xgreenx Jan 22, 2024
d75a5c1
Merge branch 'master' into feature/atomic-view-everywhere
xgreenx Jan 24, 2024
11cf96f
Merge branch 'master' into feature/atomic-view-everywhere
xgreenx Jan 24, 2024
76a689d
Merge branch 'master' into feature/atomic-view-everywhere
xgreenx Jan 26, 2024
2d63c32
Merged with `master`
xgreenx Jan 26, 2024
08c18e1
Update CHANGELOG.md
xgreenx Jan 26, 2024
5300800
Merge branch 'master' into feature/atomic-view-everywhere
xgreenx Jan 26, 2024
555d4e1
Merge with `master`
xgreenx Jan 26, 2024
ff51296
Apply comments from the PR
xgreenx Jan 26, 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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ jobs:
- command: check
args: --all-targets
- command: doc
args: --all-features --workspace
args: --all-features --workspace --no-deps
- command: make
args: check --locked
- command: test
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ Description of the upcoming release here.

### Changed

- [#1613](https://github.com/FuelLabs/fuel-core/pull/1613): Add api endpoint to retrieve a message by its nonce
- [#1613](https://github.com/FuelLabs/fuel-core/pull/1613): Add api endpoint to retrieve a message by its nonce.
- [#1612](https://github.com/FuelLabs/fuel-core/pull/1612): Use `AtomicView` in all services for consistent results.
- [#1597](https://github.com/FuelLabs/fuel-core/pull/1597): Unify namespacing for `libp2p` modules
- [#1591](https://github.com/FuelLabs/fuel-core/pull/1591): Simplify libp2p dependencies and not depend on all sub modules directly.
- [#1590](https://github.com/FuelLabs/fuel-core/pull/1590): Use `AtomicView` in the `TxPool` to read the state of the database during insertion of the transactions.
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

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

6 changes: 3 additions & 3 deletions bin/fuel-core/src/cli/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use fuel_core::{
config::Trigger,
Config,
DbType,
RelayerVerifierConfig,
RelayerConsensusConfig,
ServiceTrait,
VMConfig,
},
Expand Down Expand Up @@ -289,7 +289,7 @@ impl Command {
None
};

let verifier = RelayerVerifierConfig {
let verifier = RelayerConsensusConfig {
max_da_lag: max_da_lag.into(),
max_wait_time: max_wait_time.into(),
};
Expand Down Expand Up @@ -334,7 +334,7 @@ impl Command {
sync: sync_args.into(),
consensus_key,
name,
verifier,
relayer_consensus_config: verifier,
min_connected_reserved_peers,
time_until_synced: time_until_synced.into(),
query_log_threshold_time: query_log_threshold_time.into(),
Expand Down
2 changes: 1 addition & 1 deletion ci_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ cargo +nightly fmt --all -- --check &&
cargo sort -w --check &&
source .github/workflows/scripts/verify_openssl.sh &&
cargo clippy --all-targets --all-features &&
cargo doc --all-features --workspace &&
cargo doc --all-features --workspace --no-deps &&
cargo make check --locked &&
cargo make check --all-features --locked &&
cargo check -p fuel-core-types --target wasm32-unknown-unknown --no-default-features &&
Expand Down
66 changes: 65 additions & 1 deletion crates/fuel-core/src/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ use fuel_core_storage::{
TableWithBlueprint,
},
transactional::{
AtomicView,
StorageTransaction,
Transactional,
},
Expand All @@ -38,7 +39,10 @@ use fuel_core_storage::{
Result as StorageResult,
};
use fuel_core_types::{
blockchain::primitives::BlockId,
blockchain::primitives::{
BlockId,
DaBlockHeight,
},
fuel_types::{
BlockHeight,
Bytes32,
Expand Down Expand Up @@ -411,6 +415,66 @@ impl fuel_core_storage::vm_storage::VmStorageRequirements for Database {
}
}

impl AtomicView for Database {
type View = Database;

type Height = BlockHeight;

fn latest_height(&self) -> BlockHeight {
// TODO: The database should track the latest height inside of the database object
// instead of fetching it from the `FuelBlocks` table. As a temporary solution,
// fetch it from the table for now.
self.latest_height().unwrap_or_default()
}

fn view_at(&self, _: &BlockHeight) -> StorageResult<Self::View> {
// TODO: Unimplemented until of the https://github.com/FuelLabs/fuel-core/issues/451
Copy link
Member

@MitchTurner MitchTurner Jan 26, 2024

Choose a reason for hiding this comment

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

It looks like this is closed now.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Without state rewind we can't implement it properly=) It uses the latest for now to simulate the current behavior=)

Ok(self.latest_view())
}

fn latest_view(&self) -> Self::View {
// TODO: https://github.com/FuelLabs/fuel-core/issues/1581
self.clone()
}
}

pub struct RelayerReadDatabase(Database);

impl RelayerReadDatabase {
pub fn new(database: Database) -> Self {
Self(database)
}
}

impl AtomicView for RelayerReadDatabase {
type View = Database;
type Height = DaBlockHeight;

fn latest_height(&self) -> Self::Height {
#[cfg(feature = "relayer")]
{
use fuel_core_relayer::ports::RelayerDb;
// TODO: The database should track the latest da height inside of the database object
Copy link
Member

Choose a reason for hiding this comment

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

Is there a follow-up issue fore this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yep, #1589

// instead of fetching it from the `RelayerMetadata` table. As a temporary solution,
// fetch it from the table for now.
// https://github.com/FuelLabs/fuel-core/issues/1589
self.0.get_finalized_da_height().unwrap_or_default()
}
#[cfg(not(feature = "relayer"))]
{
DaBlockHeight(0)
}
}

fn view_at(&self, _: &Self::Height) -> StorageResult<Self::View> {
Ok(self.latest_view())
}

fn latest_view(&self) -> Self::View {
self.0.clone()
}
}

#[cfg(feature = "rocksdb")]
pub fn convert_to_rocksdb_direction(
direction: fuel_core_storage::iter::IterDirection,
Expand Down
Loading
Loading