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

Extract t8n arguments from daemon query string #1030

Merged
merged 1 commit into from
Nov 12, 2024

Conversation

SamWilsn
Copy link
Collaborator

@SamWilsn SamWilsn commented Nov 6, 2024

What was wrong?

Closes #1029
Closes #1006

How was it fixed?

This commit allows daemon clients to pass command line arguments in the query string (under the key arg.) To add multiple arguments, use multiple key/value pairs. For example:

curl --unix-socket /run/user/1000/ethereum-spec-evm/daemon.sock 'http://localhost/?arg=--help'
curl --unix-socket /run/user/1000/ethereum-spec-evm/daemon.sock 'http://localhost/?arg=--help&arg=--state-test'

Cute Animal Picture

Put a link to a cute animal picture inside the parenthesis-->

@SamWilsn
Copy link
Collaborator Author

SamWilsn commented Nov 6, 2024

This is paired with petertdavies/ethereum-spec-evm-resolver#5

@marioevz
Copy link
Member

marioevz commented Nov 6, 2024

It seems to be working when passing a single parameter as "?key=--state-test" for example, but when passing none is complaining with the following error:

Exception occurred during processing of request from ['local', 0]                                                                    
Traceback (most recent call last):                                                                                                   
  File "/usr/lib/python3.10/socketserver.py", line 316, in _handle_request_noblock                                                   
    self.process_request(request, client_address)                                                                                    
  File "/usr/lib/python3.10/socketserver.py", line 347, in process_request                                                           
    self.finish_request(request, client_address)                                                                                     
  File "/home/marioevz/.cache/ethereum-spec-evm-resolver/Cancun/src/ethereum_spec_tools/evm_tools/daemon.py", line 100, in finish_req
uest                                                                                                                                 
    super().finish_request(request, client_address)                                                                                  
  File "/usr/lib/python3.10/socketserver.py", line 360, in finish_request                                                            
    self.RequestHandlerClass(request, client_address, self)                                                                          
  File "/usr/lib/python3.10/socketserver.py", line 747, in __init__                                                                  
    self.handle()                                                                                                                      File "/usr/lib/python3.10/http/server.py", line 433, in handle                                                                     
    self.handle_one_request()                                                                                                        
  File "/usr/lib/python3.10/http/server.py", line 421, in handle_one_request                                                         
    method()                                                                                                                         
  File "/home/marioevz/.cache/ethereum-spec-evm-resolver/Cancun/src/ethereum_spec_tools/evm_tools/daemon.py", line 62, in do_POST    
    query = parse_qs(                                                                                                                
  File "/usr/lib/python3.10/urllib/parse.py", line 714, in parse_qs                                                                  
    pairs = parse_qsl(qs, keep_blank_values, strict_parsing,                                                                         
  File "/usr/lib/python3.10/urllib/parse.py", line 775, in parse_qsl                                                                 
    raise ValueError("bad query field: %r" % (name_value,))                                                                          
ValueError: bad query field: ''

I'm debugging to see if I can find the issue, I tried passing empty string and "?" but same behavior.

@SamWilsn
Copy link
Collaborator Author

SamWilsn commented Nov 6, 2024

What's the full URL you're using?

@marioevz
Copy link
Member

marioevz commented Nov 6, 2024

What's the full URL you're using?

This is an example I obtained from the resolver right before sending the query:
With --state-test:

http+unix://%2Ftmp%2Ftmp5975ll06%2FCancun.3885864.sock/?arg=--state-test

Without --state-test:

http+unix://%2Ftmp%2Ftmpjshog8l0%2FCancun.3886038.sock/

@marioevz
Copy link
Member

marioevz commented Nov 6, 2024

I reproduced locally and it seems like parse_qs complains if the result from urlparse(self.path).query is an empty string, which is the case if no arguments are passed.

It's a weird behavior from parse_qs IMO, but the easiest solution seems to be to skip the query parsing altogether in the case that urlparse(self.path).query is an empty string.

I tested locally and it seems to work, but let me know what you think.

@SamWilsn
Copy link
Collaborator Author

SamWilsn commented Nov 6, 2024

That's really odd. Only thing I can think of is that I'm in Python 3.12, and maybe they changed the behaviour? Pushed a fix; let me know if it works for you.

Copy link
Member

@marioevz marioevz left a comment

Choose a reason for hiding this comment

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

LGTM.

Last change seems to have fixed my issue, thanks!

@gurukamath gurukamath merged commit 5e8aeb3 into ethereum:master Nov 12, 2024
5 checks passed
@SamWilsn SamWilsn deleted the daemon-args branch November 21, 2024 16:06
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.

3 participants