-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Fix InvalidOperationException #3558
Conversation
@AnnaShaleva it seems that is not called inside the VM, could you also checked please? |
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.
A really nice catch and fix, especially for stackitem serialization, because it may affect contracts state. no fork required.
Inspired by neo-project/neo#3558, although this PR fixes different implementation of stackitem serializatior that is used outside of VM. Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
json["value"] = new JArray(((IList<KeyValuePair<ContractParameter, ContractParameter>>)parameter.Value).Select(p => | ||
{ | ||
JObject item = new(); | ||
item["key"] = ToJson(p.Key, context); | ||
item["value"] = ToJson(p.Value, context); | ||
return item; | ||
})); | ||
context.Remove(parameter); | ||
if (!context.Remove(parameter)) throw new InvalidOperationException("Circular reference."); |
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.
Why is this if
statement needed?
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 should not happen, but always is a good practice checks the methods returns
Description
Close #3553
Type of change
How Has This Been Tested?
Test Configuration:
Checklist: