-
Notifications
You must be signed in to change notification settings - Fork 51
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
feat: added special address with block number and block hash #347
Conversation
} | ||
Ok(None) => { | ||
// this shouldn't happen, ideally should panic | ||
log::error!("No block hash found for block number {}", prev_block_number); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's panic ig?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resolved
if block_n >= 10 { | ||
let prev_block_number = block_n - 10; | ||
match self.backend.get_block_hash(&BlockId::Number(prev_block_number)) { | ||
Ok(Some(prev_block_hash)) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's add a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
block_time: Duration::from_secs(4), | ||
pending_block_update_time: Duration::from_secs(1), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
block_time: Duration::from_secs(4), | |
pending_block_update_time: Duration::from_secs(1), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resolved
This logic for block hashes is already implemented for blockifier with the StateAdapter, it should be changed accordingly while keeping a compatibility of re-execution of the mainnet. madara/crates/client/exec/src/blockifier_state_adapter.rs Lines 33 to 55 in fe09932
|
@jbcaron, I am mostly missing something but do we need this custom logic in the reader? The feeder gateway does return state diffs where it says |
we should just delete this code in the same PR but be sure that we can re-execute the mainnet blocks (I don't know from when this feature was introduced) |
makes sense, we can delete and see if the test cases pass + that we can resync a few hundred blocks on mainnet + get_storage_at on 0x1 address works as expected EDIT: @Mohiiit has also already informed the visoft team for e2e cases for this specific case |
// at address 0x1 with the block number as the key | ||
if block_n >= 10 { | ||
let prev_block_number = block_n - 10; | ||
match self.backend.get_block_hash(&BlockId::Number(prev_block_number)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this match can be simplified to
let prev_block_hash = self.backend.get_block_hash(&BlockId::Number(prev_block_number))
.map_err(|err| Error::Unexpected(
format!("Error fetching block hash for block {prev_block_number}: {err:#}").into()
))?
.ok_or_else(|| Error::Unexpected(
format!("No block hash found for block number {prev_block_number}").into()
))?;
let address = Felt::ONE;
new_state_diff.storage_diffs.push(ContractStorageDiffItem {
address,
storage_entries: vec![StorageEntry { key: Felt::from(block_n), value: prev_block_hash }],
});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resolved
workflow udpated
.backend | ||
.get_contract_class_hash_at(&block_id, &contract_address) | ||
.or_internal_server_error("Failed to check if contract is deployed")? | ||
.ok_or(StarknetRpcApiError::ContractNotFound)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should only return 0x0 in this case
we can therefore remove this check
this is already the implementation in the state adapter but maybe this logic should be in the db
@cchudant what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked with the juno rpc call and it has this behaviour hence implemented this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
apparently you have to return ContractNotFound
https://github.com/starkware-libs/starknet-specs/blob/master/api/starknet_api_openrpc.json#L216
but we need to bring this up into full node collab channel - getNonce also returns ContractNotFound but I think it's possible to increment the nonce of an undeclared contract
Small fix for SNOS to run, it requires special address in the state diff
Pull Request type
Please add the labels corresponding to the type of changes your PR introduces:
What is the current behavior?
Currently we were not adding the block hash and block number of previous block with special address which was breaking the SNOS
Resolves: #NA
What is the new behavior?
Does this introduce a breaking change?
No