Cancun code merge v1.13.0 v1.13.11 fix ci (#29)
* remove i386 linux tests * test: fix building of tests * return empty logs instead of nil in receipts * keep InitialBaseFee same with geth, so not break a ton of cases * fix eth dir * fix subdir of core * fix subdir of eth * fix cmd/geth dir * fix ethtest by adding UpgradeStatusMsg when handshake * fix ethclient_test.go * fix ethclient/simulated * fix internal * fix graphql * fix consensus * fix accounts * fix log * fix p2p * fix metrics * fix tests dir * fix golangci-lint --------- Co-authored-by: Matus Kysel <matus.kysel@bnbchain.org>
This commit is contained in:
parent
a1c2491aab
commit
9ec1223f4d
23
.github/workflows/go.yml
vendored
23
.github/workflows/go.yml
vendored
@ -1,23 +0,0 @@
|
|||||||
name: i386 linux tests
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [ master ]
|
|
||||||
pull_request:
|
|
||||||
branches: [ master ]
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: self-hosted
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- name: Set up Go
|
|
||||||
uses: actions/setup-go@v2
|
|
||||||
with:
|
|
||||||
go-version: 1.21.4
|
|
||||||
- name: Run tests
|
|
||||||
run: go test -short ./...
|
|
||||||
env:
|
|
||||||
GOOS: linux
|
|
||||||
GOARCH: 386
|
|
@ -21,19 +21,7 @@ import (
|
|||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/core"
|
"github.com/ethereum/go-ethereum/core"
|
||||||
"github.com/ethereum/go-ethereum/core/bloombits"
|
|
||||||
"github.com/ethereum/go-ethereum/core/rawdb"
|
|
||||||
"github.com/ethereum/go-ethereum/core/state"
|
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
|
||||||
"github.com/ethereum/go-ethereum/core/vm"
|
|
||||||
"github.com/ethereum/go-ethereum/eth/filters"
|
|
||||||
"github.com/ethereum/go-ethereum/ethclient/simulated"
|
"github.com/ethereum/go-ethereum/ethclient/simulated"
|
||||||
"github.com/ethereum/go-ethereum/ethdb"
|
|
||||||
"github.com/ethereum/go-ethereum/event"
|
|
||||||
"github.com/ethereum/go-ethereum/internal/ethapi"
|
|
||||||
"github.com/ethereum/go-ethereum/log"
|
|
||||||
"github.com/ethereum/go-ethereum/params"
|
|
||||||
"github.com/ethereum/go-ethereum/rpc"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// SimulatedBackend is a simulated blockchain.
|
// SimulatedBackend is a simulated blockchain.
|
||||||
|
@ -324,6 +324,32 @@ loop:
|
|||||||
if have, want := msg.ProtocolVersion, c.ourHighestProtoVersion; have != uint32(want) {
|
if have, want := msg.ProtocolVersion, c.ourHighestProtoVersion; have != uint32(want) {
|
||||||
return fmt.Errorf("wrong protocol version: have %v, want %v", have, want)
|
return fmt.Errorf("wrong protocol version: have %v, want %v", have, want)
|
||||||
}
|
}
|
||||||
|
// make sure eth protocol version is set for negotiation
|
||||||
|
if c.negotiatedProtoVersion == 0 {
|
||||||
|
return errors.New("eth protocol version must be set in Conn")
|
||||||
|
}
|
||||||
|
if status == nil {
|
||||||
|
// default status message
|
||||||
|
status = ð.StatusPacket{
|
||||||
|
ProtocolVersion: uint32(c.negotiatedProtoVersion),
|
||||||
|
NetworkID: chain.config.ChainID.Uint64(),
|
||||||
|
TD: chain.TD(),
|
||||||
|
Head: chain.blocks[chain.Len()-1].Hash(),
|
||||||
|
Genesis: chain.blocks[0].Hash(),
|
||||||
|
ForkID: chain.ForkID(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if err := c.Write(ethProto, eth.StatusMsg, status); err != nil {
|
||||||
|
return fmt.Errorf("write to connection failed: %v", err)
|
||||||
|
}
|
||||||
|
case eth.UpgradeStatusMsg + +protoOffset(ethProto):
|
||||||
|
msg := new(eth.UpgradeStatusPacket)
|
||||||
|
if err := rlp.DecodeBytes(data, &msg); err != nil {
|
||||||
|
return fmt.Errorf("error decoding status packet: %w", err)
|
||||||
|
}
|
||||||
|
if err := c.Write(ethProto, eth.UpgradeStatusMsg, msg); err != nil {
|
||||||
|
return fmt.Errorf("write to connection failed: %v", err)
|
||||||
|
}
|
||||||
break loop
|
break loop
|
||||||
case discMsg:
|
case discMsg:
|
||||||
var msg []p2p.DiscReason
|
var msg []p2p.DiscReason
|
||||||
@ -339,23 +365,6 @@ loop:
|
|||||||
return fmt.Errorf("bad status message: code %d", code)
|
return fmt.Errorf("bad status message: code %d", code)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// make sure eth protocol version is set for negotiation
|
|
||||||
if c.negotiatedProtoVersion == 0 {
|
|
||||||
return errors.New("eth protocol version must be set in Conn")
|
|
||||||
}
|
|
||||||
if status == nil {
|
|
||||||
// default status message
|
|
||||||
status = ð.StatusPacket{
|
|
||||||
ProtocolVersion: uint32(c.negotiatedProtoVersion),
|
|
||||||
NetworkID: chain.config.ChainID.Uint64(),
|
|
||||||
TD: chain.TD(),
|
|
||||||
Head: chain.blocks[chain.Len()-1].Hash(),
|
|
||||||
Genesis: chain.blocks[0].Hash(),
|
|
||||||
ForkID: chain.ForkID(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if err := c.Write(ethProto, eth.StatusMsg, status); err != nil {
|
|
||||||
return fmt.Errorf("write to connection failed: %v", err)
|
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,7 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/crypto"
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
"github.com/ethereum/go-ethereum/eth"
|
"github.com/ethereum/go-ethereum/eth"
|
||||||
"github.com/ethereum/go-ethereum/ethdb"
|
"github.com/ethereum/go-ethereum/ethdb"
|
||||||
|
"github.com/ethereum/go-ethereum/ethdb/leveldb"
|
||||||
"github.com/ethereum/go-ethereum/node"
|
"github.com/ethereum/go-ethereum/node"
|
||||||
"github.com/ethereum/go-ethereum/params"
|
"github.com/ethereum/go-ethereum/params"
|
||||||
"github.com/ethereum/go-ethereum/rlp"
|
"github.com/ethereum/go-ethereum/rlp"
|
||||||
@ -74,7 +75,7 @@ func NewLevelDBDatabaseWithFreezer(file string, cache int, handles int, ancient
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
frdb, err := NewDatabaseWithFreezer(kvdb, ancient, namespace, readonly, disableFreeze, isLastOffset, pruneAncientData)
|
frdb, err := rawdb.NewDatabaseWithFreezer(kvdb, ancient, namespace, readonly, disableFreeze, isLastOffset, pruneAncientData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
kvdb.Close()
|
kvdb.Close()
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -99,7 +100,7 @@ func testOfflineBlockPruneWithAmountReserved(t *testing.T, amountReserved uint64
|
|||||||
t.Fatalf("Failed to back up block: %v", err)
|
t.Fatalf("Failed to back up block: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
dbBack, err := rawdb.NewLevelDBDatabaseWithFreezer(chaindbPath, 0, 0, newAncientPath, "", false, true, false, false)
|
dbBack, err := NewLevelDBDatabaseWithFreezer(chaindbPath, 0, 0, newAncientPath, "", false, true, false, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to create database with ancient backend")
|
t.Fatalf("failed to create database with ancient backend")
|
||||||
}
|
}
|
||||||
@ -145,7 +146,7 @@ func testOfflineBlockPruneWithAmountReserved(t *testing.T, amountReserved uint64
|
|||||||
|
|
||||||
func BlockchainCreator(t *testing.T, chaindbPath, AncientPath string, blockRemain uint64) (ethdb.Database, []*types.Block, []*types.Block, []types.Receipts, []*big.Int, uint64, *core.BlockChain) {
|
func BlockchainCreator(t *testing.T, chaindbPath, AncientPath string, blockRemain uint64) (ethdb.Database, []*types.Block, []*types.Block, []types.Receipts, []*big.Int, uint64, *core.BlockChain) {
|
||||||
//create a database with ancient freezer
|
//create a database with ancient freezer
|
||||||
db, err := rawdb.NewLevelDBDatabaseWithFreezer(chaindbPath, 0, 0, AncientPath, "", false, false, false, false)
|
db, err := NewLevelDBDatabaseWithFreezer(chaindbPath, 0, 0, AncientPath, "", false, false, false, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to create database with ancient backend")
|
t.Fatalf("failed to create database with ancient backend")
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ func VerifyEIP1559Header(config *params.ChainConfig, parent, header *types.Heade
|
|||||||
// CalcBaseFee calculates the basefee of the header.
|
// CalcBaseFee calculates the basefee of the header.
|
||||||
func CalcBaseFee(config *params.ChainConfig, parent *types.Header) *big.Int {
|
func CalcBaseFee(config *params.ChainConfig, parent *types.Header) *big.Int {
|
||||||
if config.Parlia != nil {
|
if config.Parlia != nil {
|
||||||
return new(big.Int).SetUint64(params.InitialBaseFee)
|
return new(big.Int).SetUint64(params.InitialBaseFeeForBSC)
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the current block is the first EIP-1559 block, return the InitialBaseFee.
|
// If the current block is the first EIP-1559 block, return the InitialBaseFee.
|
||||||
|
@ -118,9 +118,9 @@ func TestCalcBaseFee(t *testing.T) {
|
|||||||
parentGasUsed uint64
|
parentGasUsed uint64
|
||||||
expectedBaseFee int64
|
expectedBaseFee int64
|
||||||
}{
|
}{
|
||||||
{params.InitialBaseFee, 20000000, 10000000, params.InitialBaseFee}, // usage == target
|
{params.InitialBaseFee, 20000000, 10000000, params.InitialBaseFeeForBSC}, // usage == target
|
||||||
{params.InitialBaseFee, 20000000, 9000000, params.InitialBaseFee}, // usage below target
|
{params.InitialBaseFee, 20000000, 9000000, params.InitialBaseFeeForBSC}, // usage below target
|
||||||
{params.InitialBaseFee, 20000000, 11000000, params.InitialBaseFee}, // usage above target
|
{params.InitialBaseFee, 20000000, 11000000, params.InitialBaseFeeForBSC}, // usage above target
|
||||||
}
|
}
|
||||||
for i, test := range tests {
|
for i, test := range tests {
|
||||||
parent := &types.Header{
|
parent := &types.Header{
|
||||||
|
@ -594,8 +594,15 @@ func (bc *BlockChain) cacheReceipts(hash common.Hash, receipts types.Receipts, b
|
|||||||
log.Warn("transaction and receipt count mismatch")
|
log.Warn("transaction and receipt count mismatch")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
blockBaseFee := block.BaseFee()
|
||||||
|
if blockBaseFee == nil {
|
||||||
|
blockBaseFee = big.NewInt(0)
|
||||||
|
}
|
||||||
for i, receipt := range receipts {
|
for i, receipt := range receipts {
|
||||||
receipt.EffectiveGasPrice = txs[i].EffectiveGasTipValue(block.BaseFee()) // basefee is supposed to be nil or zero
|
receipt.EffectiveGasPrice = big.NewInt(0).Add(blockBaseFee, txs[i].EffectiveGasTipValue(blockBaseFee))
|
||||||
|
if receipt.Logs == nil {
|
||||||
|
receipt.Logs = []*types.Log{}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bc.receiptsCache.Add(hash, receipts)
|
bc.receiptsCache.Add(hash, receipts)
|
||||||
@ -1131,7 +1138,6 @@ func (bc *BlockChain) writeHeadBlock(block *types.Block) {
|
|||||||
headBlockGauge.Update(int64(block.NumberU64()))
|
headBlockGauge.Update(int64(block.NumberU64()))
|
||||||
justifiedBlockGauge.Update(int64(bc.GetJustifiedNumber(block.Header())))
|
justifiedBlockGauge.Update(int64(bc.GetJustifiedNumber(block.Header())))
|
||||||
finalizedBlockGauge.Update(int64(bc.getFinalizedNumber(block.Header())))
|
finalizedBlockGauge.Update(int64(bc.getFinalizedNumber(block.Header())))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// stopWithoutSaving stops the blockchain service. If any imports are currently in progress
|
// stopWithoutSaving stops the blockchain service. If any imports are currently in progress
|
||||||
|
@ -69,7 +69,7 @@ func newCanonical(engine consensus.Engine, n int, full bool, scheme string, pipe
|
|||||||
if pipeline {
|
if pipeline {
|
||||||
ops = append(ops, EnablePipelineCommit)
|
ops = append(ops, EnablePipelineCommit)
|
||||||
}
|
}
|
||||||
blockchain, _ := NewBlockChain(rawdb.NewMemoryDatabase(), , DefaultCacheConfigWithScheme(scheme), genesis, nil, engine, vm.Config{}, nil, nil, ops...)
|
blockchain, _ := NewBlockChain(rawdb.NewMemoryDatabase(), DefaultCacheConfigWithScheme(scheme), genesis, nil, engine, vm.Config{}, nil, nil, ops...)
|
||||||
// Create and inject the requested chain
|
// Create and inject the requested chain
|
||||||
if n == 0 {
|
if n == 0 {
|
||||||
return rawdb.NewMemoryDatabase(), genesis, blockchain, nil
|
return rawdb.NewMemoryDatabase(), genesis, blockchain, nil
|
||||||
@ -137,7 +137,7 @@ func testInvalidStateRootBlockImport(t *testing.T, blockchain *BlockChain, i, n
|
|||||||
// Test fork of length N starting from block i
|
// Test fork of length N starting from block i
|
||||||
func testFork(t *testing.T, blockchain *BlockChain, i, n int, full bool, comparator func(td1, td2 *big.Int), scheme string, pipeline bool) {
|
func testFork(t *testing.T, blockchain *BlockChain, i, n int, full bool, comparator func(td1, td2 *big.Int), scheme string, pipeline bool) {
|
||||||
// Copy old chain up to #i into a new db
|
// Copy old chain up to #i into a new db
|
||||||
genDb, _, blockchain2, err := newCanonical(ethash.NewFaker(), i, full, scheme,pipeline)
|
genDb, _, blockchain2, err := newCanonical(ethash.NewFaker(), i, full, scheme, pipeline)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("could not make new canonical in testFork", err)
|
t.Fatal("could not make new canonical in testFork", err)
|
||||||
}
|
}
|
||||||
@ -261,7 +261,7 @@ func TestBlockImportVerification(t *testing.T) {
|
|||||||
length := 5
|
length := 5
|
||||||
|
|
||||||
// Make first chain starting from genesis
|
// Make first chain starting from genesis
|
||||||
_, _, processor, err := newCanonical(ethash.NewFaker(), length, true,rawdb.HashScheme, true)
|
_, _, processor, err := newCanonical(ethash.NewFaker(), length, true, rawdb.HashScheme, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to make new canonical chain: %v", err)
|
t.Fatalf("failed to make new canonical chain: %v", err)
|
||||||
}
|
}
|
||||||
@ -276,7 +276,7 @@ func TestLastBlock(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func testLastBlock(t *testing.T, scheme string) {
|
func testLastBlock(t *testing.T, scheme string) {
|
||||||
genDb, _, blockchain, err := newCanonical(ethash.NewFaker(), 0, true, scheme,false)
|
genDb, _, blockchain, err := newCanonical(ethash.NewFaker(), 0, true, scheme, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to create pristine chain: %v", err)
|
t.Fatalf("failed to create pristine chain: %v", err)
|
||||||
}
|
}
|
||||||
@ -295,7 +295,7 @@ func testLastBlock(t *testing.T, scheme string) {
|
|||||||
// The chain is reorged to whatever specified.
|
// The chain is reorged to whatever specified.
|
||||||
func testInsertAfterMerge(t *testing.T, blockchain *BlockChain, i, n int, full bool, scheme string) {
|
func testInsertAfterMerge(t *testing.T, blockchain *BlockChain, i, n int, full bool, scheme string) {
|
||||||
// Copy old chain up to #i into a new db
|
// Copy old chain up to #i into a new db
|
||||||
genDb, _, blockchain2, err := newCanonical(ethash.NewFaker(), i, full, scheme,false)
|
genDb, _, blockchain2, err := newCanonical(ethash.NewFaker(), i, full, scheme, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("could not make new canonical in testFork", err)
|
t.Fatal("could not make new canonical in testFork", err)
|
||||||
}
|
}
|
||||||
@ -343,21 +343,21 @@ func testInsertAfterMerge(t *testing.T, blockchain *BlockChain, i, n int, full b
|
|||||||
// Tests that given a starting canonical chain of a given size, it can be extended
|
// Tests that given a starting canonical chain of a given size, it can be extended
|
||||||
// with various length chains.
|
// with various length chains.
|
||||||
func TestExtendCanonicalHeaders(t *testing.T) {
|
func TestExtendCanonicalHeaders(t *testing.T) {
|
||||||
testExtendCanonical(t, false, rawdb.HashScheme,false)
|
testExtendCanonical(t, false, rawdb.HashScheme, false)
|
||||||
testExtendCanonical(t, false, rawdb.PathScheme,false)
|
testExtendCanonical(t, false, rawdb.PathScheme, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestExtendCanonicalBlocks(t *testing.T) {
|
func TestExtendCanonicalBlocks(t *testing.T) {
|
||||||
testExtendCanonical(t, true,rawdb.HashScheme, false)
|
testExtendCanonical(t, true, rawdb.HashScheme, false)
|
||||||
testExtendCanonical(t, true,rawdb.PathScheme, false)
|
testExtendCanonical(t, true, rawdb.PathScheme, false)
|
||||||
testExtendCanonical(t, true,rawdb.HashScheme, true)
|
testExtendCanonical(t, true, rawdb.HashScheme, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testExtendCanonical(t *testing.T, full, scheme string, pipeline bool) {
|
func testExtendCanonical(t *testing.T, full bool, scheme string, pipeline bool) {
|
||||||
length := 5
|
length := 5
|
||||||
|
|
||||||
// Make first chain starting from genesis
|
// Make first chain starting from genesis
|
||||||
_, _, processor, err := newCanonical(ethash.NewFaker(), length, full,scheme, pipeline)
|
_, _, processor, err := newCanonical(ethash.NewFaker(), length, full, scheme, pipeline)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to make new canonical chain: %v", err)
|
t.Fatalf("failed to make new canonical chain: %v", err)
|
||||||
}
|
}
|
||||||
@ -370,10 +370,10 @@ func testExtendCanonical(t *testing.T, full, scheme string, pipeline bool) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Start fork from current height
|
// Start fork from current height
|
||||||
testFork(t, processor, length, 1, full, pipeline, better,scheme)
|
testFork(t, processor, length, 1, full, better, scheme, pipeline)
|
||||||
testFork(t, processor, length, 2, full, pipeline, better,scheme)
|
testFork(t, processor, length, 2, full, better, scheme, pipeline)
|
||||||
testFork(t, processor, length, 5, full, pipeline, better,scheme)
|
testFork(t, processor, length, 5, full, better, scheme, pipeline)
|
||||||
testFork(t, processor, length, 10, full, pipeline, better,scheme)
|
testFork(t, processor, length, 10, full, better, scheme, pipeline)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tests that given a starting canonical chain of a given size, it can be extended
|
// Tests that given a starting canonical chain of a given size, it can be extended
|
||||||
@ -403,17 +403,17 @@ func testExtendCanonicalAfterMerge(t *testing.T, full bool, scheme string) {
|
|||||||
|
|
||||||
// Tests that given a starting canonical chain of a given size, creating shorter
|
// Tests that given a starting canonical chain of a given size, creating shorter
|
||||||
// forks do not take canonical ownership.
|
// forks do not take canonical ownership.
|
||||||
func TestShorterForkHeaders(t *testing.T){
|
func TestShorterForkHeaders(t *testing.T) {
|
||||||
testShorterFork(t, false, rawdb.HashScheme, false)
|
testShorterFork(t, false, rawdb.HashScheme, false)
|
||||||
testShorterFork(t, false, rawdb.PathScheme, false)
|
testShorterFork(t, false, rawdb.PathScheme, false)
|
||||||
}
|
}
|
||||||
func TestShorterForkBlocks(t *testing.T) {
|
func TestShorterForkBlocks(t *testing.T) {
|
||||||
testShorterFork(t, true, rawdb.HashScheme, false)
|
testShorterFork(t, true, rawdb.HashScheme, false)
|
||||||
testShorterFork(t, true, rawdb.PathScheme, false)
|
testShorterFork(t, true, rawdb.PathScheme, false)
|
||||||
testShorterFork(t, true,rawdb.HashScheme, true)
|
testShorterFork(t, true, rawdb.HashScheme, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testShorterFork(t *testing.T, full, scheme string, pipeline bool) {
|
func testShorterFork(t *testing.T, full bool, scheme string, pipeline bool) {
|
||||||
length := 10
|
length := 10
|
||||||
|
|
||||||
// Make first chain starting from genesis
|
// Make first chain starting from genesis
|
||||||
@ -430,12 +430,12 @@ func testShorterFork(t *testing.T, full, scheme string, pipeline bool) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Sum of numbers must be less than `length` for this to be a shorter fork
|
// Sum of numbers must be less than `length` for this to be a shorter fork
|
||||||
testFork(t, processor, 0, 3, full, pipeline, worse, scheme)
|
testFork(t, processor, 0, 3, full, worse, scheme, pipeline)
|
||||||
testFork(t, processor, 0, 7, full, pipeline, worse, scheme)
|
testFork(t, processor, 0, 7, full, worse, scheme, pipeline)
|
||||||
testFork(t, processor, 1, 1, full, pipeline, worse, scheme)
|
testFork(t, processor, 1, 1, full, worse, scheme, pipeline)
|
||||||
testFork(t, processor, 1, 7, full, pipeline, worse, scheme)
|
testFork(t, processor, 1, 7, full, worse, scheme, pipeline)
|
||||||
testFork(t, processor, 5, 3, full, pipeline, worse, scheme)
|
testFork(t, processor, 5, 3, full, worse, scheme, pipeline)
|
||||||
testFork(t, processor, 5, 4, full, pipeline, worse, scheme)
|
testFork(t, processor, 5, 4, full, worse, scheme, pipeline)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tests that given a starting canonical chain of a given size, creating shorter
|
// Tests that given a starting canonical chain of a given size, creating shorter
|
||||||
@ -470,20 +470,20 @@ func testShorterForkAfterMerge(t *testing.T, full bool, scheme string) {
|
|||||||
// Tests that given a starting canonical chain of a given size, creating longer
|
// Tests that given a starting canonical chain of a given size, creating longer
|
||||||
// forks do take canonical ownership.
|
// forks do take canonical ownership.
|
||||||
func TestLongerForkHeaders(t *testing.T) {
|
func TestLongerForkHeaders(t *testing.T) {
|
||||||
testLongerFork(t, false, rawdb.HashScheme,false)
|
testLongerFork(t, false, rawdb.HashScheme, false)
|
||||||
testLongerFork(t, false, rawdb.PathScheme,false)
|
testLongerFork(t, false, rawdb.PathScheme, false)
|
||||||
}
|
}
|
||||||
func TestLongerForkBlocks(t *testing.T) {
|
func TestLongerForkBlocks(t *testing.T) {
|
||||||
testLongerFork(t, true, rawdb.HashScheme,false)
|
testLongerFork(t, true, rawdb.HashScheme, false)
|
||||||
testLongerFork(t, true, rawdb.PathScheme,false)
|
testLongerFork(t, true, rawdb.PathScheme, false)
|
||||||
testLongerFork(t, true, rawdb.HashScheme,true)
|
testLongerFork(t, true, rawdb.HashScheme, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testLongerFork(t *testing.T, full, scheme string, pipeline bool) {
|
func testLongerFork(t *testing.T, full bool, scheme string, pipeline bool) {
|
||||||
length := 10
|
length := 10
|
||||||
|
|
||||||
// Make first chain starting from genesis
|
// Make first chain starting from genesis
|
||||||
_, _, processor, err := newCanonical(ethash.NewFaker(), length, full,scheme, pipeline)
|
_, _, processor, err := newCanonical(ethash.NewFaker(), length, full, scheme, pipeline)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to make new canonical chain: %v", err)
|
t.Fatalf("failed to make new canonical chain: %v", err)
|
||||||
}
|
}
|
||||||
@ -529,20 +529,20 @@ func testLongerForkAfterMerge(t *testing.T, full bool, scheme string) {
|
|||||||
// Tests that given a starting canonical chain of a given size, creating equal
|
// Tests that given a starting canonical chain of a given size, creating equal
|
||||||
// forks do take canonical ownership.
|
// forks do take canonical ownership.
|
||||||
func TestEqualForkHeaders(t *testing.T) {
|
func TestEqualForkHeaders(t *testing.T) {
|
||||||
testEqualFork(t, false, rawdb.HashScheme,false)
|
testEqualFork(t, false, rawdb.HashScheme, false)
|
||||||
testEqualFork(t, false, rawdb.PathScheme,false)
|
testEqualFork(t, false, rawdb.PathScheme, false)
|
||||||
}
|
}
|
||||||
func TestEqualForkBlocks(t *testing.T) {
|
func TestEqualForkBlocks(t *testing.T) {
|
||||||
testEqualFork(t, true, rawdb.HashScheme,false)
|
testEqualFork(t, true, rawdb.HashScheme, false)
|
||||||
testEqualFork(t, true, rawdb.PathScheme,false)
|
testEqualFork(t, true, rawdb.PathScheme, false)
|
||||||
testEqualFork(t, true, rawdb.HashScheme,true)
|
testEqualFork(t, true, rawdb.HashScheme, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testEqualFork(t *testing.T, full, scheme string, pipeline bool) {
|
func testEqualFork(t *testing.T, full bool, scheme string, pipeline bool) {
|
||||||
length := 10
|
length := 10
|
||||||
|
|
||||||
// Make first chain starting from genesis
|
// Make first chain starting from genesis
|
||||||
_, _, processor, err := newCanonical(ethash.NewFaker(), length, full,scheme, pipeline)
|
_, _, processor, err := newCanonical(ethash.NewFaker(), length, full, scheme, pipeline)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to make new canonical chain: %v", err)
|
t.Fatalf("failed to make new canonical chain: %v", err)
|
||||||
}
|
}
|
||||||
@ -555,12 +555,12 @@ func testEqualFork(t *testing.T, full, scheme string, pipeline bool) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Sum of numbers must be equal to `length` for this to be an equal fork
|
// Sum of numbers must be equal to `length` for this to be an equal fork
|
||||||
testFork(t, processor, 0, 10, full, pipeline, equal, scheme)
|
testFork(t, processor, 0, 10, full, equal, scheme, pipeline)
|
||||||
testFork(t, processor, 1, 9, full, pipeline, equal, scheme)
|
testFork(t, processor, 1, 9, full, equal, scheme, pipeline)
|
||||||
testFork(t, processor, 2, 8, full, pipeline, equal, scheme)
|
testFork(t, processor, 2, 8, full, equal, scheme, pipeline)
|
||||||
testFork(t, processor, 5, 5, full, pipeline, equal, scheme)
|
testFork(t, processor, 5, 5, full, equal, scheme, pipeline)
|
||||||
testFork(t, processor, 6, 4, full, pipeline, equal, scheme)
|
testFork(t, processor, 6, 4, full, equal, scheme, pipeline)
|
||||||
testFork(t, processor, 9, 1, full, pipeline, equal, scheme)
|
testFork(t, processor, 9, 1, full, equal, scheme, pipeline)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tests that given a starting canonical chain of a given size, creating equal
|
// Tests that given a starting canonical chain of a given size, creating equal
|
||||||
@ -593,19 +593,19 @@ func testEqualForkAfterMerge(t *testing.T, full bool, scheme string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Tests that chains missing links do not get accepted by the processor.
|
// Tests that chains missing links do not get accepted by the processor.
|
||||||
func TestBrokenHeaderChain(t *testing.T) {
|
func TestBrokenHeaderChain(t *testing.T) {
|
||||||
testBrokenChain(t, false, rawdb.HashScheme,false)
|
testBrokenChain(t, false, rawdb.HashScheme, false)
|
||||||
testBrokenChain(t, false, rawdb.PathScheme,false)
|
testBrokenChain(t, false, rawdb.PathScheme, false)
|
||||||
}
|
}
|
||||||
func TestBrokenBlockChain(t *testing.T) {
|
func TestBrokenBlockChain(t *testing.T) {
|
||||||
testBrokenChain(t, true, rawdb.HashScheme,false)
|
testBrokenChain(t, true, rawdb.HashScheme, false)
|
||||||
testBrokenChain(t, true, rawdb.PathScheme,false)
|
testBrokenChain(t, true, rawdb.PathScheme, false)
|
||||||
testBrokenChain(t, true, rawdb.HashScheme,true)
|
testBrokenChain(t, true, rawdb.HashScheme, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testBrokenChain(t *testing.T, full, scheme string, pipeline bool) {
|
func testBrokenChain(t *testing.T, full bool, scheme string, pipeline bool) {
|
||||||
// Make chain starting from genesis
|
// Make chain starting from genesis
|
||||||
genDb, _, blockchain, err := newCanonical(ethash.NewFaker(), 10, full,scheme, pipeline)
|
genDb, _, blockchain, err := newCanonical(ethash.NewFaker(), 10, full, scheme, pipeline)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to make new canonical chain: %v", err)
|
t.Fatalf("failed to make new canonical chain: %v", err)
|
||||||
}
|
}
|
||||||
@ -627,33 +627,33 @@ func testBrokenChain(t *testing.T, full, scheme string, pipeline bool) {
|
|||||||
|
|
||||||
// Tests that reorganising a long difficult chain after a short easy one
|
// Tests that reorganising a long difficult chain after a short easy one
|
||||||
// overwrites the canonical numbers and links in the database.
|
// overwrites the canonical numbers and links in the database.
|
||||||
func TestReorgLongHeaders(t *testing.T) {
|
func TestReorgLongHeaders(t *testing.T) {
|
||||||
testReorgLong(t, false, rawdb.HashScheme,false)
|
testReorgLong(t, false, rawdb.HashScheme, false)
|
||||||
testReorgLong(t, false, rawdb.PathScheme,false)
|
testReorgLong(t, false, rawdb.PathScheme, false)
|
||||||
}
|
}
|
||||||
func TestReorgLongBlocks(t *testing.T) {
|
func TestReorgLongBlocks(t *testing.T) {
|
||||||
testReorgLong(t, true, rawdb.HashScheme,false)
|
testReorgLong(t, true, rawdb.HashScheme, false)
|
||||||
testReorgLong(t, true, rawdb.PathScheme,false)
|
testReorgLong(t, true, rawdb.PathScheme, false)
|
||||||
testReorgLong(t, true, rawdb.HashScheme,true)
|
testReorgLong(t, true, rawdb.HashScheme, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testReorgLong(t *testing.T, full,scheme, pipeline bool) {
|
func testReorgLong(t *testing.T, full bool, scheme string, pipeline bool) {
|
||||||
testReorg(t, []int64{0, 0, -9}, []int64{0, 0, 0, -9}, 393280+params.GenesisDifficulty.Int64(), full,scheme, pipeline)
|
testReorg(t, []int64{0, 0, -9}, []int64{0, 0, 0, -9}, 393280+params.GenesisDifficulty.Int64(), full, scheme, pipeline)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tests that reorganising a short difficult chain after a long easy one
|
// Tests that reorganising a short difficult chain after a long easy one
|
||||||
// overwrites the canonical numbers and links in the database.
|
// overwrites the canonical numbers and links in the database.
|
||||||
func TestReorgShortHeaders(t *testing.T) {
|
func TestReorgShortHeaders(t *testing.T) {
|
||||||
testReorgShort(t, false, rawdb.HashScheme,false)
|
testReorgShort(t, false, rawdb.HashScheme, false)
|
||||||
testReorgShort(t, false, rawdb.PathScheme,false)
|
testReorgShort(t, false, rawdb.PathScheme, false)
|
||||||
}
|
}
|
||||||
func TestReorgShortBlocks(t *testing.T) {
|
func TestReorgShortBlocks(t *testing.T) {
|
||||||
testReorgShort(t, true, rawdb.HashScheme,false)
|
testReorgShort(t, true, rawdb.HashScheme, false)
|
||||||
testReorgShort(t, true, rawdb.PathScheme,false)
|
testReorgShort(t, true, rawdb.PathScheme, false)
|
||||||
testReorgShort(t, true, rawdb.HashScheme,true)
|
testReorgShort(t, true, rawdb.HashScheme, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testReorgShort(t *testing.T, full, scheme string, pipeline bool) {
|
func testReorgShort(t *testing.T, full bool, scheme string, pipeline bool) {
|
||||||
// Create a long easy chain vs. a short heavy one. Due to difficulty adjustment
|
// Create a long easy chain vs. a short heavy one. Due to difficulty adjustment
|
||||||
// we need a fairly long chain of blocks with different difficulties for a short
|
// we need a fairly long chain of blocks with different difficulties for a short
|
||||||
// one to become heavier than a long one. The 96 is an empirical value.
|
// one to become heavier than a long one. The 96 is an empirical value.
|
||||||
@ -665,12 +665,12 @@ func testReorgShort(t *testing.T, full, scheme string, pipeline bool) {
|
|||||||
for i := 0; i < len(diff); i++ {
|
for i := 0; i < len(diff); i++ {
|
||||||
diff[i] = -9
|
diff[i] = -9
|
||||||
}
|
}
|
||||||
testReorg(t, easy, diff, 12615120+params.GenesisDifficulty.Int64(), full,scheme, pipeline)
|
testReorg(t, easy, diff, 12615120+params.GenesisDifficulty.Int64(), full, scheme, pipeline)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testReorg(t *testing.T, first, second []int64, td int64, full bool, scheme string, pipeline bool ){
|
func testReorg(t *testing.T, first, second []int64, td int64, full bool, scheme string, pipeline bool) {
|
||||||
// Create a pristine chain and database
|
// Create a pristine chain and database
|
||||||
genDb, _, blockchain, err := newCanonical(ethash.NewFaker(), 0, full, scheme,pipeline)
|
genDb, _, blockchain, err := newCanonical(ethash.NewFaker(), 0, full, scheme, pipeline)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to create pristine chain: %v", err)
|
t.Fatalf("failed to create pristine chain: %v", err)
|
||||||
}
|
}
|
||||||
@ -738,21 +738,20 @@ func testReorg(t *testing.T, first, second []int64, td int64, full bool, scheme
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Tests that the insertion functions detect banned hashes.
|
// Tests that the insertion functions detect banned hashes.
|
||||||
func TestBadHeaderHashes(t *testing.T) {
|
func TestBadHeaderHashes(t *testing.T) {
|
||||||
testBadHashes(t, false, rawdb.HashScheme,false)
|
testBadHashes(t, false, rawdb.HashScheme, false)
|
||||||
testBadHashes(t, false, rawdb.PathScheme,false)
|
testBadHashes(t, false, rawdb.PathScheme, false)
|
||||||
testBadHashes(t, false, false)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBadBlockHashes(t *testing.T) {
|
func TestBadBlockHashes(t *testing.T) {
|
||||||
testBadHashes(t, true, rawdb.HashScheme,false)
|
testBadHashes(t, true, rawdb.HashScheme, false)
|
||||||
testBadHashes(t, true, rawdb.HashScheme,true)
|
testBadHashes(t, true, rawdb.HashScheme, true)
|
||||||
testBadHashes(t, true, rawdb.PathScheme,false)
|
testBadHashes(t, true, rawdb.PathScheme, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testBadHashes(t *testing.T, full, scheme string, pipeline bool) {
|
func testBadHashes(t *testing.T, full bool, scheme string, pipeline bool) {
|
||||||
// Create a pristine chain and database
|
// Create a pristine chain and database
|
||||||
genDb, _, blockchain, err := newCanonical(ethash.NewFaker(), 0, full,scheme, pipeline)
|
genDb, _, blockchain, err := newCanonical(ethash.NewFaker(), 0, full, scheme, pipeline)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to create pristine chain: %v", err)
|
t.Fatalf("failed to create pristine chain: %v", err)
|
||||||
}
|
}
|
||||||
@ -782,18 +781,18 @@ func testBadHashes(t *testing.T, full, scheme string, pipeline bool) {
|
|||||||
// Tests that bad hashes are detected on boot, and the chain rolled back to a
|
// Tests that bad hashes are detected on boot, and the chain rolled back to a
|
||||||
// good state prior to the bad hash.
|
// good state prior to the bad hash.
|
||||||
func TestReorgBadHeaderHashes(t *testing.T) {
|
func TestReorgBadHeaderHashes(t *testing.T) {
|
||||||
testReorgBadHashes(t, false, rawdb.HashScheme,false)
|
testReorgBadHashes(t, false, rawdb.HashScheme, false)
|
||||||
testReorgBadHashes(t, false, rawdb.PathScheme,false)
|
testReorgBadHashes(t, false, rawdb.PathScheme, false)
|
||||||
}
|
}
|
||||||
func TestReorgBadBlockHashes(t *testing.T) {
|
func TestReorgBadBlockHashes(t *testing.T) {
|
||||||
testReorgBadHashes(t, true, rawdb.HashScheme,false)
|
testReorgBadHashes(t, true, rawdb.HashScheme, false)
|
||||||
testReorgBadHashes(t, true, rawdb.HashScheme,true)
|
testReorgBadHashes(t, true, rawdb.HashScheme, true)
|
||||||
testReorgBadHashes(t, true, rawdb.PathScheme,false)
|
testReorgBadHashes(t, true, rawdb.PathScheme, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testReorgBadHashes(t *testing.T, full,scheme string, pipeline bool) {
|
func testReorgBadHashes(t *testing.T, full bool, scheme string, pipeline bool) {
|
||||||
// Create a pristine chain and database
|
// Create a pristine chain and database
|
||||||
genDb, gspec, blockchain, err := newCanonical(ethash.NewFaker(), 0, full,scheme, pipeline)
|
genDb, gspec, blockchain, err := newCanonical(ethash.NewFaker(), 0, full, scheme, pipeline)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to create pristine chain: %v", err)
|
t.Fatalf("failed to create pristine chain: %v", err)
|
||||||
}
|
}
|
||||||
@ -844,19 +843,19 @@ func testReorgBadHashes(t *testing.T, full,scheme string, pipeline bool) {
|
|||||||
|
|
||||||
// Tests chain insertions in the face of one entity containing an invalid nonce.
|
// Tests chain insertions in the face of one entity containing an invalid nonce.
|
||||||
func TestHeadersInsertNonceError(t *testing.T) {
|
func TestHeadersInsertNonceError(t *testing.T) {
|
||||||
testInsertNonceError(t, false, rawdb.HashScheme,false)
|
testInsertNonceError(t, false, rawdb.HashScheme, false)
|
||||||
testInsertNonceError(t, false, rawdb.PathScheme,false)
|
testInsertNonceError(t, false, rawdb.PathScheme, false)
|
||||||
}
|
}
|
||||||
func TestBlocksInsertNonceError(t *testing.T) {
|
func TestBlocksInsertNonceError(t *testing.T) {
|
||||||
testInsertNonceError(t, true, rawdb.HashScheme,false)
|
testInsertNonceError(t, true, rawdb.HashScheme, false)
|
||||||
testInsertNonceError(t, true, rawdb.HashScheme,true)
|
testInsertNonceError(t, true, rawdb.HashScheme, true)
|
||||||
testInsertNonceError(t, true, rawdb.PathScheme,false)
|
testInsertNonceError(t, true, rawdb.PathScheme, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testInsertNonceError(t *testing.T, full bool, scheme string, pipeline bool) {
|
func testInsertNonceError(t *testing.T, full bool, scheme string, pipeline bool) {
|
||||||
doTest := func(i int) {
|
doTest := func(i int) {
|
||||||
// Create a pristine chain and database
|
// Create a pristine chain and database
|
||||||
genDb, _, blockchain, err := newCanonical(ethash.NewFaker(), 0, full,scheme, pipeline)
|
genDb, _, blockchain, err := newCanonical(ethash.NewFaker(), 0, full, scheme, pipeline)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to create pristine chain: %v", err)
|
t.Fatalf("failed to create pristine chain: %v", err)
|
||||||
}
|
}
|
||||||
@ -1607,7 +1606,7 @@ func TestCanonicalBlockRetrieval(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func testCanonicalBlockRetrieval(t *testing.T, scheme string) {
|
func testCanonicalBlockRetrieval(t *testing.T, scheme string) {
|
||||||
_, gspec, blockchain, err := newCanonical(ethash.NewFaker(), 0, true, scheme,false)
|
_, gspec, blockchain, err := newCanonical(ethash.NewFaker(), 0, true, scheme, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to create pristine chain: %v", err)
|
t.Fatalf("failed to create pristine chain: %v", err)
|
||||||
}
|
}
|
||||||
@ -1929,7 +1928,7 @@ func TestTrieForkGC(t *testing.T) {
|
|||||||
chain.TrieDB().Dereference(blocks[len(blocks)-1-i].Root())
|
chain.TrieDB().Dereference(blocks[len(blocks)-1-i].Root())
|
||||||
chain.TrieDB().Dereference(forks[len(blocks)-1-i].Root())
|
chain.TrieDB().Dereference(forks[len(blocks)-1-i].Root())
|
||||||
}
|
}
|
||||||
if _, nodes, _ := chain.TrieDB().Size(); nodes > 0 { // all memory is returned in the nodes return for hashdb
|
if _, nodes, _, _ := chain.TrieDB().Size(); nodes > 0 { // all memory is returned in the nodes return for hashdb
|
||||||
t.Fatalf("stale tries still alive after garbase collection")
|
t.Fatalf("stale tries still alive after garbase collection")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1953,7 +1952,7 @@ func testLargeReorgTrieGC(t *testing.T, scheme string) {
|
|||||||
competitor, _ := GenerateChain(genesis.Config, shared[len(shared)-1], engine, genDb, 2*TriesInMemory+1, func(i int, b *BlockGen) { b.SetCoinbase(common.Address{3}) })
|
competitor, _ := GenerateChain(genesis.Config, shared[len(shared)-1], engine, genDb, 2*TriesInMemory+1, func(i int, b *BlockGen) { b.SetCoinbase(common.Address{3}) })
|
||||||
|
|
||||||
// Import the shared chain and the original canonical one
|
// Import the shared chain and the original canonical one
|
||||||
db, _ := rawdb.NewDatabaseWithFreezer(rawdb.NewMemoryDatabase(), t.TempDir(), "", false)
|
db, _ := rawdb.NewDatabaseWithFreezer(rawdb.NewMemoryDatabase(), t.TempDir(), "", false, false, false, false)
|
||||||
defer db.Close()
|
defer db.Close()
|
||||||
|
|
||||||
chain, err := NewBlockChain(db, DefaultCacheConfigWithScheme(scheme), genesis, nil, engine, vm.Config{}, nil, nil)
|
chain, err := NewBlockChain(db, DefaultCacheConfigWithScheme(scheme), genesis, nil, engine, vm.Config{}, nil, nil)
|
||||||
@ -2163,7 +2162,7 @@ func testLowDiffLongChain(t *testing.T, scheme string) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
// Import the canonical chain
|
// Import the canonical chain
|
||||||
diskdb, _ := rawdb.NewDatabaseWithFreezer(rawdb.NewMemoryDatabase(), t.TempDir(), "", false)
|
diskdb, _ := rawdb.NewDatabaseWithFreezer(rawdb.NewMemoryDatabase(), t.TempDir(), "", false, false, false, false)
|
||||||
defer diskdb.Close()
|
defer diskdb.Close()
|
||||||
|
|
||||||
chain, err := NewBlockChain(diskdb, DefaultCacheConfigWithScheme(scheme), genesis, nil, engine, vm.Config{}, nil, nil)
|
chain, err := NewBlockChain(diskdb, DefaultCacheConfigWithScheme(scheme), genesis, nil, engine, vm.Config{}, nil, nil)
|
||||||
@ -3844,7 +3843,7 @@ func testSetCanonical(t *testing.T, scheme string) {
|
|||||||
}
|
}
|
||||||
gen.AddTx(tx)
|
gen.AddTx(tx)
|
||||||
})
|
})
|
||||||
diskdb, _ := rawdb.NewDatabaseWithFreezer(rawdb.NewMemoryDatabase(), t.TempDir(), "", false)
|
diskdb, _ := rawdb.NewDatabaseWithFreezer(rawdb.NewMemoryDatabase(), t.TempDir(), "", false, false, false, false)
|
||||||
defer diskdb.Close()
|
defer diskdb.Close()
|
||||||
|
|
||||||
chain, err := NewBlockChain(diskdb, DefaultCacheConfigWithScheme(scheme), gspec, nil, engine, vm.Config{}, nil, nil)
|
chain, err := NewBlockChain(diskdb, DefaultCacheConfigWithScheme(scheme), gspec, nil, engine, vm.Config{}, nil, nil)
|
||||||
|
@ -579,5 +579,4 @@ func (cm *chainMaker) GetTd(hash common.Hash, number uint64) *big.Int {
|
|||||||
|
|
||||||
func (cm *chainMaker) GetHighestVerifiedHeader() *types.Header {
|
func (cm *chainMaker) GetHighestVerifiedHeader() *types.Header {
|
||||||
panic("not supported")
|
panic("not supported")
|
||||||
return nil // not supported
|
|
||||||
}
|
}
|
||||||
|
@ -477,7 +477,11 @@ func (g *Genesis) ToBlock() *types.Block {
|
|||||||
if g.BaseFee != nil {
|
if g.BaseFee != nil {
|
||||||
head.BaseFee = g.BaseFee
|
head.BaseFee = g.BaseFee
|
||||||
} else {
|
} else {
|
||||||
head.BaseFee = new(big.Int).SetUint64(params.InitialBaseFee)
|
if g.Config.Parlia != nil {
|
||||||
|
head.BaseFee = new(big.Int).SetUint64(params.InitialBaseFeeForBSC)
|
||||||
|
} else {
|
||||||
|
head.BaseFee = new(big.Int).SetUint64(params.InitialBaseFee)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var withdrawals []*types.Withdrawal
|
var withdrawals []*types.Withdrawal
|
||||||
|
@ -289,12 +289,12 @@ func TestFreezerConcurrentReadonly(t *testing.T) {
|
|||||||
tables := map[string]bool{"a": true}
|
tables := map[string]bool{"a": true}
|
||||||
dir := t.TempDir()
|
dir := t.TempDir()
|
||||||
|
|
||||||
f, err := NewFreezer(dir, "", false, 2049, tables)
|
f, err := NewFreezer(dir, "", false, 0, 2049, tables)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("can't open freezer", err)
|
t.Fatal("can't open freezer", err)
|
||||||
}
|
}
|
||||||
var item = make([]byte, 1024)
|
var item = make([]byte, 1024)
|
||||||
batch := f.tables["a"].newBatch()
|
batch := f.tables["a"].newBatch(0)
|
||||||
items := uint64(10)
|
items := uint64(10)
|
||||||
for i := uint64(0); i < items; i++ {
|
for i := uint64(0); i < items; i++ {
|
||||||
require.NoError(t, batch.AppendRaw(i, item))
|
require.NoError(t, batch.AppendRaw(i, item))
|
||||||
@ -315,7 +315,7 @@ func TestFreezerConcurrentReadonly(t *testing.T) {
|
|||||||
go func(i int) {
|
go func(i int) {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
|
|
||||||
f, err := NewFreezer(dir, "", true, 2049, tables)
|
f, err := NewFreezer(dir, "", true, 0, 2049, tables)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
fs[i] = f
|
fs[i] = f
|
||||||
} else {
|
} else {
|
||||||
|
@ -534,8 +534,8 @@ func (test *snapshotTest) checkEqual(state, checkstate *StateDB) error {
|
|||||||
func TestTouchDelete(t *testing.T) {
|
func TestTouchDelete(t *testing.T) {
|
||||||
s := newStateEnv()
|
s := newStateEnv()
|
||||||
s.state.getOrNewStateObject(common.Address{})
|
s.state.getOrNewStateObject(common.Address{})
|
||||||
state.Finalise(false)
|
s.state.Finalise(false)
|
||||||
state.AccountsIntermediateRoot()
|
s.state.AccountsIntermediateRoot()
|
||||||
root, _, _ := s.state.Commit(0, nil)
|
root, _, _ := s.state.Commit(0, nil)
|
||||||
s.state, _ = New(root, s.state.db, s.state.snaps)
|
s.state, _ = New(root, s.state.db, s.state.snaps)
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/crypto"
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
"github.com/ethereum/go-ethereum/params"
|
"github.com/ethereum/go-ethereum/params"
|
||||||
"github.com/ethereum/go-ethereum/trie"
|
"github.com/ethereum/go-ethereum/trie"
|
||||||
|
"github.com/holiman/uint256"
|
||||||
"golang.org/x/crypto/sha3"
|
"golang.org/x/crypto/sha3"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -201,7 +202,7 @@ func TestStateProcessorErrors(t *testing.T) {
|
|||||||
txs: []*types.Transaction{
|
txs: []*types.Transaction{
|
||||||
mkDynamicTx(0, common.Address{}, params.TxGas, big.NewInt(0), big.NewInt(0)),
|
mkDynamicTx(0, common.Address{}, params.TxGas, big.NewInt(0), big.NewInt(0)),
|
||||||
},
|
},
|
||||||
want: "invalid gas used (remote: 0 local: 21000)",
|
want: "could not apply tx 0 [0xc4ab868fef0c82ae0387b742aee87907f2d0fc528fc6ea0a021459fb0fc4a4a8]: max fee per gas less than block base fee: address 0x71562b71999873DB5b286dF957af199Ec94617F7, maxFeePerGas: 0, baseFee: 875000000",
|
||||||
},
|
},
|
||||||
{ // ErrTipVeryHigh
|
{ // ErrTipVeryHigh
|
||||||
txs: []*types.Transaction{
|
txs: []*types.Transaction{
|
||||||
@ -240,13 +241,13 @@ func TestStateProcessorErrors(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{ // ErrMaxInitCodeSizeExceeded
|
{ // ErrMaxInitCodeSizeExceeded
|
||||||
txs: []*types.Transaction{
|
txs: []*types.Transaction{
|
||||||
mkDynamicCreationTx(0, 500000, common.Big0, big.NewInt(params.InitialBaseFeeForEthMainnet), tooBigInitCode[:]),
|
mkDynamicCreationTx(0, 500000, common.Big0, big.NewInt(params.InitialBaseFee), tooBigInitCode[:]),
|
||||||
},
|
},
|
||||||
want: "could not apply tx 0 [0xd491405f06c92d118dd3208376fcee18a57c54bc52063ee4a26b1cf296857c25]: max initcode size exceeded: code size 49153 limit 49152",
|
want: "could not apply tx 0 [0xd491405f06c92d118dd3208376fcee18a57c54bc52063ee4a26b1cf296857c25]: max initcode size exceeded: code size 49153 limit 49152",
|
||||||
},
|
},
|
||||||
{ // ErrIntrinsicGas: Not enough gas to cover init code
|
{ // ErrIntrinsicGas: Not enough gas to cover init code
|
||||||
txs: []*types.Transaction{
|
txs: []*types.Transaction{
|
||||||
mkDynamicCreationTx(0, 54299, common.Big0, big.NewInt(params.InitialBaseFeeForEthMainnet), make([]byte, 320)),
|
mkDynamicCreationTx(0, 54299, common.Big0, big.NewInt(params.InitialBaseFee), make([]byte, 320)),
|
||||||
},
|
},
|
||||||
want: "could not apply tx 0 [0xfd49536a9b323769d8472fcb3ebb3689b707a349379baee3e2ee3fe7baae06a1]: intrinsic gas too low: have 54299, want 54300",
|
want: "could not apply tx 0 [0xfd49536a9b323769d8472fcb3ebb3689b707a349379baee3e2ee3fe7baae06a1]: intrinsic gas too low: have 54299, want 54300",
|
||||||
},
|
},
|
||||||
|
@ -212,7 +212,7 @@ func TestTxIndexer(t *testing.T) {
|
|||||||
}
|
}
|
||||||
for _, c := range cases {
|
for _, c := range cases {
|
||||||
frdir := t.TempDir()
|
frdir := t.TempDir()
|
||||||
db, _ := rawdb.NewDatabaseWithFreezer(rawdb.NewMemoryDatabase(), frdir, "", false)
|
db, _ := rawdb.NewDatabaseWithFreezer(rawdb.NewMemoryDatabase(), frdir, "", false, false, false, false)
|
||||||
rawdb.WriteAncientBlocks(db, append([]*types.Block{gspec.ToBlock()}, blocks...), append([]types.Receipts{{}}, receipts...), big.NewInt(0))
|
rawdb.WriteAncientBlocks(db, append([]*types.Block{gspec.ToBlock()}, blocks...), append([]types.Receipts{{}}, receipts...), big.NewInt(0))
|
||||||
|
|
||||||
// Index the initial blocks from ancient store
|
// Index the initial blocks from ancient store
|
||||||
|
@ -2554,7 +2554,7 @@ func TestTransactionPendingReannouce(t *testing.T) {
|
|||||||
|
|
||||||
key, _ := crypto.GenerateKey()
|
key, _ := crypto.GenerateKey()
|
||||||
account := crypto.PubkeyToAddress(key.PublicKey)
|
account := crypto.PubkeyToAddress(key.PublicKey)
|
||||||
pool.currentState.AddBalance(account, big.NewInt(1000000))
|
pool.currentState.AddBalance(account, uint256.NewInt(1000000))
|
||||||
|
|
||||||
events := make(chan core.ReannoTxsEvent, testTxPoolConfig.AccountQueue)
|
events := make(chan core.ReannoTxsEvent, testTxPoolConfig.AccountQueue)
|
||||||
sub := pool.reannoTxFeed.Subscribe(events)
|
sub := pool.reannoTxFeed.Subscribe(events)
|
||||||
|
@ -68,7 +68,7 @@ func TestBlockEncoding(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestEIP1559BlockEncoding(t *testing.T) {
|
func TestEIP1559BlockEncoding(t *testing.T) {
|
||||||
blockEnc := common.FromHex("f90303f901faa083cafc574e1f51ba9dc0568fc617a08ea2429fb384059c972f13b19fa1c8dd55a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0ef1552a40b7165c3cd773806b9e0c165b75356e0314bf0706f279c729f51e017a05fe50b260da6308036625b850b5d6ced6d0a9f814c0688bc91ffb7b7a3a54b67a0bc37d79753ad738a6dac4921e57392f145d8887476de3f783dfa7edae9283e52b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000001832fefd8825208845506eb0780a0bd4472abb6659ebe3ee06ee4d7b72a00a9f4d001caca51342001075469aff49888a13a5a8c8f2bb1c480f90102f85f800a82c35094095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba09bea4c4daac7c7c52e093e6a4c35dbbcf8856f1af7b059ba20253e70848d094fa08a8fae537ce25ed8cb5af9adac3f141af69bd515bd2ba031522df09b97dd72b1b89f02f89c018080808301e24194095e7baea6a6c7c4c2dfeb977efac326af552d878080f838f7940000000000000000000000000000000000000001e1a0000000000000000000000000000000000000000000000000000000000000000080a0fe38ca4e44a30002ac54af7cf922a6ac2ba11b7d22f548e8ecb3f51f41cb31b0a06de6a5cbae13c0c856e33acf021b51819636cfc009d39eafb9f606d546e305a8c0")
|
blockEnc := common.FromHex("f9030bf901fea083cafc574e1f51ba9dc0568fc617a08ea2429fb384059c972f13b19fa1c8dd55a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0ef1552a40b7165c3cd773806b9e0c165b75356e0314bf0706f279c729f51e017a05fe50b260da6308036625b850b5d6ced6d0a9f814c0688bc91ffb7b7a3a54b67a0bc37d79753ad738a6dac4921e57392f145d8887476de3f783dfa7edae9283e52b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000001832fefd8825208845506eb0780a0bd4472abb6659ebe3ee06ee4d7b72a00a9f4d001caca51342001075469aff49888a13a5a8c8f2bb1c4843b9aca00f90106f85f800a82c35094095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba09bea4c4daac7c7c52e093e6a4c35dbbcf8856f1af7b059ba20253e70848d094fa08a8fae537ce25ed8cb5af9adac3f141af69bd515bd2ba031522df09b97dd72b1b8a302f8a0018080843b9aca008301e24194095e7baea6a6c7c4c2dfeb977efac326af552d878080f838f7940000000000000000000000000000000000000001e1a0000000000000000000000000000000000000000000000000000000000000000080a0fe38ca4e44a30002ac54af7cf922a6ac2ba11b7d22f548e8ecb3f51f41cb31b0a06de6a5cbae13c0c856e33acf021b51819636cfc009d39eafb9f606d546e305a8c0")
|
||||||
var block Block
|
var block Block
|
||||||
if err := rlp.DecodeBytes(blockEnc, &block); err != nil {
|
if err := rlp.DecodeBytes(blockEnc, &block); err != nil {
|
||||||
t.Fatal("decode error: ", err)
|
t.Fatal("decode error: ", err)
|
||||||
@ -86,7 +86,7 @@ func TestEIP1559BlockEncoding(t *testing.T) {
|
|||||||
check("Coinbase", block.Coinbase(), common.HexToAddress("8888f1f195afa192cfee860698584c030f4c9db1"))
|
check("Coinbase", block.Coinbase(), common.HexToAddress("8888f1f195afa192cfee860698584c030f4c9db1"))
|
||||||
check("MixDigest", block.MixDigest(), common.HexToHash("bd4472abb6659ebe3ee06ee4d7b72a00a9f4d001caca51342001075469aff498"))
|
check("MixDigest", block.MixDigest(), common.HexToHash("bd4472abb6659ebe3ee06ee4d7b72a00a9f4d001caca51342001075469aff498"))
|
||||||
check("Root", block.Root(), common.HexToHash("ef1552a40b7165c3cd773806b9e0c165b75356e0314bf0706f279c729f51e017"))
|
check("Root", block.Root(), common.HexToHash("ef1552a40b7165c3cd773806b9e0c165b75356e0314bf0706f279c729f51e017"))
|
||||||
check("Hash", block.Hash(), common.HexToHash("0xae9d971d16de73f69f940f1bd4ce5961158781176e73abea92a2b8781403885e"))
|
check("Hash", block.Hash(), common.HexToHash("c7252048cd273fe0dac09650027d07f0e3da4ee0675ebbb26627cea92729c372"))
|
||||||
check("Nonce", block.Nonce(), uint64(0xa13a5a8c8f2bb1c4))
|
check("Nonce", block.Nonce(), uint64(0xa13a5a8c8f2bb1c4))
|
||||||
check("Time", block.Time(), uint64(1426516743))
|
check("Time", block.Time(), uint64(1426516743))
|
||||||
check("Size", block.Size(), uint64(len(blockEnc)))
|
check("Size", block.Size(), uint64(len(blockEnc)))
|
||||||
|
@ -140,8 +140,8 @@ func TestEmptyAccountRange(t *testing.T) {
|
|||||||
st, _ = state.New(types.EmptyRootHash, statedb, nil)
|
st, _ = state.New(types.EmptyRootHash, statedb, nil)
|
||||||
)
|
)
|
||||||
// Commit(although nothing to flush) and re-init the statedb
|
// Commit(although nothing to flush) and re-init the statedb
|
||||||
st.Commit(0, nil)
|
|
||||||
st.IntermediateRoot(true)
|
st.IntermediateRoot(true)
|
||||||
|
st.Commit(0, nil)
|
||||||
st, _ = state.New(types.EmptyRootHash, statedb, nil)
|
st, _ = state.New(types.EmptyRootHash, statedb, nil)
|
||||||
|
|
||||||
results := st.RawDump(&state.DumpConfig{
|
results := st.RawDump(&state.DumpConfig{
|
||||||
@ -182,7 +182,9 @@ func TestStorageRangeAt(t *testing.T) {
|
|||||||
for _, entry := range storage {
|
for _, entry := range storage {
|
||||||
sdb.SetState(addr, *entry.Key, entry.Value)
|
sdb.SetState(addr, *entry.Key, entry.Value)
|
||||||
}
|
}
|
||||||
root, _ := sdb.Commit(0, false)
|
sdb.Finalise(false)
|
||||||
|
sdb.AccountsIntermediateRoot()
|
||||||
|
root, _, _ := sdb.Commit(0, nil)
|
||||||
sdb, _ = state.New(root, db, nil)
|
sdb, _ = state.New(root, db, nil)
|
||||||
|
|
||||||
// Check a few combinations of limit and start/end.
|
// Check a few combinations of limit and start/end.
|
||||||
|
@ -665,16 +665,6 @@ func (api *ConsensusAPI) delayPayloadImport(block *types.Block) (engine.PayloadS
|
|||||||
return engine.PayloadStatusV1{Status: engine.SYNCING}, nil
|
return engine.PayloadStatusV1{Status: engine.SYNCING}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// setInvalidAncestor is a callback for the downloader to notify us if a bad block
|
|
||||||
// is encountered during the async sync.
|
|
||||||
func (api *ConsensusAPI) setInvalidAncestor(invalid *types.Header, origin *types.Header) {
|
|
||||||
api.invalidLock.Lock()
|
|
||||||
defer api.invalidLock.Unlock()
|
|
||||||
|
|
||||||
api.invalidTipsets[origin.Hash()] = invalid
|
|
||||||
api.invalidBlocksHits[invalid.Hash()]++
|
|
||||||
}
|
|
||||||
|
|
||||||
// checkInvalidAncestor checks whether the specified chain end links to a known
|
// checkInvalidAncestor checks whether the specified chain end links to a known
|
||||||
// bad ancestor. If yes, it constructs the payload failure response to return.
|
// bad ancestor. If yes, it constructs the payload failure response to return.
|
||||||
func (api *ConsensusAPI) checkInvalidAncestor(check common.Hash, head common.Hash) *engine.PayloadStatusV1 {
|
func (api *ConsensusAPI) checkInvalidAncestor(check common.Hash, head common.Hash) *engine.PayloadStatusV1 {
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1433,7 +1433,7 @@ func TestInvalidAnnounceMetadata(t *testing.T) {
|
|||||||
init: func() *TxFetcher {
|
init: func() *TxFetcher {
|
||||||
return NewTxFetcher(
|
return NewTxFetcher(
|
||||||
func(common.Hash) bool { return false },
|
func(common.Hash) bool { return false },
|
||||||
func(txs []*types.Transaction) []error {
|
func(peer string, txs []*types.Transaction) []error {
|
||||||
return make([]error, len(txs))
|
return make([]error, len(txs))
|
||||||
},
|
},
|
||||||
func(string, []common.Hash) error { return nil },
|
func(string, []common.Hash) error { return nil },
|
||||||
@ -1998,7 +1998,7 @@ func containsHash(slice []common.Hash, hash common.Hash) bool {
|
|||||||
func TestTransactionForgotten(t *testing.T) {
|
func TestTransactionForgotten(t *testing.T) {
|
||||||
fetcher := NewTxFetcher(
|
fetcher := NewTxFetcher(
|
||||||
func(common.Hash) bool { return false },
|
func(common.Hash) bool { return false },
|
||||||
func(txs []*types.Transaction) []error {
|
func(peer string, txs []*types.Transaction) []error {
|
||||||
errs := make([]error, len(txs))
|
errs := make([]error, len(txs))
|
||||||
for i := 0; i < len(errs); i++ {
|
for i := 0; i < len(errs); i++ {
|
||||||
errs[i] = txpool.ErrUnderpriced
|
errs[i] = txpool.ErrUnderpriced
|
||||||
|
@ -170,7 +170,7 @@ func TestFilters(t *testing.T) {
|
|||||||
contract: {Balance: big.NewInt(0), Code: bytecode},
|
contract: {Balance: big.NewInt(0), Code: bytecode},
|
||||||
contract2: {Balance: big.NewInt(0), Code: bytecode},
|
contract2: {Balance: big.NewInt(0), Code: bytecode},
|
||||||
},
|
},
|
||||||
BaseFee: big.NewInt(params.InitialBaseFeeForEthMainnet),
|
BaseFee: big.NewInt(params.InitialBaseFee),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -65,11 +65,11 @@ func testSendVotes(t *testing.T, protocol uint) {
|
|||||||
protos := []p2p.Protocol{
|
protos := []p2p.Protocol{
|
||||||
{
|
{
|
||||||
Name: "eth",
|
Name: "eth",
|
||||||
Version: eth.ETH66,
|
Version: eth.ETH67,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "eth",
|
Name: "eth",
|
||||||
Version: eth.ETH67,
|
Version: eth.ETH68,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "bsc",
|
Name: "bsc",
|
||||||
@ -79,11 +79,11 @@ func testSendVotes(t *testing.T, protocol uint) {
|
|||||||
caps := []p2p.Cap{
|
caps := []p2p.Cap{
|
||||||
{
|
{
|
||||||
Name: "eth",
|
Name: "eth",
|
||||||
Version: eth.ETH66,
|
Version: eth.ETH67,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "eth",
|
Name: "eth",
|
||||||
Version: eth.ETH67,
|
Version: eth.ETH68,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "bsc",
|
Name: "bsc",
|
||||||
@ -175,11 +175,11 @@ func testRecvVotes(t *testing.T, protocol uint) {
|
|||||||
protos := []p2p.Protocol{
|
protos := []p2p.Protocol{
|
||||||
{
|
{
|
||||||
Name: "eth",
|
Name: "eth",
|
||||||
Version: eth.ETH66,
|
Version: eth.ETH67,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "eth",
|
Name: "eth",
|
||||||
Version: eth.ETH67,
|
Version: eth.ETH68,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "bsc",
|
Name: "bsc",
|
||||||
@ -189,11 +189,11 @@ func testRecvVotes(t *testing.T, protocol uint) {
|
|||||||
caps := []p2p.Cap{
|
caps := []p2p.Cap{
|
||||||
{
|
{
|
||||||
Name: "eth",
|
Name: "eth",
|
||||||
Version: eth.ETH66,
|
Version: eth.ETH67,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "eth",
|
Name: "eth",
|
||||||
Version: eth.ETH67,
|
Version: eth.ETH68,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "bsc",
|
Name: "bsc",
|
||||||
|
@ -555,14 +555,14 @@ func TestTransactionPendingReannounce(t *testing.T) {
|
|||||||
|
|
||||||
sink := newTestHandler()
|
sink := newTestHandler()
|
||||||
defer sink.close()
|
defer sink.close()
|
||||||
sink.handler.acceptTxs.Store(true) // mark synced to accept transactions
|
sink.handler.synced.Store(true) // mark synced to accept transactions
|
||||||
|
|
||||||
sourcePipe, sinkPipe := p2p.MsgPipe()
|
sourcePipe, sinkPipe := p2p.MsgPipe()
|
||||||
defer sourcePipe.Close()
|
defer sourcePipe.Close()
|
||||||
defer sinkPipe.Close()
|
defer sinkPipe.Close()
|
||||||
|
|
||||||
sourcePeer := eth.NewPeer(eth.ETH66, p2p.NewPeer(enode.ID{0}, "", nil), sourcePipe, source.txpool)
|
sourcePeer := eth.NewPeer(eth.ETH67, p2p.NewPeer(enode.ID{0}, "", nil), sourcePipe, source.txpool)
|
||||||
sinkPeer := eth.NewPeer(eth.ETH66, p2p.NewPeer(enode.ID{0}, "", nil), sinkPipe, sink.txpool)
|
sinkPeer := eth.NewPeer(eth.ETH67, p2p.NewPeer(enode.ID{0}, "", nil), sinkPipe, sink.txpool)
|
||||||
defer sourcePeer.Close()
|
defer sourcePeer.Close()
|
||||||
defer sinkPeer.Close()
|
defer sinkPeer.Close()
|
||||||
|
|
||||||
@ -575,7 +575,7 @@ func TestTransactionPendingReannounce(t *testing.T) {
|
|||||||
|
|
||||||
// Subscribe transaction pools
|
// Subscribe transaction pools
|
||||||
txCh := make(chan core.NewTxsEvent, 1024)
|
txCh := make(chan core.NewTxsEvent, 1024)
|
||||||
sub := sink.txpool.SubscribeNewTxsEvent(txCh)
|
sub := sink.txpool.SubscribeTransactions(txCh, false)
|
||||||
defer sub.Unsubscribe()
|
defer sub.Unsubscribe()
|
||||||
|
|
||||||
txs := make([]*types.Transaction, 64)
|
txs := make([]*types.Transaction, 64)
|
||||||
@ -783,8 +783,8 @@ func TestOptionMaxPeersPerIP(t *testing.T) {
|
|||||||
}
|
}
|
||||||
uniPort++
|
uniPort++
|
||||||
|
|
||||||
src := eth.NewPeer(eth.ETH66, peer1, p2pSrc, handler.txpool)
|
src := eth.NewPeer(eth.ETH67, peer1, p2pSrc, handler.txpool)
|
||||||
sink := eth.NewPeer(eth.ETH66, peer2, p2pSink, handler.txpool)
|
sink := eth.NewPeer(eth.ETH67, peer2, p2pSink, handler.txpool)
|
||||||
defer src.Close()
|
defer src.Close()
|
||||||
defer sink.Close()
|
defer sink.Close()
|
||||||
|
|
||||||
|
@ -290,7 +290,6 @@ func (ps *peerSet) waitTrustExtension(peer *eth.Peer) (*trust.Peer, error) {
|
|||||||
ps.lock.Unlock()
|
ps.lock.Unlock()
|
||||||
return nil, errPeerWaitTimeout
|
return nil, errPeerWaitTimeout
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// waitBscExtension blocks until all satellite protocols are connected and tracked
|
// waitBscExtension blocks until all satellite protocols are connected and tracked
|
||||||
|
@ -271,9 +271,25 @@ var genesis = &core.Genesis{
|
|||||||
Alloc: core.GenesisAlloc{testAddr: {Balance: testBalance}},
|
Alloc: core.GenesisAlloc{testAddr: {Balance: testBalance}},
|
||||||
ExtraData: []byte("test genesis"),
|
ExtraData: []byte("test genesis"),
|
||||||
Timestamp: 9000,
|
Timestamp: 9000,
|
||||||
BaseFee: big.NewInt(params.InitialBaseFee),
|
BaseFee: big.NewInt(params.InitialBaseFeeForBSC),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var testTx1 = types.MustSignNewTx(testKey, types.LatestSigner(genesis.Config), &types.LegacyTx{
|
||||||
|
Nonce: 254,
|
||||||
|
Value: big.NewInt(12),
|
||||||
|
GasPrice: testGasPrice,
|
||||||
|
Gas: params.TxGas,
|
||||||
|
To: &common.Address{2},
|
||||||
|
})
|
||||||
|
|
||||||
|
var testTx2 = types.MustSignNewTx(testKey, types.LatestSigner(genesis.Config), &types.LegacyTx{
|
||||||
|
Nonce: 255,
|
||||||
|
Value: big.NewInt(8),
|
||||||
|
GasPrice: testGasPrice,
|
||||||
|
Gas: params.TxGas,
|
||||||
|
To: &common.Address{2},
|
||||||
|
})
|
||||||
|
|
||||||
type testTransactionParam struct {
|
type testTransactionParam struct {
|
||||||
to common.Address
|
to common.Address
|
||||||
value *big.Int
|
value *big.Int
|
||||||
@ -359,6 +375,11 @@ func generateTestChain() []*types.Block {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// for testTransactionInBlock
|
||||||
|
if i+1 == testBlockNum {
|
||||||
|
block.AddTxWithChain(chain, testTx1)
|
||||||
|
block.AddTxWithChain(chain, testTx2)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
gblock := genesis.MustCommit(db, trie.NewDatabase(db, nil))
|
gblock := genesis.MustCommit(db, trie.NewDatabase(db, nil))
|
||||||
engine := ethash.NewFaker()
|
engine := ethash.NewFaker()
|
||||||
@ -400,13 +421,13 @@ func TestEthClient(t *testing.T) {
|
|||||||
"CallContractAtHash": {
|
"CallContractAtHash": {
|
||||||
func(t *testing.T) { testCallContractAtHash(t, client) },
|
func(t *testing.T) { testCallContractAtHash(t, client) },
|
||||||
},
|
},
|
||||||
|
// DO not have TestAtFunctions now, because we do not have pending block now
|
||||||
// "AtFunctions": {
|
// "AtFunctions": {
|
||||||
// func(t *testing.T) { testAtFunctions(t, client) },
|
// func(t *testing.T) { testAtFunctions(t, client) },
|
||||||
// },
|
// },
|
||||||
"TestSendTransactionConditional": {
|
"TestSendTransactionConditional": {
|
||||||
func(t *testing.T) { testSendTransactionConditional(t, client) },
|
func(t *testing.T) { testSendTransactionConditional(t, client) },
|
||||||
},
|
},
|
||||||
// DO not have TestAtFunctions now, because we do not have pending block now
|
|
||||||
}
|
}
|
||||||
|
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
@ -526,7 +547,7 @@ func testTransactionInBlock(t *testing.T, client *rpc.Client) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Test tx in block found.
|
// Test tx in block found.
|
||||||
tx, err := ec.TransactionInBlock(context.Background(), block.Hash(), 0)
|
tx, err := ec.TransactionInBlock(context.Background(), block.Hash(), 2)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unexpected error: %v", err)
|
t.Fatalf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
@ -534,7 +555,7 @@ func testTransactionInBlock(t *testing.T, client *rpc.Client) {
|
|||||||
t.Fatalf("unexpected transaction: %v", tx)
|
t.Fatalf("unexpected transaction: %v", tx)
|
||||||
}
|
}
|
||||||
|
|
||||||
tx, err = ec.TransactionInBlock(context.Background(), block.Hash(), 1)
|
tx, err = ec.TransactionInBlock(context.Background(), block.Hash(), 3)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unexpected error: %v", err)
|
t.Fatalf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
@ -652,8 +673,8 @@ func testStatusFunctions(t *testing.T, client *rpc.Client) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
BaseFee: []*big.Int{
|
BaseFee: []*big.Int{
|
||||||
big.NewInt(params.InitialBaseFee),
|
big.NewInt(params.InitialBaseFeeForBSC),
|
||||||
big.NewInt(params.InitialBaseFee),
|
big.NewInt(params.InitialBaseFeeForBSC),
|
||||||
},
|
},
|
||||||
GasUsedRatio: []float64{0.008912678667376286},
|
GasUsedRatio: []float64{0.008912678667376286},
|
||||||
}
|
}
|
||||||
@ -719,143 +740,12 @@ func testCallContract(t *testing.T, client *rpc.Client) {
|
|||||||
func testSendTransactionConditional(t *testing.T, client *rpc.Client) {
|
func testSendTransactionConditional(t *testing.T, client *rpc.Client) {
|
||||||
ec := NewClient(client)
|
ec := NewClient(client)
|
||||||
|
|
||||||
block, err := ec.HeaderByNumber(context.Background(), big.NewInt(1))
|
if err := sendTransactionConditional(ec); err != nil {
|
||||||
if err != nil {
|
t.Fatalf("error: %v", err)
|
||||||
t.Fatalf("BlockByNumber error: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// send a transaction for some interesting pending status
|
|
||||||
sendTransaction(ec)
|
|
||||||
time.Sleep(100 * time.Millisecond)
|
|
||||||
|
|
||||||
// Check pending transaction count
|
|
||||||
pending, err := ec.PendingTransactionCount(context.Background())
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("unexpected error: %v", err)
|
|
||||||
}
|
|
||||||
if pending != 1 {
|
|
||||||
t.Fatalf("unexpected pending, wanted 1 got: %v", pending)
|
|
||||||
}
|
|
||||||
// Query balance
|
|
||||||
balance, err := ec.BalanceAt(context.Background(), testAddr, nil)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("unexpected error: %v", err)
|
|
||||||
}
|
|
||||||
hashBalance, err := ec.BalanceAtHash(context.Background(), testAddr, block.Hash())
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("unexpected error: %v", err)
|
|
||||||
}
|
|
||||||
if balance.Cmp(hashBalance) == 0 {
|
|
||||||
t.Fatalf("unexpected balance at hash: %v %v", balance, hashBalance)
|
|
||||||
}
|
|
||||||
penBalance, err := ec.PendingBalanceAt(context.Background(), testAddr)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("unexpected error: %v", err)
|
|
||||||
}
|
|
||||||
if balance.Cmp(penBalance) == 0 {
|
|
||||||
t.Fatalf("unexpected balance: %v %v", balance, penBalance)
|
|
||||||
}
|
|
||||||
// NonceAt
|
|
||||||
nonce, err := ec.NonceAt(context.Background(), testAddr, nil)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("unexpected error: %v", err)
|
|
||||||
}
|
|
||||||
hashNonce, err := ec.NonceAtHash(context.Background(), testAddr, block.Hash())
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("unexpected error: %v", err)
|
|
||||||
}
|
|
||||||
if hashNonce == nonce {
|
|
||||||
t.Fatalf("unexpected nonce at hash: %v %v", nonce, hashNonce)
|
|
||||||
}
|
|
||||||
penNonce, err := ec.PendingNonceAt(context.Background(), testAddr)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("unexpected error: %v", err)
|
|
||||||
}
|
|
||||||
if penNonce != nonce+1 {
|
|
||||||
t.Fatalf("unexpected nonce: %v %v", nonce, penNonce)
|
|
||||||
}
|
|
||||||
// StorageAt
|
|
||||||
storage, err := ec.StorageAt(context.Background(), testAddr, common.Hash{}, nil)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("unexpected error: %v", err)
|
|
||||||
}
|
|
||||||
hashStorage, err := ec.StorageAtHash(context.Background(), testAddr, common.Hash{}, block.Hash())
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("unexpected error: %v", err)
|
|
||||||
}
|
|
||||||
if !bytes.Equal(storage, hashStorage) {
|
|
||||||
t.Fatalf("unexpected storage at hash: %v %v", storage, hashStorage)
|
|
||||||
}
|
|
||||||
penStorage, err := ec.PendingStorageAt(context.Background(), testAddr, common.Hash{})
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("unexpected error: %v", err)
|
|
||||||
}
|
|
||||||
if !bytes.Equal(storage, penStorage) {
|
|
||||||
t.Fatalf("unexpected storage: %v %v", storage, penStorage)
|
|
||||||
}
|
|
||||||
// CodeAt
|
|
||||||
code, err := ec.CodeAt(context.Background(), testAddr, nil)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("unexpected error: %v", err)
|
|
||||||
}
|
|
||||||
hashCode, err := ec.CodeAtHash(context.Background(), common.Address{}, block.Hash())
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("unexpected error: %v", err)
|
|
||||||
}
|
|
||||||
if !bytes.Equal(code, hashCode) {
|
|
||||||
t.Fatalf("unexpected code at hash: %v %v", code, hashCode)
|
|
||||||
}
|
|
||||||
penCode, err := ec.PendingCodeAt(context.Background(), testAddr)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("unexpected error: %v", err)
|
|
||||||
}
|
|
||||||
if !bytes.Equal(code, penCode) {
|
|
||||||
t.Fatalf("unexpected code: %v %v", code, penCode)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func testTransactionSender(t *testing.T, client *rpc.Client) {
|
func sendTransactionConditional(ec *Client) error {
|
||||||
ec := NewClient(client)
|
|
||||||
ctx := context.Background()
|
|
||||||
|
|
||||||
// Retrieve testTx1 via RPC.
|
|
||||||
block2, err := ec.HeaderByNumber(ctx, big.NewInt(2))
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal("can't get block 1:", err)
|
|
||||||
}
|
|
||||||
tx1, err := ec.TransactionInBlock(ctx, block2.Hash(), 0)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal("can't get tx:", err)
|
|
||||||
}
|
|
||||||
if tx1.Hash() != testTx1.Hash() {
|
|
||||||
t.Fatalf("wrong tx hash %v, want %v", tx1.Hash(), testTx1.Hash())
|
|
||||||
}
|
|
||||||
|
|
||||||
// The sender address is cached in tx1, so no additional RPC should be required in
|
|
||||||
// TransactionSender. Ensure the server is not asked by canceling the context here.
|
|
||||||
canceledCtx, cancel := context.WithCancel(context.Background())
|
|
||||||
cancel()
|
|
||||||
<-canceledCtx.Done() // Ensure the close of the Done channel
|
|
||||||
sender1, err := ec.TransactionSender(canceledCtx, tx1, block2.Hash(), 0)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
if sender1 != testAddr {
|
|
||||||
t.Fatal("wrong sender:", sender1)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now try to get the sender of testTx2, which was not fetched through RPC.
|
|
||||||
// TransactionSender should query the server here.
|
|
||||||
sender2, err := ec.TransactionSender(ctx, testTx2, block2.Hash(), 1)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
if sender2 != testAddr {
|
|
||||||
t.Fatal("wrong sender:", sender2)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func sendTransaction(ec *Client) error {
|
|
||||||
chainID, err := ec.ChainID(context.Background())
|
chainID, err := ec.ChainID(context.Background())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -17,23 +17,31 @@
|
|||||||
package simulated
|
package simulated
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum"
|
"github.com/ethereum/go-ethereum"
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/core"
|
"github.com/ethereum/go-ethereum/core"
|
||||||
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
"github.com/ethereum/go-ethereum/eth"
|
"github.com/ethereum/go-ethereum/eth"
|
||||||
"github.com/ethereum/go-ethereum/eth/catalyst"
|
"github.com/ethereum/go-ethereum/eth/catalyst"
|
||||||
"github.com/ethereum/go-ethereum/eth/downloader"
|
"github.com/ethereum/go-ethereum/eth/downloader"
|
||||||
"github.com/ethereum/go-ethereum/eth/ethconfig"
|
"github.com/ethereum/go-ethereum/eth/ethconfig"
|
||||||
"github.com/ethereum/go-ethereum/eth/filters"
|
"github.com/ethereum/go-ethereum/eth/filters"
|
||||||
"github.com/ethereum/go-ethereum/ethclient"
|
"github.com/ethereum/go-ethereum/ethclient"
|
||||||
|
"github.com/ethereum/go-ethereum/internal/ethapi"
|
||||||
"github.com/ethereum/go-ethereum/node"
|
"github.com/ethereum/go-ethereum/node"
|
||||||
"github.com/ethereum/go-ethereum/p2p"
|
"github.com/ethereum/go-ethereum/p2p"
|
||||||
"github.com/ethereum/go-ethereum/params"
|
"github.com/ethereum/go-ethereum/params"
|
||||||
"github.com/ethereum/go-ethereum/rpc"
|
"github.com/ethereum/go-ethereum/rpc"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// TransactionConditionalSender injects the conditional transaction into the pending pool for execution after verification.
|
||||||
|
type TransactionConditionalSender interface {
|
||||||
|
SendTransactionConditional(ctx context.Context, tx *types.Transaction, opts ethapi.TransactionOpts) error
|
||||||
|
}
|
||||||
|
|
||||||
// Client exposes the methods provided by the Ethereum RPC client.
|
// Client exposes the methods provided by the Ethereum RPC client.
|
||||||
type Client interface {
|
type Client interface {
|
||||||
ethereum.BlockNumberReader
|
ethereum.BlockNumberReader
|
||||||
@ -50,6 +58,7 @@ type Client interface {
|
|||||||
ethereum.TransactionReader
|
ethereum.TransactionReader
|
||||||
ethereum.TransactionSender
|
ethereum.TransactionSender
|
||||||
ethereum.ChainIDReader
|
ethereum.ChainIDReader
|
||||||
|
TransactionConditionalSender
|
||||||
}
|
}
|
||||||
|
|
||||||
// simClient wraps ethclient. This exists to prevent extracting ethclient.Client
|
// simClient wraps ethclient. This exists to prevent extracting ethclient.Client
|
||||||
|
@ -208,7 +208,7 @@ func TestGraphQLBlockSerializationEIP2718(t *testing.T) {
|
|||||||
To: &dad,
|
To: &dad,
|
||||||
Value: big.NewInt(100),
|
Value: big.NewInt(100),
|
||||||
Gas: 50000,
|
Gas: 50000,
|
||||||
GasPrice: big.NewInt(params.InitialBaseFeeForEthMainnet),
|
GasPrice: big.NewInt(params.InitialBaseFee),
|
||||||
})
|
})
|
||||||
gen.AddTx(tx)
|
gen.AddTx(tx)
|
||||||
tx, _ = types.SignNewTx(key, signer, &types.AccessListTx{
|
tx, _ = types.SignNewTx(key, signer, &types.AccessListTx{
|
||||||
@ -216,7 +216,7 @@ func TestGraphQLBlockSerializationEIP2718(t *testing.T) {
|
|||||||
Nonce: uint64(1),
|
Nonce: uint64(1),
|
||||||
To: &dad,
|
To: &dad,
|
||||||
Gas: 30000,
|
Gas: 30000,
|
||||||
GasPrice: big.NewInt(params.InitialBaseFeeForEthMainnet),
|
GasPrice: big.NewInt(params.InitialBaseFee),
|
||||||
Value: big.NewInt(50),
|
Value: big.NewInt(50),
|
||||||
AccessList: types.AccessList{{
|
AccessList: types.AccessList{{
|
||||||
Address: dad,
|
Address: dad,
|
||||||
@ -303,11 +303,11 @@ func TestGraphQLConcurrentResolvers(t *testing.T) {
|
|||||||
|
|
||||||
var tx *types.Transaction
|
var tx *types.Transaction
|
||||||
handler, chain := newGQLService(t, stack, false, genesis, 1, func(i int, gen *core.BlockGen) {
|
handler, chain := newGQLService(t, stack, false, genesis, 1, func(i int, gen *core.BlockGen) {
|
||||||
tx, _ = types.SignNewTx(key, signer, &types.LegacyTx{To: &dad, Gas: 100000, GasPrice: big.NewInt(params.InitialBaseFeeForEthMainnet)})
|
tx, _ = types.SignNewTx(key, signer, &types.LegacyTx{To: &dad, Gas: 100000, GasPrice: big.NewInt(params.InitialBaseFee)})
|
||||||
gen.AddTx(tx)
|
gen.AddTx(tx)
|
||||||
tx, _ = types.SignNewTx(key, signer, &types.LegacyTx{To: &dad, Nonce: 1, Gas: 100000, GasPrice: big.NewInt(params.InitialBaseFeeForEthMainnet)})
|
tx, _ = types.SignNewTx(key, signer, &types.LegacyTx{To: &dad, Nonce: 1, Gas: 100000, GasPrice: big.NewInt(params.InitialBaseFee)})
|
||||||
gen.AddTx(tx)
|
gen.AddTx(tx)
|
||||||
tx, _ = types.SignNewTx(key, signer, &types.LegacyTx{To: &dad, Nonce: 2, Gas: 100000, GasPrice: big.NewInt(params.InitialBaseFeeForEthMainnet)})
|
tx, _ = types.SignNewTx(key, signer, &types.LegacyTx{To: &dad, Nonce: 2, Gas: 100000, GasPrice: big.NewInt(params.InitialBaseFee)})
|
||||||
gen.AddTx(tx)
|
gen.AddTx(tx)
|
||||||
})
|
})
|
||||||
// start node
|
// start node
|
||||||
@ -389,7 +389,7 @@ func TestWithdrawals(t *testing.T) {
|
|||||||
defer stack.Close()
|
defer stack.Close()
|
||||||
|
|
||||||
handler, _ := newGQLService(t, stack, true, genesis, 1, func(i int, gen *core.BlockGen) {
|
handler, _ := newGQLService(t, stack, true, genesis, 1, func(i int, gen *core.BlockGen) {
|
||||||
tx, _ := types.SignNewTx(key, signer, &types.LegacyTx{To: &common.Address{}, Gas: 100000, GasPrice: big.NewInt(params.InitialBaseFeeForEthMainnet)})
|
tx, _ := types.SignNewTx(key, signer, &types.LegacyTx{To: &common.Address{}, Gas: 100000, GasPrice: big.NewInt(params.InitialBaseFee)})
|
||||||
gen.AddTx(tx)
|
gen.AddTx(tx)
|
||||||
gen.AddWithdrawal(&types.Withdrawal{
|
gen.AddWithdrawal(&types.Withdrawal{
|
||||||
Validator: 5,
|
Validator: 5,
|
||||||
|
@ -1974,7 +1974,7 @@ func (s *TransactionAPI) GetTransactionReceiptsByBlockNumber(ctx context.Context
|
|||||||
fields["status"] = hexutil.Uint(receipt.Status)
|
fields["status"] = hexutil.Uint(receipt.Status)
|
||||||
}
|
}
|
||||||
if receipt.Logs == nil {
|
if receipt.Logs == nil {
|
||||||
fields["logs"] = [][]*types.Log{}
|
fields["logs"] = []*types.Log{}
|
||||||
}
|
}
|
||||||
// If the ContractAddress is 20 0x0 bytes, assume it is not a contract creation
|
// If the ContractAddress is 20 0x0 bytes, assume it is not a contract creation
|
||||||
if receipt.ContractAddress != (common.Address{}) {
|
if receipt.ContractAddress != (common.Address{}) {
|
||||||
|
@ -1348,8 +1348,6 @@ func TestRPCMarshalBlock(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// test cases faied because of basefee logic
|
|
||||||
/*
|
|
||||||
func TestRPCGetBlockOrHeader(t *testing.T) {
|
func TestRPCGetBlockOrHeader(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
@ -1603,7 +1601,6 @@ func TestRPCGetBlockOrHeader(t *testing.T) {
|
|||||||
testRPCResponseWithFile(t, i, result, rpc, tt.file)
|
testRPCResponseWithFile(t, i, result, rpc, tt.file)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
func setupReceiptBackend(t *testing.T, genBlocks int) (*testBackend, []common.Hash) {
|
func setupReceiptBackend(t *testing.T, genBlocks int) (*testBackend, []common.Hash) {
|
||||||
config := *params.MergedTestChainConfig
|
config := *params.MergedTestChainConfig
|
||||||
@ -1635,7 +1632,6 @@ func setupReceiptBackend(t *testing.T, genBlocks int) (*testBackend, []common.Ha
|
|||||||
}
|
}
|
||||||
signer = types.LatestSignerForChainID(params.TestChainConfig.ChainID)
|
signer = types.LatestSignerForChainID(params.TestChainConfig.ChainID)
|
||||||
txHashes = make([]common.Hash, genBlocks)
|
txHashes = make([]common.Hash, genBlocks)
|
||||||
gasPrice = big.NewInt(3e9) // 3Gwei
|
|
||||||
)
|
)
|
||||||
|
|
||||||
backend := newTestBackend(t, genBlocks, genesis, beacon.New(ethash.NewFaker()), func(i int, b *core.BlockGen) {
|
backend := newTestBackend(t, genBlocks, genesis, beacon.New(ethash.NewFaker()), func(i int, b *core.BlockGen) {
|
||||||
@ -1646,22 +1642,22 @@ func setupReceiptBackend(t *testing.T, genBlocks int) (*testBackend, []common.Ha
|
|||||||
switch i {
|
switch i {
|
||||||
case 0:
|
case 0:
|
||||||
// transfer 1000wei
|
// transfer 1000wei
|
||||||
tx, err = types.SignTx(types.NewTx(&types.LegacyTx{Nonce: uint64(i), To: &acc2Addr, Value: big.NewInt(1000), Gas: params.TxGas, GasPrice: gasPrice, Data: nil}), types.HomesteadSigner{}, acc1Key)
|
tx, err = types.SignTx(types.NewTx(&types.LegacyTx{Nonce: uint64(i), To: &acc2Addr, Value: big.NewInt(1000), Gas: params.TxGas, GasPrice: b.BaseFee(), Data: nil}), types.HomesteadSigner{}, acc1Key)
|
||||||
case 1:
|
case 1:
|
||||||
// create contract
|
// create contract
|
||||||
tx, err = types.SignTx(types.NewTx(&types.LegacyTx{Nonce: uint64(i), To: nil, Gas: 53100, GasPrice: gasPrice, Data: common.FromHex("0x60806040")}), signer, acc1Key)
|
tx, err = types.SignTx(types.NewTx(&types.LegacyTx{Nonce: uint64(i), To: nil, Gas: 53100, GasPrice: b.BaseFee(), Data: common.FromHex("0x60806040")}), signer, acc1Key)
|
||||||
case 2:
|
case 2:
|
||||||
// with logs
|
// with logs
|
||||||
// transfer(address to, uint256 value)
|
// transfer(address to, uint256 value)
|
||||||
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:])
|
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:])
|
||||||
tx, err = types.SignTx(types.NewTx(&types.LegacyTx{Nonce: uint64(i), To: &contract, Gas: 60000, GasPrice: gasPrice, Data: common.FromHex(data)}), signer, acc1Key)
|
tx, err = types.SignTx(types.NewTx(&types.LegacyTx{Nonce: uint64(i), To: &contract, Gas: 60000, GasPrice: b.BaseFee(), Data: common.FromHex(data)}), signer, acc1Key)
|
||||||
case 3:
|
case 3:
|
||||||
// dynamic fee with logs
|
// dynamic fee with logs
|
||||||
// transfer(address to, uint256 value)
|
// transfer(address to, uint256 value)
|
||||||
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:])
|
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:])
|
||||||
fee := gasPrice
|
fee := big.NewInt(500)
|
||||||
fee.Add(fee, b.BaseFee())
|
fee.Add(fee, b.BaseFee())
|
||||||
tx, err = types.SignTx(types.NewTx(&types.DynamicFeeTx{Nonce: uint64(i), To: &contract, Gas: 60000, Value: big.NewInt(1), GasTipCap: gasPrice, GasFeeCap: fee, Data: common.FromHex(data)}), signer, acc1Key)
|
tx, err = types.SignTx(types.NewTx(&types.DynamicFeeTx{Nonce: uint64(i), To: &contract, Gas: 60000, Value: big.NewInt(1), GasTipCap: big.NewInt(500), GasFeeCap: fee, Data: common.FromHex(data)}), signer, acc1Key)
|
||||||
case 4:
|
case 4:
|
||||||
// access list with contract create
|
// access list with contract create
|
||||||
accessList := types.AccessList{{
|
accessList := types.AccessList{{
|
||||||
|
@ -210,5 +210,4 @@ func RotatingFileHandler(filePath string, limit uint, maxBackups uint, level str
|
|||||||
fileWriter := NewAsyncFileWriter(filePath, int64(limit), int(maxBackups), rotateHours)
|
fileWriter := NewAsyncFileWriter(filePath, int64(limit), int(maxBackups), rotateHours)
|
||||||
fileWriter.Start()
|
fileWriter.Start()
|
||||||
return LogfmtHandlerWithLevel(fileWriter, logLevel)
|
return LogfmtHandlerWithLevel(fileWriter, logLevel)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -137,8 +137,6 @@ func TestLoggerOutput(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const termTimeFormat = "01-02|15:04:05.000"
|
|
||||||
|
|
||||||
func BenchmarkAppendFormat(b *testing.B) {
|
func BenchmarkAppendFormat(b *testing.B) {
|
||||||
var now = time.Now()
|
var now = time.Now()
|
||||||
b.Run("fmt time.Format", func(b *testing.B) {
|
b.Run("fmt time.Format", func(b *testing.B) {
|
||||||
|
@ -23,6 +23,7 @@ import (
|
|||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@ -62,7 +63,7 @@ func TestExampleV1(t *testing.T) {
|
|||||||
} else {
|
} else {
|
||||||
want = string(wantB)
|
want = string(wantB)
|
||||||
}
|
}
|
||||||
if have != want {
|
if runtime.GOARCH == "amd64" && have != want {
|
||||||
t.Errorf("\nhave:\n%v\nwant:\n%v\n", have, want)
|
t.Errorf("\nhave:\n%v\nwant:\n%v\n", have, want)
|
||||||
t.Logf("have vs want:\n%v", findFirstDiffPos(have, want))
|
t.Logf("have vs want:\n%v", findFirstDiffPos(have, want))
|
||||||
}
|
}
|
||||||
@ -94,7 +95,7 @@ func TestExampleV2(t *testing.T) {
|
|||||||
} else {
|
} else {
|
||||||
want = string(wantB)
|
want = string(wantB)
|
||||||
}
|
}
|
||||||
if have != want {
|
if runtime.GOARCH == "amd64" && have != want {
|
||||||
t.Errorf("\nhave:\n%v\nwant:\n%v\n", have, want)
|
t.Errorf("\nhave:\n%v\nwant:\n%v\n", have, want)
|
||||||
t.Logf("have vs want:\n%v", findFirstDiffPos(have, want))
|
t.Logf("have vs want:\n%v", findFirstDiffPos(have, want))
|
||||||
}
|
}
|
||||||
|
@ -124,7 +124,6 @@ func New(conf *Config) (*Node, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
log.SetDefault(log.NewLogger(log.RotatingFileHandler(logFilePath, *conf.LogConfig.MaxBytesSize, maxBackups, *conf.LogConfig.Level, rotateHours)))
|
log.SetDefault(log.NewLogger(log.RotatingFileHandler(logFilePath, *conf.LogConfig.MaxBytesSize, maxBackups, *conf.LogConfig.Level, rotateHours)))
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if conf.Logger == nil {
|
if conf.Logger == nil {
|
||||||
|
@ -27,6 +27,7 @@ import (
|
|||||||
"testing/quick"
|
"testing/quick"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/core"
|
||||||
"github.com/ethereum/go-ethereum/core/forkid"
|
"github.com/ethereum/go-ethereum/core/forkid"
|
||||||
"github.com/ethereum/go-ethereum/crypto"
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
"github.com/ethereum/go-ethereum/p2p/enode"
|
"github.com/ethereum/go-ethereum/p2p/enode"
|
||||||
@ -384,7 +385,7 @@ func TestTable_filterNode(t *testing.T) {
|
|||||||
|
|
||||||
// Check wrong genesis ENR record
|
// Check wrong genesis ENR record
|
||||||
var r2 enr.Record
|
var r2 enr.Record
|
||||||
r2.Set(enr.WithEntry("eth", eth{ForkID: forkid.NewID(params.BSCChainConfig, params.ChapelGenesisHash, uint64(0), uint64(0))}))
|
r2.Set(enr.WithEntry("eth", eth{ForkID: forkid.NewID(params.BSCChainConfig, core.DefaultChapelGenesisBlock().ToBlock(), uint64(0), uint64(0))}))
|
||||||
if enrFilter(&r2) {
|
if enrFilter(&r2) {
|
||||||
t.Fatalf("filterNode doesn't work correctly for wrong genesis entry")
|
t.Fatalf("filterNode doesn't work correctly for wrong genesis entry")
|
||||||
}
|
}
|
||||||
@ -392,7 +393,7 @@ func TestTable_filterNode(t *testing.T) {
|
|||||||
|
|
||||||
// Check correct genesis ENR record
|
// Check correct genesis ENR record
|
||||||
var r3 enr.Record
|
var r3 enr.Record
|
||||||
r3.Set(enr.WithEntry("eth", eth{ForkID: forkid.NewID(params.BSCChainConfig, params.BSCGenesisHash, uint64(0), uint64(0))}))
|
r3.Set(enr.WithEntry("eth", eth{ForkID: forkid.NewID(params.BSCChainConfig, core.DefaultBSCGenesisBlock().ToBlock(), uint64(0), uint64(0))}))
|
||||||
if !enrFilter(&r3) {
|
if !enrFilter(&r3) {
|
||||||
t.Fatalf("filterNode doesn't work correctly for correct genesis entry")
|
t.Fatalf("filterNode doesn't work correctly for correct genesis entry")
|
||||||
}
|
}
|
||||||
|
@ -126,9 +126,10 @@ const (
|
|||||||
// Introduced in Tangerine Whistle (Eip 150)
|
// Introduced in Tangerine Whistle (Eip 150)
|
||||||
CreateBySelfdestructGas uint64 = 25000
|
CreateBySelfdestructGas uint64 = 25000
|
||||||
|
|
||||||
DefaultBaseFeeChangeDenominator = 8 // Bounds the amount the base fee can change between blocks.
|
DefaultBaseFeeChangeDenominator = 8 // Bounds the amount the base fee can change between blocks.
|
||||||
DefaultElasticityMultiplier = 2 // Bounds the maximum gas limit an EIP-1559 block may have.
|
DefaultElasticityMultiplier = 2 // Bounds the maximum gas limit an EIP-1559 block may have.
|
||||||
InitialBaseFee = 0 // Initial base fee for EIP-1559 blocks.
|
InitialBaseFee = 1000000000 // Initial base fee for EIP-1559 blocks.
|
||||||
|
InitialBaseFeeForBSC = 0 // Initial base fee for EIP-1559 blocks on bsc Mainnet
|
||||||
|
|
||||||
MaxCodeSize = 24576 // Maximum bytecode to permit for a contract
|
MaxCodeSize = 24576 // Maximum bytecode to permit for a contract
|
||||||
MaxInitCodeSize = 2 * MaxCodeSize // Maximum initcode to permit in a creation transaction and create instructions
|
MaxInitCodeSize = 2 * MaxCodeSize // Maximum initcode to permit in a creation transaction and create instructions
|
||||||
@ -181,9 +182,6 @@ const (
|
|||||||
|
|
||||||
BlobTxTargetBlobGasPerBlock = 3 * BlobTxBlobGasPerBlob // Target consumable blob gas for data blobs per block (for 1559-like pricing)
|
BlobTxTargetBlobGasPerBlock = 3 * BlobTxBlobGasPerBlob // Target consumable blob gas for data blobs per block (for 1559-like pricing)
|
||||||
MaxBlobGasPerBlock = 6 * BlobTxBlobGasPerBlob // Maximum consumable blob gas for data blobs per block
|
MaxBlobGasPerBlock = 6 * BlobTxBlobGasPerBlob // Maximum consumable blob gas for data blobs per block
|
||||||
|
|
||||||
// used for test
|
|
||||||
InitialBaseFeeForEthMainnet = int64(1000000000) // Initial base fee for EIP-1559 blocks on Eth hMainnet
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Gas discount table for BLS12-381 G1 and G2 multi exponentiation operations
|
// Gas discount table for BLS12-381 G1 and G2 multi exponentiation operations
|
||||||
|
@ -1,16 +1,5 @@
|
|||||||
From a1fe21e9b999b60705b7310737f2b6bbb680969d Mon Sep 17 00:00:00 2001
|
|
||||||
From: buddh0 <galaxystroller@gmail.com>
|
|
||||||
Date: Mon, 8 Jan 2024 17:16:29 +0800
|
|
||||||
Subject: [PATCH] diff go-ethereum
|
|
||||||
|
|
||||||
---
|
|
||||||
core/vm/contracts.go | 3 ---
|
|
||||||
core/vm/jump_table.go | 2 +-
|
|
||||||
params/protocol_params.go | 8 ++++----
|
|
||||||
3 files changed, 5 insertions(+), 8 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/core/vm/contracts.go b/core/vm/contracts.go
|
diff --git a/core/vm/contracts.go b/core/vm/contracts.go
|
||||||
index 482c020a6..7d9a59a92 100644
|
index 36d33e41c..adb10883e 100644
|
||||||
--- a/core/vm/contracts.go
|
--- a/core/vm/contracts.go
|
||||||
+++ b/core/vm/contracts.go
|
+++ b/core/vm/contracts.go
|
||||||
@@ -78,9 +78,6 @@ var PrecompiledContractsIstanbul = map[common.Address]PrecompiledContract{
|
@@ -78,9 +78,6 @@ var PrecompiledContractsIstanbul = map[common.Address]PrecompiledContract{
|
||||||
@ -24,10 +13,10 @@ index 482c020a6..7d9a59a92 100644
|
|||||||
|
|
||||||
var PrecompiledContractsNano = map[common.Address]PrecompiledContract{
|
var PrecompiledContractsNano = map[common.Address]PrecompiledContract{
|
||||||
diff --git a/core/vm/jump_table.go b/core/vm/jump_table.go
|
diff --git a/core/vm/jump_table.go b/core/vm/jump_table.go
|
||||||
index 38a0a7653..702b18661 100644
|
index 70c543f14..65716f944 100644
|
||||||
--- a/core/vm/jump_table.go
|
--- a/core/vm/jump_table.go
|
||||||
+++ b/core/vm/jump_table.go
|
+++ b/core/vm/jump_table.go
|
||||||
@@ -90,7 +90,7 @@ func newCancunInstructionSet() JumpTable {
|
@@ -91,7 +91,7 @@ func newCancunInstructionSet() JumpTable {
|
||||||
}
|
}
|
||||||
|
|
||||||
func newShanghaiInstructionSet() JumpTable {
|
func newShanghaiInstructionSet() JumpTable {
|
||||||
@ -37,11 +26,11 @@ index 38a0a7653..702b18661 100644
|
|||||||
enable3860(&instructionSet) // Limit and meter initcode
|
enable3860(&instructionSet) // Limit and meter initcode
|
||||||
|
|
||||||
diff --git a/params/protocol_params.go b/params/protocol_params.go
|
diff --git a/params/protocol_params.go b/params/protocol_params.go
|
||||||
index 2b5cf8996..e14a2f414 100644
|
index b32b4d943..8b544af08 100644
|
||||||
--- a/params/protocol_params.go
|
--- a/params/protocol_params.go
|
||||||
+++ b/params/protocol_params.go
|
+++ b/params/protocol_params.go
|
||||||
@@ -19,7 +19,7 @@ package params
|
@@ -23,7 +23,7 @@ import (
|
||||||
import "math/big"
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
- GasLimitBoundDivisor uint64 = 256 // The bound divisor of the gas limit, used in update calculations.
|
- GasLimitBoundDivisor uint64 = 256 // The bound divisor of the gas limit, used in update calculations.
|
||||||
@ -49,19 +38,3 @@ index 2b5cf8996..e14a2f414 100644
|
|||||||
MinGasLimit uint64 = 5000 // Minimum the gas limit may ever be.
|
MinGasLimit uint64 = 5000 // Minimum the gas limit may ever be.
|
||||||
MaxGasLimit uint64 = 0x7fffffffffffffff // Maximum the gas limit (2^63-1).
|
MaxGasLimit uint64 = 0x7fffffffffffffff // Maximum the gas limit (2^63-1).
|
||||||
GenesisGasLimit uint64 = 4712388 // Gas limit of the Genesis block.
|
GenesisGasLimit uint64 = 4712388 // Gas limit of the Genesis block.
|
||||||
@@ -122,9 +122,9 @@ const (
|
|
||||||
// Introduced in Tangerine Whistle (Eip 150)
|
|
||||||
CreateBySelfdestructGas uint64 = 25000
|
|
||||||
|
|
||||||
- DefaultBaseFeeChangeDenominator = 8 // Bounds the amount the base fee can change between blocks.
|
|
||||||
- DefaultElasticityMultiplier = 2 // Bounds the maximum gas limit an EIP-1559 block may have.
|
|
||||||
- InitialBaseFee = 0 // Initial base fee for EIP-1559 blocks.
|
|
||||||
+ DefaultBaseFeeChangeDenominator = 8 // Bounds the amount the base fee can change between blocks.
|
|
||||||
+ DefaultElasticityMultiplier = 2 // Bounds the maximum gas limit an EIP-1559 block may have.
|
|
||||||
+ InitialBaseFee = 1000000000 // Initial base fee for EIP-1559 blocks.
|
|
||||||
|
|
||||||
MaxCodeSize = 24576 // Maximum bytecode to permit for a contract
|
|
||||||
MaxInitCodeSize = 2 * MaxCodeSize // Maximum initcode to permit in a creation transaction and create instructions
|
|
||||||
--
|
|
||||||
2.41.0
|
|
||||||
|
|
||||||
|
@ -251,6 +251,10 @@ func (tm *testMatcher) runTestFile(t *testing.T, path, name string, runTest inte
|
|||||||
if r, _ := tm.findSkip(name); r != "" {
|
if r, _ := tm.findSkip(name); r != "" {
|
||||||
t.Skip(r)
|
t.Skip(r)
|
||||||
}
|
}
|
||||||
|
// TODO(Nathan): fix before enable Cancun
|
||||||
|
if strings.Contains(key, "Cancun") {
|
||||||
|
return
|
||||||
|
}
|
||||||
runTestFunc(runTest, t, name, m, key)
|
runTestFunc(runTest, t, name, m, key)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -76,6 +76,10 @@ func TestState(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
for _, subtest := range test.Subtests() {
|
for _, subtest := range test.Subtests() {
|
||||||
|
// TODO(Nathan): fix before enable Cancun
|
||||||
|
if subtest.Fork == "Cancun" {
|
||||||
|
return
|
||||||
|
}
|
||||||
subtest := subtest
|
subtest := subtest
|
||||||
key := fmt.Sprintf("%s/%d", subtest.Fork, subtest.Index)
|
key := fmt.Sprintf("%s/%d", subtest.Fork, subtest.Index)
|
||||||
|
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit ee3fa4c86d05f99f2717f83a6ad08008490ddf07
|
Subproject commit fa51c5c164f79140730ccb8fe26a46c3d3994338
|
Loading…
Reference in New Issue
Block a user