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

Add getter pending block extrinsics #7

Open
wants to merge 4 commits into
base: massa-dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
227 changes: 115 additions & 112 deletions Cargo.lock

Large diffs are not rendered by default.

124 changes: 62 additions & 62 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -81,78 +81,78 @@ version = "0.8.0"

[workspace.dependencies]
# Substrate frame dependencies
frame-executive = { git = "https://github.com/massalabs/polkadot-sdk", branch = "release-polkadot-v1.3.0-std" }
frame-support = { git = "https://github.com/massalabs/polkadot-sdk", branch = "release-polkadot-v1.3.0-std" }
frame-benchmarking = { git = "https://github.com/massalabs/polkadot-sdk", branch = "release-polkadot-v1.3.0-std" }
frame-benchmarking-cli = { git = "https://github.com/massalabs/polkadot-sdk", branch = "release-polkadot-v1.3.0-std" }
frame-system = { git = "https://github.com/massalabs/polkadot-sdk", branch = "release-polkadot-v1.3.0-std" }
frame-system-benchmarking = { git = "https://github.com/massalabs/polkadot-sdk", branch = "release-polkadot-v1.3.0-std" }
frame-system-rpc-runtime-api = { git = "https://github.com/massalabs/polkadot-sdk", branch = "release-polkadot-v1.3.0-std" }
frame-try-runtime = { git = "https://github.com/massalabs/polkadot-sdk", branch = "release-polkadot-v1.3.0-std" }
substrate-frame-rpc-system = { git = "https://github.com/massalabs/polkadot-sdk", branch = "release-polkadot-v1.3.0-std" }
frame-executive = { git = "https://github.com/massalabs/polkadot-sdk", branch = "features/add_block_builder_extrinsic_getters" }
frame-support = { git = "https://github.com/massalabs/polkadot-sdk", branch = "features/add_block_builder_extrinsic_getters" }
frame-benchmarking = { git = "https://github.com/massalabs/polkadot-sdk", branch = "features/add_block_builder_extrinsic_getters" }
frame-benchmarking-cli = { git = "https://github.com/massalabs/polkadot-sdk", branch = "features/add_block_builder_extrinsic_getters" }
frame-system = { git = "https://github.com/massalabs/polkadot-sdk", branch = "features/add_block_builder_extrinsic_getters" }
frame-system-benchmarking = { git = "https://github.com/massalabs/polkadot-sdk", branch = "features/add_block_builder_extrinsic_getters" }
frame-system-rpc-runtime-api = { git = "https://github.com/massalabs/polkadot-sdk", branch = "features/add_block_builder_extrinsic_getters" }
frame-try-runtime = { git = "https://github.com/massalabs/polkadot-sdk", branch = "features/add_block_builder_extrinsic_getters" }
substrate-frame-rpc-system = { git = "https://github.com/massalabs/polkadot-sdk", branch = "features/add_block_builder_extrinsic_getters" }

# Substrate primitives dependencies
sp-core = { git = "https://github.com/massalabs/polkadot-sdk", branch = "release-polkadot-v1.3.0-std" }
sp-std = { git = "https://github.com/massalabs/polkadot-sdk", branch = "release-polkadot-v1.3.0-std" }
sp-io = { git = "https://github.com/massalabs/polkadot-sdk", branch = "release-polkadot-v1.3.0-std" }
sp-runtime = { git = "https://github.com/massalabs/polkadot-sdk", branch = "release-polkadot-v1.3.0-std" }
sp-consensus-aura = { git = "http://github.com/massalabs/polkadot-sdk", branch = "release-polkadot-v1.3.0-std" }
sp-consensus = { git = "https://github.com/massalabs/polkadot-sdk", branch = "release-polkadot-v1.3.0-std" }
sp-consensus-grandpa = { git = "https://github.com/massalabs/polkadot-sdk", branch = "release-polkadot-v1.3.0-std" }
sp-timestamp = { git = "https://github.com/massalabs/polkadot-sdk", branch = "release-polkadot-v1.3.0-std" }
sp-inherents = { git = "https://github.com/massalabs/polkadot-sdk", branch = "release-polkadot-v1.3.0-std" }
sp-keyring = { git = "https://github.com/massalabs/polkadot-sdk", branch = "release-polkadot-v1.3.0-std" }
sp-api = { git = "https://github.com/massalabs/polkadot-sdk", branch = "release-polkadot-v1.3.0-std" }
sp-blockchain = { git = "https://github.com/massalabs/polkadot-sdk", branch = "release-polkadot-v1.3.0-std" }
sp-block-builder = { git = "https://github.com/massalabs/polkadot-sdk", branch = "release-polkadot-v1.3.0-std" }
sp-offchain = { git = "https://github.com/massalabs/polkadot-sdk", branch = "release-polkadot-v1.3.0-std" }
sp-session = { git = "https://github.com/massalabs/polkadot-sdk", branch = "release-polkadot-v1.3.0-std" }
sp-transaction-pool = { git = "https://github.com/massalabs/polkadot-sdk", branch = "release-polkadot-v1.3.0-std" }
sp-version = { git = "https://github.com/massalabs/polkadot-sdk", branch = "release-polkadot-v1.3.0-std" }
sp-database = { git = "https://github.com/massalabs/polkadot-sdk", branch = "release-polkadot-v1.3.0-std" }
sp-arithmetic = { git = "https://github.com/massalabs/polkadot-sdk", branch = "release-polkadot-v1.3.0-std" }
sp-storage = { git = "https://github.com/massalabs/polkadot-sdk", branch = "release-polkadot-v1.3.0-std" }
sp-state-machine = { git = "https://github.com/massalabs/polkadot-sdk", branch = "release-polkadot-v1.3.0-std" }
sp-statement-store = { git = "https://github.com/massalabs/polkadot-sdk", branch = "release-polkadot-v1.3.0-std" }
sp-trie = { version = "22.0.0", git = "https://github.com/massalabs/polkadot-sdk", branch = "release-polkadot-v1.3.0-std" }
sp-tracing = { git = "https://github.com/massalabs/polkadot-sdk", branch = "release-polkadot-v1.3.0-std" }
sp-core = { git = "https://github.com/massalabs/polkadot-sdk", branch = "features/add_block_builder_extrinsic_getters" }
sp-std = { git = "https://github.com/massalabs/polkadot-sdk", branch = "features/add_block_builder_extrinsic_getters" }
sp-io = { git = "https://github.com/massalabs/polkadot-sdk", branch = "features/add_block_builder_extrinsic_getters" }
sp-runtime = { git = "https://github.com/massalabs/polkadot-sdk", branch = "features/add_block_builder_extrinsic_getters" }
sp-consensus-aura = { git = "http://github.com/massalabs/polkadot-sdk", branch = "features/add_block_builder_extrinsic_getters" }
sp-consensus = { git = "https://github.com/massalabs/polkadot-sdk", branch = "features/add_block_builder_extrinsic_getters" }
sp-consensus-grandpa = { git = "https://github.com/massalabs/polkadot-sdk", branch = "features/add_block_builder_extrinsic_getters" }
sp-timestamp = { git = "https://github.com/massalabs/polkadot-sdk", branch = "features/add_block_builder_extrinsic_getters" }
sp-inherents = { git = "https://github.com/massalabs/polkadot-sdk", branch = "features/add_block_builder_extrinsic_getters" }
sp-keyring = { git = "https://github.com/massalabs/polkadot-sdk", branch = "features/add_block_builder_extrinsic_getters" }
sp-api = { git = "https://github.com/massalabs/polkadot-sdk", branch = "features/add_block_builder_extrinsic_getters" }
sp-blockchain = { git = "https://github.com/massalabs/polkadot-sdk", branch = "features/add_block_builder_extrinsic_getters" }
sp-block-builder = { git = "https://github.com/massalabs/polkadot-sdk", branch = "features/add_block_builder_extrinsic_getters" }
sp-offchain = { git = "https://github.com/massalabs/polkadot-sdk", branch = "features/add_block_builder_extrinsic_getters" }
sp-session = { git = "https://github.com/massalabs/polkadot-sdk", branch = "features/add_block_builder_extrinsic_getters" }
sp-transaction-pool = { git = "https://github.com/massalabs/polkadot-sdk", branch = "features/add_block_builder_extrinsic_getters" }
sp-version = { git = "https://github.com/massalabs/polkadot-sdk", branch = "features/add_block_builder_extrinsic_getters" }
sp-database = { git = "https://github.com/massalabs/polkadot-sdk", branch = "features/add_block_builder_extrinsic_getters" }
sp-arithmetic = { git = "https://github.com/massalabs/polkadot-sdk", branch = "features/add_block_builder_extrinsic_getters" }
sp-storage = { git = "https://github.com/massalabs/polkadot-sdk", branch = "features/add_block_builder_extrinsic_getters" }
sp-state-machine = { git = "https://github.com/massalabs/polkadot-sdk", branch = "features/add_block_builder_extrinsic_getters" }
sp-statement-store = { git = "https://github.com/massalabs/polkadot-sdk", branch = "features/add_block_builder_extrinsic_getters" }
sp-trie = { version = "22.0.0", git = "https://github.com/massalabs/polkadot-sdk", branch = "features/add_block_builder_extrinsic_getters" }
sp-tracing = { git = "https://github.com/massalabs/polkadot-sdk", branch = "features/add_block_builder_extrinsic_getters" }

# Substrate client dependencies
sc-client-db = { git = "https://github.com/massalabs/polkadot-sdk", branch = "release-polkadot-v1.3.0-std" }
sc-network = { git = "https://github.com/massalabs/polkadot-sdk", branch = "release-polkadot-v1.3.0-std" }
sc-network-common = { git = "https://github.com/massalabs/polkadot-sdk", branch = "release-polkadot-v1.3.0-std" }
sc-network-sync = { git = "https://github.com/massalabs/polkadot-sdk", branch = "release-polkadot-v1.3.0-std" }
sc-consensus = { git = "https://github.com/massalabs/polkadot-sdk", branch = "release-polkadot-v1.3.0-std" }
sc-client-db = { git = "https://github.com/massalabs/polkadot-sdk", branch = "features/add_block_builder_extrinsic_getters" }
sc-network = { git = "https://github.com/massalabs/polkadot-sdk", branch = "features/add_block_builder_extrinsic_getters" }
sc-network-common = { git = "https://github.com/massalabs/polkadot-sdk", branch = "features/add_block_builder_extrinsic_getters" }
sc-network-sync = { git = "https://github.com/massalabs/polkadot-sdk", branch = "features/add_block_builder_extrinsic_getters" }
sc-consensus = { git = "https://github.com/massalabs/polkadot-sdk", branch = "features/add_block_builder_extrinsic_getters" }
# For integration tests in order to create blocks on demand
sc-consensus-manual-seal = { git = "https://github.com/massalabs/polkadot-sdk", branch = "release-polkadot-v1.3.0-std" }
sc-consensus-grandpa = { git = "https://github.com/massalabs/polkadot-sdk", branch = "release-polkadot-v1.3.0-std" }
sc-rpc = { git = "https://github.com/massalabs/polkadot-sdk", branch = "release-polkadot-v1.3.0-std" }
sc-rpc-api = { git = "https://github.com/massalabs/polkadot-sdk", branch = "release-polkadot-v1.3.0-std" }
sc-basic-authorship = { git = "https://github.com/massalabs/polkadot-sdk", branch = "release-polkadot-v1.3.0-std" }
sc-client-api = { git = "https://github.com/massalabs/polkadot-sdk", branch = "release-polkadot-v1.3.0-std" }
sc-cli = { git = "https://github.com/massalabs/polkadot-sdk", branch = "release-polkadot-v1.3.0-std" }
sc-executor = { git = "https://github.com/massalabs/polkadot-sdk", branch = "release-polkadot-v1.3.0-std" }
sc-service = { git = "https://github.com/massalabs/polkadot-sdk", branch = "release-polkadot-v1.3.0-std" }
sc-telemetry = { git = "https://github.com/massalabs/polkadot-sdk", branch = "release-polkadot-v1.3.0-std" }
sc-keystore = { git = "https://github.com/massalabs/polkadot-sdk", branch = "release-polkadot-v1.3.0-std" }
sc-transaction-pool = { git = "https://github.com/massalabs/polkadot-sdk", branch = "release-polkadot-v1.3.0-std" }
sc-transaction-pool-api = { git = "https://github.com/massalabs/polkadot-sdk", branch = "release-polkadot-v1.3.0-std" }
sc-offchain = { git = "https://github.com/massalabs/polkadot-sdk", branch = "release-polkadot-v1.3.0-std" }
sc-consensus-aura = { git = "https://github.com/massalabs/polkadot-sdk", branch = "release-polkadot-v1.3.0-std" }
sc-block-builder = { git = "https://github.com/massalabs/polkadot-sdk", branch = "release-polkadot-v1.3.0-std" }
sc-proposer-metrics = { git = "https://github.com/massalabs/polkadot-sdk", branch = "release-polkadot-v1.3.0-std" }
sc-utils = { git = "https://github.com/massalabs/polkadot-sdk", branch = "release-polkadot-v1.3.0-std" }
substrate-test-runtime-client = { git = "https://github.com/massalabs/polkadot-sdk", branch = "release-polkadot-v1.3.0-std" }
sc-consensus-manual-seal = { git = "https://github.com/massalabs/polkadot-sdk", branch = "features/add_block_builder_extrinsic_getters" }
sc-consensus-grandpa = { git = "https://github.com/massalabs/polkadot-sdk", branch = "features/add_block_builder_extrinsic_getters" }
sc-rpc = { git = "https://github.com/massalabs/polkadot-sdk", branch = "features/add_block_builder_extrinsic_getters" }
sc-rpc-api = { git = "https://github.com/massalabs/polkadot-sdk", branch = "features/add_block_builder_extrinsic_getters" }
sc-basic-authorship = { git = "https://github.com/massalabs/polkadot-sdk", branch = "features/add_block_builder_extrinsic_getters" }
sc-client-api = { git = "https://github.com/massalabs/polkadot-sdk", branch = "features/add_block_builder_extrinsic_getters" }
sc-cli = { git = "https://github.com/massalabs/polkadot-sdk", branch = "features/add_block_builder_extrinsic_getters" }
sc-executor = { git = "https://github.com/massalabs/polkadot-sdk", branch = "features/add_block_builder_extrinsic_getters" }
sc-service = { git = "https://github.com/massalabs/polkadot-sdk", branch = "features/add_block_builder_extrinsic_getters" }
sc-telemetry = { git = "https://github.com/massalabs/polkadot-sdk", branch = "features/add_block_builder_extrinsic_getters" }
sc-keystore = { git = "https://github.com/massalabs/polkadot-sdk", branch = "features/add_block_builder_extrinsic_getters" }
sc-transaction-pool = { git = "https://github.com/massalabs/polkadot-sdk", branch = "features/add_block_builder_extrinsic_getters" }
sc-transaction-pool-api = { git = "https://github.com/massalabs/polkadot-sdk", branch = "features/add_block_builder_extrinsic_getters" }
sc-offchain = { git = "https://github.com/massalabs/polkadot-sdk", branch = "features/add_block_builder_extrinsic_getters" }
sc-consensus-aura = { git = "https://github.com/massalabs/polkadot-sdk", branch = "features/add_block_builder_extrinsic_getters" }
sc-block-builder = { git = "https://github.com/massalabs/polkadot-sdk", branch = "features/add_block_builder_extrinsic_getters" }
sc-proposer-metrics = { git = "https://github.com/massalabs/polkadot-sdk", branch = "features/add_block_builder_extrinsic_getters" }
sc-utils = { git = "https://github.com/massalabs/polkadot-sdk", branch = "features/add_block_builder_extrinsic_getters" }
substrate-test-runtime-client = { git = "https://github.com/massalabs/polkadot-sdk", branch = "features/add_block_builder_extrinsic_getters" }


# Substrate build & tools dependencies
substrate-build-script-utils = { git = "https://github.com/massalabs/polkadot-sdk", branch = "release-polkadot-v1.3.0-std" }
prometheus-endpoint = { package = "substrate-prometheus-endpoint", version = "0.10.0-dev", git = "https://github.com/massalabs/polkadot-sdk", branch = "release-polkadot-v1.3.0-std" }
substrate-build-script-utils = { git = "https://github.com/massalabs/polkadot-sdk", branch = "features/add_block_builder_extrinsic_getters" }
prometheus-endpoint = { package = "substrate-prometheus-endpoint", version = "0.10.0-dev", git = "https://github.com/massalabs/polkadot-sdk", branch = "features/add_block_builder_extrinsic_getters" }

# Substrate Frame pallet
pallet-aura = { git = "https://github.com/massalabs/polkadot-sdk", branch = "release-polkadot-v1.3.0-std" }
pallet-grandpa = { git = "https://github.com/massalabs/polkadot-sdk", branch = "release-polkadot-v1.3.0-std" }
pallet-timestamp = { git = "https://github.com/massalabs/polkadot-sdk", branch = "release-polkadot-v1.3.0-std" }
pallet-aura = { git = "https://github.com/massalabs/polkadot-sdk", branch = "features/add_block_builder_extrinsic_getters" }
pallet-grandpa = { git = "https://github.com/massalabs/polkadot-sdk", branch = "features/add_block_builder_extrinsic_getters" }
pallet-timestamp = { git = "https://github.com/massalabs/polkadot-sdk", branch = "features/add_block_builder_extrinsic_getters" }

# Madara pallets
pallet-starknet = { path = "crates/pallets/starknet" }
Expand Down
1 change: 1 addition & 0 deletions crates/client/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ mc-genesis-data-provider = { workspace = true }
mc-rpc-core = { workspace = true }
mc-storage = { workspace = true }
pallet-starknet-runtime-api = { workspace = true }
sc-block-builder = { workspace = true }
sc-transaction-pool = { workspace = true }
sc-transaction-pool-api = { workspace = true }
sp-api = { workspace = true }
Expand Down
13 changes: 7 additions & 6 deletions crates/client/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,13 @@ use mp_transactions::from_broadcasted_transactions::{
use mp_transactions::to_starknet_core_transaction::to_starknet_core_tx;
use mp_transactions::{compute_message_hash, get_transaction_hash, TransactionStatus};
use pallet_starknet_runtime_api::{ConvertTransactionRuntimeApi, StarknetRuntimeApi};
use sc_block_builder::GetPendingBlockExtrinsics;
use sc_client_api::backend::{Backend, StorageProvider};
use sc_client_api::BlockBackend;
use sc_network_sync::SyncingService;
use sc_transaction_pool::{ChainApi, Pool};
use sc_transaction_pool_api::error::{Error as PoolError, IntoPoolError};
use sc_transaction_pool_api::{InPoolTransaction, TransactionPool, TransactionSource};
use sc_transaction_pool_api::{TransactionPool, TransactionSource};
use sp_api::ProvideRuntimeApi;
use sp_arithmetic::traits::UniqueSaturatedInto;
use sp_blockchain::HeaderBackend;
Expand Down Expand Up @@ -228,6 +229,7 @@ where
BE: Backend<B> + 'static,
C: HeaderBackend<B> + BlockBackend<B> + StorageProvider<B, BE> + 'static,
C: ProvideRuntimeApi<B>,
C: GetPendingBlockExtrinsics<B>,
C::Api: StarknetRuntimeApi<B> + ConvertTransactionRuntimeApi<B>,
G: GenesisProvider + Send + Sync + 'static,
H: HasherT + Send + Sync + 'static,
Expand Down Expand Up @@ -272,6 +274,7 @@ where
BE: Backend<B> + 'static,
C: HeaderBackend<B> + BlockBackend<B> + StorageProvider<B, BE> + 'static,
C: ProvideRuntimeApi<B>,
C: GetPendingBlockExtrinsics<B>,
C::Api: StarknetRuntimeApi<B> + ConvertTransactionRuntimeApi<B>,
G: GenesisProvider + Send + Sync + 'static,
H: HasherT + Send + Sync + 'static,
Expand Down Expand Up @@ -391,6 +394,7 @@ where
BE: Backend<B> + 'static,
C: HeaderBackend<B> + BlockBackend<B> + StorageProvider<B, BE> + 'static,
C: ProvideRuntimeApi<B>,
C: GetPendingBlockExtrinsics<B>,
C::Api: StarknetRuntimeApi<B> + ConvertTransactionRuntimeApi<B>,
G: GenesisProvider + Send + Sync + 'static,
H: HasherT + Send + Sync + 'static,
Expand Down Expand Up @@ -1318,6 +1322,7 @@ where
BE: Backend<B> + 'static,
C: HeaderBackend<B> + BlockBackend<B> + StorageProvider<B, BE> + 'static,
C: ProvideRuntimeApi<B>,
C: GetPendingBlockExtrinsics<B>,
C::Api: StarknetRuntimeApi<B> + ConvertTransactionRuntimeApi<B>,
G: GenesisProvider + Send + Sync + 'static,
H: HasherT + Send + Sync + 'static,
Expand Down Expand Up @@ -1368,11 +1373,7 @@ where
&self,
latest_block: B::Hash,
) -> Result<Vec<blockifier::transaction::transaction_execution::Transaction>, StarknetRpcApiError> {
// Fetch all Pending Txs from Transaction Pool
// Operates as RPC Call `author_pendingExtrinsics`
// See https://github.com/paritytech/polkadot-sdk/blob/release-polkadot-v1.6.0/substrate/client/rpc/src/author/mod.rs#L153-L155
// But fetches pending transactions as Vec<B::Extrinsic>
let pending_transactions: Vec<B::Extrinsic> = self.pool.ready().map(|tx| tx.data().clone()).collect();
let pending_transactions: Vec<B::Extrinsic> = self.client.get_pending_extrinsics();

// Use Runtime API to filter all Pending Txs
// And get only Starknet Txs (Pallet Starknet calls) as
Expand Down
2 changes: 2 additions & 0 deletions crates/client/rpc/src/madara_routes.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use jsonrpsee::core::{async_trait, RpcResult};
use log::error;
use sc_block_builder::GetPendingBlockExtrinsics;
use mc_genesis_data_provider::GenesisProvider;
pub use mc_rpc_core::{
Felt, MadaraRpcApiServer, PredeployedAccountWithBalance, StarknetReadRpcApiServer, StarknetTraceRpcApiServer,
Expand Down Expand Up @@ -31,6 +32,7 @@ where
BE: Backend<B> + 'static,
C: HeaderBackend<B> + BlockBackend<B> + StorageProvider<B, BE> + 'static,
C: ProvideRuntimeApi<B>,
C: GetPendingBlockExtrinsics<B>,
G: GenesisProvider + Send + Sync + 'static,
C::Api: StarknetRuntimeApi<B> + ConvertTransactionRuntimeApi<B>,
P: TransactionPool<Block = B> + 'static,
Expand Down
2 changes: 2 additions & 0 deletions crates/client/rpc/src/runtime_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use mp_felt::Felt252Wrapper;
use mp_hashers::HasherT;
use mp_simulations::SimulationFlags;
use pallet_starknet_runtime_api::{ConvertTransactionRuntimeApi, StarknetRuntimeApi};
use sc_block_builder::GetPendingBlockExtrinsics;
use sc_client_api::backend::Backend;
use sc_transaction_pool::ChainApi;
use sp_api::{ApiError, ProvideRuntimeApi};
Expand All @@ -32,6 +33,7 @@ where
BE: Backend<B>,
C: HeaderBackend<B> + 'static,
C: ProvideRuntimeApi<B>,
C: GetPendingBlockExtrinsics<B>,
C::Api: StarknetRuntimeApi<B> + ConvertTransactionRuntimeApi<B>,
H: HasherT + Send + Sync + 'static,
{
Expand Down
Loading