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

Implement cancun tests #26

Merged
merged 2 commits into from
Jan 29, 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
33 changes: 29 additions & 4 deletions blockgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
"fmt"
"math/big"

"github.com/ethereum/go-ethereum/common"

Check failure on line 7 in blockgen.go

View workflow job for this annotation

GitHub Actions / Lint

github.com/ethereum/go-ethereum@v1.13.3: replacement directory ../go-ethereum does not exist

Check failure on line 7 in blockgen.go

View workflow job for this annotation

GitHub Actions / Test

github.com/ethereum/go-ethereum@v1.13.3: replacement directory ../go-ethereum does not exist
"github.com/ethereum/go-ethereum/consensus"

Check failure on line 8 in blockgen.go

View workflow job for this annotation

GitHub Actions / Lint

github.com/ethereum/go-ethereum@v1.13.3: replacement directory ../go-ethereum does not exist

Check failure on line 8 in blockgen.go

View workflow job for this annotation

GitHub Actions / Test

github.com/ethereum/go-ethereum@v1.13.3: replacement directory ../go-ethereum does not exist
"github.com/ethereum/go-ethereum/core"

Check failure on line 9 in blockgen.go

View workflow job for this annotation

GitHub Actions / Lint

github.com/ethereum/go-ethereum@v1.13.3: replacement directory ../go-ethereum does not exist

Check failure on line 9 in blockgen.go

View workflow job for this annotation

GitHub Actions / Test

github.com/ethereum/go-ethereum@v1.13.3: replacement directory ../go-ethereum does not exist
"github.com/ethereum/go-ethereum/core/rawdb"

Check failure on line 10 in blockgen.go

View workflow job for this annotation

GitHub Actions / Lint

github.com/ethereum/go-ethereum@v1.13.3: replacement directory ../go-ethereum does not exist

Check failure on line 10 in blockgen.go

View workflow job for this annotation

GitHub Actions / Test

github.com/ethereum/go-ethereum@v1.13.3: replacement directory ../go-ethereum does not exist
"github.com/ethereum/go-ethereum/core/types"

Check failure on line 11 in blockgen.go

View workflow job for this annotation

GitHub Actions / Lint

github.com/ethereum/go-ethereum@v1.13.3: replacement directory ../go-ethereum does not exist

Check failure on line 11 in blockgen.go

View workflow job for this annotation

GitHub Actions / Test

github.com/ethereum/go-ethereum@v1.13.3: replacement directory ../go-ethereum does not exist
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/trie"
"github.com/holiman/uint256"
)

// genSimpleChain generates a short chain with a few basic transactions.
Expand All @@ -25,18 +26,23 @@
funds = big.NewInt(0).Mul(big.NewInt(1337), big.NewInt(params.Ether))
contract = common.HexToAddress("0000000000000000000000000000000000031ec7")
gspec = &core.Genesis{
Config: params.AllEthashProtocolChanges,
Alloc: core.GenesisAlloc{address: {Balance: funds}},
Config: params.AllEthashProtocolChanges,
Alloc: core.GenesisAlloc{
address: {Balance: funds},
common.HexToAddress("a94f5374fce5edbc8e2a8697c15331677e6ebf0b"): {Balance: funds},
},
BaseFee: big.NewInt(params.InitialBaseFee),
Difficulty: common.Big1,
GasLimit: 5_000_000,
}
gendb = rawdb.NewMemoryDatabase()
signer = types.LatestSigner(gspec.Config)
gendb = rawdb.NewMemoryDatabase()
)
gspec.Config.TerminalTotalDifficultyPassed = true
gspec.Config.TerminalTotalDifficulty = common.Big0
gspec.Config.ShanghaiTime = uintptr(0)
gspec.Config.CancunTime = uintptr(0)

signer := types.LatestSigner(gspec.Config)

// init 0xaa with some storage elements
storage := make(map[common.Hash]common.Hash)
Expand Down Expand Up @@ -75,6 +81,7 @@
genesis := gspec.MustCommit(gendb, trie.NewDatabase(gendb, trie.HashDefaults))

chain, _ := core.GenerateChain(gspec.Config, genesis, engine, gendb, 10, func(i int, gen *core.BlockGen) {
gen.SetParentBeaconRoot(common.Hash{byte(i)})
var (
tx *types.Transaction
err error
Expand Down Expand Up @@ -102,6 +109,24 @@
StorageKeys: []common.Hash{{0}},
}}
tx, err = types.SignTx(types.NewTx(&types.AccessListTx{Nonce: uint64(i), To: nil, Gas: 58100, GasPrice: gen.BaseFee(), Data: common.FromHex("0x60806040"), AccessList: accessList}), signer, key)
case 6:
fee := uint256.NewInt(500)
fee.Add(fee, uint256.MustFromBig(gen.BaseFee()))
data := fmt.Sprintf("0xa9059cbb%s%s", common.HexToHash(common.BigToAddress(big.NewInt(int64(i + 1))).Hex()).String()[2:], common.BytesToHash([]byte{byte(i + 11)}).String()[2:])

// blob tx
inner := types.BlobTx{
Nonce: uint64(i),
To: contract,
Gas: 60000,
Value: uint256.NewInt(1),
GasTipCap: uint256.NewInt(500),
GasFeeCap: fee,
Data: common.FromHex(data),
BlobFeeCap: uint256.NewInt(params.BlobTxBlobGasPerBlob),
BlobHashes: []common.Hash{{0x01, 0x42}},
}
tx, err = types.SignTx(types.NewTx(&inner), signer, key)
default:
tx, err = types.SignTx(types.NewTransaction(gen.TxNonce(address), address, big.NewInt(1000), params.TxGas, new(big.Int).Add(gen.BaseFee(), common.Big1), nil), signer, key)
}
Expand Down
36 changes: 20 additions & 16 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ module github.com/lightclient/rpctestgen

go 1.18

replace github.com/ethereum/go-ethereum => ../go-ethereum
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably left in by mistake


require (
github.com/alexflint/go-arg v1.4.3
github.com/ethereum/go-ethereum v1.13.1
github.com/ethereum/go-ethereum v1.13.3
github.com/holiman/uint256 v1.2.3
github.com/open-rpc/meta-schema v0.0.0-20210416041958-626a15d0a618
github.com/santhosh-tekuri/jsonschema/v5 v5.0.0
)
Expand All @@ -13,18 +16,19 @@ require (
github.com/DataDog/zstd v1.5.2 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/StackExchange/wmi v1.2.1 // indirect
github.com/VictoriaMetrics/fastcache v1.6.0 // indirect
github.com/VictoriaMetrics/fastcache v1.12.1 // indirect
github.com/alexflint/go-scalar v1.1.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bits-and-blooms/bitset v1.5.0 // indirect
github.com/bits-and-blooms/bitset v1.7.0 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cockroachdb/errors v1.9.1 // indirect
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
github.com/cockroachdb/pebble v0.0.0-20230906160148-46873a6a7a06 // indirect
github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593 // indirect
github.com/cockroachdb/redact v1.1.3 // indirect
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect
github.com/consensys/bavard v0.1.13 // indirect
github.com/consensys/gnark-crypto v0.10.0 // indirect
github.com/consensys/gnark-crypto v0.12.1 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/crate-crypto/go-kzg-4844 v0.3.0 // indirect
github.com/deckarep/golang-set/v2 v2.1.0 // indirect
Expand All @@ -36,21 +40,20 @@ require (
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-jwt/jwt/v4 v4.3.0 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/hashicorp/go-bexpr v0.1.10 // indirect
github.com/holiman/bloomfilter/v2 v2.0.3 // indirect
github.com/holiman/uint256 v1.2.3 // indirect
github.com/huin/goupnp v1.3.0 // indirect
github.com/jackpal/go-nat-pmp v1.0.2 // indirect
github.com/klauspost/compress v1.15.15 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/mattn/go-runewidth v0.0.9 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/mattn/go-runewidth v0.0.13 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/mitchellh/mapstructure v1.4.1 // indirect
github.com/mitchellh/pointerstructure v1.2.0 // indirect
Expand All @@ -61,6 +64,7 @@ require (
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.39.0 // indirect
github.com/prometheus/procfs v0.9.0 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/rogpeppe/go-internal v1.9.0 // indirect
github.com/rs/cors v1.7.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
Expand All @@ -71,13 +75,13 @@ require (
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/urfave/cli/v2 v2.25.7 // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
golang.org/x/crypto v0.12.0 // indirect
golang.org/x/exp v0.0.0-20230810033253-352e893a4cad // indirect
golang.org/x/mod v0.11.0 // indirect
golang.org/x/crypto v0.14.0 // indirect
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
golang.org/x/mod v0.12.0 // indirect
golang.org/x/sync v0.3.0 // indirect
golang.org/x/sys v0.11.0 // indirect
golang.org/x/text v0.12.0 // indirect
golang.org/x/tools v0.9.1 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/tools v0.13.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
rsc.io/tmplfunc v0.0.3 // indirect
Expand Down
Loading
Loading