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

cmd/evm: transaction validation tool #23494

Merged
merged 4 commits into from Sep 13, 2021
Merged

cmd/evm: transaction validation tool #23494

merged 4 commits into from Sep 13, 2021

Conversation

holiman
Copy link
Contributor

@holiman holiman commented Aug 29, 2021

This is a tool to fix #23486, provide a tool for test-makers to validate transactions, based on a fork but no state.

Follow-up to #23507

The input is a json string, the contents of which must be a hex-encoded RLP list.
The elements in the RLP list can be anything -- a transaction or a "hello world". If the input is not an RLP list, the input is considered invalid.

For each element in the list, validation is performed as if it were a transaction, and each result is (for now) echoed on the output (subject to change -- it'll be json eventually).

Example input data :

[user@work evm]$ cat ./signed_txs.rlp
"0xf8d2b86702f864010180820fa08284d09411111111111111111111111111111111111111118080c001a0b7dfab36232379bb3d1497a4f91c1966b1f932eae3ade107bf5d723b9cb474e0a06261c359a10f2132f126d250485b90cf20f30340801244a08ef6142ab33d1904b86702f864010280820fa08284d09411111111111111111111111111111111111111118080c080a0d4ec563b6568cd42d998fc4134b36933c6568d01533b5adf08769270243c6c7fa072bf7c21eac6bbeae5143371eef26d5e279637f3bd73482b55979d76d935b1e9"

Examples below no longer accurate, output format changed

On homestead:

[user@work evm]$ ./evm t9n --input.txs ./signed_txs.rlp --state.fork=Homestead
error deriving sender, tx 0, transaction type not supported
error deriving sender, tx 1, transaction type not supported

On London:

[user@work evm]$ ./evm t9n --input.txs ./signed_txs.rlp --state.fork=London
sender tx 0: 0xd02d72E067e77158444ef2020Ff2d325f929B363
sender tx 1: 0xd02d72E067e77158444ef2020Ff2d325f929B363

cc @winsvega

@holiman holiman changed the title cmd/evm: transaction validation tool [DRAFT] cmd/evm: transaction validation tool Aug 30, 2021
@winsvega
Copy link
Contributor

this can be the behaviour on t8n when pre and env are not provided.

@holiman
Copy link
Contributor Author

holiman commented Aug 31, 2021

this can be the behaviour on t8n when pre and env are not provided.

I'm not sure. I think it may be better to have very well-specified one-job tools, instead of having implicit behaviour changes based on the presence/absence of inputs.

@holiman holiman changed the title [DRAFT] cmd/evm: transaction validation tool cmd/evm: transaction validation tool Aug 31, 2021
@winsvega
Copy link
Contributor

winsvega commented Sep 1, 2021

I fhinished implementation on my side.

One question. The transaction hash calculation would always stay the same as "hash of (bytespayload)"
where bytes payload is rlp 0xf8... for legacy and 0x01f8.... 0x02f8.... for typed transactions?

test example:
https://github.com/ethereum/tests/pull/936/files

@holiman
Copy link
Contributor Author

holiman commented Sep 2, 2021 via email

@winsvega
Copy link
Contributor

winsvega commented Sep 2, 2021

the hash is just the hash of byte data that coming in?
string const hash = "0x" + dev::toString(dev::sha3(fromHex(_rlp.asString())));

so even if rlp is invalid it is still being calculated.
I can calculate the hash. Just to be super safe for the future, (what if the hash logic would change) we can export the hash from t9n for hash function verification.

@holiman
Copy link
Contributor Author

holiman commented Sep 2, 2021 via email

@holiman
Copy link
Contributor Author

holiman commented Sep 6, 2021

@winsvega hashes are now added. Please give it a spin and 👍 or 👎

@winsvega
Copy link
Contributor

winsvega commented Sep 7, 2021

doesn't compile

cmd/evm/internal/t8ntool/transaction.go:79:34: undefined: fmt

@winsvega
Copy link
Contributor

winsvega commented Sep 8, 2021

ok

@holiman
Copy link
Contributor Author

holiman commented Sep 9, 2021

@winsvega fixed, PTAL

@winsvega
Copy link
Contributor

winsvega commented Sep 9, 2021

Yes, it's good

Copy link
Member

@MariusVanDerWijden MariusVanDerWijden left a comment

Choose a reason for hiding this comment

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

SGTM

cmd/evm/internal/t8ntool/transaction.go Outdated Show resolved Hide resolved
@holiman holiman added this to the 1.10.9 milestone Sep 13, 2021
@holiman holiman merged commit babe9b9 into ethereum:master Sep 13, 2021
yongjun925 pushed a commit to DODOEX/go-ethereum that referenced this pull request Dec 3, 2022
* cmd/evm: transaction validation tool

* cmd/evm: add hash to t9n tool

* cmd/evm: lint nits

* cmd/evm: nitpicks
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.

t8ntool / evm transaction structure unit test interface
5 participants