Support l1_accepted; expand custom blockID; get balance by any blockID#819
Support l1_accepted; expand custom blockID; get balance by any blockID#819
l1_accepted; expand custom blockID; get balance by any blockID#819Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThis set of changes introduces a new Estimated code review effort4 (~90 minutes) Possibly related PRs
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
- support l1_accepted - accept any block_id (not just block_tag) in mint
16a549d to
afc05af
Compare
l1_accepted block tag; replace starknet-rs block ID with customl1_accepted; expand custom blockID; get balance by any blockID
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (6)
website/docs/balance.md (1)
62-62: Add language specification to fenced code block.The markdown linter suggests adding a language specification to improve syntax highlighting.
-``` +```httptests/integration/test_accepting_blocks_on_l1.rs (2)
153-164: Test implementation looks correct but is currently ignored.The test logic for verifying L1 acceptance appears sound. However, it's marked as ignored pending a starknet-rs update.
Would you like me to help verify if the starknet-rs dependency has been updated and these tests can be un-ignored?
166-176: Incomplete test implementations.These test functions are placeholders with
unimplemented!(). They should either be implemented or removed if not needed.Would you like me to help implement these test cases for:
- Verifying that transactions in blocks accepted on L1 have the correct status
- Testing error handling when no blocks have been accepted on L1
I can generate the test implementations based on the existing test patterns in this file.
crates/starknet-devnet-server/src/api/json_rpc/endpoints.rs (2)
413-419: Consider extracting duplicated L1Accepted handling logic.The handling of
BlockTag::L1Acceptedis duplicated for bothfrom_blockandto_block. Consider extracting this into a helper method to reduce duplication.+ async fn get_l1_accepted_block_number( + &self, + starknet: &tokio::sync::MutexGuard<'_, Starknet>, + ) -> Result<u64, ApiError> { + let block_id = BlockId::Tag(BlockTag::L1Accepted); + match starknet.get_block(&block_id) { + Ok(block) => Ok(block.block_number().0), + Err(_) => Err(ApiError::UnsupportedAction { msg: L1_ACCEPTED_NOTICE.into() }), + } + } let from_block_number = match from_block { Some(BlockId::Tag(BlockTag::Latest | BlockTag::PreConfirmed)) => { return Ok((None, from_block, to_block)); } - Some(block_id @ BlockId::Tag(BlockTag::L1Accepted)) => { - match starknet.get_block(&block_id) { - Ok(block) => block.block_number().0, - Err(_) => { - return Err(ApiError::UnsupportedAction { msg: L1_ACCEPTED_NOTICE.into() }); - } - } - } + Some(BlockId::Tag(BlockTag::L1Accepted)) => { + self.get_l1_accepted_block_number(&starknet).await? + }Also applies to: 444-451
453-454: Address the TODO comment regarding origin query behavior.The TODO suggests uncertainty about immediately querying the origin for hash-based block IDs. This could lead to performance issues or incorrect behavior if the block exists locally.
Would you like me to help implement a solution that first checks locally before querying the origin?
crates/starknet-devnet-core/src/starknet/mod.rs (1)
36-37: Consider removing the "Custom" prefix from BlockId and BlockTag imports.The renaming to
CustomBlockIdandCustomBlockTagadds unnecessary complexity. Since these types are already from the localstarknet_typesmodule (not the externalstarknet_rs_core), the prefix doesn't provide additional clarity and makes the code harder to read.-use starknet_types::rpc::block::{ - Block, BlockHeader, BlockId as CustomBlockId, BlockResult, BlockStatus, - BlockTag as CustomBlockTag, PreConfirmedBlock, PreConfirmedBlockHeader, -}; +use starknet_types::rpc::block::{ + Block, BlockHeader, BlockId, BlockResult, BlockStatus, + BlockTag, PreConfirmedBlock, PreConfirmedBlockHeader, +};Then update all usages throughout the file to use
BlockIdandBlockTagdirectly.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (22)
crates/starknet-devnet-core/src/blocks/mod.rs(5 hunks)crates/starknet-devnet-core/src/error.rs(1 hunks)crates/starknet-devnet-core/src/messaging/mod.rs(1 hunks)crates/starknet-devnet-core/src/starknet/add_deploy_account_transaction.rs(1 hunks)crates/starknet-devnet-core/src/starknet/estimations.rs(3 hunks)crates/starknet-devnet-core/src/starknet/events.rs(5 hunks)crates/starknet-devnet-core/src/starknet/get_class_impls.rs(2 hunks)crates/starknet-devnet-core/src/starknet/mod.rs(35 hunks)crates/starknet-devnet-core/src/starknet/state_update.rs(2 hunks)crates/starknet-devnet-core/src/state/state_diff.rs(1 hunks)crates/starknet-devnet-server/src/api/http/endpoints/accounts.rs(4 hunks)crates/starknet-devnet-server/src/api/http/endpoints/mint_token.rs(3 hunks)crates/starknet-devnet-server/src/api/json_rpc/endpoints.rs(20 hunks)crates/starknet-devnet-server/src/api/json_rpc/endpoints_ws.rs(1 hunks)crates/starknet-devnet-server/src/api/json_rpc/mod.rs(2 hunks)crates/starknet-devnet-server/src/api/json_rpc/models.rs(7 hunks)crates/starknet-devnet-server/src/api/json_rpc/write_endpoints.rs(1 hunks)crates/starknet-devnet-server/src/test_utils.rs(1 hunks)crates/starknet-devnet-types/src/rpc/block.rs(6 hunks)tests/integration/common/background_devnet.rs(1 hunks)tests/integration/test_accepting_blocks_on_l1.rs(1 hunks)website/docs/balance.md(2 hunks)
🧠 Learnings (20)
crates/starknet-devnet-core/src/starknet/add_deploy_account_transaction.rs (1)
Learnt from: FabijanC
PR: #799
File: crates/starknet-devnet-core/src/starknet/mod.rs:240-246
Timestamp: 2025-06-16T07:35:24.725Z
Learning: In the Starknet devnet codebase, get_class_hash_at has different behaviors at different layers: at the internal state level (blockifier), it returns Ok(ClassHash(Felt::ZERO)) for undeployed addresses, while at the RPC layer, this gets converted to Err(Error::ContractNotFound). When checking if a contract is deployed at the internal state level, use is_ok_and(|h| h.0 == Felt::ZERO) to detect undeployed addresses.
crates/starknet-devnet-core/src/state/state_diff.rs (1)
Learnt from: FabijanC
PR: #799
File: crates/starknet-devnet-core/src/starknet/mod.rs:240-246
Timestamp: 2025-06-16T07:35:24.725Z
Learning: In the Starknet devnet codebase, get_class_hash_at has different behaviors at different layers: at the internal state level (blockifier), it returns Ok(ClassHash(Felt::ZERO)) for undeployed addresses, while at the RPC layer, this gets converted to Err(Error::ContractNotFound). When checking if a contract is deployed at the internal state level, use is_ok_and(|h| h.0 == Felt::ZERO) to detect undeployed addresses.
crates/starknet-devnet-core/src/starknet/state_update.rs (1)
Learnt from: FabijanC
PR: #799
File: crates/starknet-devnet-core/src/starknet/mod.rs:240-246
Timestamp: 2025-06-16T07:35:24.725Z
Learning: In the Starknet devnet codebase, get_class_hash_at has different behaviors at different layers: at the internal state level (blockifier), it returns Ok(ClassHash(Felt::ZERO)) for undeployed addresses, while at the RPC layer, this gets converted to Err(Error::ContractNotFound). When checking if a contract is deployed at the internal state level, use is_ok_and(|h| h.0 == Felt::ZERO) to detect undeployed addresses.
crates/starknet-devnet-server/src/api/json_rpc/write_endpoints.rs (1)
Learnt from: FabijanC
PR: #799
File: crates/starknet-devnet-core/src/starknet/mod.rs:240-246
Timestamp: 2025-06-16T07:35:24.725Z
Learning: In the Starknet devnet codebase, get_class_hash_at has different behaviors at different layers: at the internal state level (blockifier), it returns Ok(ClassHash(Felt::ZERO)) for undeployed addresses, while at the RPC layer, this gets converted to Err(Error::ContractNotFound). When checking if a contract is deployed at the internal state level, use is_ok_and(|h| h.0 == Felt::ZERO) to detect undeployed addresses.
crates/starknet-devnet-core/src/error.rs (1)
Learnt from: FabijanC
PR: #799
File: crates/starknet-devnet-core/src/starknet/mod.rs:240-246
Timestamp: 2025-06-16T07:35:24.725Z
Learning: In the Starknet devnet codebase, get_class_hash_at has different behaviors at different layers: at the internal state level (blockifier), it returns Ok(ClassHash(Felt::ZERO)) for undeployed addresses, while at the RPC layer, this gets converted to Err(Error::ContractNotFound). When checking if a contract is deployed at the internal state level, use is_ok_and(|h| h.0 == Felt::ZERO) to detect undeployed addresses.
crates/starknet-devnet-server/src/api/json_rpc/endpoints_ws.rs (1)
Learnt from: FabijanC
PR: #799
File: crates/starknet-devnet-core/src/starknet/mod.rs:240-246
Timestamp: 2025-06-16T07:35:24.725Z
Learning: In the Starknet devnet codebase, get_class_hash_at has different behaviors at different layers: at the internal state level (blockifier), it returns Ok(ClassHash(Felt::ZERO)) for undeployed addresses, while at the RPC layer, this gets converted to Err(Error::ContractNotFound). When checking if a contract is deployed at the internal state level, use is_ok_and(|h| h.0 == Felt::ZERO) to detect undeployed addresses.
tests/integration/common/background_devnet.rs (1)
Learnt from: FabijanC
PR: #799
File: crates/starknet-devnet-core/src/starknet/mod.rs:240-246
Timestamp: 2025-06-16T07:35:24.725Z
Learning: In the Starknet devnet codebase, get_class_hash_at has different behaviors at different layers: at the internal state level (blockifier), it returns Ok(ClassHash(Felt::ZERO)) for undeployed addresses, while at the RPC layer, this gets converted to Err(Error::ContractNotFound). When checking if a contract is deployed at the internal state level, use is_ok_and(|h| h.0 == Felt::ZERO) to detect undeployed addresses.
crates/starknet-devnet-core/src/messaging/mod.rs (1)
Learnt from: FabijanC
PR: #799
File: crates/starknet-devnet-core/src/starknet/mod.rs:240-246
Timestamp: 2025-06-16T07:35:24.725Z
Learning: In the Starknet devnet codebase, get_class_hash_at has different behaviors at different layers: at the internal state level (blockifier), it returns Ok(ClassHash(Felt::ZERO)) for undeployed addresses, while at the RPC layer, this gets converted to Err(Error::ContractNotFound). When checking if a contract is deployed at the internal state level, use is_ok_and(|h| h.0 == Felt::ZERO) to detect undeployed addresses.
crates/starknet-devnet-server/src/api/json_rpc/mod.rs (1)
Learnt from: FabijanC
PR: #799
File: crates/starknet-devnet-core/src/starknet/mod.rs:240-246
Timestamp: 2025-06-16T07:35:24.725Z
Learning: In the Starknet devnet codebase, get_class_hash_at has different behaviors at different layers: at the internal state level (blockifier), it returns Ok(ClassHash(Felt::ZERO)) for undeployed addresses, while at the RPC layer, this gets converted to Err(Error::ContractNotFound). When checking if a contract is deployed at the internal state level, use is_ok_and(|h| h.0 == Felt::ZERO) to detect undeployed addresses.
crates/starknet-devnet-core/src/starknet/events.rs (1)
Learnt from: FabijanC
PR: #799
File: crates/starknet-devnet-core/src/starknet/mod.rs:240-246
Timestamp: 2025-06-16T07:35:24.725Z
Learning: In the Starknet devnet codebase, get_class_hash_at has different behaviors at different layers: at the internal state level (blockifier), it returns Ok(ClassHash(Felt::ZERO)) for undeployed addresses, while at the RPC layer, this gets converted to Err(Error::ContractNotFound). When checking if a contract is deployed at the internal state level, use is_ok_and(|h| h.0 == Felt::ZERO) to detect undeployed addresses.
crates/starknet-devnet-server/src/api/http/endpoints/accounts.rs (1)
Learnt from: FabijanC
PR: #799
File: crates/starknet-devnet-core/src/starknet/mod.rs:240-246
Timestamp: 2025-06-16T07:35:24.725Z
Learning: In the Starknet devnet codebase, get_class_hash_at has different behaviors at different layers: at the internal state level (blockifier), it returns Ok(ClassHash(Felt::ZERO)) for undeployed addresses, while at the RPC layer, this gets converted to Err(Error::ContractNotFound). When checking if a contract is deployed at the internal state level, use is_ok_and(|h| h.0 == Felt::ZERO) to detect undeployed addresses.
crates/starknet-devnet-core/src/starknet/get_class_impls.rs (1)
Learnt from: FabijanC
PR: #799
File: crates/starknet-devnet-core/src/starknet/mod.rs:240-246
Timestamp: 2025-06-16T07:35:24.725Z
Learning: In the Starknet devnet codebase, get_class_hash_at has different behaviors at different layers: at the internal state level (blockifier), it returns Ok(ClassHash(Felt::ZERO)) for undeployed addresses, while at the RPC layer, this gets converted to Err(Error::ContractNotFound). When checking if a contract is deployed at the internal state level, use is_ok_and(|h| h.0 == Felt::ZERO) to detect undeployed addresses.
crates/starknet-devnet-server/src/api/http/endpoints/mint_token.rs (1)
Learnt from: FabijanC
PR: #799
File: crates/starknet-devnet-core/src/starknet/mod.rs:240-246
Timestamp: 2025-06-16T07:35:24.725Z
Learning: In the Starknet devnet codebase, get_class_hash_at has different behaviors at different layers: at the internal state level (blockifier), it returns Ok(ClassHash(Felt::ZERO)) for undeployed addresses, while at the RPC layer, this gets converted to Err(Error::ContractNotFound). When checking if a contract is deployed at the internal state level, use is_ok_and(|h| h.0 == Felt::ZERO) to detect undeployed addresses.
crates/starknet-devnet-core/src/blocks/mod.rs (1)
Learnt from: FabijanC
PR: #799
File: crates/starknet-devnet-core/src/starknet/mod.rs:240-246
Timestamp: 2025-06-16T07:35:24.725Z
Learning: In the Starknet devnet codebase, get_class_hash_at has different behaviors at different layers: at the internal state level (blockifier), it returns Ok(ClassHash(Felt::ZERO)) for undeployed addresses, while at the RPC layer, this gets converted to Err(Error::ContractNotFound). When checking if a contract is deployed at the internal state level, use is_ok_and(|h| h.0 == Felt::ZERO) to detect undeployed addresses.
crates/starknet-devnet-server/src/api/json_rpc/models.rs (1)
Learnt from: FabijanC
PR: #799
File: crates/starknet-devnet-core/src/starknet/mod.rs:240-246
Timestamp: 2025-06-16T07:35:24.725Z
Learning: In the Starknet devnet codebase, get_class_hash_at has different behaviors at different layers: at the internal state level (blockifier), it returns Ok(ClassHash(Felt::ZERO)) for undeployed addresses, while at the RPC layer, this gets converted to Err(Error::ContractNotFound). When checking if a contract is deployed at the internal state level, use is_ok_and(|h| h.0 == Felt::ZERO) to detect undeployed addresses.
crates/starknet-devnet-core/src/starknet/estimations.rs (1)
Learnt from: FabijanC
PR: #799
File: crates/starknet-devnet-core/src/starknet/mod.rs:240-246
Timestamp: 2025-06-16T07:35:24.725Z
Learning: In the Starknet devnet codebase, get_class_hash_at has different behaviors at different layers: at the internal state level (blockifier), it returns Ok(ClassHash(Felt::ZERO)) for undeployed addresses, while at the RPC layer, this gets converted to Err(Error::ContractNotFound). When checking if a contract is deployed at the internal state level, use is_ok_and(|h| h.0 == Felt::ZERO) to detect undeployed addresses.
tests/integration/test_accepting_blocks_on_l1.rs (1)
Learnt from: FabijanC
PR: #799
File: crates/starknet-devnet-core/src/starknet/mod.rs:240-246
Timestamp: 2025-06-16T07:35:24.725Z
Learning: In the Starknet devnet codebase, get_class_hash_at has different behaviors at different layers: at the internal state level (blockifier), it returns Ok(ClassHash(Felt::ZERO)) for undeployed addresses, while at the RPC layer, this gets converted to Err(Error::ContractNotFound). When checking if a contract is deployed at the internal state level, use is_ok_and(|h| h.0 == Felt::ZERO) to detect undeployed addresses.
crates/starknet-devnet-types/src/rpc/block.rs (1)
Learnt from: FabijanC
PR: #799
File: crates/starknet-devnet-core/src/starknet/mod.rs:240-246
Timestamp: 2025-06-16T07:35:24.725Z
Learning: In the Starknet devnet codebase, get_class_hash_at has different behaviors at different layers: at the internal state level (blockifier), it returns Ok(ClassHash(Felt::ZERO)) for undeployed addresses, while at the RPC layer, this gets converted to Err(Error::ContractNotFound). When checking if a contract is deployed at the internal state level, use is_ok_and(|h| h.0 == Felt::ZERO) to detect undeployed addresses.
crates/starknet-devnet-server/src/api/json_rpc/endpoints.rs (1)
Learnt from: FabijanC
PR: #799
File: crates/starknet-devnet-core/src/starknet/mod.rs:240-246
Timestamp: 2025-06-16T07:35:24.725Z
Learning: In the Starknet devnet codebase, get_class_hash_at has different behaviors at different layers: at the internal state level (blockifier), it returns Ok(ClassHash(Felt::ZERO)) for undeployed addresses, while at the RPC layer, this gets converted to Err(Error::ContractNotFound). When checking if a contract is deployed at the internal state level, use is_ok_and(|h| h.0 == Felt::ZERO) to detect undeployed addresses.
crates/starknet-devnet-core/src/starknet/mod.rs (1)
Learnt from: FabijanC
PR: #799
File: crates/starknet-devnet-core/src/starknet/mod.rs:240-246
Timestamp: 2025-06-16T07:35:24.725Z
Learning: In the Starknet devnet codebase, get_class_hash_at has different behaviors at different layers: at the internal state level (blockifier), it returns Ok(ClassHash(Felt::ZERO)) for undeployed addresses, while at the RPC layer, this gets converted to Err(Error::ContractNotFound). When checking if a contract is deployed at the internal state level, use is_ok_and(|h| h.0 == Felt::ZERO) to detect undeployed addresses.
🧬 Code Graph Analysis (2)
crates/starknet-devnet-server/src/api/json_rpc/write_endpoints.rs (2)
crates/starknet-devnet-core/src/starknet/mod.rs (1)
accept_on_l1(1025-1054)tests/integration/test_accepting_blocks_on_l1.rs (1)
accept_on_l1(16-27)
crates/starknet-devnet-server/src/api/json_rpc/mod.rs (1)
crates/starknet-devnet-server/src/test_utils.rs (1)
assert_contains(12-21)
🪛 markdownlint-cli2 (0.17.2)
website/docs/balance.md
62-62: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
🧰 Additional context used
🧠 Learnings (20)
crates/starknet-devnet-core/src/starknet/add_deploy_account_transaction.rs (1)
Learnt from: FabijanC
PR: #799
File: crates/starknet-devnet-core/src/starknet/mod.rs:240-246
Timestamp: 2025-06-16T07:35:24.725Z
Learning: In the Starknet devnet codebase, get_class_hash_at has different behaviors at different layers: at the internal state level (blockifier), it returns Ok(ClassHash(Felt::ZERO)) for undeployed addresses, while at the RPC layer, this gets converted to Err(Error::ContractNotFound). When checking if a contract is deployed at the internal state level, use is_ok_and(|h| h.0 == Felt::ZERO) to detect undeployed addresses.
crates/starknet-devnet-core/src/state/state_diff.rs (1)
Learnt from: FabijanC
PR: #799
File: crates/starknet-devnet-core/src/starknet/mod.rs:240-246
Timestamp: 2025-06-16T07:35:24.725Z
Learning: In the Starknet devnet codebase, get_class_hash_at has different behaviors at different layers: at the internal state level (blockifier), it returns Ok(ClassHash(Felt::ZERO)) for undeployed addresses, while at the RPC layer, this gets converted to Err(Error::ContractNotFound). When checking if a contract is deployed at the internal state level, use is_ok_and(|h| h.0 == Felt::ZERO) to detect undeployed addresses.
crates/starknet-devnet-core/src/starknet/state_update.rs (1)
Learnt from: FabijanC
PR: #799
File: crates/starknet-devnet-core/src/starknet/mod.rs:240-246
Timestamp: 2025-06-16T07:35:24.725Z
Learning: In the Starknet devnet codebase, get_class_hash_at has different behaviors at different layers: at the internal state level (blockifier), it returns Ok(ClassHash(Felt::ZERO)) for undeployed addresses, while at the RPC layer, this gets converted to Err(Error::ContractNotFound). When checking if a contract is deployed at the internal state level, use is_ok_and(|h| h.0 == Felt::ZERO) to detect undeployed addresses.
crates/starknet-devnet-server/src/api/json_rpc/write_endpoints.rs (1)
Learnt from: FabijanC
PR: #799
File: crates/starknet-devnet-core/src/starknet/mod.rs:240-246
Timestamp: 2025-06-16T07:35:24.725Z
Learning: In the Starknet devnet codebase, get_class_hash_at has different behaviors at different layers: at the internal state level (blockifier), it returns Ok(ClassHash(Felt::ZERO)) for undeployed addresses, while at the RPC layer, this gets converted to Err(Error::ContractNotFound). When checking if a contract is deployed at the internal state level, use is_ok_and(|h| h.0 == Felt::ZERO) to detect undeployed addresses.
crates/starknet-devnet-core/src/error.rs (1)
Learnt from: FabijanC
PR: #799
File: crates/starknet-devnet-core/src/starknet/mod.rs:240-246
Timestamp: 2025-06-16T07:35:24.725Z
Learning: In the Starknet devnet codebase, get_class_hash_at has different behaviors at different layers: at the internal state level (blockifier), it returns Ok(ClassHash(Felt::ZERO)) for undeployed addresses, while at the RPC layer, this gets converted to Err(Error::ContractNotFound). When checking if a contract is deployed at the internal state level, use is_ok_and(|h| h.0 == Felt::ZERO) to detect undeployed addresses.
crates/starknet-devnet-server/src/api/json_rpc/endpoints_ws.rs (1)
Learnt from: FabijanC
PR: #799
File: crates/starknet-devnet-core/src/starknet/mod.rs:240-246
Timestamp: 2025-06-16T07:35:24.725Z
Learning: In the Starknet devnet codebase, get_class_hash_at has different behaviors at different layers: at the internal state level (blockifier), it returns Ok(ClassHash(Felt::ZERO)) for undeployed addresses, while at the RPC layer, this gets converted to Err(Error::ContractNotFound). When checking if a contract is deployed at the internal state level, use is_ok_and(|h| h.0 == Felt::ZERO) to detect undeployed addresses.
tests/integration/common/background_devnet.rs (1)
Learnt from: FabijanC
PR: #799
File: crates/starknet-devnet-core/src/starknet/mod.rs:240-246
Timestamp: 2025-06-16T07:35:24.725Z
Learning: In the Starknet devnet codebase, get_class_hash_at has different behaviors at different layers: at the internal state level (blockifier), it returns Ok(ClassHash(Felt::ZERO)) for undeployed addresses, while at the RPC layer, this gets converted to Err(Error::ContractNotFound). When checking if a contract is deployed at the internal state level, use is_ok_and(|h| h.0 == Felt::ZERO) to detect undeployed addresses.
crates/starknet-devnet-core/src/messaging/mod.rs (1)
Learnt from: FabijanC
PR: #799
File: crates/starknet-devnet-core/src/starknet/mod.rs:240-246
Timestamp: 2025-06-16T07:35:24.725Z
Learning: In the Starknet devnet codebase, get_class_hash_at has different behaviors at different layers: at the internal state level (blockifier), it returns Ok(ClassHash(Felt::ZERO)) for undeployed addresses, while at the RPC layer, this gets converted to Err(Error::ContractNotFound). When checking if a contract is deployed at the internal state level, use is_ok_and(|h| h.0 == Felt::ZERO) to detect undeployed addresses.
crates/starknet-devnet-server/src/api/json_rpc/mod.rs (1)
Learnt from: FabijanC
PR: #799
File: crates/starknet-devnet-core/src/starknet/mod.rs:240-246
Timestamp: 2025-06-16T07:35:24.725Z
Learning: In the Starknet devnet codebase, get_class_hash_at has different behaviors at different layers: at the internal state level (blockifier), it returns Ok(ClassHash(Felt::ZERO)) for undeployed addresses, while at the RPC layer, this gets converted to Err(Error::ContractNotFound). When checking if a contract is deployed at the internal state level, use is_ok_and(|h| h.0 == Felt::ZERO) to detect undeployed addresses.
crates/starknet-devnet-core/src/starknet/events.rs (1)
Learnt from: FabijanC
PR: #799
File: crates/starknet-devnet-core/src/starknet/mod.rs:240-246
Timestamp: 2025-06-16T07:35:24.725Z
Learning: In the Starknet devnet codebase, get_class_hash_at has different behaviors at different layers: at the internal state level (blockifier), it returns Ok(ClassHash(Felt::ZERO)) for undeployed addresses, while at the RPC layer, this gets converted to Err(Error::ContractNotFound). When checking if a contract is deployed at the internal state level, use is_ok_and(|h| h.0 == Felt::ZERO) to detect undeployed addresses.
crates/starknet-devnet-server/src/api/http/endpoints/accounts.rs (1)
Learnt from: FabijanC
PR: #799
File: crates/starknet-devnet-core/src/starknet/mod.rs:240-246
Timestamp: 2025-06-16T07:35:24.725Z
Learning: In the Starknet devnet codebase, get_class_hash_at has different behaviors at different layers: at the internal state level (blockifier), it returns Ok(ClassHash(Felt::ZERO)) for undeployed addresses, while at the RPC layer, this gets converted to Err(Error::ContractNotFound). When checking if a contract is deployed at the internal state level, use is_ok_and(|h| h.0 == Felt::ZERO) to detect undeployed addresses.
crates/starknet-devnet-core/src/starknet/get_class_impls.rs (1)
Learnt from: FabijanC
PR: #799
File: crates/starknet-devnet-core/src/starknet/mod.rs:240-246
Timestamp: 2025-06-16T07:35:24.725Z
Learning: In the Starknet devnet codebase, get_class_hash_at has different behaviors at different layers: at the internal state level (blockifier), it returns Ok(ClassHash(Felt::ZERO)) for undeployed addresses, while at the RPC layer, this gets converted to Err(Error::ContractNotFound). When checking if a contract is deployed at the internal state level, use is_ok_and(|h| h.0 == Felt::ZERO) to detect undeployed addresses.
crates/starknet-devnet-server/src/api/http/endpoints/mint_token.rs (1)
Learnt from: FabijanC
PR: #799
File: crates/starknet-devnet-core/src/starknet/mod.rs:240-246
Timestamp: 2025-06-16T07:35:24.725Z
Learning: In the Starknet devnet codebase, get_class_hash_at has different behaviors at different layers: at the internal state level (blockifier), it returns Ok(ClassHash(Felt::ZERO)) for undeployed addresses, while at the RPC layer, this gets converted to Err(Error::ContractNotFound). When checking if a contract is deployed at the internal state level, use is_ok_and(|h| h.0 == Felt::ZERO) to detect undeployed addresses.
crates/starknet-devnet-core/src/blocks/mod.rs (1)
Learnt from: FabijanC
PR: #799
File: crates/starknet-devnet-core/src/starknet/mod.rs:240-246
Timestamp: 2025-06-16T07:35:24.725Z
Learning: In the Starknet devnet codebase, get_class_hash_at has different behaviors at different layers: at the internal state level (blockifier), it returns Ok(ClassHash(Felt::ZERO)) for undeployed addresses, while at the RPC layer, this gets converted to Err(Error::ContractNotFound). When checking if a contract is deployed at the internal state level, use is_ok_and(|h| h.0 == Felt::ZERO) to detect undeployed addresses.
crates/starknet-devnet-server/src/api/json_rpc/models.rs (1)
Learnt from: FabijanC
PR: #799
File: crates/starknet-devnet-core/src/starknet/mod.rs:240-246
Timestamp: 2025-06-16T07:35:24.725Z
Learning: In the Starknet devnet codebase, get_class_hash_at has different behaviors at different layers: at the internal state level (blockifier), it returns Ok(ClassHash(Felt::ZERO)) for undeployed addresses, while at the RPC layer, this gets converted to Err(Error::ContractNotFound). When checking if a contract is deployed at the internal state level, use is_ok_and(|h| h.0 == Felt::ZERO) to detect undeployed addresses.
crates/starknet-devnet-core/src/starknet/estimations.rs (1)
Learnt from: FabijanC
PR: #799
File: crates/starknet-devnet-core/src/starknet/mod.rs:240-246
Timestamp: 2025-06-16T07:35:24.725Z
Learning: In the Starknet devnet codebase, get_class_hash_at has different behaviors at different layers: at the internal state level (blockifier), it returns Ok(ClassHash(Felt::ZERO)) for undeployed addresses, while at the RPC layer, this gets converted to Err(Error::ContractNotFound). When checking if a contract is deployed at the internal state level, use is_ok_and(|h| h.0 == Felt::ZERO) to detect undeployed addresses.
tests/integration/test_accepting_blocks_on_l1.rs (1)
Learnt from: FabijanC
PR: #799
File: crates/starknet-devnet-core/src/starknet/mod.rs:240-246
Timestamp: 2025-06-16T07:35:24.725Z
Learning: In the Starknet devnet codebase, get_class_hash_at has different behaviors at different layers: at the internal state level (blockifier), it returns Ok(ClassHash(Felt::ZERO)) for undeployed addresses, while at the RPC layer, this gets converted to Err(Error::ContractNotFound). When checking if a contract is deployed at the internal state level, use is_ok_and(|h| h.0 == Felt::ZERO) to detect undeployed addresses.
crates/starknet-devnet-types/src/rpc/block.rs (1)
Learnt from: FabijanC
PR: #799
File: crates/starknet-devnet-core/src/starknet/mod.rs:240-246
Timestamp: 2025-06-16T07:35:24.725Z
Learning: In the Starknet devnet codebase, get_class_hash_at has different behaviors at different layers: at the internal state level (blockifier), it returns Ok(ClassHash(Felt::ZERO)) for undeployed addresses, while at the RPC layer, this gets converted to Err(Error::ContractNotFound). When checking if a contract is deployed at the internal state level, use is_ok_and(|h| h.0 == Felt::ZERO) to detect undeployed addresses.
crates/starknet-devnet-server/src/api/json_rpc/endpoints.rs (1)
Learnt from: FabijanC
PR: #799
File: crates/starknet-devnet-core/src/starknet/mod.rs:240-246
Timestamp: 2025-06-16T07:35:24.725Z
Learning: In the Starknet devnet codebase, get_class_hash_at has different behaviors at different layers: at the internal state level (blockifier), it returns Ok(ClassHash(Felt::ZERO)) for undeployed addresses, while at the RPC layer, this gets converted to Err(Error::ContractNotFound). When checking if a contract is deployed at the internal state level, use is_ok_and(|h| h.0 == Felt::ZERO) to detect undeployed addresses.
crates/starknet-devnet-core/src/starknet/mod.rs (1)
Learnt from: FabijanC
PR: #799
File: crates/starknet-devnet-core/src/starknet/mod.rs:240-246
Timestamp: 2025-06-16T07:35:24.725Z
Learning: In the Starknet devnet codebase, get_class_hash_at has different behaviors at different layers: at the internal state level (blockifier), it returns Ok(ClassHash(Felt::ZERO)) for undeployed addresses, while at the RPC layer, this gets converted to Err(Error::ContractNotFound). When checking if a contract is deployed at the internal state level, use is_ok_and(|h| h.0 == Felt::ZERO) to detect undeployed addresses.
🧬 Code Graph Analysis (2)
crates/starknet-devnet-server/src/api/json_rpc/write_endpoints.rs (2)
crates/starknet-devnet-core/src/starknet/mod.rs (1)
accept_on_l1(1025-1054)tests/integration/test_accepting_blocks_on_l1.rs (1)
accept_on_l1(16-27)
crates/starknet-devnet-server/src/api/json_rpc/mod.rs (1)
crates/starknet-devnet-server/src/test_utils.rs (1)
assert_contains(12-21)
🪛 markdownlint-cli2 (0.17.2)
website/docs/balance.md
62-62: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
🔇 Additional comments (35)
crates/starknet-devnet-core/src/messaging/mod.rs (1)
37-37: LGTM: Import refactoring aligns with BlockId consolidation effort.This import change is part of the broader refactoring to use the custom
BlockIdimplementation fromstarknet_types::rpc::blockinstead ofstarknet_rs_core::types. The change maintains functionality while improving consistency across the codebase.crates/starknet-devnet-server/src/api/json_rpc/endpoints_ws.rs (1)
3-3: LGTM: Clean import consolidation improves maintainability.Consolidating the block-related type imports (
BlockId,BlockTag, etc.) under a single import fromstarknet_types::rpc::blockimproves code organization and aligns with the broader type unification effort.crates/starknet-devnet-core/src/error.rs (1)
13-13: LGTM: Consistent import update maintains error handling functionality.The import change for
BlockIdfromstarknet_types::rpc::blockis consistent with the broader refactoring effort and maintains existing error handling behavior.crates/starknet-devnet-server/src/test_utils.rs (1)
23-25: LGTM: Centralized error message improves consistency and includes new l1_accepted tag.The addition of
EXPECTED_INVALID_BLOCK_ID_MSGconstant provides a standardized error message for invalid block ID validation. It correctly includes the new'l1_accepted'tag alongside existing tags, improving error message consistency across the codebase.crates/starknet-devnet-server/src/api/json_rpc/write_endpoints.rs (1)
156-156: LGTM: Clean removal of unnecessary type conversions.The removal of
.into()calls aligns perfectly with the broader refactor to unifyBlockIdusage across the codebase. The underlying methods now acceptCustomBlockIddirectly, making these conversions unnecessary.Also applies to: 162-162
crates/starknet-devnet-core/src/starknet/add_deploy_account_transaction.rs (1)
79-79: LGTM: Import reorganization aligns with codebase refactor.The import change moves
BlockIdandBlockTagfromstarknet_rs_core::typestostarknet_types::rpc::block, which is consistent with the broader refactor to unify block identification handling and support the newL1Acceptedvariant.crates/starknet-devnet-core/src/starknet/state_update.rs (1)
1-1: LGTM: Consistent import updates for unified block ID handling.The import changes align with the codebase-wide refactor to source
BlockIdandBlockTagfromstarknet_types::rpc::block, supporting the new customBlockIdenum andL1Acceptedvariant introduction.Also applies to: 23-23
crates/starknet-devnet-core/src/state/state_diff.rs (1)
185-185: LGTM: Import reorganization follows the established refactor pattern.The separation of imports correctly maintains
Feltfromstarknet_rs_core::typeswhile movingBlockIdandBlockTagtostarknet_types::rpc::block, consistent with the codebase-wide unification of block identification types.Also applies to: 190-190
crates/starknet-devnet-server/src/api/json_rpc/mod.rs (2)
29-29: LGTM: Import reorganization maintains consistency with codebase refactor.The import updates correctly separate concerns by keeping
ContractClassandFeltfromstarknet_rs_core::typeswhile moving block-related types to the unifiedstarknet_types::rpc::blocklocation.Also applies to: 31-31
1061-1061: LGTM: Good practice consolidating test utilities.Moving
EXPECTED_INVALID_BLOCK_ID_MSGto the sharedtest_utilsmodule promotes code reuse and reduces duplication across test modules.website/docs/balance.md (1)
60-60: LGTM! Documentation correctly updated to reflect API changes.The parameter name changes from
block_tagtoblock_idare consistent with the broader refactoring to use the more flexibleBlockIdenum instead of justBlockTag.Also applies to: 63-63, 75-75
crates/starknet-devnet-core/src/starknet/get_class_impls.rs (1)
7-7: LGTM! Import updates align with the BlockId/BlockTag refactoring.The changes correctly update imports to use the custom
BlockId,BlockStatus, andBlockTagtypes fromstarknet_types::rpc::blockinstead of the starknet-rs versions, which is consistent with the broader refactoring effort.Also applies to: 78-78, 80-80
crates/starknet-devnet-core/src/starknet/events.rs (2)
1-1: LGTM! Import updates are consistent with the BlockId/BlockTag refactoring.The changes correctly update imports to use the custom types and all test code properly uses the new import paths.
Also applies to: 4-4, 134-134, 137-137
293-294: Test code correctly updated to use new BlockTag import.The test functions properly use
BlockId::Tag(BlockTag::Latest)with the updated import path.Also applies to: 308-309, 324-325
crates/starknet-devnet-server/src/api/http/endpoints/accounts.rs (3)
7-7: LGTM! Added necessary imports for BlockId and BlockTag.The import additions support the API change from
block_tagtoblock_idparameter.
80-80: Breaking change: API parameter updated from block_tag to block_id.The change from
block_tag: Option<BlockTag>toblock_id: Option<BlockId>is a breaking change that provides more flexibility by supporting block identification by hash, number, or tag. This aligns with the PR objectives.
39-40: Implementation correctly wraps BlockTag in BlockId::Tag.The function calls properly use
BlockId::Tag(BlockTag::...)to maintain the existing behavior while using the new type structure.Also applies to: 106-106
crates/starknet-devnet-server/src/api/json_rpc/models.rs (3)
264-264: LGTM! Simplified imports and removed unnecessary alias.Removing the
ImportedBlockIdalias and directly usingBlockIdimproves code clarity and consistency. Moving test utility imports to a central location enhances maintainability.Also applies to: 268-268, 274-274
490-490: Test assertions correctly updated to use BlockId variants.The test code properly uses
BlockId::Number,BlockId::Hash, and other variants instead of the previous alias.Also applies to: 513-513, 536-536
694-694: Pattern matching in test helpers correctly updated.The assertion helper functions properly use
BlockIdvariants in pattern matching instead of the removed alias.Also applies to: 709-710, 723-723
crates/starknet-devnet-core/src/blocks/mod.rs (4)
10-10: Import change aligns with PR objectives.The migration from
starknet_rs_core::typestostarknet_types::rpc::blockforBlockIdandBlockTagis consistent with the PR's goal to replace starknet-rs block_id with a custom implementation.
29-29: Field addition properly supports L1Accepted functionality.The
last_accepted_on_l1field correctly usesOption<BlockHash>to track the last block accepted on L1, appropriately handling the case where no blocks have been accepted yet.
54-54: Proper initialization in Default implementation.The
last_accepted_on_l1field is correctly initialized toNone, reflecting that no blocks have been accepted on L1 at startup.
105-107: Correct handling of L1Accepted block tag.The implementation properly handles the
BlockTag::L1Acceptedcase by usingand_thento safely retrieve the block whenlast_accepted_on_l1is set, and returningNonewhen no blocks have been accepted on L1 yet.crates/starknet-devnet-server/src/api/http/endpoints/mint_token.rs (3)
8-8: Import change is consistent with codebase refactor.The import of
BlockIdandBlockTagfromstarknet_types::rpc::blockaligns with the project-wide migration to use custom block ID types.
21-21: API enhancement to accept any block_id.The change from
BlockTagtoBlockIdaligns with the PR objective to allowdevnet_getAccountBalanceto accept any block_id. This provides more flexibility by supporting block hashes and numbers in addition to tags.Also applies to: 28-28
70-75: Correct adaptation to new function signature.The call properly wraps
BlockTag::PreConfirmedinBlockId::Tag()to match the updatedget_balancefunction signature.crates/starknet-devnet-core/src/starknet/estimations.rs (2)
11-11: Consistent migration to custom BlockId type.The import and parameter type changes correctly migrate to using
CustomBlockIdfrom the local types module, with appropriate use of references for better performance.Also applies to: 21-21, 101-101
104-104: Correct dereferencing for owned value.The dereference of
block_idis necessary sinceEstimateMessageFeeRequest::newexpects an ownedBlockIdvalue rather than a reference.crates/starknet-devnet-types/src/rpc/block.rs (5)
11-19: Well-structured BlockId enum definition.The custom
BlockIdenum properly defines all necessary variants for block identification with appropriate derive attributes for common traits.
36-44: Deserialization properly handles L1Accepted tag.The deserialization logic correctly identifies and constructs the
L1Acceptedtag variant, and the error message appropriately lists all valid options.
143-143: Consistent L1Accepted support in SubscriptionBlockId.The
L1Acceptedvariant is properly added toSubscriptionBlockIdwith correct deserialization and conversion implementations.Also applies to: 161-161, 178-178
188-188: BlockTag enum properly extended with L1Accepted.The
L1Acceptedvariant is correctly added to theBlockTagenum.
191-222: Comprehensive test coverage for new functionality.The tests thoroughly verify deserialization of all
BlockIdandBlockTagvariants, including the newL1Acceptedtag, ensuring the implementation works as expected.Also applies to: 242-244
crates/starknet-devnet-server/src/api/json_rpc/endpoints.rs (1)
28-29: Good use of a descriptive constant for the error message.The constant clearly communicates the limitation to users when they attempt to use
l1_acceptedwith forking origin.
Usage related changes
l1_acceptedblock tag.devnet_getAccountBalance.l1_acceptedblock tag in forking mode if the block is present on forking origin.Development related changes
Checklist:
./scripts/format.sh./scripts/clippy_check.sh./scripts/check_unused_deps.sh./scripts/check_spelling.sh./website/README.mdSummary by CodeRabbit
New Features
l1_acceptedblock tag, enabling queries for the last block accepted on L1.API Changes
block_tagparameters withblock_idin balance and related queries for both HTTP and JSON-RPC endpoints.BlockIdtype with support for block number, hash, and tag variants.Bug Fixes
l1_acceptedqueries in certain contexts.Documentation
block_idinstead ofblock_tag.Tests
l1_acceptedblock tag behavior.