-
Notifications
You must be signed in to change notification settings - Fork 19
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
target_hash
RPC Level validation
#1860
Comments
I think one question to answer is: is it possible to read only the first N bytes of a page? I hate to have to read the entire page in the signed extension when we only care about the page hash in the first few bytes of the page storage for each page. |
Few things we can check if possible
|
Please remind me how someone might gat a bad_hash. Also, Can you please elaborate on why is this a problem? |
Should we provide an RPC to validate a hash ? That way we can check for correctness of hash at the time of computing it via graphsdk Advantage: we can proactively make sure only valid hashes are being sent to chain than wait for chain to tell us it's bad ? |
Our RPC returns current hash once a page is retrieved. Not sure if we need an additional RPC. |
Is there a way to know with the above info if a given hash is stale or not ? |
Not possible. Accessing the node is the heavier side of the operation compared to deserialization to the type.
RPC only returns the data already stored on blockchain (so it might not be finalized but we have this problem in everywhere and also it does not consider anything in the transaction pool). So from RPC standpoint it only return the valid hash at the exact time asked but then it might not be accurate for T + 1 but we can't do much about it. My recommendation is that we do not change the extrinsic implementations and only add following checks in
|
I like this. Simple and provides the number one thing we are missing: RPC safety. |
It is not good practice to not call your validate function in pre-dispatch. Your pre-dispatch must call your validation function. @aramikm If you intend to add it to pre-dispatch will this be included in the block. Thus, not much advantage over keeping it in the extrinsic. However, you might be saying to add it to both validate and pre-dispatch. I think these should be uniquely booted at the validation level. We have an example in one of our extrinsic. Overall, it is unclear to me how much of a problem this is. If it does become one we might need to revisit or storage solution. |
I disagree with "Check schema validity". We have plenty of extrinsics that check schema validity; what's the argument for checking only this one in pre_dispatch? Content hash is a special case unique to stateful storage, and the potential for a rejected call is outside the control of the caller. A bad schema ID is entirely the fault of the caller and within their control to prevent; no need to add a schema and/or delegation read to the pre_dispatch as well. |
@enddynayn I agree that this is uncommon, but I think this is a great example of a place to do it. We have a validation in the extrinsic that is (from my understanding) expensive to extract to The danger would be if someone thinks it is enough to just do the That said @aramikm, if the worry is that we have to add a database read, I don't think this is so. The caching layer would cache the first read in |
@wilwade I thought we wanted to prevent this from getting in the block and using capacity. I do not see why we would only add this to pre_dispatch. I guess I am unclear about the problem we are trying to solve. @wilwade I also don't think this is going to prevent nodes from gossiping about these type of transactions. Can you please update the description of what problems we are trying to solve? |
I believe all the questions have been resolved and the details are now in the issue description. If this is incorrect, please post the list of open questions. |
I don't think it would cost anything to keep the |
As someone transacting using stateful storage, I want to have my transaction stopped at the node level if I submit something with a bad
target_hash
so that I don't waste capacity on a transaction that will fail.Scenario
Checklist
Questions
pre_dispatch
as well asvalidate
?pre_dispatch
andvalidate
, we should remove the check in the extrinsicvalidate
, we cannot remove the extrinsic check, but also no weights etc...Draft PR: #1288
The text was updated successfully, but these errors were encountered: