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

Adding support for declare v0, l1 handler and l1->l2 messages #321

Merged
merged 35 commits into from
Oct 21, 2024
Merged
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
789f457
feat: declare v0 working
Oct 3, 2024
d448b65
debug: debuging declare v0
Oct 4, 2024
b842ae6
main merged
Oct 4, 2024
3da2f1a
adding comments for debugging
Oct 7, 2024
2938bef
debugging with bootstraper
Oct 7, 2024
b8c554c
making l1 handler execute in the mempool
Oct 8, 2024
62e174f
feat: refactored Mempool to accept L1Handler txn
Oct 9, 2024
4c16c8e
fixing test for l1 message and mempool inner
Oct 10, 2024
7f31dde
merged with main
Oct 10, 2024
50dcc7a
formatting and linting
Oct 10, 2024
f9650f5
formatting and changelog
Oct 10, 2024
334c258
comments removed
Oct 10, 2024
7c98ebd
main merged
Oct 10, 2024
bc05e4f
Merge branch 'main' into feat/declare_v0
Trantorian1 Oct 11, 2024
7c63396
validation added for txns
Oct 11, 2024
1485eca
feat: main merged
Oct 15, 2024
c857b79
resolving issues
Oct 15, 2024
8e510c9
refactor: declare v0 refactored with different rpc namespace
Oct 16, 2024
0ca66af
main merged
Oct 16, 2024
501eaf8
merged with upstream
Oct 16, 2024
21d12f5
merged with main
Oct 16, 2024
2ad4d19
msgL2 hash added
Oct 16, 2024
fc16ff3
formatting and linting
Oct 16, 2024
2209885
tests added for proc macros, error added for empty namespace, removed…
Oct 18, 2024
ed5b6c0
fixing comments
Oct 18, 2024
eaf5411
main merged
Oct 18, 2024
f21baad
fix: build fix
Oct 18, 2024
77038a2
feat: added error when namespace is not present or method is not pres…
Oct 18, 2024
7669670
feat: de/serialize tests added for BroadcastedDeclareTransactionV0, c…
Oct 18, 2024
51054f8
fix: state diff special address should have current_block - 10 block …
Oct 19, 2024
b7a2a3e
feat: updating filter of l1 message to check between last and finaliz…
Oct 19, 2024
8ed287c
linting and formatting
Oct 19, 2024
638c645
refactor: reverting the event filter in l1 messaging
Oct 19, 2024
859e50c
Merge branch 'main' into feat/declare_v0
Mohiiit Oct 21, 2024
2fa3b46
extra clones removed
Oct 21, 2024
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
Prev Previous commit
Next Next commit
formatting and linting
mohiiit committed Oct 16, 2024
commit fc16ff3f8b0966dcfa7365e046e760d4c640896e
2 changes: 0 additions & 2 deletions crates/client/rpc/src/lib.rs
Original file line number Diff line number Diff line change
@@ -108,7 +108,5 @@ pub fn versioned_rpc_api(
// , v0_8_0 (for example)
);

log::debug!("rpc here is: {:?}", rpc_api);

Ok(rpc_api)
}
40 changes: 17 additions & 23 deletions crates/primitives/receipt/src/from_blockifier.rs
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ use blockifier::execution::call_info::CallInfo;
use blockifier::transaction::{
account_transaction::AccountTransaction,
objects::{FeeType, GasVector, HasRelatedFeeType, TransactionExecutionInfo},
transaction_execution::Transaction,
transaction_execution::Transaction, transactions::L1HandlerTransaction
};
use cairo_vm::types::builtin_name::BuiltinName;
use starknet_core::types::MsgToL2;
@@ -41,26 +41,21 @@ pub enum L1HandlerMessageError {
InvalidNonce,
}

fn get_l1_handler_message_hash(tx: &Transaction) -> Result<Felt, L1HandlerMessageError> {
match tx {
Transaction::L1HandlerTransaction(tx) => {
let (from_address, payload) = tx.tx.calldata.0.split_first().ok_or(L1HandlerMessageError::EmptyCalldata)?;
fn get_l1_handler_message_hash(tx: &L1HandlerTransaction) -> Result<Felt, L1HandlerMessageError> {
let (from_address, payload) = tx.tx.calldata.0.split_first().ok_or(L1HandlerMessageError::EmptyCalldata)?;

let from_address = (*from_address).try_into().map_err(|_| L1HandlerMessageError::FromAddressOutOfRange)?;
let from_address = (*from_address).try_into().map_err(|_| L1HandlerMessageError::FromAddressOutOfRange)?;

let nonce = tx.tx.nonce.0.to_bigint().try_into().map_err(|_| L1HandlerMessageError::InvalidNonce)?;
let nonce = tx.tx.nonce.0.to_bigint().try_into().map_err(|_| L1HandlerMessageError::InvalidNonce)?;

let message = MsgToL2 {
from_address,
to_address: tx.tx.contract_address.into(),
selector: tx.tx.entry_point_selector.0,
payload: payload.into(),
nonce,
};
Ok(Felt::from_bytes_le(message.hash().as_bytes()))
}
_ => Err(L1HandlerMessageError::EmptyCalldata), // or another appropriate error
}
let message = MsgToL2 {
from_address,
to_address: tx.tx.contract_address.into(),
selector: tx.tx.entry_point_selector.0,
payload: payload.into(),
nonce,
};
Ok(Felt::from_bytes_le(message.hash().as_bytes()))
}

pub fn from_blockifier_execution_info(res: &TransactionExecutionInfo, tx: &Transaction) -> TransactionReceipt {
@@ -76,11 +71,10 @@ pub fn from_blockifier_execution_info(res: &TransactionExecutionInfo, tx: &Trans
get_events_from_call_info(res.execute_call_info.as_ref(), 0, &mut events);

let message_hash = match tx {
Transaction::L1HandlerTransaction(_) => match get_l1_handler_message_hash(tx) {
Transaction::L1HandlerTransaction(tx) => match get_l1_handler_message_hash(tx) {
Ok(hash) => Some(hash),
Err(_err) => {
// ideal this should panic
None
Err(err) => {
panic!("Error getting l1 handler message hash: {:?}", err);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the error should be reported

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed it to log the error

}
},
_ => None,
@@ -165,7 +159,7 @@ pub fn from_blockifier_execution_info(res: &TransactionExecutionInfo, tx: &Trans
events,
execution_resources,
execution_result,
message_hash: message_hash.unwrap_or_else(|| Felt::from(0)),
message_hash: message_hash.unwrap(), // it's a safe unwrap because it would've panicked earlier if it was Err
}),
}
}