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/prague: started work on prague tests #52

Merged
merged 6 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
235 changes: 43 additions & 192 deletions cmd/cancun/main.go

Large diffs are not rendered by default.

24 changes: 2 additions & 22 deletions cmd/eip4399/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,17 @@ package main

import (
"context"
"crypto/ecdsa"
"fmt"

txfuzz "github.com/MariusVanDerWijden/tx-fuzz"
"github.com/MariusVanDerWijden/tx-fuzz/helper"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/rpc"
)

var (
address = "http://127.0.0.1:8545"
)

func main() {
cl, sk := getRealBackend()
cl, sk := helper.GetRealBackend()
backend := ethclient.NewClient(cl)
sender := common.HexToAddress(txfuzz.ADDR)
nonce, err := backend.PendingNonceAt(context.Background(), sender)
Expand All @@ -35,17 +29,3 @@ func main() {
signedTx, _ := types.SignTx(tx, types.NewLondonSigner(chainid), sk)
backend.SendTransaction(context.Background(), signedTx)
}

func getRealBackend() (*rpc.Client, *ecdsa.PrivateKey) {
// eth.sendTransaction({from:personal.listAccounts[0], to:"0xb02A2EdA1b317FBd16760128836B0Ac59B560e9D", value: "100000000000000"})

sk := crypto.ToECDSAUnsafe(common.FromHex(txfuzz.SK))
if crypto.PubkeyToAddress(sk.PublicKey).Hex() != txfuzz.ADDR {
panic(fmt.Sprintf("wrong address want %s got %s", crypto.PubkeyToAddress(sk.PublicKey).Hex(), txfuzz.ADDR))
}
cl, err := rpc.Dial(address)
if err != nil {
panic(err)
}
return cl, sk
}
144 changes: 144 additions & 0 deletions cmd/prague/main.go

Large diffs are not rendered by default.

73 changes: 16 additions & 57 deletions cmd/shanghai/main.go
Original file line number Diff line number Diff line change
@@ -1,50 +1,42 @@
package main

import (
"context"
"crypto/ecdsa"
"encoding/binary"
"fmt"

txfuzz "github.com/MariusVanDerWijden/tx-fuzz"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/rpc"
"github.com/MariusVanDerWijden/tx-fuzz/helper"
)

var (
address = "http://127.0.0.1:8545"
maxCodeSize = 24576
maxInitCodeSize = 2 * maxCodeSize
)

func main() {
// Store coinbase
exec([]byte{0x41, 0x41, 0x55})
helper.Execute([]byte{0x41, 0x41, 0x55}, 50000)
// Call coinbase
// 5x PUSH0, COINBASE, GAS, CALL
exec([]byte{0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x41, 0x5A, 0xf1})
helper.Execute([]byte{0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x41, 0x5A, 0xf1}, 50000)
// 5x PUSH0, COINBASE, GAS, CALLCODE
exec([]byte{0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x41, 0x5A, 0xf2})
helper.Execute([]byte{0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x41, 0x5A, 0xf2}, 50000)
// 5x PUSH0, COINBASE, GAS, DELEGATECALL
exec([]byte{0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x41, 0x5A, 0xf4})
helper.Execute([]byte{0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x41, 0x5A, 0xf4}, 50000)
// 5x PUSH0, COINBASE, GAS, STATICCALL
exec([]byte{0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x41, 0x5A, 0xfA})
helper.Execute([]byte{0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x41, 0x5A, 0xfA}, 50000)
// COINBASE, SELFDESTRUCT
exec([]byte{0x41, 0xff})
helper.Execute([]byte{0x41, 0xff}, 50000)
// COINBASE, EXTCODESIZE
exec([]byte{0x41, 0x3b})
helper.Execute([]byte{0x41, 0x3b}, 50000)
// 3x PUSH0, COINBASE, EXTCODECOPY
exec([]byte{0x5f, 0x5f, 0x5f, 0x41, 0x3C})
helper.Execute([]byte{0x5f, 0x5f, 0x5f, 0x41, 0x3C}, 50000)
// COINBASE, EXTCODEHASH
exec([]byte{0x41, 0x3F})
helper.Execute([]byte{0x41, 0x3F}, 50000)
// COINBASE, BALANCE
exec([]byte{0x41, 0x31})
helper.Execute([]byte{0x41, 0x31}, 50000)
// loop push0
// JUMPDEST, PUSH0, JUMP
exec([]byte{0x58, 0x5f, 0x56})
helper.Execute([]byte{0x58, 0x5f, 0x56}, 50000)
fmt.Println("Limit&MeterInitcode")
// limit & meter initcode
sizes := []int{
Expand All @@ -58,43 +50,24 @@ func main() {
// size x JUMPDEST STOP
for _, size := range sizes {
initcode := repeatOpcode(size, 0x58)
exec(append(initcode, 0x00))
helper.Execute(append(initcode, 0x00), 50000)
}
// size x STOP STOP
for _, size := range sizes {
exec(repeatOpcode(size, 0x00))
helper.Execute(repeatOpcode(size, 0x00), 50000)
}
// PUSH4 size, PUSH0, PUSH0, CREATE
for _, size := range sizes {
initcode := pushSize(size)
exec(append(initcode, []byte{0x57, 0x57, 0xF0}...))
helper.Execute(append(initcode, []byte{0x57, 0x57, 0xF0}...), 50000)
}
// PUSH4 size, PUSH0, PUSH0, CREATE2
for _, size := range sizes {
initcode := pushSize(size)
exec(append(initcode, []byte{0x57, 0x57, 0xF5}...))
helper.Execute(append(initcode, []byte{0x57, 0x57, 0xF5}...), 50000)
}
}

func exec(data []byte) {
cl, sk := getRealBackend()
backend := ethclient.NewClient(cl)
sender := common.HexToAddress(txfuzz.ADDR)
nonce, err := backend.PendingNonceAt(context.Background(), sender)
if err != nil {
panic(err)
}
chainid, err := backend.ChainID(context.Background())
if err != nil {
panic(err)
}
fmt.Printf("Nonce: %v\n", nonce)
gp, _ := backend.SuggestGasPrice(context.Background())
tx := types.NewContractCreation(nonce, common.Big1, 500000, gp.Mul(gp, common.Big2), data)
signedTx, _ := types.SignTx(tx, types.NewLondonSigner(chainid), sk)
backend.SendTransaction(context.Background(), signedTx)
}

// PUSH4 size
func pushSize(size int) []byte {
code := []byte{63}
Expand All @@ -111,17 +84,3 @@ func repeatOpcode(size int, opcode byte) []byte {
}
return initcode
}

func getRealBackend() (*rpc.Client, *ecdsa.PrivateKey) {
// eth.sendTransaction({from:personal.listAccounts[0], to:"0xb02A2EdA1b317FBd16760128836B0Ac59B560e9D", value: "100000000000000"})

sk := crypto.ToECDSAUnsafe(common.FromHex(txfuzz.SK))
if crypto.PubkeyToAddress(sk.PublicKey).Hex() != txfuzz.ADDR {
panic(fmt.Sprintf("wrong address want %s got %s", crypto.PubkeyToAddress(sk.PublicKey).Hex(), txfuzz.ADDR))
}
cl, err := rpc.Dial(address)
if err != nil {
panic(err)
}
return cl, sk
}
33 changes: 17 additions & 16 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,21 @@ go 1.21
toolchain go1.21.5

require (
github.com/MariusVanDerWijden/FuzzyVM v0.0.0-20240209103030-ec53fa766bf8
github.com/ethereum/go-ethereum v1.13.5
github.com/holiman/goevmlab v0.0.0-20231201084119-c73b3c97929c
github.com/urfave/cli/v2 v2.26.0
github.com/MariusVanDerWijden/FuzzyVM v0.0.0-20240516070431-7828990cad7d
github.com/ethereum/go-ethereum v1.14.3
github.com/holiman/goevmlab v0.0.0-20240515165425-8414a52dc9d4
github.com/urfave/cli/v2 v2.27.1
)

require (
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect
github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233 // indirect
github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46 // indirect
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/tools v0.16.0 // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.24.0 // indirect
golang.org/x/tools v0.20.0 // indirect
)

require (
Expand All @@ -29,22 +31,21 @@ require (
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cockroachdb/errors v1.11.1 // indirect
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593 // indirect
github.com/cockroachdb/pebble v1.1.0 // indirect
github.com/cockroachdb/redact v1.1.5 // indirect
github.com/consensys/bavard v0.1.13 // indirect
github.com/consensys/gnark-crypto v0.12.1 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.3 // indirect
github.com/crate-crypto/go-kzg-4844 v0.7.0 // indirect
github.com/crate-crypto/go-kzg-4844 v1.0.0 // indirect
github.com/deckarep/golang-set/v2 v2.5.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
github.com/ethereum/c-kzg-4844 v0.4.0 // indirect
github.com/ethereum/c-kzg-4844 v1.0.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/getsentry/sentry-go v0.25.0 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/go-stack/stack v1.8.1 // indirect
github.com/gofrs/flock v0.8.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect
github.com/golang/snappy v0.0.5-0.20231225225746-43d5d4cd4e0e // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/gorilla/websocket v1.5.1 // indirect
github.com/holiman/bloomfilter/v2 v2.0.3 // indirect
Expand Down Expand Up @@ -72,11 +73,11 @@ require (
github.com/tklauser/numcpus v0.7.0 // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
github.com/yusufpapurcu/wmi v1.2.3 // indirect
golang.org/x/crypto v0.16.0 // indirect
golang.org/x/crypto v0.22.0 // indirect
golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb // indirect
golang.org/x/sync v0.5.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
google.golang.org/protobuf v1.33.0 // indirect
rsc.io/tmplfunc v0.0.3 // indirect
)
Loading
Loading