-
Notifications
You must be signed in to change notification settings - Fork 20.2k
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
cmd/evm: handle rlp errors in t9n #23771
Conversation
still have:
ah, I see. thats because it is invalid RLP I don't catch error exit codes from retesteth. any error exit code treated as a failure. the invalid rlp handling needed only for t9n. |
hmm still failing with valid rlp but malicious field in structure:
I put 00 prefix to transaction gasPrice when it is expected to be integer (no leading zeros) |
Could you please provide sample rlp? |
I tested this now, here's what I get:
It's as expected, no? One transaction, we can't derive sender / hash, because it fails to even marshal it as a transaction.
rlp: |
It is a failure. t9n is a tool to validate transactions, not block bodies. You are supposed to feed it valid rlp. |
rlp that crashes t8ntool
t9n was doing it fine all the way. |
Ah, right, so it's |
So -- what would you expect |
Translate valid rlp (but invalid structure coded in rlp) trandactions into error message like you do with transactions that fail (oog/evm exception) Will it check geth core logic since its in t8n? |
Well, that's kind of how it is now. Geth internally iterates over a slice of transactions, meaning that in order to even reach the point where it starts applying transactions, the payload must be parse:able into a slice of transactions. Which means that errors such as So if you want me to change that, then that change will make |
No. On contrary I want the logic to be the same as if it was a real block coming with such rlp. Just need to catch an exception and report it somehow so the t8n doesn't crash. An invalid tr we would have one at a time. |
Well, |
Can this exit be supressed and instead write an error message in outalloc.json result section? |
Like, right now it returns:
Want:
|
The
? |
No, I am talking about t9n output. It is the same format of output t9n use to report other errors. In t8n case it would be good to place an error here in outAlloc
|
Right, ok. Now I understand what you ask. And that's doable, yes, however,
TLDR; you're both asking that we change it to not validate the transactions as if they were a block body (parse all of them at the same time, and reject them all if there's an error) - but instead parse/apply them one at a time, _and that we stick to what geth does internally. Those are two conflicting requirements. |
No. Don't change the core logic. As I understand you construct a block from the input data and feed to evm then it raises the exception. I just need the exception. If block has a malicious transaction I understand that it is invalid. No need to check transactions befor calling the evm. (This is for t8n) So if possible to catch that abort of procedure in t8n, just return in outAlloc the same pre state and exception message in rejected. |
I don't know, it feels like a hack. The You're suggesting to simply handle invalid rlp as if it were an error on tx I'd rather either make t8n do like t9n, or leave it as it is. |
And having prefixed zeroes in transaction field is the same level of error as having unreadable rlp? Meaning t8n can't produce an error message per transaction if one transaction has leading zeroes kind of rlp error? Another option perhaps I can catch error exit code, but that one doesn't tell me the exception string. I am not sure how I can get error log when running multiple instances of t8n simultaneously, I should have a look. Perhaps t8n could export stderr to logfile? |
Let's go one issue at a time. Can you make t9n transaction tool catch and report invalid rlp exceptions the same way it reports prefixed 00 fields? |
Like this |
No. As I've said: the input to
We can change that, so e.g it can output some sort of json toplevel error, but it will not look the same way, structurally, as if one of the txs has bad rlp encoding. |
Ok then perhaps this would be a solution. Since I see the error message I need in error log. If t9n/t8n return with error code of invalid rlp input. Using the option --errorlog /path/to/stderrfile Can you make such an option? |
* cmd/evm: handle rlp errors in t9n * cmd/evm/testdata: fix readme
* cmd/evm: handle rlp errors in t9n * cmd/evm/testdata: fix readme
This PR closes #23770, by checking the iterator error when handling transactions.
The input to the tool is expected to be valid rlp, containing binary blobs of potentially invalid transactions. As opposed to invalid rlp. If invalid RLP is input, then the tool should exit with error code
11
.