Skip to content

Commit

Permalink
simulators/pyspec: Update to use correct fcuVersion.
Browse files Browse the repository at this point in the history
  • Loading branch information
spencer-tb committed Sep 6, 2023
1 parent 5d3adb8 commit afee83d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 94 deletions.
6 changes: 0 additions & 6 deletions simulators/ethereum/pyspec/gen_bh.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

62 changes: 0 additions & 62 deletions simulators/ethereum/pyspec/gen_enp.go

This file was deleted.

6 changes: 1 addition & 5 deletions simulators/ethereum/pyspec/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ func (tc *testcase) run(t *hivesim.T) {

// send payloads and check response
latestValidHash := common.Hash{}
latestVersion := uint64(1)
for i, engineNewPayload := range tc.payloads {
// execute fixture block payload
plStatus, plErr := engineClient.NewPayload(
Expand All @@ -133,7 +132,6 @@ func (tc *testcase) run(t *hivesim.T) {
&engineNewPayload.BlobVersionedHashes,
engineNewPayload.ParentBeaconBlockRoot,
)
latestVersion = engineNewPayload.Version
// check for rpc errors and compare error codes
fxErrCode := int(tc.fixture.json.Blocks[i].EngineNewPayload.ErrorCode)
if fxErrCode != 0 {
Expand Down Expand Up @@ -161,9 +159,7 @@ func (tc *testcase) run(t *hivesim.T) {
if latestValidHash != (common.Hash{}) {
// update with latest valid response
fcState := &api.ForkchoiceStateV1{HeadBlockHash: latestValidHash}
// TODO: This is incorrect, up to this point, the `engine_forkchoiceUpdated` and `engine_newPayload` versions for each
// fork match, but it could change in the future. Ideally we should embed the version in the fixture.
if _, fcErr := engineClient.ForkchoiceUpdated(ctx, int(latestVersion), fcState, nil); fcErr != nil {
if _, fcErr := engineClient.ForkchoiceUpdated(ctx, int(tc.fixture.json.EngineFcuVersion), fcState, nil); fcErr != nil {
tc.failedErr = fcErr
t.Fatalf("unable to update head of beacon chain in test %s: %v ", tc.name, fcErr)
}
Expand Down
36 changes: 15 additions & 21 deletions simulators/ethereum/pyspec/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"encoding/json"
"math/big"

api "github.com/ethereum/go-ethereum/beacon/engine"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/common/math"
Expand Down Expand Up @@ -36,14 +35,18 @@ func (t *fixtureTest) UnmarshalJSON(in []byte) error {
return nil
}

//go:generate go run github.com/fjl/gencodec -type blockHeader -field-override blockHeaderUnmarshaling -out gen_bh.go
//go:generate go run github.com/fjl/gencodec -type transaction -field-override transactionUnmarshaling -out gen_txs.go
//go:generate go run github.com/fjl/gencodec -type withdrawals -field-override withdrawalsUnmarshaling -out gen_wds.go
type fixtureJSON struct {
Blocks []block `json:"blocks"`
Genesis blockHeader `json:"genesisBlockHeader"`
Pre core.GenesisAlloc `json:"pre"`
Post core.GenesisAlloc `json:"postState"`
BestBlock common.UnprefixedHash `json:"lastblockhash"`
Network string `json:"network"`
SealEngine string `json:"sealEngine"`
Blocks []block `json:"blocks"`
Genesis blockHeader `json:"genesisBlockHeader"`
Pre core.GenesisAlloc `json:"pre"`
Post core.GenesisAlloc `json:"postState"`
BestBlock common.UnprefixedHash `json:"lastblockhash"`
Network string `json:"network"`
SealEngine string `json:"sealEngine"`
EngineFcuVersion math.HexOrDecimal64 `json:"engineFcuVersion"`
}

type block struct {
Expand All @@ -56,10 +59,6 @@ type block struct {
EngineNewPayload *engineNewPayload `json:"engineNewPayload"`
}

//go:generate go run github.com/fjl/gencodec -type blockHeader -field-override blockHeaderUnmarshaling -out gen_bh.go
//go:generate go run github.com/fjl/gencodec -type transaction -field-override transactionUnmarshaling -out gen_txs.go
//go:generate go run github.com/fjl/gencodec -type withdrawals -field-override withdrawalsUnmarshaling -out gen_wds.go
//go:generate go run github.com/fjl/gencodec -type engineNewPayload -field-override engineNewPayloadUnmarshaling -out gen_enp.go
type blockHeader struct {
ParentHash common.Hash `json:"parentHash"`
UncleHash common.Hash `json:"sha3Uncles"`
Expand All @@ -69,9 +68,8 @@ type blockHeader struct {
CoinbaseAlt2 common.Address `json:"miner"` // geth/besu name
StateRoot common.Hash `json:"stateRoot"`
TransactionTrie common.Hash `json:"transactionRoot"`
TransactionTrieAlt common.Hash `json:"transactionTrie"` // name in fixtures
ReceiptTrie common.Hash `json:"receiptsRoot"`
ReceiptTrieAlt common.Hash `json:"receiptTrie"` // name in fixtures
TransactionTrieAlt common.Hash `json:"transactionTrie"` // name in fixtures ReceiptTrie common.Hash `json:"receiptsRoot"`
ReceiptTrieAlt common.Hash `json:"receiptTrie"` // name in fixtures
Bloom types.Bloom `json:"bloom"`
Difficulty *big.Int `json:"difficulty"`
Number *big.Int `json:"number"`
Expand Down Expand Up @@ -152,13 +150,9 @@ type withdrawalsUnmarshaling struct {
}

type engineNewPayload struct {
Payload *api.ExecutableData `json:"executionPayload"`
Payload interface{} `json:"executionPayload"`
BlobVersionedHashes []common.Hash `json:"expectedBlobVersionedHashes"`
ParentBeaconBlockRoot *common.Hash `json:"parentBeaconBlockRoot"`
Version uint64 `json:"version"`
Version math.HexOrDecimal64 `json:"version"`
ErrorCode int64 `json:"errorCode,string"`
}

type engineNewPayloadUnmarshaling struct {
Version math.HexOrDecimal64 `json:"version"`
}

0 comments on commit afee83d

Please sign in to comment.