Skip to content
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

OnPersist and PostPersist have the same application log hash #354

Closed
fyrchik opened this issue Sep 24, 2020 · 15 comments · Fixed by neo-project/neo#2022
Closed

OnPersist and PostPersist have the same application log hash #354

fyrchik opened this issue Sep 24, 2020 · 15 comments · Fixed by neo-project/neo#2022
Assignees

Comments

@fyrchik
Copy link

fyrchik commented Sep 24, 2020

Describe the bug
After addition of postPersist method, we have 2 scripts with their own application logs (onPersist and postPersist), which are both saved and queried by the block hash.
https://github.com/neo-project/neo-modules/blob/master/src/ApplicationLogs/LogReader.cs#L78

Expected behavior
Both onPersist and postPersist scripts should be accessible for query by getapplicationlog RPC.

@roman-khimov
Copy link
Contributor

IMO the situation is a little worse than just an RPC problem, because it's impossible to differentiate between these two ApplicationExecuted events generated by the system, so all users of this event stream might be affected.

@Tommo-L
Copy link
Contributor

Tommo-L commented Oct 9, 2020

I think it's reasonable, onPersist and postPersist, which are both saved and queried by the block hash.

@roman-khimov
Copy link
Contributor

So, how do we store both with the same key and which one do we return when there is a getapplicationlog request for block hash?

@Tommo-L
Copy link
Contributor

Tommo-L commented Oct 9, 2020

I got your point, they both use the same storage key.

@erikzhang
Copy link
Member

I prefer to use different triggers.

@shargon
Copy link
Member

shargon commented Oct 13, 2020

Does we need to publish the result Context.System.EventStream.Publish(application_executed); ?

@roman-khimov
Copy link
Contributor

Absolutely. Events are important and events can be generated in any execution context, be it block or transaction. And they're generated already for blocks (GAS burn/mint events).

@Tommo-L
Copy link
Contributor

Tommo-L commented Oct 15, 2020

I prefer to use different triggers.

Any more details about "different triggers"?

@superboyiii
Copy link
Member

@erikzhang Any solution? Or shall we move it to the version after preview4?

@erikzhang
Copy link
Member

https://github.com/neo-project/neo/blob/6fc4161258408cae3d754cab784dcee2235b63ef/src/neo/SmartContract/TriggerType.cs#L5-L27

We can use different triggers to call these two methods.

@roman-khimov
Copy link
Contributor

I don't think we can close this one. neo-project/neo#2022 makes it possible to solve this, but we still need to decide how to store and request these.

@shargon shargon reopened this Oct 29, 2020
@Tommo-L
Copy link
Contributor

Tommo-L commented Oct 30, 2020

#380 fixed?

@roman-khimov
Copy link
Contributor

Not yet, it solves storage problem, but getapplicationlog needs to be updated to take this change into account. The way #380 is now actually breaks the plugin completely, GetApplicationLog still does db.Get(ReadOptions.Default, hash.ToArray()) and now the key has changed.

We'll probably need another parameter for getapplicationlog (trigger) and then decide on behavior for requests lacking this parameter (for transactions that's easy, but for blocks I'd probably answer with an array of execution results for different triggers).

@Tommo-L
Copy link
Contributor

Tommo-L commented Nov 16, 2020

Close? I think it was fixed by #380

@roman-khimov
Copy link
Contributor

Yep, I think we're fine now. We've implemented the same scheme in neo-go and it works.

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 a pull request may close this issue.

6 participants