Skip to content

Commit 195a476

Browse files
cmd/prague: add 7702 test scenarios (#61)
* cmd/prague: add 7702 test scenarios * cmd/prague: fix 2935 * cmd/prague: lint
1 parent 8f33c9b commit 195a476

6 files changed

Lines changed: 386 additions & 73 deletions

File tree

cmd/prague/deploy.go

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"strings"
6+
7+
txfuzz "github.com/MariusVanDerWijden/tx-fuzz"
8+
"github.com/MariusVanDerWijden/tx-fuzz/helper"
9+
"github.com/ethereum/go-ethereum/common"
10+
)
11+
12+
/*
13+
pragma solidity >=0.7.0 <0.9.0;
14+
15+
contract EIP2935Caller {
16+
bool _ok;
17+
bytes out;
18+
fallback (bytes calldata _input) external returns (bytes memory _output) {
19+
address contrAddr = address(0x0AAE40965E6800cD9b1f4b05ff21581047E3F91e);
20+
(bool ok, bytes memory output) = contrAddr.call{gas: 500000}(_input);
21+
_output = output;
22+
// Store return values to trigger sstore
23+
_ok = ok;
24+
out = output;
25+
}
26+
}
27+
*/
28+
func deploy2935Caller() (common.Address, error) {
29+
bytecode1 := "6080604052348015600e575f80fd5b506104698061001c5f395ff3fe608060405234801561000f575f80fd5b505f3660605f730aae40965e6800cd9b1f4b05ff21581047e3f91e90505f808273ffffffffffffffffffffffffffffffffffffffff166207a1208787604051610059929190610112565b5f604051808303815f8787f1925050503d805f8114610093576040519150601f19603f3d011682016040523d82523d5f602084013e610098565b606091505b5091509150809350815f806101000a81548160ff02191690831515021790555080600190816100c79190610364565b50505050915050805190602001f35b5f81905092915050565b828183375f83830152505050565b5f6100f983856100d6565b93506101068385846100e0565b82840190509392505050565b5f61011e8284866100ee565b91508190509392505050565b5f81519050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b5f60028204905060018216806101a557607f821691505b6020821081036101b8576101b7610161565b5b50919050565b5f819050815f5260205f209050919050565b5f6020601f8301049050919050565b5f82821b905092915050565b5f6008830261021a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff826101df565b61022486836101df565b95508019841693508086168417925050509392505050565b5f819050919050565b5f819050919050565b5f61026861026361025e8461023c565b610245565b61023c565b9050919050565b5f819050919050565b6102818361024e565b61029561028d8261026f565b8484546101eb565b825550505050565b5f90565b6102a961029d565b6102b4818484610278565b505050565b5b818110156102d7576102cc5f826102a1565b6001810190506102ba565b5050565b601f82111561031c576102ed816101be565b6102f6846101d0565b81016020851015610305578190505b610319610311856101d0565b8301826102b9565b50505b505050565b5f82821c905092915050565b5f61033c5f1984600802610321565b1980831691505092915050565b5f610354838361032d565b9150826002028217905092915050565b61036d8261012a565b67ffffffffffffffff81111561038657610385610134565b5b610390825461018e565b61039b8282856102db565b5f60209050601f8311600181146103cc575f84156103ba578287015190505b6103c48582610349565b86555061042b565b601f1984166103da866101be565b5f5b82811015610401578489015182556001820191506020850194506020810190506103dc565b8683101561041e578489015161041a601f89168261032d565b8355505b6001600288020188555050505b50505050505056fea264697066735822122033feaed59f5038b726e0ad09706fc2b959f0781cd00f5b4961c7ce6a676215f764736f6c634300081a0033"
30+
return helper.Deploy(bytecode1)
31+
}
32+
33+
func deploy7702Proxy() (common.Address, error) {
34+
// See: https://raw.githubusercontent.com/ethereum/hive/refs/heads/master/cmd/hivechain/contracts/deployer.eas
35+
deployer := "600d380380600d6000396000f3"
36+
// See: https://gist.github.com/lightclient/7742e84fde4962f32928c6177eda7523
37+
bytecode := "5f54808060ff1c15600e575f5ffd5b15606f57337300000000000000000000000000000000000010921415605557507f80000000000000000000000000000000000000000000000000000000000000005f555f5ff35b5f365f5f37365f345f945af45b3d5f3e5f3d91606d57fd5bf35b465f5260805f60203760405f205f5260205f60805f737a40026a3b9a41754a95eec8c92c6b99886f440c5afa505f51301460a7575f5ffd5b5f35805f555f608036038060805f375f345f945af1606256"
38+
// replace placeholder address
39+
bytecode = strings.Replace(bytecode, "7a40026A3b9A41754a95EeC8c92C6B99886f440C", txfuzz.ADDR, 1)
40+
return helper.Deploy(fmt.Sprintf("%v%v", deployer, bytecode))
41+
}
42+
43+
/*
44+
pragma solidity >=0.7.0 <0.9.0;
45+
46+
contract BlobCaller {
47+
bool _ok;
48+
bytes out;
49+
50+
fallback (bytes calldata _input) external returns (bytes memory _output) {
51+
address precompile = address(0x0A);
52+
(bool ok, bytes memory output) = precompile.call{gas: 500000}(_input);
53+
_output = output;
54+
// Store return values to trigger sstore
55+
_ok = ok;
56+
out = output;
57+
}
58+
}
59+
*/
60+
func deployPrecompileCaller(precompile string) (common.Address, error) {
61+
bytecode1 := "6080604052348015600e575f80fd5b506104568061001c5f395ff3fe608060405234801561000f575f80fd5b505f3660605f60"
62+
bytecode2 := "90505f808273ffffffffffffffffffffffffffffffffffffffff1661c35087876040516100459291906100fe565b5f604051808303815f8787f1925050503d805f811461007f576040519150601f19603f3d011682016040523d82523d5f602084013e610084565b606091505b5091509150809350815f806101000a81548160ff02191690831515021790555080600190816100b39190610350565b50505050915050805190602001f35b5f81905092915050565b828183375f83830152505050565b5f6100e583856100c2565b93506100f28385846100cc565b82840190509392505050565b5f61010a8284866100da565b91508190509392505050565b5f81519050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b5f600282049050600182168061019157607f821691505b6020821081036101a4576101a361014d565b5b50919050565b5f819050815f5260205f209050919050565b5f6020601f8301049050919050565b5f82821b905092915050565b5f600883026102067fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff826101cb565b61021086836101cb565b95508019841693508086168417925050509392505050565b5f819050919050565b5f819050919050565b5f61025461024f61024a84610228565b610231565b610228565b9050919050565b5f819050919050565b61026d8361023a565b6102816102798261025b565b8484546101d7565b825550505050565b5f90565b610295610289565b6102a0818484610264565b505050565b5b818110156102c3576102b85f8261028d565b6001810190506102a6565b5050565b601f821115610308576102d9816101aa565b6102e2846101bc565b810160208510156102f1578190505b6103056102fd856101bc565b8301826102a5565b50505b505050565b5f82821c905092915050565b5f6103285f198460080261030d565b1980831691505092915050565b5f6103408383610319565b9150826002028217905092915050565b61035982610116565b67ffffffffffffffff81111561037257610371610120565b5b61037c825461017a565b6103878282856102c7565b5f60209050601f8311600181146103b8575f84156103a6578287015190505b6103b08582610335565b865550610417565b601f1984166103c6866101aa565b5f5b828110156103ed578489015182556001820191506020850194506020810190506103c8565b8683101561040a5784890151610406601f891682610319565b8355505b6001600288020188555050505b50505050505056fea2646970667358221220bc28435cfa3208db8cae33e216a1ff54a6e5dce073695cad36274cc363055c5564736f6c63430008190033"
63+
// The byte in between bytecode1 and bytecode2 denotes the precompile which we want to call
64+
return helper.Deploy(fmt.Sprintf("%v%v%v", bytecode1, precompile, bytecode2))
65+
}
66+
67+
/*
68+
pragma solidity >=0.7.0 <0.9.0;
69+
70+
contract EIP7702Callee {
71+
fallback () external {
72+
address payable contrAddr = payable(0xb02A2EdA1b317FBd16760128836B0Ac59B560e9D);
73+
selfdestruct(contrAddr);
74+
}
75+
}
76+
*/
77+
func deploy7702Callee(faucet string) (common.Address, error) {
78+
bytecode := "6080604052348015600e575f80fd5b50607680601a5f395ff3fe6080604052348015600e575f80fd5b505f73b02a2eda1b317fbd16760128836b0ac59b560e9d90508073ffffffffffffffffffffffffffffffffffffffff16fffea26469706673582212204a31a78bf4820c06477cee3ba9c3511c039b5c95bf5da3cff36851f4eb96cce264736f6c634300081a0033"
79+
bytecode = strings.Replace(bytecode, "b02A2EdA1b317FBd16760128836B0Ac59B560e9D", faucet, 1)
80+
return helper.Deploy(bytecode)
81+
}
82+
83+
/*
84+
pragma solidity >=0.7.0 <0.9.0;
85+
86+
contract EIP7702Caller {
87+
fallback (bytes calldata list) external payable returns (bytes memory _output) {
88+
for (uint256 i = 0; i < list.length / 20; i++) {
89+
address payable caller = payable(address(uint160(bytes20(list[i * 20:i*20+20]))));
90+
(bool sent, bytes memory data) = caller.call{gas: 6000}("");
91+
}
92+
return list;
93+
}
94+
}
95+
*/
96+
func deploy7702Caller() (common.Address, error) {
97+
bytecode := "6080604052348015600e575f80fd5b506103948061001c5f395ff3fe60806040525f3660605f5b60148484905061001a9190610198565b8110156100e3575f848460148461003191906101c8565b906014808661004091906101c8565b61004a9190610209565b9261005793929190610244565b9061006291906102bf565b60601c90505f808273ffffffffffffffffffffffffffffffffffffffff1661177060405161008f9061034a565b5f604051808303815f8787f1925050503d805f81146100c9576040519150601f19603f3d011682016040523d82523d5f602084013e6100ce565b606091505b5091509150505050808060010191505061000a565b5082828080601f0160208091040260200160405190810160405280939291908181526020018383808284375f81840152601f19601f820116905080830192505050505050509050915050805190602001f35b5f819050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f6101a282610135565b91506101ad83610135565b9250826101bd576101bc61013e565b5b828204905092915050565b5f6101d282610135565b91506101dd83610135565b92508282026101eb81610135565b915082820484148315176102025761020161016b565b5b5092915050565b5f61021382610135565b915061021e83610135565b92508282019050808211156102365761023561016b565b5b92915050565b5f80fd5b5f80fd5b5f80858511156102575761025661023c565b5b8386111561026857610267610240565b5b6001850283019150848603905094509492505050565b5f82905092915050565b5f7fffffffffffffffffffffffffffffffffffffffff00000000000000000000000082169050919050565b5f82821b905092915050565b5f6102ca838361027e565b826102d58135610288565b92506014821015610315576103107fffffffffffffffffffffffffffffffffffffffff000000000000000000000000836014036008026102b3565b831692505b505092915050565b5f81905092915050565b50565b5f6103355f8361031d565b915061034082610327565b5f82019050919050565b5f6103548261032a565b915081905091905056fea26469706673582212206e52e424f779b172c0e793095d58f2eeffcb9223f89c8f9a6b8d05845eb6d58c64736f6c634300081a0033"
98+
return helper.Deploy(bytecode)
99+
}

cmd/prague/main.go

Lines changed: 6 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"encoding/binary"
77
"fmt"
88
"math/big"
9-
"strings"
109

1110
txfuzz "github.com/MariusVanDerWijden/tx-fuzz"
1211
"github.com/MariusVanDerWijden/tx-fuzz/helper"
@@ -28,6 +27,8 @@ func main() {
2827
test2935()
2928
test7002()
3029
test7251()
30+
test7702BlobTxs()
31+
test7702NormalTxs() // flakey
3132
}
3233

3334
func testTouchContracts() {
@@ -192,30 +193,6 @@ func testBLS(prec int, input []byte) {
192193
helper.Exec(addr, input, false)
193194
}
194195

195-
/*
196-
pragma solidity >=0.7.0 <0.9.0;
197-
198-
contract BlobCaller {
199-
bool _ok;
200-
bytes out;
201-
202-
fallback (bytes calldata _input) external returns (bytes memory _output) {
203-
address precompile = address(0x0A);
204-
(bool ok, bytes memory output) = precompile.call{gas: 500000}(_input);
205-
_output = output;
206-
// Store return values to trigger sstore
207-
_ok = ok;
208-
out = output;
209-
}
210-
}
211-
*/
212-
func deployPrecompileCaller(precompile string) (common.Address, error) {
213-
bytecode1 := "6080604052348015600e575f80fd5b506104568061001c5f395ff3fe608060405234801561000f575f80fd5b505f3660605f60"
214-
bytecode2 := "90505f808273ffffffffffffffffffffffffffffffffffffffff1661c35087876040516100459291906100fe565b5f604051808303815f8787f1925050503d805f811461007f576040519150601f19603f3d011682016040523d82523d5f602084013e610084565b606091505b5091509150809350815f806101000a81548160ff02191690831515021790555080600190816100b39190610350565b50505050915050805190602001f35b5f81905092915050565b828183375f83830152505050565b5f6100e583856100c2565b93506100f28385846100cc565b82840190509392505050565b5f61010a8284866100da565b91508190509392505050565b5f81519050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b5f600282049050600182168061019157607f821691505b6020821081036101a4576101a361014d565b5b50919050565b5f819050815f5260205f209050919050565b5f6020601f8301049050919050565b5f82821b905092915050565b5f600883026102067fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff826101cb565b61021086836101cb565b95508019841693508086168417925050509392505050565b5f819050919050565b5f819050919050565b5f61025461024f61024a84610228565b610231565b610228565b9050919050565b5f819050919050565b61026d8361023a565b6102816102798261025b565b8484546101d7565b825550505050565b5f90565b610295610289565b6102a0818484610264565b505050565b5b818110156102c3576102b85f8261028d565b6001810190506102a6565b5050565b601f821115610308576102d9816101aa565b6102e2846101bc565b810160208510156102f1578190505b6103056102fd856101bc565b8301826102a5565b50505b505050565b5f82821c905092915050565b5f6103285f198460080261030d565b1980831691505092915050565b5f6103408383610319565b9150826002028217905092915050565b61035982610116565b67ffffffffffffffff81111561037257610371610120565b5b61037c825461017a565b6103878282856102c7565b5f60209050601f8311600181146103b8575f84156103a6578287015190505b6103b08582610335565b865550610417565b601f1984166103c6866101aa565b5f5b828110156103ed578489015182556001820191506020850194506020810190506103c8565b8683101561040a5784890151610406601f891682610319565b8355505b6001600288020188555050505b50505050505056fea2646970667358221220bc28435cfa3208db8cae33e216a1ff54a6e5dce073695cad36274cc363055c5564736f6c63430008190033"
215-
// The byte in between bytecode1 and bytecode2 denotes the precompile which we want to call
216-
return helper.Deploy(fmt.Sprintf("%v%v%v", bytecode1, precompile, bytecode2))
217-
}
218-
219196
// makeTxWithValue creates a transaction invoking addr, sending eth along with calldata.
220197
func makeTxWithValue(addr common.Address, value *big.Int, data []byte) *types.Transaction {
221198
ctx := context.Background()
@@ -319,16 +296,6 @@ func do7702Calls(addr common.Address) {
319296
helper.ExecAuth(addr, []byte{}, list)
320297
}
321298

322-
func deploy7702Proxy() (common.Address, error) {
323-
// See: https://raw.githubusercontent.com/ethereum/hive/refs/heads/master/cmd/hivechain/contracts/deployer.eas
324-
deployer := "600d380380600d6000396000f3"
325-
// See: https://gist.github.com/lightclient/7742e84fde4962f32928c6177eda7523
326-
bytecode := "5f54808060ff1c15600e575f5ffd5b15606f57337300000000000000000000000000000000000010921415605557507f80000000000000000000000000000000000000000000000000000000000000005f555f5ff35b5f365f5f37365f345f945af45b3d5f3e5f3d91606d57fd5bf35b465f5260805f60203760405f205f5260205f60805f737a40026a3b9a41754a95eec8c92c6b99886f440c5afa505f51301460a7575f5ffd5b5f35805f555f608036038060805f375f345f945af1606256"
327-
// replace placeholder address
328-
bytecode = strings.Replace(bytecode, "0x7a40026A3b9A41754a95EeC8c92C6B99886f440C", txfuzz.ADDR, 1)
329-
return helper.Deploy(fmt.Sprintf("%v%v", deployer, bytecode))
330-
}
331-
332299
func test2935() {
333300
fmt.Println("EIP-2935")
334301
contr, err := deploy2935Caller()
@@ -372,30 +339,12 @@ func test2935() {
372339
currentBlock - 8192,
373340
currentBlock - 256,
374341
currentBlock - 255,
342+
currentBlock - 20000,
375343
}
376344
for _, number := range blocknumbers {
377-
helper.Exec(addr, binary.BigEndian.AppendUint64([]byte{}, number), false)
345+
input := make([]byte, 32)
346+
binary.BigEndian.PutUint64(input[24:], number)
347+
helper.Exec(addr, input, false)
378348
}
379349
}
380350
}
381-
382-
/*
383-
pragma solidity >=0.7.0 <0.9.0;
384-
385-
contract EIP2935Caller {
386-
bool _ok;
387-
bytes out;
388-
fallback (bytes calldata _input) external returns (bytes memory _output) {
389-
address contrAddr = address(0x0AAE40965E6800cD9b1f4b05ff21581047E3F91e);
390-
(bool ok, bytes memory output) = contrAddr.call{gas: 500000}(_input);
391-
_output = output;
392-
// Store return values to trigger sstore
393-
_ok = ok;
394-
out = output;
395-
}
396-
}
397-
*/
398-
func deploy2935Caller() (common.Address, error) {
399-
bytecode1 := "6080604052348015600e575f80fd5b506104698061001c5f395ff3fe608060405234801561000f575f80fd5b505f3660605f730aae40965e6800cd9b1f4b05ff21581047e3f91e90505f808273ffffffffffffffffffffffffffffffffffffffff166207a1208787604051610059929190610112565b5f604051808303815f8787f1925050503d805f8114610093576040519150601f19603f3d011682016040523d82523d5f602084013e610098565b606091505b5091509150809350815f806101000a81548160ff02191690831515021790555080600190816100c79190610364565b50505050915050805190602001f35b5f81905092915050565b828183375f83830152505050565b5f6100f983856100d6565b93506101068385846100e0565b82840190509392505050565b5f61011e8284866100ee565b91508190509392505050565b5f81519050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b5f60028204905060018216806101a557607f821691505b6020821081036101b8576101b7610161565b5b50919050565b5f819050815f5260205f209050919050565b5f6020601f8301049050919050565b5f82821b905092915050565b5f6008830261021a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff826101df565b61022486836101df565b95508019841693508086168417925050509392505050565b5f819050919050565b5f819050919050565b5f61026861026361025e8461023c565b610245565b61023c565b9050919050565b5f819050919050565b6102818361024e565b61029561028d8261026f565b8484546101eb565b825550505050565b5f90565b6102a961029d565b6102b4818484610278565b505050565b5b818110156102d7576102cc5f826102a1565b6001810190506102ba565b5050565b601f82111561031c576102ed816101be565b6102f6846101d0565b81016020851015610305578190505b610319610311856101d0565b8301826102b9565b50505b505050565b5f82821c905092915050565b5f61033c5f1984600802610321565b1980831691505092915050565b5f610354838361032d565b9150826002028217905092915050565b61036d8261012a565b67ffffffffffffffff81111561038657610385610134565b5b610390825461018e565b61039b8282856102db565b5f60209050601f8311600181146103cc575f84156103ba578287015190505b6103c48582610349565b86555061042b565b601f1984166103da866101be565b5f5b82811015610401578489015182556001820191506020850194506020810190506103dc565b8683101561041e578489015161041a601f89168261032d565b8355505b6001600288020188555050505b50505050505056fea264697066735822122033feaed59f5038b726e0ad09706fc2b959f0781cd00f5b4961c7ce6a676215f764736f6c634300081a0033"
400-
return helper.Deploy(bytecode1)
401-
}

0 commit comments

Comments
 (0)