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

core/types: improve error for too short transaction / receipt encoding #24256

Merged
merged 5 commits into from
Mar 9, 2022

Conversation

Juicestus
Copy link
Contributor

Because the switch statement checks for EIP-2718 (String and Bytes) and legacy (List) transactions, the default should throw an error expecting the newer String and Bytes rather than the List. Changed return rlp.ErrExpectedList to return rlp.ErrExpectedString in the default cases.

closes #24227

@fjl
Copy link
Contributor

fjl commented Jan 20, 2022

I think this issue is being extremely picky. The only case where this error will happen is when trying to decode the transaction from a single byte, i.e. input 0x01. We could just work around this by removing the default: completely and always attempt to parse as a typed tx.

Copy link
Contributor

@holiman holiman left a comment

Choose a reason for hiding this comment

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

LGTM

@holiman
Copy link
Contributor

holiman commented Mar 7, 2022

Needs this fix

diff --git a/cmd/evm/testdata/15/exp3.json b/cmd/evm/testdata/15/exp3.json
index 6c46d267cf..b5a6c3324d 100644
--- a/cmd/evm/testdata/15/exp3.json
+++ b/cmd/evm/testdata/15/exp3.json
@@ -21,19 +21,19 @@
     "error": "transaction type not supported"
   },
   {
-    "error": "rlp: expected List"
+    "error": "transaction type not supported"
   },
   {
-    "error": "rlp: expected List"
+    "error": "EOF"
   },
   {
-    "error": "rlp: expected List"
+    "error": "EOF"
   },
   {
-    "error": "rlp: expected List"
+    "error": "EOF"
   },
   {
-    "error": "rlp: expected List"
+    "error": "transaction type not supported"
   },
   {
     "error": "rlp: expected input list for types.AccessListTx"

@fjl
Copy link
Contributor

fjl commented Mar 7, 2022

I don't want to merge this as-is because returning io.EOF as an error is not good. I will improve the error.

@fjl
Copy link
Contributor

fjl commented Mar 8, 2022

Actually, this uncovered that rlp.DecodeBytes returns io.EOF for empty input. I don't dare change that right now, but it's wrong. It should return io.ErrUnexpectedEOF instead.

@fjl fjl added this to the 1.10.17 milestone Mar 8, 2022
@fjl fjl merged commit d1f6a9f into ethereum:master Mar 9, 2022
@fjl fjl changed the title core/types: change default for DecodeRLP in transaction and recipt core/types: improve error for too short transaction / receipt encoding Mar 9, 2022
sidhujag pushed a commit to syscoin/go-ethereum that referenced this pull request Mar 9, 2022
JacekGlen pushed a commit to JacekGlen/go-ethereum that referenced this pull request May 26, 2022
cp-wjhan pushed a commit to cp-yoonjin/go-wemix that referenced this pull request Nov 16, 2022
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 2, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 6, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 9, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 9, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 9, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 10, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 12, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 12, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 19, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 19, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 19, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 21, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 22, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 22, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 23, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 23, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 26, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 26, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 27, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Oct 9, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Oct 17, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Oct 18, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Oct 25, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Oct 25, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Oct 29, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Oct 30, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Oct 31, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Oct 31, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Nov 1, 2024
wanwiset25 pushed a commit to XinFinOrg/XDPoSChain that referenced this pull request Nov 13, 2024
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.

core: error message is not relevant anymore
3 participants