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: add more docs for t8n, t9n, and b11r #26111

Closed
wants to merge 2 commits into from

Conversation

lightclient
Copy link
Member

The EELS team is getting ready to implement t8n and b11r so they can join in on the test-filling-fun. I tried to include some more information about that actual structure of the different objects used as input and returned as output from the various tools. I also wanted to make a note of where to look for conformance tests as other clients look to implement the evm utility.

Comment on lines +67 to +77
// Map of address to account definition.
type Alloc map[common.Address]Account

// Genesis account. Each field is optional.
type Account struct {
Code []byte `json:"code"`
Storage map[common.Hash]common.Hash `json:"storage"`
Balance *big.Int `json:"balance"`
Nonce uint64 `json:"nonce"`
SecretKey []byte `json:"secretKey"`
}
Copy link

Choose a reason for hiding this comment

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

For those of us that don't speak go as fluently, how do these get translated into JSON? Especially the big.Int fields.

Copy link
Member Author

Choose a reason for hiding this comment

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

I added a note on encoding at the bottom, but basically we use a intermediary type math.HexOrDecimalN which can decode json strings that are either hex format or decimal format.

@holiman
Copy link
Contributor

holiman commented Nov 5, 2022

A little-known and, to be honest, pretty hidden fact, is that the README.md here can be/is fully generated from the script https://github.com/ethereum/go-ethereum/blob/master/cmd/evm/transition-test.sh. From the start, I felt that it's a PITA to write a lot of examples and copy-paste terminal outputs, so I decided to write a script to generate it instead.

That way, if the input or output changes, those changes will be reflected in the documentation, as long as we just remember to regenerate it from time to time.

@holiman
Copy link
Contributor

holiman commented Nov 5, 2022

And also, another idea I had was that the exact same script, when executed against a different but spec-compliant t8n implementation, would spit out a nearly identical readme.

I always wanted the framework around t8n to not be only golang-specific, but that it should be usable for non-golang implementations too.

@lightclient
Copy link
Member Author

Ah shoot didn't realize that existed! I was thinking of doing something similar, but decided to just do it manually to save time 😅. Okay, let me look into that and update.

The encoding of values for `evm` utility attempts to be relatively flexible. It
generally supports hex-encoded or decimal-encoded numeric values, and
hex-encoded byte values (like `common.Address`, `common.Hash`, etc). When in
doubt, the [`execution-apis`](https://github.com/ethereum/execution-apis) way

Choose a reason for hiding this comment

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

Do you know why the receipt in the output of evm t8n is different to the receipt in the output of eth_getTransactionReceipt?

For a simple transfer, I'm getting:
evm t8n

"logs": null,
"contractAddress": "0x0000000000000000000000000000000000000000",

eth_getTransactionReceipt:

"logs":[],
"contractAddress":null,

For eth_getTransactionReceipt, I tried a local erigon node and alchemy.io. I don't have a geth node to try against. execution-apis would consider the evm t8n output to be invalid.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think there is a particular reason, it's just that the way we marshal the receipt for RPC uses a custom marshaller in internal/ethapi/api.go#L1626 and here we just use the default golang json marshaller.

* transaction tool (t9n) : a transaction validation utility
* block builder tool (b11r): a block assembler utility

## State transition tool (t8n)

Choose a reason for hiding this comment

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

You should add a discussion of how t8n handles invalid transactions. I found the fact it skips them and keeps going somewhat surprising.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think this choice of behavior is because t8n is a filler tool and if you ask to fill and invalid state transition for a test, it will do the best it can (just in case the client it eventually tests against also fails to process the tx, but somehow doesn't cause the whole block to fail).

@@ -45,27 +54,175 @@ Command line params that has to be supported are

```

### Error codes and output
#### Objects

Choose a reason for hiding this comment

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

You haven't described the rejected section for transactions that are rejected. Also are other implementations required the reproduce the error strings exactly? If so, we need a comprehensive list of possible strings.

Copy link
Member Author

Choose a reason for hiding this comment

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

As long as the tx is correctly rejected, that is enough I think. If you want a (I think) a full list of possible errors, see core/errors.go.

@holiman
Copy link
Contributor

holiman commented Dec 7, 2022

I've incorporated half of these changes into #26314, since I had to update the script and some docs anyway. Will keep this PR open until we've migrated the rest of the content too.

@holiman
Copy link
Contributor

holiman commented Dec 27, 2022

Closing in favour of #26385

@holiman holiman closed this Dec 27, 2022
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.

4 participants