diff --git a/crates/gateway-types/src/reply.rs b/crates/gateway-types/src/reply.rs index 874e616836..d570ad2583 100644 --- a/crates/gateway-types/src/reply.rs +++ b/crates/gateway-types/src/reply.rs @@ -1099,7 +1099,7 @@ pub mod transaction { } } - #[derive(Clone, Debug, Serialize, PartialEq, Eq, Dummy)] + #[derive(Clone, Debug, Serialize, PartialEq, Eq)] #[serde(tag = "version")] pub enum DeclareTransaction { #[serde(rename = "0x0")] @@ -1161,6 +1161,22 @@ pub mod transaction { } } + impl Dummy for DeclareTransaction { + fn dummy_with_rng(_: &T, rng: &mut R) -> Self { + match rng.gen_range(0..=3) { + 0 => { + let mut v0: DeclareTransactionV0V1 = Faker.fake_with_rng(rng); + v0.nonce = TransactionNonce::ZERO; + Self::V0(v0) + } + 1 => Self::V1(Faker.fake_with_rng(rng)), + 2 => Self::V2(Faker.fake_with_rng(rng)), + 3 => Self::V3(Faker.fake_with_rng(rng)), + _ => unreachable!(), + } + } + } + /// A version 0 or 1 declare transaction. #[serde_as] #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq, Dummy)] @@ -1463,7 +1479,7 @@ pub mod transaction { /// Represents deserialized L2 invoke transaction v0 data. #[serde_as] - #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq, Dummy)] + #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)] #[serde(deny_unknown_fields)] pub struct InvokeTransactionV0 { #[serde_as(as = "Vec")] @@ -1483,6 +1499,20 @@ pub mod transaction { pub transaction_hash: TransactionHash, } + impl Dummy for InvokeTransactionV0 { + fn dummy_with_rng(_: &T, rng: &mut R) -> Self { + Self { + calldata: Faker.fake_with_rng(rng), + sender_address: Faker.fake_with_rng(rng), + entry_point_selector: Faker.fake_with_rng(rng), + entry_point_type: None, + max_fee: Faker.fake_with_rng(rng), + signature: Faker.fake_with_rng(rng), + transaction_hash: Faker.fake_with_rng(rng), + } + } + } + /// Represents deserialized L2 invoke transaction v1 data. #[serde_as] #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq, Dummy)] diff --git a/crates/p2p/src/client/types.rs b/crates/p2p/src/client/types.rs index 6515462a27..90799b511e 100644 --- a/crates/p2p/src/client/types.rs +++ b/crates/p2p/src/client/types.rs @@ -8,7 +8,7 @@ use pathfinder_common::signature::BlockCommitmentSignature; use pathfinder_common::state_update::SystemContractUpdate; use pathfinder_common::transaction::{ DataAvailabilityMode, DeclareTransactionV0V1, DeclareTransactionV2, DeclareTransactionV3, - DeployAccountTransactionV0V1, DeployAccountTransactionV3, DeployTransaction, EntryPointType, + DeployAccountTransactionV0V1, DeployAccountTransactionV3, DeployTransaction, InvokeTransactionV0, InvokeTransactionV1, InvokeTransactionV3, L1HandlerTransaction, ResourceBound, ResourceBounds, TransactionVariant, }; @@ -201,7 +201,7 @@ impl TryFromDto for TransactionVariant { DeclareV0(x) => TransactionVariant::DeclareV0(DeclareTransactionV0V1 { class_hash: ClassHash(x.class_hash.0), max_fee: Fee(x.max_fee), - nonce: TransactionNonce(x.nonce), + nonce: TransactionNonce::ZERO, sender_address: ContractAddress(x.sender.0), signature: x .signature @@ -305,13 +305,7 @@ impl TryFromDto for TransactionVariant { calldata: x.calldata.into_iter().map(CallParam).collect(), sender_address: ContractAddress(x.address.0), entry_point_selector: EntryPoint(x.entry_point_selector), - entry_point_type: x.entry_point_type.map(|x| { - use p2p_proto::transaction::EntryPointType::{External, L1Handler}; - match x { - External => EntryPointType::External, - L1Handler => EntryPointType::L1Handler, - } - }), + entry_point_type: None, max_fee: Fee(x.max_fee), signature: x .signature diff --git a/crates/p2p_proto/proto/transaction.proto b/crates/p2p_proto/proto/transaction.proto index c45db4da13..df8b79bcbd 100644 --- a/crates/p2p_proto/proto/transaction.proto +++ b/crates/p2p_proto/proto/transaction.proto @@ -25,10 +25,6 @@ message Transaction starknet.common.Felt252 max_fee = 2; AccountSignature signature = 3; starknet.common.Hash class_hash = 4; - // FIXME added missing field - // example: - // https://alpha4.starknet.io/feeder_gateway/get_transaction?transactionHash=0x6d346ba207eb124355960c19c737698ad37a3c920a588b741e0130ff5bd4d6d - starknet.common.Felt252 nonce = 5; } message DeclareV1 { @@ -104,13 +100,6 @@ message Transaction starknet.common.Address address = 3; starknet.common.Felt252 entry_point_selector = 4; repeated starknet.common.Felt252 calldata = 5; - // FIXME added missing fields - optional EntryPointType entry_point_type = 6; - } - - enum EntryPointType { - EXTERNAL = 0; - L1_HANDLER = 1; } message InvokeV1 { diff --git a/crates/p2p_proto/src/transaction.rs b/crates/p2p_proto/src/transaction.rs index 5b454587ba..db9c879a32 100644 --- a/crates/p2p_proto/src/transaction.rs +++ b/crates/p2p_proto/src/transaction.rs @@ -30,7 +30,6 @@ pub struct DeclareV0 { pub max_fee: Felt, pub signature: AccountSignature, pub class_hash: Hash, - pub nonce: Felt, } #[derive(Debug, Clone, PartialEq, Eq, ToProtobuf, TryFromProtobuf, Dummy)] @@ -119,9 +118,6 @@ pub struct InvokeV0 { pub address: Address, pub entry_point_selector: Felt, pub calldata: Vec, - // FIXME added missing field - #[optional] - pub entry_point_type: Option, } #[derive(Debug, Clone, PartialEq, Eq, Dummy)] @@ -326,22 +322,3 @@ impl TryFromProtobuf } } } - -impl ToProtobuf for EntryPointType { - fn to_protobuf(self) -> i32 { - match self { - EntryPointType::External => 0, - EntryPointType::L1Handler => 1, - } - } -} - -impl TryFromProtobuf for EntryPointType { - fn try_from_protobuf(input: i32, _: &'static str) -> Result { - use proto::transaction::transaction::EntryPointType::{External, L1Handler}; - Ok(match TryFrom::try_from(input)? { - External => Self::External, - L1Handler => Self::L1Handler, - }) - } -} diff --git a/crates/pathfinder/src/p2p_network/sync_handlers/conv.rs b/crates/pathfinder/src/p2p_network/sync_handlers/conv.rs index 9a51ecc1a3..027625a4b0 100644 --- a/crates/pathfinder/src/p2p_network/sync_handlers/conv.rs +++ b/crates/pathfinder/src/p2p_network/sync_handlers/conv.rs @@ -121,7 +121,6 @@ impl ToProto for Transaction { parts: x.signature.into_iter().map(|s| s.0).collect(), }, class_hash: Hash(x.class_hash.0), - nonce: x.nonce.0, }), DeclareV1(x) => proto::Transaction::DeclareV1(proto::DeclareV1 { sender: Address(x.sender_address.0), @@ -220,13 +219,6 @@ impl ToProto for Transaction { address: Address(x.sender_address.0), entry_point_selector: x.entry_point_selector.0, calldata: x.calldata.into_iter().map(|c| c.0).collect(), - entry_point_type: x.entry_point_type.map(|e| { - use pathfinder_common::transaction::EntryPointType::{External, L1Handler}; - match e { - External => proto::EntryPointType::External, - L1Handler => proto::EntryPointType::L1Handler, - } - }), }), InvokeV1(x) => proto::Transaction::InvokeV1(proto::InvokeV1 { sender: Address(x.sender_address.0),