Skip to content

Adding RPC log plugin: catch each rpc request and send log into GCS b… - #8

Draft
olegfomenko wants to merge 8 commits into
masterfrom
plugin/rpc-log
Draft

Adding RPC log plugin: catch each rpc request and send log into GCS b…#8
olegfomenko wants to merge 8 commits into
masterfrom
plugin/rpc-log

Conversation

@olegfomenko

Copy link
Copy Markdown
Member

Adding RPC log plugin: it catches each RPC request and sends the log to the GCS bucket

…ucket. WIP

Co-authored-by: Mykhailo Khotian
 <khotyanmisha@gmail.com>

Co-authored-by: Oleg Fomenko <oleg.fomenko2002@gmail.com>
@olegfomenko

Copy link
Copy Markdown
Member Author

TODO: from rune metadata get a requester info

@olegfomenko olegfomenko self-assigned this Aug 31, 2026
@olegfomenko
olegfomenko marked this pull request as draft August 31, 2026 15:58
@olegfomenko
olegfomenko requested a review from Nazarevsky August 31, 2026 15:59
@olegfomenko

Copy link
Copy Markdown
Member Author

Credits to @nepet for the idea and reference
Credits to @erdoganishe for the implementation parts and reference

Oleh Fomenko and others added 2 commits August 31, 2026 19:28
Co-authored-by: Oleg Fomenko <oleg.fomenko2002@gmail.com>
Co-authored-by: Oleg Fomenko <oleg.fomenko2002@gmail.com>

@Nazarevsky Nazarevsky left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That's already a lot of honest work here, Oleg! I totally understand that's the current implementation is sort of 'in draft', however, I left you a couple of suggestions aimed for the inner logic and possible (maybe not in the current PR) improvements that users might benefit from.


async fn upload_rpc_log(client: &Storage, bucket: &str, log: &RpcLog<'_>) -> Result<String> {
let timestamp = OffsetDateTime::now_utc();
let id = Uuid::new_v4();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we may cosider using UUIDv6 here since it supports time ordering. That way file names will explicitly tell about the log order.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Is it really needed? We already have a timestamp prefix for each file. The use of a UUID here is just additional protection to ensure that, with high probability, two files with the same name can't exist.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yup, sorry, missed that

Comment thread rpc-log-plugin/src/main.rs Outdated
}
};

upload_rpc_log(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

So, right now we're producing a log on an every RPC call. That means that on every command a plugin should communicate GCP in order to send log data. It might be ok in case of the node won't be queried with RPCs too much but it might be pretty nasty in big load periods.

Let's consider the other approach here. What about instead of querying GCS on an every call we have a local file. The file has append only attributes set up, so it is not possible to modify data in any way unless to append some more. On an every RPC call the hook appends a new log line into the file. Every 5 minutes the file gets rotated - it is pushed to GCS, new file is created. If no logs are produced within 5 minutes - no file is pushed.

The '5 min' constant is obviously configured here

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We are ok with pushing logs into GCS each time for now.

Comment thread rpc-log-plugin/src/main.rs Outdated
}
};

upload_rpc_log(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also, I think that we may allow a node operator to choose a list of RPC call for being logged in that way (or exclude some). The thing is that some of calls are not really crucial to be logged. E.g. observational calls like getinfo.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Its actually a great idea!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Added. By default, it will log only checkrune, which suits our use case - log mostly authorized methods

async fn upload_rpc_log(client: &Storage, bucket: &str, log: &RpcLog<'_>) -> Result<String> {
let timestamp = OffsetDateTime::now_utc();
let id = Uuid::new_v4();
let object_name = format!("rpc/{}-{id}.json", timestamp.format(&Rfc3339)?,);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hm, how about using jsonl instead? This file extension allows parsing json data line by line that might be helpful in case of really big files. Yes, currently we have one file for each log, but that's something that we can consider in case of using the 'rotation' approach that was described a couple of comments up from here

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

As I said above, I don't want to overcomplicate the plugin at this stage, so saving each log to the bucket is ok for now

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Actually, you can create an issue with this proposal, can be a good starting point for future improvements

Oleh Fomenko and others added 5 commits September 1, 2026 03:45
…runes in rpc call params and tries to parse it.

Co-authored-by: Oleg Fomenko <oleg.fomenko2002@gmail.com>
# Conflicts:
#	Cargo.lock
Co-authored-by: Oleg Fomenko <oleg.fomenko2002@gmail.com>
…g. By default - only checkrune rpc command will be logged.

Co-authored-by: Oleg Fomenko <oleg.fomenko2002@gmail.com>
…ing integration tests.

Co-authored-by: Oleg Fomenko <oleg.fomenko2002@gmail.com>
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.

2 participants