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

Add debug mode to the applicationlog to get log info #842

Closed
wants to merge 4 commits into from

Conversation

Jim8y
Copy link
Contributor

@Jim8y Jim8y commented Nov 12, 2023

Closes #841

This pr focus on adding a debug mode to the applicationlog plugin such that developers can get the transaction execution log via the rpc interface.

What has changed?

  • The config adds a debug field.
  • Added Log monitor logic.
  • Logs field will be added to the json response under debug mode.
  • Update the rpcclient to support logs in response.

Will this impact other tools?

No

@Jim8y Jim8y marked this pull request as draft November 12, 2023 17:42
@Jim8y
Copy link
Contributor Author

Jim8y commented Nov 12, 2023

@cschuchardt88 just finished coding, not tested yet, but you can take a look. Will finish it tomorrow.

@cschuchardt88
Copy link
Member

Still need to update RpcClient RpcApplicationLog Class. neo-express uses that for FromJson

@shargon
Copy link
Member

shargon commented Nov 12, 2023

Why only during debug? It seems reasonable to get this information always

@Jim8y
Copy link
Contributor Author

Jim8y commented Nov 13, 2023

Why only during debug? It seems reasonable to get this information always

This changes the response message size and processing time, without a solid test, i dare not add it directly in fear of DOS attacks. So, debug mode first. But we can also go straightforward to add it for production env if you think it is OK.

@vncoelho
Copy link
Member

In this case, test the potential DOS first would be good. And leave as not default for now.

@Jim8y
Copy link
Contributor Author

Jim8y commented Nov 13, 2023

@cschuchardt88 this will not be merged until we have a monorepo.

@cschuchardt88
Copy link
Member

@Liaojinghui @vncoelho PR #807 should be able to handle any amount of logs.

@Liaojinghui also im updating PR #807 for these new changes. Can you give an example template of the json? or is it the same as what I posted in #841

@Jim8y
Copy link
Contributor Author

Jim8y commented Nov 13, 2023

@Liaojinghui @vncoelho PR #807 should be able to handle any amount of logs.

@Liaojinghui also im updating PR #807 for these new changes. Can you give an example template of the json? or is it the same as what I posted in #841

Exactly the same as you posted

{
if (!Settings.Default.Debug) return;

var tx = ((Transaction)args.ScriptContainer).Hash;
Copy link
Member

Choose a reason for hiding this comment

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

It can be not only a transaction, right? E.g. block for OnPersist and PostPersist execution results.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It can be not only a transaction, right? E.g. block for OnPersist and PostPersist execution results.

I think it can only be transaction, but i might be wrong. May you please confirm @shargon @roman-khimov

["contract"] = args.ScriptHash.ToString(),
["message"] = args.Message
};
logList?.Add(logJson);
Copy link
Member

Choose a reason for hiding this comment

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

Why do you need ? here? logList is always non-null.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why do you need ? here? logList is always non-null.

It is possible since in the else block, the assignment might be null.

@@ -18,13 +18,16 @@ internal class Settings
public uint Network { get; }
public int MaxStackSize { get; }

public bool Debug { get; }
Copy link
Member

Choose a reason for hiding this comment

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

Are we planning to enable this setting in public networks?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could, after solid test and monorepo. but now this is only to answer the need of @cschuchardt88 on neo-express.

Comment on lines +38 to +39
if (Settings.Default.Debug)
ApplicationEngine.Log += ApplicationEngine_Log;
Copy link
Member

Choose a reason for hiding this comment

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

It's a nice feature. How about adding the same ability to add logs to execution result for invokescript, invokefunction and etc. in debug mode? This change is more invasive and requires changing the core library as far, but it might be useful for someone.

Copy link
Member

Choose a reason for hiding this comment

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

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.

ApplicationLog Output LogEventArgs
5 participants