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

graphql-api ports for database queries #890

Merged
merged 9 commits into from
Jan 11, 2023

Conversation

xgreenx
Copy link
Collaborator

@xgreenx xgreenx commented Jan 6, 2023

  • Renamed Transactional into Transaction.
  • Added Transactional trait with transaction method.
  • Used BlockId instead of Bytes32 in Database.
  • Created ports for block.rs, tx.rs, message.rs, balance.rs, coin.rs and updated corresponding schema.
  • Added and used in ports BoxedIter instead of associated types(In most cases they were Box<dyn> too).
  • Almost removed usage of fuel_core::database from schema. Only dap.rs uses it right now for VMDatabase.
  • Introduced CompressedCoin and Coin(contains UtxoId). CompressedCoin is used during work with the database, Coin in external API.
  • Moved resources into fuel-core-type and simplified it by removing generics.
  • Tried to re-work dap.rs but the change is big and also related to fuel-core-executor, so will do it in a separate PR.
  • Updated Transactional to support Transactional<dyn Database>

Added `Transactional` trait with `transaction` method.
Used `BlockId` instead of `Bytes32` in `Database`.
Created ports for `block.rs`, `tx.rs`, `message.rs` and updated corresponding schema.
Added and used in ports `BoxedIter` instead of associated types(In most cases they were `Box<dyn>` too).
@xgreenx xgreenx self-assigned this Jan 6, 2023
Co-authored-by: Green Baneling <XgreenX9999@gmail.com>
@@ -3,7 +3,7 @@ use crate::{
state::in_memory::transaction::MemoryTransactionView,
Copy link
Member

Choose a reason for hiding this comment

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

should the name of this file/module be renamed now that we no longer use Transactional?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I will update it in a separate PR to not lose history

@@ -1,10 +1,10 @@
use crate::{
database::resource::{
Copy link
Member

@Voxelot Voxelot Jan 6, 2023

Choose a reason for hiding this comment

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

We should make the whole schema module a sub-module of the new graphql service module.

e.g.

src/schema.rs -> src/grapqhl_api/schema.rs
src/schema/* -> src/graphql_api/schema/*

Copy link
Collaborator Author

@xgreenx xgreenx Jan 6, 2023

Choose a reason for hiding this comment

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

Yes, of course, we do it step by step)

/// The type is transactional and holds uncommitted state.
pub trait Transactional<Storage>: AsRef<Storage> + AsMut<Storage> + Send + Sync {
/// The types is transactional and may create `StorageTransaction`.
pub trait Transactional<Storage> {
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't seem to be used anywhere?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It will be, it is not final PR=)

balances.reverse();
}

let balances = balances.into_iter();
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It is not updated yet=)

xgreenx and others added 5 commits January 6, 2023 21:36
…p.rs` uses it right now for `VMDatabase`.

Introduced `CompressedCoin` and `Coin`(contains `UtxoId`). `CompressedCoin` is used during work with database, `Coin` in external API.

Moved resources into `fuel-core-type` and simplified it by removing generics.

Tried to re-work `dapp.rs` but the change is big, so will do it in a separate PR.

Updated `Transactional` to support `Transactional<dyn Database>`
crates/fuel-core/src/database/vm_database.rs Show resolved Hide resolved
@@ -3,7 +3,7 @@ use crate::{
state::in_memory::transaction::MemoryTransactionView,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I will update it in a separate PR to not lose history

.transaction_status(&transaction_id)
.into_api_result::<TransactionStatus, StorageError>()?
{
Some(TransactionStatus::Success { block_id, .. }) => block_id,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed the logic here, not allowing generate proofs for failed transactions.

@@ -200,80 +158,6 @@ impl MessageProof {
}
}

struct MessageProofContext<'a>(&'a Database);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Moved to message_proof.rs

@xgreenx xgreenx changed the title graphql-api ports for blocks, txs, and messages graphql-api ports for database queries Jan 9, 2023
@ControlCplusControlV
Copy link
Contributor

Comments addressed except for issues which @xgreenx has deferred to future PRs, merging upstream

@ControlCplusControlV ControlCplusControlV merged commit 4e0a983 into controlc/gql_refactor Jan 11, 2023
@ControlCplusControlV ControlCplusControlV deleted the feature/graphql-ports branch January 11, 2023 04:11
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.

3 participants