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

Fix bug report request IDs being reset when using multiple KoreClients #4480

Merged
merged 18 commits into from
Jun 27, 2024

Conversation

nwatson22
Copy link
Member

@nwatson22 nwatson22 commented Jun 25, 2024

Fixes #4478.

We were generating response json files for bug reports in a non-unique way so that when we have multiple JsonRpcClients they will overwrite each other's response files. This change ensures that each client will have a unique ID associated which will be included in the path of the response files generated by that client so there are no more name conflicts.

Tested generating bug reports for kontrol prove and kevm prove.

@nwatson22 nwatson22 self-assigned this Jun 25, 2024
@rv-jenkins rv-jenkins changed the base branch from master to develop June 25, 2024 17:48
@@ -291,23 +291,24 @@ def close(self) -> None:
self._transport.close()

def request(self, method: str, **params: Any) -> dict[str, Any]:
old_id = self._req_id
# Generate unique ID regardless of different clients, repeated requests from the same client, etc.
uid = hash_str((id(self), self._req_id))
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this mean that the requests will no longer be linear? If they are not, is there any way of establishing the correct order in the bug reports?

Copy link
Member Author

Choose a reason for hiding this comment

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

My understanding is that the order is determined by the ordering of the commands files, which are bash scripts that refer to the request files, and those are still named using a counter. This would only be changing the names of the request files (and the IDs of the requests referred to in the requests themselves)
See:

def add_command(self, args: Iterable[str]) -> None:

Copy link
Contributor

@tothtamas28 tothtamas28 left a comment

Choose a reason for hiding this comment

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

LGTM, let's consider further refactorings.

self._bug_report.add_file_contents(req, Path(bug_report_request))
self._bug_report.add_command(self._transport.command(self._bug_report_id, old_id, bug_report_request))
self._bug_report.add_command(self._transport.command(req_name, bug_report_request))
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder, is it possible to pull all this logic into Transport (and its subclasses)? Then command and client_id can become private on Transport.

@nwatson22 nwatson22 requested a review from tothtamas28 June 27, 2024 15:52
pyk/src/pyk/kore/rpc.py Outdated Show resolved Hide resolved
pyk/src/pyk/kore/rpc.py Outdated Show resolved Hide resolved
pyk/src/pyk/kore/rpc.py Outdated Show resolved Hide resolved
pyk/src/pyk/kore/rpc.py Outdated Show resolved Hide resolved
@nwatson22 nwatson22 requested a review from tothtamas28 June 27, 2024 17:35
Comment on lines 62 to 64
def __init__(self, bug_report_id: str | None = None, bug_report: BugReport | None = None) -> None:
self._bug_report_id = bug_report_id
self._bug_report = bug_report
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
def __init__(self, bug_report_id: str | None = None, bug_report: BugReport | None = None) -> None:
self._bug_report_id = bug_report_id
self._bug_report = bug_report
def __init__(self, bug_report: BugReport | None = None, bug_report_id: str | None = None) -> None:
self._bug_report = bug_report
self._bug_report_id = bug_report_id

Copy link
Contributor

Choose a reason for hiding this comment

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

Is it valid to have a bug_report_id but not a bug_report? If it isn't, ValueError should be raised when it happens.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added this error.

pyk/src/pyk/kore/rpc.py Outdated Show resolved Hide resolved
@@ -87,7 +123,8 @@ class SingleSocketTransport(Transport):
_sock: socket.socket
_file: TextIO

def __init__(self, host: str, port: int, *, timeout: int | None = None):
def __init__(self, host: str, port: int, *, timeout: int | None = None, **kwargs: Any):
super().__init__(**kwargs)
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider just explicitly listing kwargs here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

Copy link
Contributor

@tothtamas28 tothtamas28 left a comment

Choose a reason for hiding this comment

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

Before merging, please test this on evm-semantics and kontrol.

nwatson22 and others added 3 commits June 27, 2024 16:07
@rv-jenkins rv-jenkins merged commit 67edd93 into develop Jun 27, 2024
18 checks passed
@rv-jenkins rv-jenkins deleted the noah/bug-report-fix branch June 27, 2024 22:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Backend bug-reporting broken due to request enumeration being reset
4 participants