Skip to content

Commit 5e9d551

Browse files
committed
wip
1 parent b6a749c commit 5e9d551

File tree

4 files changed

+16
-30
lines changed

4 files changed

+16
-30
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/node/src/full/pending/provider.rs

Lines changed: 14 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
use std::fmt::Debug;
22

33
use katana_gateway_types::TxTryFromError;
4-
use katana_primitives::block::{GasPrices, PartialHeader, PendingBlock};
5-
use katana_primitives::transaction::{TxHash, TxWithHash};
6-
use katana_primitives::Felt;
4+
use katana_primitives::transaction::{TxHash, TxNumber, TxWithHash};
75
use katana_provider::api::state::{StateFactoryProvider, StateProvider};
86
use katana_rpc::starknet::{PendingBlockProvider, StarknetApiResult};
9-
use katana_rpc_types::PreConfirmedBlockWithTxs;
10-
use num_traits::ToPrimitive;
11-
use starknet::core::types::ResourcePrice;
7+
use katana_rpc_types::RpcTxWithHash;
128

139
use crate::full::pending::PreconfStateFactory;
1410

@@ -21,17 +17,17 @@ impl<P: StateFactoryProvider + Debug> PendingBlockProvider for PreconfStateFacto
2117
.transactions
2218
.clone()
2319
.into_iter()
24-
.map(TxWithHash::try_from)
20+
.map(|tx| Ok(RpcTxWithHash::from(TxWithHash::try_from(tx)?)))
2521
.collect::<Result<Vec<_>, TxTryFromError>>()
2622
.unwrap();
2723

2824
Ok(Some(katana_rpc_types::PreConfirmedBlockWithTxs {
2925
transactions,
3026
block_number: 0,
3127
l1_da_mode: block.l1_da_mode,
32-
l1_gas_price: to_gas_prices(block.l1_gas_price),
33-
l2_gas_price: to_gas_prices(block.l2_gas_price),
34-
l1_data_gas_price: to_gas_prices(block.l1_data_gas_price),
28+
l1_gas_price: block.l1_gas_price,
29+
l2_gas_price: block.l2_gas_price,
30+
l1_data_gas_price: block.l1_data_gas_price,
3531
sequencer_address: block.sequencer_address,
3632
starknet_version: block.starknet_version,
3733
timestamp: block.timestamp,
@@ -49,9 +45,9 @@ impl<P: StateFactoryProvider + Debug> PendingBlockProvider for PreconfStateFacto
4945
transactions: Vec::new(),
5046
block_number: 0,
5147
l1_da_mode: block.l1_da_mode,
52-
l1_gas_price: to_gas_prices(block.l1_gas_price),
53-
l2_gas_price: to_gas_prices(block.l2_gas_price),
54-
l1_data_gas_price: to_gas_prices(block.l1_data_gas_price),
48+
l1_gas_price: block.l1_gas_price,
49+
l2_gas_price: block.l2_gas_price,
50+
l1_data_gas_price: block.l1_data_gas_price,
5551
sequencer_address: block.sequencer_address,
5652
starknet_version: block.starknet_version,
5753
timestamp: block.timestamp,
@@ -76,9 +72,9 @@ impl<P: StateFactoryProvider + Debug> PendingBlockProvider for PreconfStateFacto
7672
transactions,
7773
block_number: 0,
7874
l1_da_mode: block.l1_da_mode,
79-
l1_gas_price: to_gas_prices(block.l1_gas_price),
80-
l2_gas_price: to_gas_prices(block.l2_gas_price),
81-
l1_data_gas_price: to_gas_prices(block.l1_data_gas_price),
75+
l1_gas_price: block.l1_gas_price,
76+
l2_gas_price: block.l2_gas_price,
77+
l1_data_gas_price: block.l1_data_gas_price,
8278
sequencer_address: block.sequencer_address,
8379
starknet_version: block.starknet_version,
8480
timestamp: block.timestamp,
@@ -110,23 +106,12 @@ impl<P: StateFactoryProvider + Debug> PendingBlockProvider for PreconfStateFacto
110106

111107
fn get_pending_transaction_by_index(
112108
&self,
113-
hash: TxHash,
109+
index: TxNumber,
114110
) -> StarknetApiResult<Option<katana_rpc_types::RpcTxWithHash>> {
115111
Ok(None)
116112
}
117113

118114
fn pending_state(&self) -> StarknetApiResult<Option<Box<dyn StateProvider>>> {
119-
Some(Box::new(self.state()))
115+
Ok(Some(Box::new(self.state())))
120116
}
121117
}
122-
123-
fn to_gas_prices(prices: ResourcePrice) -> GasPrices {
124-
let eth = prices.price_in_wei.to_u128().expect("valid u128");
125-
let strk = prices.price_in_fri.to_u128().expect("valid u128");
126-
// older blocks might have zero gas prices (recent Starknet upgrade has made the minimum gas
127-
// prices to 1) we may need to handle this case if we want to be able to compute the
128-
// block hash correctly
129-
let eth = if eth == 0 { 1 } else { eth };
130-
let strk = if strk == 0 { 1 } else { strk };
131-
unsafe { GasPrices::new_unchecked(eth, strk) }
132-
}

crates/primitives/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ strum_macros.workspace = true
3333

3434
[dev-dependencies]
3535
assert_matches.workspace = true
36+
bincode = "1.3"
3637
postcard.workspace = true
3738
rstest.workspace = true
3839
similar-asserts.workspace = true

crates/rpc/rpc/src/starknet/pending.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use katana_primitives::da::L1DataAvailabilityMode;
77
use katana_primitives::execution::TypedTransactionExecutionInfo;
88
use katana_primitives::transaction::{TxHash, TxNumber};
99
use katana_primitives::version::CURRENT_STARKNET_VERSION;
10-
use katana_primitives::{block::PartialHeader, transaction::TxNumber};
1110
use katana_provider::api::state::StateProvider;
1211
use katana_rpc_types::{
1312
FinalityStatus, PreConfirmedBlockWithReceipts, PreConfirmedBlockWithTxHashes,

0 commit comments

Comments
 (0)