-
Notifications
You must be signed in to change notification settings - Fork 85
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
fix: add check for address 1 in gateway:get_storage_at #1000
Conversation
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.
Reviewed 4 of 4 files at r1, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @DvirYo-starkware and @Yael-Starkware)
a discussion (no related file):
I see that there are other places in the code that check is a contract exists (e.g. fn verify_contract_exists() in papyrus_execution).
Is the check of "contract1" relevant for it too?
If it is, we should probably put this logic in one common place instead of doing it in multiple places.
0142ee8
to
961b718
Compare
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.
Reviewable status: 0 of 4 files reviewed, 5 unresolved discussions (waiting on @OmriEshhar1 and @Yael-Starkware)
a discussion (no related file):
Previously, OmriEshhar1 wrote…
I see that there are other places in the code that check is a contract exists (e.g. fn verify_contract_exists() in papyrus_execution).
Is the check of "contract1" relevant for it too?
If it is, we should probably put this logic in one common place instead of doing it in multiple places.
This is irrelevant to the execution.
-- commits
line 2 at r2:
Add () after the" fix" and consider changing "address != 1" to "address != 0x1"
crates/papyrus_gateway/src/v0_3_0/api/api_impl.rs
line 57 at r2 (raw file):
ContinuationTokenAsStruct, }; pub const BLOCK_HASH_TABLE_CONTRACT_ADDRESS: &str = "0x1";
Instead of creating the ContractAddress from this string every time, create it only one time. Try to create this using a const function or using the lazy_static macro.
crates/papyrus_gateway/src/v0_3_0/api/api_impl.rs
line 137 at r2 (raw file):
.get_storage_at(state, &contract_address, &key) .map_err(internal_server_error); if res == Ok(StarkFelt::default()) {
Document what is special in this contract.
In addition, consider using only one if statement with two conditions.
crates/papyrus_gateway/src/v0_3_0/api/test.rs
line 1116 at r2 (raw file):
} #[tokio::test]
Why not add this to the already existing test "get_storage_at"?
961b718
to
a19fe86
Compare
Codecov Report
@@ Coverage Diff @@
## main #1000 +/- ##
=======================================
Coverage 75.27% 75.27%
=======================================
Files 71 71
Lines 6054 6054
Branches 6054 6054
=======================================
Hits 4557 4557
Misses 689 689
Partials 808 808
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
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.
Reviewed 1 of 5 files at r3, all commit messages.
Reviewable status: 1 of 5 files reviewed, 7 unresolved discussions (waiting on @OmriEshhar1 and @Yael-Starkware)
crates/papyrus_gateway/src/v0_3_0/api/api_impl.rs
line 59 at r3 (raw file):
//TODO(yael): implement address 0x1 as a const function in starknet_api. lazy_static! {
Consider putting this in the function get_storage_at because this constant is only used there.
crates/papyrus_gateway/src/v0_3_0/api/api_impl.rs
line 140 at r3 (raw file):
let res = state_reader .get_storage_at(state, &contract_address, &key) .map_err(internal_server_error);
Why don't you return the error if it exists? like in line 148.
crates/papyrus_gateway/src/v0_3_0/api/test.rs
line 1107 at r3 (raw file):
)); // Ask for storage at address 1 - the block hash table contract address
Consider putting this with the successful scenarios.
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.
Reviewable status: 1 of 5 files reviewed, 7 unresolved discussions (waiting on @DvirYo-starkware and @OmriEshhar1)
Previously, DvirYo-starkware wrote…
Add () after the" fix" and consider changing "address != 1" to "address != 0x1"
Done.
crates/papyrus_gateway/src/v0_3_0/api/api_impl.rs
line 57 at r2 (raw file):
Previously, DvirYo-starkware wrote…
Instead of creating the ContractAddress from this string every time, create it only one time. Try to create this using a const function or using the lazy_static macro.
Done.
crates/papyrus_gateway/src/v0_3_0/api/api_impl.rs
line 137 at r2 (raw file):
Previously, DvirYo-starkware wrote…
Document what is special in this contract.
In addition, consider using only one if statement with two conditions.
Done.
crates/papyrus_gateway/src/v0_3_0/api/api_impl.rs
line 59 at r3 (raw file):
Previously, DvirYo-starkware wrote…
Consider putting this in the function get_storage_at because this constant is only used there.
it is also being used in the test.
crates/papyrus_gateway/src/v0_3_0/api/test.rs
line 1116 at r2 (raw file):
Previously, DvirYo-starkware wrote…
Why not add this to the already existing test "get_storage_at"?
Done.
a19fe86
to
0232de6
Compare
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.
Reviewed 4 of 4 files at r4, all commit messages.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @Yael-Starkware)
0232de6
to
15cee75
Compare
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.
Reviewed 4 of 4 files at r5, all commit messages.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @Yael-Starkware)
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.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @DvirYo-starkware)
a discussion (no related file):
Previously, DvirYo-starkware wrote…
This is irrelevant to the execution.
Done
crates/papyrus_gateway/src/v0_3_0/api/api_impl.rs
line 140 at r3 (raw file):
Previously, DvirYo-starkware wrote…
Why don't you return the error if it exists? like in line 148.
Done.
15cee75
to
771e9ce
Compare
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.
Reviewed 1 of 5 files at r3, 4 of 4 files at r5, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @DvirYo-starkware)
When handling a get_storage_at request in the gateway, need to check first if the contract address is 1,
the contract address for the block hash table.
If it is, we need to return a value and not a ContractNotFound error.
Pull Request type
Please check the type of change your PR introduces:
What is the current behavior?
Issue Number: N/A
What is the new behavior?
Does this introduce a breaking change?
Other information
This change is