Skip to content

Conversation

@linh2931
Copy link
Contributor

  • Fix read_only flag in call traces such that read_only flag is true for all subsequent call traces after the first call whose read_only flag is true
  • Rename read_only enum to force_read_only and introduce read_only to call_context to make code cleaner
  • Add more comments explaining read_only request by the user and read_only state of the call_context
  • Add tests to verify read_only flag values are correct in call traces

Resolves #1408

@linh2931 linh2931 linked an issue Apr 20, 2025 that may be closed by this pull request
@linh2931 linh2931 requested review from heifner and spoonincode April 20, 2025 18:56
const uint32_t ordinal = 1;
action_trace& current_action_trace;
const account_name sender{};
const uint64_t flags = 0;
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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,

// 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

Copy link
Contributor Author

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.
Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Base automatically changed from call_trace to sync_call April 23, 2025 23:33
@linh2931 linh2931 merged commit 72fdc46 into sync_call Apr 23, 2025
36 checks passed
@linh2931 linh2931 deleted the ro_trace_fix branch April 23, 2025 23:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SC: Make sure read-only flags in call_traces are consistent

4 participants