mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-12 01:41:36 +00:00
all: fix rebasing issues
This commit is contained in:
parent
1a8c2e0918
commit
7e4656581f
12 changed files with 76 additions and 83 deletions
|
|
@ -18,10 +18,11 @@ package engine
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/ethereum/go-ethereum/core/types/bal"
|
||||
"math/big"
|
||||
"slices"
|
||||
|
||||
"github.com/ethereum/go-ethereum/core/types/bal"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
|
|
|
|||
|
|
@ -258,7 +258,7 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
|
|||
snapshot = statedb.Snapshot()
|
||||
gp = gaspool.Snapshot()
|
||||
)
|
||||
_, receipt, err := core.ApplyTransactionWithEVM(msg, gaspool, statedb, vmContext.BlockNumber, blockHash, pre.Env.Timestamp, tx, evm)
|
||||
_, _, receipt, err := core.ApplyTransactionWithEVM(msg, gaspool, statedb, vmContext.BlockNumber, blockHash, pre.Env.Timestamp, tx, evm)
|
||||
if err != nil {
|
||||
statedb.RevertToSnapshot(snapshot)
|
||||
log.Info("rejected tx", "index", i, "hash", tx.Hash(), "from", msg.From, "error", err)
|
||||
|
|
@ -327,11 +327,11 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
|
|||
return nil, nil, nil, NewError(ErrorEVM, fmt.Errorf("could not parse requests logs: %v", err))
|
||||
}
|
||||
// EIP-7002
|
||||
if _, err := core.ProcessWithdrawalQueue(&requests, evm); err != nil {
|
||||
if _, _, err := core.ProcessWithdrawalQueue(&requests, evm); err != nil {
|
||||
return nil, nil, nil, NewError(ErrorEVM, fmt.Errorf("could not process withdrawal requests: %v", err))
|
||||
}
|
||||
// EIP-7251
|
||||
if _, err := core.ProcessConsolidationQueue(&requests, evm); err != nil {
|
||||
if _, _, err := core.ProcessConsolidationQueue(&requests, evm); err != nil {
|
||||
return nil, nil, nil, NewError(ErrorEVM, fmt.Errorf("could not process consolidation requests: %v", err))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,13 +21,14 @@ import (
|
|||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/ethereum/go-ethereum/core/types/bal"
|
||||
"io"
|
||||
"math/big"
|
||||
"math/rand"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/ethereum/go-ethereum/core/types/bal"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
"github.com/ethereum/go-ethereum/common/lru"
|
||||
|
|
@ -579,28 +580,6 @@ func (c *Clique) Finalize(chain consensus.ChainHeaderReader, header *types.Heade
|
|||
return nil, nil
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// FinalizeAndAssemble implements consensus.Engine, ensuring no uncles are set,
|
||||
// nor block rewards given, and returns the final block.
|
||||
func (c *Clique) FinalizeAndAssemble(ctx context.Context, chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, body *types.Body, receipts []*types.Receipt, createBAL func(*bal.StateAccessList, *bal.StateMutations) *bal.BlockAccessList) (*types.Block, error) {
|
||||
if createBAL != nil {
|
||||
panic("BALs not supported")
|
||||
}
|
||||
if len(body.Withdrawals) > 0 {
|
||||
return nil, errors.New("clique does not support withdrawals")
|
||||
}
|
||||
// Finalize block
|
||||
c.Finalize(chain, header, state, body)
|
||||
|
||||
// Assign the final state root to header.
|
||||
header.Root = state.IntermediateRoot(chain.Config().IsEIP158(header.Number))
|
||||
|
||||
// Assemble and return the final block for sealing.
|
||||
return types.NewBlock(header, &types.Body{Transactions: body.Transactions}, receipts, trie.NewStackTrie(nil)), nil
|
||||
}
|
||||
|
||||
>>>>>>> 1d26ca9bc1 (all: implement BAL single-threaded execution and validation)
|
||||
// Authorize injects a private key into the consensus engine to mint new blocks
|
||||
// with.
|
||||
func (c *Clique) Authorize(signer common.Address) {
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ import (
|
|||
"github.com/ethereum/go-ethereum/crypto/keccak"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
"github.com/ethereum/go-ethereum/rlp"
|
||||
"github.com/holiman/uint256"
|
||||
)
|
||||
|
||||
// Tests block header storage and retrieval operations.
|
||||
|
|
@ -906,13 +905,17 @@ func makeTestBAL(t *testing.T) (rlp.RawValue, *bal.BlockAccessList) {
|
|||
t.Helper()
|
||||
|
||||
cb := bal.NewConstructionBlockAccessList()
|
||||
addr := common.HexToAddress("0x1111111111111111111111111111111111111111")
|
||||
cb.AccountRead(addr)
|
||||
cb.StorageRead(addr, common.BytesToHash([]byte{0x01}))
|
||||
cb.StorageWrite(0, addr, common.BytesToHash([]byte{0x02}), common.BytesToHash([]byte{0xaa}))
|
||||
cb.BalanceChange(0, addr, uint256.NewInt(100))
|
||||
cb.NonceChange(addr, 0, 1)
|
||||
/*
|
||||
TODO MariusVanDerWijden fix after rebase
|
||||
addr := common.HexToAddress("0x1111111111111111111111111111111111111111")
|
||||
|
||||
|
||||
cb.AccountRead(addr)
|
||||
cb.StorageRead(addr, common.BytesToHash([]byte{0x01}))
|
||||
cb.StorageWrite(0, addr, common.BytesToHash([]byte{0x02}), common.BytesToHash([]byte{0xaa}))
|
||||
cb.BalanceChange(0, addr, uint256.NewInt(100))
|
||||
cb.NonceChange(addr, 0, 1)
|
||||
*/
|
||||
var buf bytes.Buffer
|
||||
if err := cb.EncodeRLP(&buf); err != nil {
|
||||
t.Fatalf("failed to encode BAL: %v", err)
|
||||
|
|
|
|||
|
|
@ -19,11 +19,12 @@ package state
|
|||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"github.com/ethereum/go-ethereum/core/types/bal"
|
||||
"maps"
|
||||
"slices"
|
||||
"time"
|
||||
|
||||
"github.com/ethereum/go-ethereum/core/types/bal"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ package state
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/ethereum/go-ethereum/core/types/bal"
|
||||
"maps"
|
||||
"slices"
|
||||
"sort"
|
||||
|
|
@ -28,6 +27,8 @@ import (
|
|||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/ethereum/go-ethereum/core/types/bal"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/stateless"
|
||||
"github.com/ethereum/go-ethereum/core/tracing"
|
||||
|
|
|
|||
|
|
@ -18,10 +18,11 @@ package state
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"github.com/ethereum/go-ethereum/core/types/bal"
|
||||
"math/big"
|
||||
"sort"
|
||||
|
||||
"github.com/ethereum/go-ethereum/core/types/bal"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/stateless"
|
||||
"github.com/ethereum/go-ethereum/core/tracing"
|
||||
|
|
|
|||
|
|
@ -18,9 +18,10 @@ package core
|
|||
|
||||
import (
|
||||
"context"
|
||||
"github.com/ethereum/go-ethereum/core/types/bal"
|
||||
"sync/atomic"
|
||||
|
||||
"github.com/ethereum/go-ethereum/core/types/bal"
|
||||
|
||||
"github.com/ethereum/go-ethereum/core/state"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/core/vm"
|
||||
|
|
|
|||
|
|
@ -19,9 +19,10 @@ package bal
|
|||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"maps"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/holiman/uint256"
|
||||
"maps"
|
||||
)
|
||||
|
||||
// ConstructionAccountAccesses contains post-block account state for mutations as well as
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import (
|
|||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/internal/testrand"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
"github.com/ethereum/go-ethereum/rlp"
|
||||
"github.com/holiman/uint256"
|
||||
)
|
||||
|
|
@ -37,48 +38,51 @@ func equalBALs(a *BlockAccessList, b *BlockAccessList) bool {
|
|||
}
|
||||
|
||||
func makeTestConstructionBAL() ConstructionBlockAccessList {
|
||||
return map[common.Address]*ConstructionAccountAccesses{
|
||||
common.BytesToAddress([]byte{0xff, 0xff}): {
|
||||
StorageWrites: map[common.Hash]map[uint16]common.Hash{
|
||||
common.BytesToHash([]byte{0x01}): {
|
||||
1: common.BytesToHash([]byte{1, 2, 3, 4}),
|
||||
2: common.BytesToHash([]byte{1, 2, 3, 4, 5, 6}),
|
||||
return ConstructionBlockAccessList{
|
||||
list: map[common.Address]*ConstructionAccountAccesses{
|
||||
common.BytesToAddress([]byte{0xff, 0xff}): {
|
||||
StorageWrites: map[common.Hash]map[uint16]common.Hash{
|
||||
common.BytesToHash([]byte{0x01}): {
|
||||
1: common.BytesToHash([]byte{1, 2, 3, 4}),
|
||||
2: common.BytesToHash([]byte{1, 2, 3, 4, 5, 6}),
|
||||
},
|
||||
common.BytesToHash([]byte{0x10}): {
|
||||
20: common.BytesToHash([]byte{1, 2, 3, 4}),
|
||||
},
|
||||
},
|
||||
common.BytesToHash([]byte{0x10}): {
|
||||
20: common.BytesToHash([]byte{1, 2, 3, 4}),
|
||||
StorageReads: map[common.Hash]struct{}{
|
||||
common.BytesToHash([]byte{1, 2, 3, 4, 5, 6, 7}): {},
|
||||
},
|
||||
},
|
||||
StorageReads: map[common.Hash]struct{}{
|
||||
common.BytesToHash([]byte{1, 2, 3, 4, 5, 6, 7}): {},
|
||||
},
|
||||
BalanceChanges: map[uint16]*uint256.Int{
|
||||
1: uint256.NewInt(100),
|
||||
2: uint256.NewInt(500),
|
||||
},
|
||||
NonceChanges: map[uint16]uint64{
|
||||
1: 2,
|
||||
2: 6,
|
||||
},
|
||||
CodeChanges: map[uint16][]byte{0: common.Hex2Bytes("deadbeef")},
|
||||
},
|
||||
common.BytesToAddress([]byte{0xff, 0xff, 0xff}): {
|
||||
StorageWrites: map[common.Hash]map[uint16]common.Hash{
|
||||
common.BytesToHash([]byte{0x01}): {
|
||||
2: common.BytesToHash([]byte{1, 2, 3, 4, 5, 6}),
|
||||
3: common.BytesToHash([]byte{1, 2, 3, 4, 5, 6, 7, 8}),
|
||||
BalanceChanges: map[uint16]*uint256.Int{
|
||||
1: uint256.NewInt(100),
|
||||
2: uint256.NewInt(500),
|
||||
},
|
||||
NonceChanges: map[uint16]uint64{
|
||||
1: 2,
|
||||
2: 6,
|
||||
},
|
||||
CodeChanges: map[uint16][]byte{0: common.Hex2Bytes("deadbeef")},
|
||||
},
|
||||
StorageReads: map[common.Hash]struct{}{
|
||||
common.BytesToHash([]byte{1, 2, 3, 4, 5, 6, 7, 8}): {},
|
||||
},
|
||||
BalanceChanges: map[uint16]*uint256.Int{
|
||||
2: uint256.NewInt(100),
|
||||
3: uint256.NewInt(500),
|
||||
},
|
||||
NonceChanges: map[uint16]uint64{
|
||||
1: 2,
|
||||
common.BytesToAddress([]byte{0xff, 0xff, 0xff}): {
|
||||
StorageWrites: map[common.Hash]map[uint16]common.Hash{
|
||||
common.BytesToHash([]byte{0x01}): {
|
||||
2: common.BytesToHash([]byte{1, 2, 3, 4, 5, 6}),
|
||||
3: common.BytesToHash([]byte{1, 2, 3, 4, 5, 6, 7, 8}),
|
||||
},
|
||||
},
|
||||
StorageReads: map[common.Hash]struct{}{
|
||||
common.BytesToHash([]byte{1, 2, 3, 4, 5, 6, 7, 8}): {},
|
||||
},
|
||||
BalanceChanges: map[uint16]*uint256.Int{
|
||||
2: uint256.NewInt(100),
|
||||
3: uint256.NewInt(500),
|
||||
},
|
||||
NonceChanges: map[uint16]uint64{
|
||||
1: 2,
|
||||
},
|
||||
},
|
||||
},
|
||||
transactionCount: 1,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -212,7 +216,7 @@ func TestBlockAccessListCopy(t *testing.T) {
|
|||
}
|
||||
|
||||
// Make sure the mutations on copy won't affect the origin
|
||||
for _, aa := range cpyCpy {
|
||||
for _, aa := range *cpyCpy {
|
||||
for i := 0; i < len(aa.StorageReads); i++ {
|
||||
aa.StorageReads[i] = &EncodedStorage{new(uint256.Int).SetBytes(testrand.Bytes(32))}
|
||||
}
|
||||
|
|
@ -226,7 +230,7 @@ func TestBlockAccessListValidation(t *testing.T) {
|
|||
// Validate the block access list after RLP decoding
|
||||
testBALMaxIndex := 20
|
||||
enc := makeTestBAL(true)
|
||||
if err := enc.Validate(testBALMaxIndex); err != nil {
|
||||
if err := enc.Validate(testBALMaxIndex, params.MaxGasLimit); err != nil {
|
||||
t.Fatalf("Unexpected validation error: %v", err)
|
||||
}
|
||||
var buf bytes.Buffer
|
||||
|
|
@ -238,14 +242,14 @@ func TestBlockAccessListValidation(t *testing.T) {
|
|||
if err := dec.DecodeRLP(rlp.NewStream(bytes.NewReader(buf.Bytes()), 0)); err != nil {
|
||||
t.Fatalf("Unexpected RLP-decode error: %v", err)
|
||||
}
|
||||
if err := dec.Validate(testBALMaxIndex); err != nil {
|
||||
if err := dec.Validate(testBALMaxIndex, params.MaxGasLimit); err != nil {
|
||||
t.Fatalf("Unexpected validation error: %v", err)
|
||||
}
|
||||
|
||||
// Validate the derived block access list
|
||||
cBAL := makeTestConstructionBAL()
|
||||
listB := cBAL.ToEncodingObj()
|
||||
if err := listB.Validate(testBALMaxIndex); err != nil {
|
||||
if err := listB.Validate(testBALMaxIndex, params.MaxGasLimit); err != nil {
|
||||
t.Fatalf("Unexpected validation error: %v", err)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,12 +37,13 @@ func makeTestBAL(minSize int) *bal.BlockAccessList {
|
|||
n := minSize/33 + 1 // 33 bytes per storage read slot in RLP
|
||||
access := bal.AccountAccess{
|
||||
Address: common.HexToAddress("0x01"),
|
||||
StorageReads: make([][32]byte, n),
|
||||
StorageReads: make([]*bal.EncodedStorage, n),
|
||||
}
|
||||
for i := range access.StorageReads {
|
||||
binary.BigEndian.PutUint64(access.StorageReads[i][24:], uint64(i))
|
||||
read := access.StorageReads[i].ToHash()
|
||||
binary.BigEndian.PutUint64(read[24:], uint64(i))
|
||||
}
|
||||
return &bal.BlockAccessList{Accesses: []bal.AccountAccess{access}}
|
||||
return &bal.BlockAccessList{access}
|
||||
}
|
||||
|
||||
// getChainWithBALs creates a minimal test chain with BALs stored for each block.
|
||||
|
|
|
|||
|
|
@ -620,7 +620,7 @@ func TestSelfdestructStateTracer(t *testing.T) {
|
|||
}
|
||||
context := core.NewEVMBlockContext(block.Header(), blockchain, nil)
|
||||
evm := vm.NewEVM(context, hookedState, tt.genesis.Config, vm.Config{Tracer: tracer.Hooks()})
|
||||
_, _, err = core.ApplyTransactionWithEVM(msg, core.NewGasPool(msg.GasLimit), statedb, block.Number(), block.Hash(), block.Time(), tx, evm)
|
||||
_, _, _, err = core.ApplyTransactionWithEVM(msg, core.NewGasPool(msg.GasLimit), statedb, block.Number(), block.Hash(), block.Time(), tx, evm)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to execute transaction: %v", err)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue