Skip to content

Commit

Permalink
fix: 🎨 fixed state root convertion + rebase cleaned and ready for prod
Browse files Browse the repository at this point in the history
  • Loading branch information
antiyro committed Jan 23, 2024
1 parent 580b136 commit 959bd4e
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 30 deletions.
24 changes: 12 additions & 12 deletions crates/client/deoxys/src/state_updates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,9 @@ impl Decode for StateUpdateWrapper {
// H: HasherT,
// {
// let starknet_block_hash = match state_update.block_hash {
// Some(hash) => hash.try_into().map_err(|_| BuildCommitmentStateDiffError::ConversionError)?,
// None => return Err(BuildCommitmentStateDiffError::BlockNotFound),
// };
// Some(hash) => hash.try_into().map_err(|_|
// BuildCommitmentStateDiffError::ConversionError)?, None => return
// Err(BuildCommitmentStateDiffError::BlockNotFound), };

// let mut commitment_state_diff = CommitmentStateDiff {
// address_to_class_hash: Default::default(),
Expand All @@ -250,8 +250,8 @@ impl Decode for StateUpdateWrapper {

// for (address, diffs) in &state_update.state_diff.storage_diffs {
// let contract_address = ContractAddress(PatriciaKey(
// Felt252Wrapper::from(*address).try_into().map_err(|_| BuildCommitmentStateDiffError::ConversionError)?,
// ));
// Felt252Wrapper::from(*address).try_into().map_err(|_|
// BuildCommitmentStateDiffError::ConversionError)?, ));
// for storage_diff in diffs {
// let storage_key = StarknetStorageKey(PatriciaKey(
// Felt252Wrapper::from(storage_diff.key)
Expand Down Expand Up @@ -284,9 +284,9 @@ impl Decode for StateUpdateWrapper {
// }

// // for contract in &state_update.state_diff.deployed_contracts {
// // let contract_address = ContractAddress(PatriciaKey(contract.address.try_into().map_err(|_|
// // BuildCommitmentStateDiffError::ConversionError)?)); let class_hash =
// // ClassHash(contract.class_hash.try_into().map_err(|_|
// // let contract_address =
// ContractAddress(PatriciaKey(contract.address.try_into().map_err(|_| // BuildCommitmentStateDiffError::ConversionError)?
// )); let class_hash = // ClassHash(contract.class_hash.try_into().map_err(|_|
// // BuildCommitmentStateDiffError::ConversionError)?); let compiled_class_hash:
// // CompiledClassHash = calculate_compiled_class_hash(&class_hash);

Expand All @@ -296,11 +296,11 @@ impl Decode for StateUpdateWrapper {

// for nonce in &state_update.state_diff.nonces {
// let contract_address = ContractAddress(PatriciaKey(
// Felt252Wrapper::from(*nonce.0).try_into().map_err(|_| BuildCommitmentStateDiffError::ConversionError)?,
// ));
// Felt252Wrapper::from(*nonce.0).try_into().map_err(|_|
// BuildCommitmentStateDiffError::ConversionError)?, ));
// let nonce_value = Nonce(
// Felt252Wrapper::from(*nonce.1).try_into().map_err(|_| BuildCommitmentStateDiffError::ConversionError)?,
// );
// Felt252Wrapper::from(*nonce.1).try_into().map_err(|_|
// BuildCommitmentStateDiffError::ConversionError)?, );
// commitment_state_diff.address_to_nonce.insert(contract_address, nonce_value);
// }

Expand Down
14 changes: 7 additions & 7 deletions crates/client/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ use starknet_api::transaction::Calldata;
use starknet_core::types::{
BlockHashAndNumber, BlockId, BlockTag, BlockWithTxHashes, BlockWithTxs, BroadcastedDeclareTransaction,
BroadcastedDeployAccountTransaction, BroadcastedInvokeTransaction, BroadcastedTransaction, ContractClass,
DeclareTransactionReceipt, DeclareTransactionResult, DeployAccountTransactionReceipt, DeployTransactionReceipt,
DeployAccountTransactionResult, EventFilterWithPage, EventsPage, ExecutionResources, ExecutionResult, FeeEstimate,
FieldElement, FunctionCall, Hash256, InvokeTransactionReceipt, InvokeTransactionResult,
L1HandlerTransactionReceipt, MaybePendingBlockWithTxHashes, MaybePendingBlockWithTxs,
DeclareTransactionReceipt, DeclareTransactionResult, DeployAccountTransactionReceipt,
DeployAccountTransactionResult, DeployTransactionReceipt, EventFilterWithPage, EventsPage, ExecutionResources,
ExecutionResult, FeeEstimate, FieldElement, FunctionCall, Hash256, InvokeTransactionReceipt,
InvokeTransactionResult, L1HandlerTransactionReceipt, MaybePendingBlockWithTxHashes, MaybePendingBlockWithTxs,
MaybePendingTransactionReceipt, StateDiff, StateUpdate, SyncStatus, SyncStatusType, Transaction,
TransactionExecutionStatus, TransactionFinalityStatus, TransactionReceipt,
};
Expand Down Expand Up @@ -871,7 +871,7 @@ where
block_hash: block_hash.into(),
parent_hash: Felt252Wrapper::from(parent_blockhash).into(),
block_number: starknet_block.header().block_number,
new_root: starknet_block.header().global_state_root,
new_root: Felt252Wrapper::from(starknet_block.header().global_state_root).into(),
timestamp: starknet_block.header().block_timestamp,
sequencer_address: Felt252Wrapper::from(starknet_block.header().sequencer_address).into(),
l1_gas_price: starknet_block.header().l1_gas_price.into(),
Expand Down Expand Up @@ -1118,7 +1118,7 @@ where
block_hash: block_hash.into(),
parent_hash: Felt252Wrapper::from(starknet_block.header().parent_block_hash).into(),
block_number: starknet_block.header().block_number,
new_root: starknet_block.header().global_state_root,
new_root: Felt252Wrapper::from(starknet_block.header().global_state_root).into(),
timestamp: starknet_block.header().block_timestamp,
sequencer_address: Felt252Wrapper::from(starknet_block.header().sequencer_address).into(),
transactions,
Expand Down Expand Up @@ -1174,7 +1174,7 @@ where

Ok(StateUpdate {
block_hash: starknet_block.header().hash::<H>().into(),
new_root: starknet_block.header().global_state_root,
new_root: Felt252Wrapper::from(starknet_block.header().global_state_root).into(),
old_root,
state_diff: StateDiff {
storage_diffs: Vec::new(),
Expand Down
2 changes: 1 addition & 1 deletion crates/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ futures = { workspace = true, features = ["thread-pool"] }
lazy_static = { workspace = true }
log = { workspace = true }
serde = { workspace = true }
tokio = { workspace = true }
sha3 = { workspace = true }
tokio = { workspace = true }

frame-system = { workspace = true }
sc-basic-authorship = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion crates/pallets/starknet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ targets = ["x86_64-unknown-linux-gnu"]
# Madara primitives
mp-block = { workspace = true }
mp-chain-id = { workspace = true }
mp-digest-log = { workspace = true }
mp-commitments = { workspace = true }
mp-digest-log = { workspace = true }
mp-fee = { workspace = true }
mp-felt = { workspace = true, features = ["parity-scale-codec", "serde"] }
mp-genesis-config = { workspace = true }
Expand Down
13 changes: 6 additions & 7 deletions crates/pallets/starknet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1235,13 +1235,12 @@ impl<T: Config> Pallet<T> {
}

pub fn config_hash() -> StarkHash {
Felt252Wrapper::from(
T::SystemHash::compute_hash_on_elements(&[
FieldElement::from_byte_slice_be(SN_OS_CONFIG_HASH_VERSION.as_bytes()).unwrap(),
T::ChainId::get().into(),
Felt252Wrapper::from(Self::fee_token_address().0.0).into(),
])
).into()
Felt252Wrapper::from(T::SystemHash::compute_hash_on_elements(&[
FieldElement::from_byte_slice_be(SN_OS_CONFIG_HASH_VERSION.as_bytes()).unwrap(),
T::ChainId::get().into(),
Felt252Wrapper::from(Self::fee_token_address().0.0).into(),
]))
.into()
}

pub fn is_transaction_fee_disabled() -> bool {
Expand Down
4 changes: 2 additions & 2 deletions crates/primitives/transactions/src/getters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use mp_felt::Felt252Wrapper;

use super::{DeclareTransaction, DeployAccountTransaction, InvokeTransaction, Transaction, UserTransaction};
use crate::{
DeclareTransactionV0, DeclareTransactionV1, DeclareTransactionV2, HandleL1MessageTransaction, InvokeTransactionV0,
InvokeTransactionV1, UserAndL1HandlerTransaction, DeployTransaction
DeclareTransactionV0, DeclareTransactionV1, DeclareTransactionV2, DeployTransaction, HandleL1MessageTransaction,
InvokeTransactionV0, InvokeTransactionV1, UserAndL1HandlerTransaction,
};

impl Transaction {
Expand Down

0 comments on commit 959bd4e

Please sign in to comment.