-
Notifications
You must be signed in to change notification settings - Fork 52
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: implement getInsecureTime precompile #278
feat: implement getInsecureTime precompile #278
Conversation
suave/gen/suave_spec.yaml
Outdated
@@ -475,3 +475,11 @@ functions: | |||
- name: message | |||
type: bytes | |||
description: "Decrypted message" | |||
- name: getInsecureTime | |||
address: "0x000000000000000000000000000000007770000c" | |||
description: "Returns the current Kettle Unix time in seconds." |
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.
would be good to add ", insecure because it assumes trust in Kettle's clock" or something like that to the description plz
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.
To really ensure the precompile isn't returning a bogus number (although the code is sound; I'm sure it won't), you could also check the system time after calling the precompile, so that you could ultimately assert start_time
precompile_time
now_time
.
But otherwise the code is solid. Thanks for the PR @pistomat!
Good idea, maybe we should add some basic checks also to the precompile so even if the TEE operator does mess with it, there are bounds? ideally shouldnt be a time before chain genesis time or outside of |
Nice idea! The bounds should be Also FYI I chose |
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.
Good call on the boundary checks. LGTM otherwise.
Is this precompile also be available in normal Suave onchain transactions (not CCR)? @dmarzzz @ferranbt If so, I think we should also set the return value to the This does not matter for CCRs, because they are processed only on a single Kettle, as opposed to Suave blocks, where all precompile return values should be deterministic (otherwise you can't validate blocks). |
This precompile is not available on the Suave chain, only in the CCR context. |
Updated the description @dmarzzz. In the end I did not add any bounds for the time returned, because the lower bound of P.S. I will add a PR to the suave-std repo to call this precompile after this one is merged. |
Nice! I will run the CI and merge if it passes. You do not need to update suave-std, it is done automatically. |
Updated the precompile to use |
📝 Summary
Implementation of the
getInsecureTime
precompile that returns the Kettle Unix time.Considerations
📚 References