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

fix: Fix commit error on GraphQL service startup #1802

Merged
merged 16 commits into from
Apr 4, 2024

Conversation

bvrooman
Copy link
Contributor

@bvrooman bvrooman commented Apr 3, 2024

Related issues:

This PR removes the unnecessary DB commit that occurs during startup of the GraphQL API service. Because the committed transaction has no corresponding change in block height, the state transition fails and throws an error. This error then causes startup of the Fuel node to fail.

This can currently happen in local and production builds, but we did not have coverage for this in test. This is because this requires loading the off-chain database using something like CombinedDatabase::open(...), while most tests in the codebase use a default off-chain database, i.e. from_database:

    pub async fn from_database(
        database: Database,
        config: Config,
    ) -> anyhow::Result<Self> {
        let combined_database =
            CombinedDatabase::new(database, Default::default(), Default::default());
        Self::from_combined_database(combined_database, config).await
    }

This PR introduces a test that performs the following steps:

  1. Creates a node using a RocksDB database on the filesystem for on-chain, off-chain, and relayer ("combined") data
  2. Sends some transactions to the node
  3. Shuts down the node
  4. Creates a second node by loading the same database on the filesystem for on-chain, off-chain, and relayer data
  5. Waits for the second node to become healthy

Before removing the commit, this test failed with the observed failure:

The initialization of the service failed.: error occurred in the underlying datastore `NewHeightIsNotSet { prev_height: 3 }`

With the code change, this test passes.

@bvrooman bvrooman self-assigned this Apr 3, 2024
@bvrooman bvrooman requested a review from a team April 3, 2024 19:29
@bvrooman bvrooman marked this pull request as ready for review April 3, 2024 19:48
@@ -141,6 +142,14 @@ where
Ok(new_tx_count)
}

fn get_tx_count(&self) -> StorageResult<u64> {
const TX_COUNT: &str = "total_tx_count";
Copy link
Collaborator

Choose a reason for hiding this comment

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

It would be nice to move it on one level upper. And reuse inside of the increase_tx_count

Copy link
Contributor Author

Choose a reason for hiding this comment

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

By one level up, do you mean the Transactional trait?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I mean reuse one constant in two functions=) Define it on file level instead of function level

@xgreenx xgreenx changed the base branch from master to bugfix/fixed-produciton-if-height-havent-changed April 4, 2024 13:09
xgreenx
xgreenx previously approved these changes Apr 4, 2024
Base automatically changed from bugfix/fixed-produciton-if-height-havent-changed to master April 4, 2024 15:14
@xgreenx xgreenx dismissed their stale review April 4, 2024 15:14

The base branch was changed.

db_tx.commit()?;
graphql_metrics().total_txs_count.set(total_tx_count as i64);
{
let db_tx = self.database.transaction();
Copy link
Member

Choose a reason for hiding this comment

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

if we aren't doing a commit here, do we still need a transaction?

Copy link
Collaborator

Choose a reason for hiding this comment

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

No, we don't, but it will require changing of constraints for the port=D I'm okay with using transaction for now to just fix the issue and release a new fuel-core with the fix=)

@bvrooman bvrooman merged commit c387de9 into master Apr 4, 2024
33 checks passed
@bvrooman bvrooman deleted the bvrooman/fix/fix-graphql-service-startup branch April 4, 2024 16:39
@xgreenx xgreenx mentioned this pull request Apr 4, 2024
xgreenx added a commit that referenced this pull request Apr 5, 2024
## Version v0.24.2

### Changed

#### Breaking
- [#1798](#1798): add nonce to
relayed transactions and also hash full messages in the inbox root.

### Fixed

- [#1802](#1802): Fixed a
runtime panic that occurred when restarting a node. The panic was caused
by an invalid database commit while loading an existing off-chain
database. The invalid commit is removed in this PR.
- [#1803](#1803): Produce
block when da height haven't changed.
- [#1795](#1795): Fixed the
building of the `fuel-core-wasm-executor` to work outside of the
`fuel-core` context. The change uses the path to the manifest file of
the `fuel-core-upgradable-executor` to build the
`fuel-core-wasm-executor` instead of relying on the workspace.

## What's Changed
* Weekly `cargo update` by @github-actions in
#1794
* Improvements for the `fuel-core-upgradable-executor` build script by
@xgreenx in #1795
* Use full hash for messages in inbox_root and add nonce to relayed
transactions by @Voxelot in
#1798
* Modify block producer to take into account the total gas used by the
L1 transactions by @MitchTurner in
#1785
* Fix: Produce block when da height haven't changed by @xgreenx in
#1803
* fix: Fix commit error on GraphQL service startup by @bvrooman in
#1802


**Full Changelog**:
v0.24.1...v0.24.2
crypto523 added a commit to crypto523/fuel-core that referenced this pull request Oct 7, 2024
## Version v0.24.2

### Changed

#### Breaking
- [#1798](FuelLabs/fuel-core#1798): add nonce to
relayed transactions and also hash full messages in the inbox root.

### Fixed

- [#1802](FuelLabs/fuel-core#1802): Fixed a
runtime panic that occurred when restarting a node. The panic was caused
by an invalid database commit while loading an existing off-chain
database. The invalid commit is removed in this PR.
- [#1803](FuelLabs/fuel-core#1803): Produce
block when da height haven't changed.
- [#1795](FuelLabs/fuel-core#1795): Fixed the
building of the `fuel-core-wasm-executor` to work outside of the
`fuel-core` context. The change uses the path to the manifest file of
the `fuel-core-upgradable-executor` to build the
`fuel-core-wasm-executor` instead of relying on the workspace.

## What's Changed
* Weekly `cargo update` by @github-actions in
FuelLabs/fuel-core#1794
* Improvements for the `fuel-core-upgradable-executor` build script by
@xgreenx in FuelLabs/fuel-core#1795
* Use full hash for messages in inbox_root and add nonce to relayed
transactions by @Voxelot in
FuelLabs/fuel-core#1798
* Modify block producer to take into account the total gas used by the
L1 transactions by @MitchTurner in
FuelLabs/fuel-core#1785
* Fix: Produce block when da height haven't changed by @xgreenx in
FuelLabs/fuel-core#1803
* fix: Fix commit error on GraphQL service startup by @bvrooman in
FuelLabs/fuel-core#1802


**Full Changelog**:
FuelLabs/fuel-core@v0.24.1...v0.24.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to start the node after restart on fuel-core 0.24.1
3 participants