mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 14:46:42 +00:00
Fixed tests
This commit is contained in:
parent
9f4c25d3ee
commit
294e2863e6
7 changed files with 39 additions and 27 deletions
|
|
@ -465,7 +465,6 @@ func blockEvent(height uint64) tracing.BlockEvent {
|
||||||
Block: types.NewBlock(&types.Header{
|
Block: types.NewBlock(&types.Header{
|
||||||
Number: big.NewInt(int64(height)),
|
Number: big.NewInt(int64(height)),
|
||||||
}, nil, nil, nil),
|
}, nil, nil, nil),
|
||||||
TD: b(1),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -54,27 +54,39 @@ func runPrestateBlock(t *testing.T, prestatePath string, hooks *tracing.Hooks) {
|
||||||
Transactions: []*types.Transaction{tx},
|
Transactions: []*types.Transaction{tx},
|
||||||
}, nil, trie.NewStackTrie(nil))
|
}, nil, trie.NewStackTrie(nil))
|
||||||
|
|
||||||
hooks.OnBlockchainInit(prestate.Genesis.Config)
|
if hooks.OnBlockchainInit != nil {
|
||||||
hooks.OnBlockStart(tracing.BlockEvent{
|
hooks.OnBlockchainInit(prestate.Genesis.Config)
|
||||||
Block: block,
|
}
|
||||||
TD: prestate.TotalDifficulty,
|
|
||||||
})
|
if hooks.OnBlockStart != nil {
|
||||||
|
hooks.OnBlockStart(tracing.BlockEvent{
|
||||||
|
Block: block,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
header := block.Header()
|
||||||
|
msg, err := core.TransactionToMessage(tx, types.MakeSigner(prestate.Genesis.Config, header.Number, header.Time), header.BaseFee)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
blockContext := core.NewEVMBlockContext(block.Header(), prestate, &context.Coinbase)
|
||||||
|
vmenv := vm.NewEVM(blockContext, state.NewHookedState(testState.StateDB, hooks), prestate.Genesis.Config, vm.Config{Tracer: hooks})
|
||||||
|
|
||||||
usedGas := uint64(0)
|
usedGas := uint64(0)
|
||||||
_, err := core.ApplyTransaction(
|
_, err = core.ApplyTransactionWithEVM(
|
||||||
prestate.Genesis.Config,
|
msg,
|
||||||
prestate,
|
|
||||||
&context.Coinbase,
|
|
||||||
new(core.GasPool).AddGas(block.GasLimit()),
|
new(core.GasPool).AddGas(block.GasLimit()),
|
||||||
testState.StateDB,
|
testState.StateDB,
|
||||||
block.Header(),
|
header.Number,
|
||||||
|
header.Hash(),
|
||||||
tx,
|
tx,
|
||||||
&usedGas,
|
&usedGas,
|
||||||
vm.Config{Tracer: hooks},
|
vmenv,
|
||||||
)
|
)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
hooks.OnBlockEnd(nil)
|
if hooks.OnBlockEnd != nil {
|
||||||
|
hooks.OnBlockEnd(nil)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func newBlockchain(t *testing.T, alloc types.GenesisAlloc, context vm.BlockContext, tracer *tracing.Hooks) (*core.Genesis, *core.BlockChain) {
|
func newBlockchain(t *testing.T, alloc types.GenesisAlloc, context vm.BlockContext, tracer *tracing.Hooks) (*core.Genesis, *core.BlockChain) {
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/core"
|
"github.com/ethereum/go-ethereum/core"
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
"github.com/ethereum/go-ethereum/core/vm"
|
"github.com/ethereum/go-ethereum/core/vm"
|
||||||
|
"github.com/ethereum/go-ethereum/params"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -52,6 +53,11 @@ type prestateData struct {
|
||||||
genesisBlock *types.Block
|
genesisBlock *types.Block
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Config implements core.ChainContext.
|
||||||
|
func (p *prestateData) Config() *params.ChainConfig {
|
||||||
|
return p.Genesis.Config
|
||||||
|
}
|
||||||
|
|
||||||
// Engine implements core.ChainContext.
|
// Engine implements core.ChainContext.
|
||||||
func (p *prestateData) Engine() consensus.Engine {
|
func (p *prestateData) Engine() consensus.Engine {
|
||||||
return ethash.NewFullFaker()
|
return ethash.NewFullFaker()
|
||||||
|
|
@ -100,9 +106,16 @@ func (c *callContext) toBlockContext(genesis *core.Genesis) vm.BlockContext {
|
||||||
if genesis.Config.IsLondon(context.BlockNumber) {
|
if genesis.Config.IsLondon(context.BlockNumber) {
|
||||||
context.BaseFee = (*big.Int)(c.BaseFee)
|
context.BaseFee = (*big.Int)(c.BaseFee)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if genesis.Config.TerminalTotalDifficulty != nil && genesis.Config.TerminalTotalDifficulty.Sign() == 0 {
|
||||||
|
context.Random = &genesis.Mixhash
|
||||||
|
}
|
||||||
|
|
||||||
if genesis.ExcessBlobGas != nil && genesis.BlobGasUsed != nil {
|
if genesis.ExcessBlobGas != nil && genesis.BlobGasUsed != nil {
|
||||||
excessBlobGas := eip4844.CalcExcessBlobGas(*genesis.ExcessBlobGas, *genesis.BlobGasUsed)
|
header := &types.Header{Number: genesis.Config.LondonBlock, Time: *genesis.Config.CancunTime}
|
||||||
context.BlobBaseFee = eip4844.CalcBlobFee(excessBlobGas)
|
excess := eip4844.CalcExcessBlobGas(genesis.Config, header, genesis.Timestamp)
|
||||||
|
header.ExcessBlobGas = &excess
|
||||||
|
context.BlobBaseFee = eip4844.CalcBlobFee(genesis.Config, header)
|
||||||
}
|
}
|
||||||
return context
|
return context
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,6 @@
|
||||||
"difficulty": {
|
"difficulty": {
|
||||||
"bytes": "Ag=="
|
"bytes": "Ag=="
|
||||||
},
|
},
|
||||||
"totalDifficulty": {
|
|
||||||
"bytes": "Aw=="
|
|
||||||
},
|
|
||||||
"number": "1",
|
"number": "1",
|
||||||
"gasLimit": "1000000",
|
"gasLimit": "1000000",
|
||||||
"timestamp": "1970-01-01T00:00:01Z",
|
"timestamp": "1970-01-01T00:00:01Z",
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,6 @@
|
||||||
"difficulty": {
|
"difficulty": {
|
||||||
"bytes": "AA=="
|
"bytes": "AA=="
|
||||||
},
|
},
|
||||||
"totalDifficulty": {
|
|
||||||
"bytes": "PGVtIwKasA=="
|
|
||||||
},
|
|
||||||
"number": "3727495",
|
"number": "3727495",
|
||||||
"gasLimit": "30000000",
|
"gasLimit": "30000000",
|
||||||
"timestamp": "2023-06-19T23:23:48Z",
|
"timestamp": "2023-06-19T23:23:48Z",
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,6 @@
|
||||||
"difficulty": {
|
"difficulty": {
|
||||||
"bytes": "AA=="
|
"bytes": "AA=="
|
||||||
},
|
},
|
||||||
"totalDifficulty": {
|
|
||||||
"bytes": "PGVtIwKasA=="
|
|
||||||
},
|
|
||||||
"number": "3733424",
|
"number": "3733424",
|
||||||
"gasLimit": "30000000",
|
"gasLimit": "30000000",
|
||||||
"timestamp": "2023-06-20T21:02:36Z",
|
"timestamp": "2023-06-20T21:02:36Z",
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,6 @@
|
||||||
"difficulty": {
|
"difficulty": {
|
||||||
"bytes": "AA=="
|
"bytes": "AA=="
|
||||||
},
|
},
|
||||||
"totalDifficulty": {
|
|
||||||
"bytes": "AQ=="
|
|
||||||
},
|
|
||||||
"number": "1",
|
"number": "1",
|
||||||
"timestamp": "1970-01-01T00:00:00Z",
|
"timestamp": "1970-01-01T00:00:00Z",
|
||||||
"mixHash": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=",
|
"mixHash": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue