-
Notifications
You must be signed in to change notification settings - Fork 33
SC: Fix read_only flag in call traces and make code cleaner in read only processing #1410
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
Conversation
| const uint32_t ordinal = 1; | ||
| action_trace& current_action_trace; | ||
| const account_name sender{}; | ||
| const uint64_t flags = 0; |
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.
It seems like don't really even need flags any more in the current implementation -- until some time in the future where maybe needing more flags.
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.
Do you mean we remove flags from the entry point function? That would remove the ability of a call to tell if it is read only or not. But not sure how useful it is as read-only is enforced at the protocol level.
An advantage of flags is it would be simpler to extend in the future without changing entry point signature.
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.
No, I'm referring to flags in sync_call_context. afaict it's currently unnecessary and actually burdens your implementation a little since you mutate the passed flags,
spring/libraries/chain/host_context.cpp
Lines 47 to 51 in fd03667
| // Update next call's flags based on is_next_call_read_only | |
| uint64_t updated_flags = flags; // get the default values | |
| if (is_next_call_read_only) { | |
| updated_flags = set_field(flags, sync_call_flags::force_read_only); | |
| } |
I approved because I don't think you need to get rid of it but I think it would slightly reduce quantity of code
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.
oh I see. I removed it as it is not needed, and we can add it back when needed as it is an implementation thing and won't break consensus.
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.
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.
You can simplify more. For example the removal of updated_flags and then just pass a bool to sync_call_context's ctor
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.
Thanks! I was a little hesitant to remove the flags in the constructor but that makes code even simpler. Let's do it.
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.
| all_allowed_bits = read_only | ||
| // `force_read_only` is a user's directive to the system, telling the system whether | ||
| // the new call context created must operate in read-only mode or if it is | ||
| // free to operate under its most permissible mode. |
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.
imo this description is missing a key point that with the flag clear it inherits the "readonlyness" from the calling context
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.
Thanks. I will reword the comments.
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.
read_onlyflag istruefor all subsequent call traces after the first call whoseread_onlyflag istrueread_onlyenum toforce_read_onlyand introduceread_onlyto call_context to make code cleanerread_onlyflag values are correct in call tracesResolves #1408