Skip to content

Commit

Permalink
Revert "core/chain_makers: add SetParentBeaconRoot(..) to chain makers (
Browse files Browse the repository at this point in the history
ethereum#28252)"

This reverts commit c547c0b.
  • Loading branch information
devopsbo3 committed Nov 10, 2023
1 parent 2ae6a0c commit 8c3478e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 34 deletions.
11 changes: 0 additions & 11 deletions core/chain_makers.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,6 @@ func (b *BlockGen) SetPoS() {
b.header.Difficulty = new(big.Int)
}

// SetParentBeaconRoot sets the parent beacon root field of the generated
// block.
func (b *BlockGen) SetParentBeaconRoot(root common.Hash) {
b.header.ParentBeaconRoot = &root
var (
blockContext = NewEVMBlockContext(b.header, nil, &b.header.Coinbase)
vmenv = vm.NewEVM(blockContext, vm.TxContext{}, b.statedb, b.config, vm.Config{})
)
ProcessBeaconBlockRoot(root, vmenv, b.statedb)
}

// addTx adds a transaction to the generated block. If no coinbase has
// been set, the block's coinbase is set to the zero address.
//
Expand Down
26 changes: 3 additions & 23 deletions core/chain_makers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
"github.com/ethereum/go-ethereum/trie"
)

func TestGeneratePOSChain(t *testing.T) {
func TestGenerateWithdrawalChain(t *testing.T) {
var (
keyHex = "9c647b8b7c4e7c3490668fb6c11473619db80c93704c70893d3813af4090c39c"
key, _ = crypto.HexToECDSA(keyHex)
Expand All @@ -41,13 +41,9 @@ func TestGeneratePOSChain(t *testing.T) {
bb = common.Address{0xbb}
funds = big.NewInt(0).Mul(big.NewInt(1337), big.NewInt(params.Ether))
config = *params.AllEthashProtocolChanges
asm4788 = common.Hex2Bytes("3373fffffffffffffffffffffffffffffffffffffffe14604d57602036146024575f5ffd5b5f35801560495762001fff810690815414603c575f5ffd5b62001fff01545f5260205ff35b5f5ffd5b62001fff42064281555f359062001fff015500")
gspec = &Genesis{
Config: &config,
Alloc: GenesisAlloc{
address: {Balance: funds},
params.BeaconRootsStorageAddress: {Balance: common.Big0, Code: asm4788},
},
Config: &config,
Alloc: GenesisAlloc{address: {Balance: funds}},
BaseFee: big.NewInt(params.InitialBaseFee),
Difficulty: common.Big1,
GasLimit: 5_000_000,
Expand All @@ -60,7 +56,6 @@ func TestGeneratePOSChain(t *testing.T) {
config.TerminalTotalDifficultyPassed = true
config.TerminalTotalDifficulty = common.Big0
config.ShanghaiTime = u64(0)
config.CancunTime = u64(0)

// init 0xaa with some storage elements
storage := make(map[common.Hash]common.Hash)
Expand All @@ -83,7 +78,6 @@ func TestGeneratePOSChain(t *testing.T) {
genesis := gspec.MustCommit(gendb, trie.NewDatabase(gendb, trie.HashDefaults))

chain, _ := GenerateChain(gspec.Config, genesis, beacon.NewFaker(), gendb, 4, func(i int, gen *BlockGen) {
gen.SetParentBeaconRoot(common.Hash{byte(i + 1)})
tx, _ := types.SignTx(types.NewTransaction(gen.TxNonce(address), address, big.NewInt(1000), params.TxGas, new(big.Int).Add(gen.BaseFee(), common.Big1), nil), signer, key)
gen.AddTx(tx)
if i == 1 {
Expand Down Expand Up @@ -131,8 +125,6 @@ func TestGeneratePOSChain(t *testing.T) {
if block == nil {
t.Fatalf("block %d not found", i)
}

// Verify withdrawals.
if len(block.Withdrawals()) == 0 {
continue
}
Expand All @@ -142,18 +134,6 @@ func TestGeneratePOSChain(t *testing.T) {
}
withdrawalIndex += 1
}

// Verify parent beacon root.
want := common.Hash{byte(i)}
if got := block.BeaconRoot(); *got != want {
t.Fatalf("block %d, wrong parent beacon root: got %s, want %s", i, got, want)
}
state, _ := blockchain.State()
idx := block.Time()%8191 + 8191
got := state.GetState(params.BeaconRootsStorageAddress, common.BigToHash(new(big.Int).SetUint64(idx)))
if got != want {
t.Fatalf("block %d, wrong parent beacon root in state: got %s, want %s", i, got, want)
}
}
}

Expand Down

0 comments on commit 8c3478e

Please sign in to comment.