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

EIP 2537 state tests #712

Closed
wants to merge 2 commits into from
Closed

EIP 2537 state tests #712

wants to merge 2 commits into from

Conversation

shamatar
Copy link

@shamatar shamatar commented Jul 9, 2020

Based on the original test vectors from my repo (linked in EIP text).

All test pass on monkey-patched (add new test YoloV1 network for retesteth command) Geth based on commit fa01117498a580f8de35e026f7e0ab38313868dd from https://github.com/ethereum/go-ethereum master branch.

Test fillers are committed without other changes (I suppose).

@shamatar
Copy link
Author

shamatar commented Jul 9, 2020

Contract source that performs the calls

pragma solidity ^0.6.0;

contract EIP2537Caller {
    function call_with_mutation(address _address, bytes memory _data) public payable returns (bool success, bytes memory out) {
        (success, out) = _address.staticcall(_data);
        bytes32 output = keccak256("error");
        if (success) {
            output = keccak256(out);
        }
        assembly {
            sstore(0x02, output)
        }
        return (success, out);
    }
}

@winsvega
Copy link
Collaborator

winsvega commented Jul 9, 2020

Thanks. This PR shows that there is a need for .yml + solidity support.

Also note if you use the same contract code allover again and only the input tx data changes. you can specify multiple data in one test to be executed on that same contract. and check each result by tx indexes (put comments which data index do which test) so it is possible to put all those tests into one file.

@winsvega
Copy link
Collaborator

winsvega commented Jul 9, 2020

As aleth is gone and geth retesteth is not supported. it's a quiate hard time for the testing tools.
We are developing new tools for test generation and we really need your feedback.

I am using the geth transition tool protocol to generate your tests.
Here is my trace log:

./retesteth -t GeneralStateTests/stEIP2537 -- --clients "t8ntool" --filltests --singletest fp_to_g1_93 --vmtrace
{"pc":0,"op":96,"gas":"0x6a7a84","gasCost":"0x3","memory":"0x","memSize":0,"stack":[],"returnStack":[],"depth":1,"refund":0,"opName":"PUSH1","error":""}
{"pc":2,"op":96,"gas":"0x6a7a81","gasCost":"0x3","memory":"0x","memSize":0,"stack":["0x80"],"returnStack":[],"depth":1,"refund":0,"opName":"PUSH1","error":""}
{"pc":4,"op":82,"gas":"0x6a7a7e","gasCost":"0xc","memory":"0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","memSize":96,"stack":["0x80","0x40"],"returnStack":[],"depth":1,"refund":0,"opName":"MSTORE","error":""}
{"pc":5,"op":96,"gas":"0x6a7a72","gasCost":"0x3","memory":"0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080","memSize":96,"stack":[],"returnStack":[],"depth":1,"refund":0,"opName":"PUSH1","error":""}
{"pc":7,"op":54,"gas":"0x6a7a6f","gasCost":"0x2","memory":"0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080","memSize":96,"stack":["0x4"],"returnStack":[],"depth":1,"refund":0,"opName":"CALLDATASIZE","error":""}
{"pc":8,"op":16,"gas":"0x6a7a6d","gasCost":"0x3","memory":"0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080","memSize":96,"stack":["0x4","0x40"],"returnStack":[],"depth":1,"refund":0,"opName":"LT","error":""}
{"pc":9,"op":97,"gas":"0x6a7a6a","gasCost":"0x3","memory":"0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080","memSize":96,"stack":["0x0"],"returnStack":[],"depth":1,"refund":0,"opName":"PUSH2","error":""}
{"pc":12,"op":87,"gas":"0x6a7a67","gasCost":"0xa","memory":"0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080","memSize":96,"stack":["0x0","0x1e"],"returnStack":[],"depth":1,"refund":0,"opName":"JUMPI","error":""}
{"pc":13,"op":96,"gas":"0x6a7a5d","gasCost":"0x3","memory":"0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080","memSize":96,"stack":[],"returnStack":[],"depth":1,"refund":0,"opName":"PUSH1","error":""}
{"pc":15,"op":53,"gas":"0x6a7a5a","gasCost":"0x3","memory":"0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080","memSize":96,"stack":["0x0"],"returnStack":[],"depth":1,"refund":0,"opName":"CALLDATALOAD","error":""}
{"pc":16,"op":96,"gas":"0x6a7a57","gasCost":"0x3","memory":"0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080","memSize":96,"stack":["0x14cbff1000bc0f9b394b18e81124dc8"],"returnStack":[],"depth":1,"refund":0,"opName":"PUSH1","error":""}
{"pc":18,"op":28,"gas":"0x6a7a54","gasCost":"0x3","memory":"0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080","memSize":96,"stack":["0x14cbff1000bc0f9b394b18e81124dc8","0xe0"],"returnStack":[],"depth":1,"refund":0,"opName":"SHR","error":""}
{"pc":19,"op":128,"gas":"0x6a7a51","gasCost":"0x3","memory":"0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080","memSize":96,"stack":["0x0"],"returnStack":[],"depth":1,"refund":0,"opName":"DUP1","error":""}
{"pc":20,"op":99,"gas":"0x6a7a4e","gasCost":"0x3","memory":"0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080","memSize":96,"stack":["0x0","0x0"],"returnStack":[],"depth":1,"refund":0,"opName":"PUSH4","error":""}
{"pc":25,"op":20,"gas":"0x6a7a4b","gasCost":"0x3","memory":"0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080","memSize":96,"stack":["0x0","0x0","0x12bd4299"],"returnStack":[],"depth":1,"refund":0,"opName":"EQ","error":""}
{"pc":26,"op":97,"gas":"0x6a7a48","gasCost":"0x3","memory":"0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080","memSize":96,"stack":["0x0","0x0"],"returnStack":[],"depth":1,"refund":0,"opName":"PUSH2","error":""}
{"pc":29,"op":87,"gas":"0x6a7a45","gasCost":"0xa","memory":"0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080","memSize":96,"stack":["0x0","0x0","0x23"],"returnStack":[],"depth":1,"refund":0,"opName":"JUMPI","error":""}
{"pc":30,"op":91,"gas":"0x6a7a3b","gasCost":"0x1","memory":"0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080","memSize":96,"stack":["0x0"],"returnStack":[],"depth":1,"refund":0,"opName":"JUMPDEST","error":""}
{"pc":31,"op":96,"gas":"0x6a7a3a","gasCost":"0x3","memory":"0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080","memSize":96,"stack":["0x0"],"returnStack":[],"depth":1,"refund":0,"opName":"PUSH1","error":""}
{"pc":33,"op":128,"gas":"0x6a7a37","gasCost":"0x3","memory":"0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080","memSize":96,"stack":["0x0","0x0"],"returnStack":[],"depth":1,"refund":0,"opName":"DUP1","error":""}
{"pc":34,"op":253,"gas":"0x6a7a34","gasCost":"0x0","memory":"0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080","memSize":96,"stack":["0x0","0x0","0x0"],"returnStack":[],"depth":1,"refund":0,"opName":"REVERT","error":""}
{"output":"","gasUsed":"0x50","time":230933,"error":"execution reverted"}

@holiman does geth transition tool support eip2537 on YOLOv1 ?
Aswer: YES

@shamatar
I can't generetate the tests. the transaction execution is reverted both by geth transition tool and besu.
Can you show me the monkey-patched commit?

@shamatar
Copy link
Author

shamatar commented Jul 9, 2020

I’ll post a diff tomorrow.

Separate Json files are present case I’ve used template engine instead of working with full Json structures.

@shamatar
Copy link
Author

Diff

From 1d977d26d731bc862b61b8b06bf09b017054f6eb Mon Sep 17 00:00:00 2001
From: Alex Vlasov <alex.m.vlasov@gmail.com>
Date: Fri, 10 Jul 2020 11:50:46 +0300
Subject: [PATCH] patch to access yolo precompiles

---
 cmd/geth/retesteth.go | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/cmd/geth/retesteth.go b/cmd/geth/retesteth.go
index 29590b63b..8e42fc905 100644
--- a/cmd/geth/retesteth.go
+++ b/cmd/geth/retesteth.go
@@ -321,6 +321,8 @@ func (api *RetestethAPI) SetChainParams(ctx context.Context, chainParams ChainPa
 		constantinopleBlock *big.Int
 		petersburgBlock     *big.Int
 		istanbulBlock       *big.Int
+		muirGlacierBlock    *big.Int
+		yoloV1Block         *big.Int
 	)
 	if chainParams.Params.HomesteadForkBlock != nil {
 		homesteadBlock = big.NewInt(int64(*chainParams.Params.HomesteadForkBlock))
@@ -350,6 +352,8 @@ func (api *RetestethAPI) SetChainParams(ctx context.Context, chainParams ChainPa
 	if chainParams.Params.IstanbulBlock != nil {
 		istanbulBlock = big.NewInt(int64(*chainParams.Params.IstanbulBlock))
 	}
+	muirGlacierBlock = big.NewInt(int64(0))
+	yoloV1Block = big.NewInt(int64(0))
 
 	genesis := &core.Genesis{
 		Config: &params.ChainConfig{
@@ -364,6 +368,8 @@ func (api *RetestethAPI) SetChainParams(ctx context.Context, chainParams ChainPa
 			ConstantinopleBlock: constantinopleBlock,
 			PetersburgBlock:     petersburgBlock,
 			IstanbulBlock:       istanbulBlock,
+			MuirGlacierBlock:    muirGlacierBlock,
+			YoloV1Block:         yoloV1Block,
 		},
 		Nonce:      uint64(chainParams.Genesis.Nonce),
 		Timestamp:  uint64(chainParams.Genesis.Timestamp),
-- 
2.21.0 (Apple Git-122.2)

@shamatar
Copy link
Author

I should note that “default” client is used white I’ve included YoloV1 fork and added mining reward.

@winsvega
Copy link
Collaborator

winsvega commented Jul 10, 2020

I can't generate the tests with your fork either. did you run --filltests command without errors?
you just activated yolo in geth retesteth.
the transaction execution is reverted.

Is that expected behavior?

@shamatar
Copy link
Author

I’ve had a problem with reverts before finally forced Geth to activate Yolo (red errors in terminal with invalid balance, invalid storage slot values). I’ll send you logs and more detailed instructions if it helps.

@shamatar
Copy link
Author

@winsvega

I've updated the vectors, looks that previous version has contained jsons from invalid generator.

@winsvega
Copy link
Collaborator

winsvega commented Jul 10, 2020

ok this works.
#713

@winsvega winsvega closed this Jul 10, 2020
@shamatar shamatar mentioned this pull request Aug 10, 2020
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.

2 participants