Skip to content

fix: eth_sendRawTransaction now handles malformed RLP data correctly #3765

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

simzzz
Copy link
Contributor

@simzzz simzzz commented May 15, 2025

Description:
In this PR, the eth_sendRawTransaction logic now handles malformed RLP data correctly by checking for INVALID_ARGUMENT error and returning a predifined error and 400 status code.

Related issue(s):

Fixes #3652

Checklist

  • Documented (Code comments, README, etc.)
  • Tested (unit, integration, etc.)

simzzz added 2 commits May 15, 2025 18:00
Signed-off-by: Simeon Nakov <simeon.nakov@limechain.tech>
Signed-off-by: Simeon Nakov <simeon.nakov@limechain.tech>
@simzzz simzzz requested review from a team as code owners May 15, 2025 15:08
@simzzz simzzz requested a review from acuarica May 15, 2025 15:08
@lfdt-bot
Copy link

lfdt-bot commented May 15, 2025

🎉 Snyk checks have passed. No issues have been found so far.

security/snyk check is complete. No issues have been found. (View Details)

license/snyk check is complete. No issues have been found. (View Details)

Copy link

github-actions bot commented May 15, 2025

Test Results

 22 files  +  2  316 suites  +61   35m 38s ⏱️ - 1m 41s
640 tests +  3  632 ✅ +  1  5 💤 ±0  3 ❌ +2 
926 runs  +189  914 ✅ +183  5 💤 ±0  7 ❌ +6 

For more details on these failures, see this check.

Results for commit 2e41c24. ± Comparison against base commit 53b6777.

♻️ This comment has been updated with latest results.

@simzzz simzzz added the bug Something isn't working label May 16, 2025
@simzzz simzzz added this to the 0.69.0 milestone May 16, 2025
simzzz added 2 commits May 16, 2025 11:17
…ed behaviour

Signed-off-by: Simeon Nakov <simeon.nakov@limechain.tech>
Signed-off-by: Simeon Nakov <simeon.nakov@limechain.tech>
@simzzz simzzz self-assigned this May 16, 2025
simzzz added 4 commits May 16, 2025 13:38
Signed-off-by: Simeon Nakov <simeon.nakov@limechain.tech>
Signed-off-by: Simeon Nakov <simeon.nakov@limechain.tech>
Signed-off-by: Simeon Nakov <simeon.nakov@limechain.tech>
Signed-off-by: Simeon Nakov <simeon.nakov@limechain.tech>
Copy link
Contributor

@quiet-node quiet-node left a comment

Choose a reason for hiding this comment

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

Left some comments.

Comment on lines +40 to 46
} catch (e: any) {
if (e.message.toString().includes('unexpected junk after rlp payload')) {
throw predefined.INVALID_ARGUMENTS(e.message.toString());
}
throw predefined.INTERNAL_ERROR(e.message.toString());
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I’d suggest removing this overhead and simply returning INVALID_ARGUMENTS. At this point, the only operation that throws an error is the Transaction.from(), which functions as a parsing engine. If it fails, it indicates an issue with the transaction hash, which is the argument itself—so I believe there’s no need to use INTERNAL_ERROR here.

const invalidTx =
'0xf8748201280585800e8dfc0085800e8dfc00832dc6c094aca85ef7e1fce27079bbf99b60fcf6fd19b99b248502540be40080c001a0210446cfb671c3174392410d52fa3cd58723d8417e40cc67c6225b8f7e3ff693a02674b392846c59f783ea96655d39560956dd987051972064a5d853cea0b6f6d711';
await RelayAssertions.assertRejection(
predefined.INVALID_ARGUMENTS('invalid hex string'),
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmmm I wanna see the unexpected junk after rlp payload to be covered since this PR is aiming to fix that, right? How about we use the provided signed transaction for this?

Comment on lines +956 to +957
expect(() => Precheck.parseRawTransaction(invalidTx)).to.throw('Error invoking RPC: invalid BytesLike value');
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's test the unexpected junk after RLP payload issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix eth_sendRawTransaction 500 error when handling malformed RLP payloads
3 participants