-
Notifications
You must be signed in to change notification settings - Fork 237
refactor(v10): check storage existence only for zeros #3790
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
base: main
Are you sure you want to change the base?
Changes from all commits
dc16671
15e2306
083df26
586ee2d
cf3e6cf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -105,22 +105,30 @@ | |
| } | ||
| defer h.callAndLogErr(stateCloser, "Error closing state reader in getStorageAt") | ||
|
|
||
| // This checks if the contract exists because if a key doesn't exist in contract storage, | ||
| // the returned value is always zero and error is nil. | ||
| _, err := stateReader.ContractClassHash(addressFelt) | ||
| value, err := stateReader.ContractStorage(addressFelt, key) | ||
| if err != nil { | ||
| if errors.Is(err, db.ErrKeyNotFound) { | ||
| return nil, rpccore.ErrContractNotFound | ||
| } | ||
| h.logger.Error("Failed to get contract class hash", zap.Error(err)) | ||
| h.logger.Error("Failed to get contract storage", zap.Error(err)) | ||
| return nil, rpccore.ErrInternal.CloneWithData(err) | ||
| } | ||
|
|
||
| result.Value, err = stateReader.ContractStorage(addressFelt, key) | ||
| if err != nil { | ||
| return nil, rpccore.ErrInternal.CloneWithData(err) | ||
| // Only the head (latest) reader returns zero for a missing contract, so probe | ||
| // the class hash to distinguish "contract absent" from "slot is zero". | ||
| // Historical and pre_confirmed readers surface it as ErrKeyNotFound above. | ||
| if value.IsZero() && id.IsLatest() { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Blocker — the latest commit ( This guard only probes when Result: at genesis, It also breaks Please revert the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The comment above is now inaccurate, and genesis The latest commit (
So the comment "Historical and pre_confirmed readers surface it as ErrKeyNotFound above" is false for the genesis case, and the two Practically the genesis-
As-is, the two halves are inconsistent. |
||
| if _, err := stateReader.ContractClassHash(addressFelt); err != nil { | ||
| if errors.Is(err, db.ErrKeyNotFound) { | ||
| return nil, rpccore.ErrContractNotFound | ||
| } | ||
| h.logger.Error("Failed to get contract class hash", zap.Error(err)) | ||
| return nil, rpccore.ErrInternal.CloneWithData(err) | ||
| } | ||
| } | ||
|
|
||
| result.Value = value | ||
|
|
||
| if !flags.IncludeLastUpdateBlock { | ||
| return &result, nil | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.