mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 02:12:23 +00:00
core: fix rebase
This commit is contained in:
parent
cd7f772ab9
commit
6a6d049815
3 changed files with 28 additions and 74 deletions
|
|
@ -18,7 +18,6 @@ package core
|
|||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math/big"
|
||||
|
|
@ -4418,11 +4417,14 @@ func TestRequests(t *testing.T) {
|
|||
}
|
||||
})
|
||||
|
||||
chain, err := NewBlockChain(rawdb.NewMemoryDatabase(), nil, gspec, nil, engine, vm.Config{Tracer: logger.NewMarkdownLogger(&logger.Config{}, os.Stderr).Hooks()}, nil, nil)
|
||||
chain, err := NewBlockChain(rawdb.NewMemoryDatabase(), nil, gspec, nil, engine, vm.Config{Tracer: logger.NewMarkdownLogger(&logger.Config{}, os.Stderr).Hooks()}, nil)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create tester chain: %v", err)
|
||||
}
|
||||
defer chain.Stop()
|
||||
if n, err := chain.InsertChain(blocks); err != nil {
|
||||
t.Fatalf("block %d: failed to insert into chain: %v", n, err)
|
||||
}
|
||||
|
||||
// Verify the withdrawal requests match.
|
||||
block := chain.GetBlockByNumber(1)
|
||||
|
|
@ -4474,57 +4476,8 @@ func TestRequests(t *testing.T) {
|
|||
}
|
||||
if want.TargetPublicKey != got.TargetPublicKey {
|
||||
t.Fatalf("wrong target public key: want %s, got %s", common.Bytes2Hex(want.TargetPublicKey[:]), common.Bytes2Hex(got.TargetPublicKey[:]))
|
||||
}// Verify the withdrawal requests match.
|
||||
block := chain.GetBlockByNumber(1)
|
||||
if block == nil {
|
||||
t.Fatalf("failed to retrieve block 1")
|
||||
}
|
||||
|
||||
// Verify the withdrawal requests match.
|
||||
got := block.Requests()
|
||||
if len(got) != 2 {
|
||||
t.Fatalf("wrong number of withdrawal requests: wanted 2, got %d", len(got))
|
||||
}
|
||||
for i, want := range wxs {
|
||||
got, ok := got[i].Inner().(*types.WithdrawalRequest)
|
||||
if !ok {
|
||||
t.Fatalf("expected withdrawal request")
|
||||
}
|
||||
if want.Source != got.Source {
|
||||
t.Fatalf("wrong source address: want %s, got %s", want.Source, got.Source)
|
||||
}
|
||||
if want.PublicKey != got.PublicKey {
|
||||
t.Fatalf("wrong public key: want %s, got %s", common.Bytes2Hex(want.PublicKey[:]), common.Bytes2Hex(got.PublicKey[:]))
|
||||
}
|
||||
if want.Amount != got.Amount {
|
||||
t.Fatalf("wrong amount: want %d, got %d", want.Amount, got.Amount)
|
||||
}
|
||||
}
|
||||
|
||||
// Verify the consolidation requests match. Even though both requests are sent
|
||||
// in block two, only one is dequeued at a time.
|
||||
for i, want := range cxs {
|
||||
block := chain.GetBlockByNumber(uint64(i + 2))
|
||||
if block == nil {
|
||||
t.Fatalf("failed to retrieve block")
|
||||
}
|
||||
requests := block.Requests()
|
||||
if len(requests) != 1 {
|
||||
t.Fatalf("wrong number of consolidation requests: wanted 1, got %d", len(got))
|
||||
}
|
||||
got, ok := requests[0].Inner().(*types.ConsolidationRequest)
|
||||
if !ok {
|
||||
t.Fatalf("expected consolidation request")
|
||||
}
|
||||
if want.Source != got.Source {
|
||||
t.Fatalf("wrong source address: want %s, got %s", want.Source, got.Source)
|
||||
}
|
||||
if want.SourcePublicKey != got.SourcePublicKey {
|
||||
t.Fatalf("wrong source public key: want %s, got %s", common.Bytes2Hex(want.SourcePublicKey[:]), common.Bytes2Hex(got.SourcePublicKey[:]))
|
||||
}
|
||||
if want.TargetPublicKey != got.TargetPublicKey {
|
||||
t.Fatalf("wrong target public key: want %s, got %s", common.Bytes2Hex(want.TargetPublicKey[:]), common.Bytes2Hex(got.TargetPublicKey[:]))
|
||||
}
|
||||
}
|
||||
|
||||
func int8ToByte(n int8) uint8 {
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ func TestEIP7702(t *testing.T) {
|
|||
}
|
||||
b.AddTx(tx)
|
||||
})
|
||||
chain, err := NewBlockChain(rawdb.NewMemoryDatabase(), nil, gspec, nil, engine, vm.Config{Tracer: logger.NewMarkdownLogger(&logger.Config{}, os.Stderr).Hooks()}, nil, nil)
|
||||
chain, err := NewBlockChain(rawdb.NewMemoryDatabase(), nil, gspec, nil, engine, vm.Config{Tracer: logger.NewMarkdownLogger(&logger.Config{}, os.Stderr).Hooks()}, nil)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create tester chain: %v", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,12 +39,12 @@ func TestValidateCode(t *testing.T) {
|
|||
byte(STOP),
|
||||
},
|
||||
section: 0,
|
||||
metadata: []*FunctionMetadata{{Input: 0, Output: 0, MaxStackHeight: 1}},
|
||||
metadata: []*FunctionMetadata{{Input: 0, Output: 0x80, MaxStackHeight: 1}},
|
||||
},
|
||||
{
|
||||
code: []byte{
|
||||
byte(CALLF), 0x00, 0x00,
|
||||
byte(STOP),
|
||||
byte(RETF),
|
||||
},
|
||||
section: 0,
|
||||
metadata: []*FunctionMetadata{{Input: 0, Output: 0, MaxStackHeight: 0}},
|
||||
|
|
@ -53,7 +53,8 @@ func TestValidateCode(t *testing.T) {
|
|||
code: []byte{
|
||||
byte(ADDRESS),
|
||||
byte(CALLF), 0x00, 0x00,
|
||||
byte(STOP),
|
||||
byte(POP),
|
||||
byte(RETF),
|
||||
},
|
||||
section: 0,
|
||||
metadata: []*FunctionMetadata{{Input: 0, Output: 0, MaxStackHeight: 1}},
|
||||
|
|
@ -64,7 +65,7 @@ func TestValidateCode(t *testing.T) {
|
|||
byte(POP),
|
||||
},
|
||||
section: 0,
|
||||
metadata: []*FunctionMetadata{{Input: 0, Output: 0, MaxStackHeight: 1}},
|
||||
metadata: []*FunctionMetadata{{Input: 0, Output: 0x80, MaxStackHeight: 1}},
|
||||
err: ErrInvalidCodeTermination,
|
||||
},
|
||||
{
|
||||
|
|
@ -76,7 +77,7 @@ func TestValidateCode(t *testing.T) {
|
|||
byte(STOP),
|
||||
},
|
||||
section: 0,
|
||||
metadata: []*FunctionMetadata{{Input: 0, Output: 0, MaxStackHeight: 0}},
|
||||
metadata: []*FunctionMetadata{{Input: 0, Output: 0x80, MaxStackHeight: 0}},
|
||||
err: ErrUnreachableCode,
|
||||
},
|
||||
{
|
||||
|
|
@ -87,7 +88,7 @@ func TestValidateCode(t *testing.T) {
|
|||
byte(STOP),
|
||||
},
|
||||
section: 0,
|
||||
metadata: []*FunctionMetadata{{Input: 0, Output: 0, MaxStackHeight: 1}},
|
||||
metadata: []*FunctionMetadata{{Input: 0, Output: 0x80, MaxStackHeight: 1}},
|
||||
err: ErrStackUnderflow{stackLen: 1, required: 2},
|
||||
},
|
||||
{
|
||||
|
|
@ -98,7 +99,7 @@ func TestValidateCode(t *testing.T) {
|
|||
byte(STOP),
|
||||
},
|
||||
section: 0,
|
||||
metadata: []*FunctionMetadata{{Input: 0, Output: 0, MaxStackHeight: 2}},
|
||||
metadata: []*FunctionMetadata{{Input: 0, Output: 0x80, MaxStackHeight: 2}},
|
||||
err: ErrInvalidMaxStackHeight,
|
||||
},
|
||||
{
|
||||
|
|
@ -113,7 +114,7 @@ func TestValidateCode(t *testing.T) {
|
|||
byte(STOP),
|
||||
},
|
||||
section: 0,
|
||||
metadata: []*FunctionMetadata{{Input: 0, Output: 0, MaxStackHeight: 1}},
|
||||
metadata: []*FunctionMetadata{{Input: 0, Output: 0x80, MaxStackHeight: 1}},
|
||||
err: ErrInvalidJumpDest,
|
||||
},
|
||||
{
|
||||
|
|
@ -131,7 +132,7 @@ func TestValidateCode(t *testing.T) {
|
|||
byte(STOP),
|
||||
},
|
||||
section: 0,
|
||||
metadata: []*FunctionMetadata{{Input: 0, Output: 0, MaxStackHeight: 1}},
|
||||
metadata: []*FunctionMetadata{{Input: 0, Output: 0x80, MaxStackHeight: 1}},
|
||||
err: ErrInvalidJumpDest,
|
||||
},
|
||||
{
|
||||
|
|
@ -142,7 +143,7 @@ func TestValidateCode(t *testing.T) {
|
|||
byte(STOP),
|
||||
},
|
||||
section: 0,
|
||||
metadata: []*FunctionMetadata{{Input: 0, Output: 0, MaxStackHeight: 1}},
|
||||
metadata: []*FunctionMetadata{{Input: 0, Output: 0x80, MaxStackHeight: 1}},
|
||||
err: ErrTruncatedImmediate,
|
||||
},
|
||||
{
|
||||
|
|
@ -160,7 +161,7 @@ func TestValidateCode(t *testing.T) {
|
|||
byte(RJUMP), 0xff, 0xef,
|
||||
},
|
||||
section: 0,
|
||||
metadata: []*FunctionMetadata{{Input: 0, Output: 0, MaxStackHeight: 3}},
|
||||
metadata: []*FunctionMetadata{{Input: 0, Output: 0x80, MaxStackHeight: 3}},
|
||||
err: ErrUnreachableCode,
|
||||
},
|
||||
{
|
||||
|
|
@ -179,7 +180,7 @@ func TestValidateCode(t *testing.T) {
|
|||
byte(RETURN),
|
||||
},
|
||||
section: 0,
|
||||
metadata: []*FunctionMetadata{{Input: 0, Output: 0, MaxStackHeight: 3}},
|
||||
metadata: []*FunctionMetadata{{Input: 0, Output: 0x80, MaxStackHeight: 3}},
|
||||
},
|
||||
{
|
||||
code: []byte{
|
||||
|
|
@ -197,7 +198,7 @@ func TestValidateCode(t *testing.T) {
|
|||
byte(RETURN),
|
||||
},
|
||||
section: 0,
|
||||
metadata: []*FunctionMetadata{{Input: 0, Output: 0, MaxStackHeight: 3}},
|
||||
metadata: []*FunctionMetadata{{Input: 0, Output: 0x80, MaxStackHeight: 3}},
|
||||
},
|
||||
{
|
||||
code: []byte{
|
||||
|
|
@ -206,7 +207,7 @@ func TestValidateCode(t *testing.T) {
|
|||
byte(INVALID),
|
||||
},
|
||||
section: 0,
|
||||
metadata: []*FunctionMetadata{{Input: 0, Output: 0, MaxStackHeight: 0}},
|
||||
metadata: []*FunctionMetadata{{Input: 0, Output: 0x80, MaxStackHeight: 0}},
|
||||
err: ErrUnreachableCode,
|
||||
},
|
||||
{
|
||||
|
|
@ -231,7 +232,7 @@ func TestValidateCode(t *testing.T) {
|
|||
byte(STOP),
|
||||
},
|
||||
section: 0,
|
||||
metadata: []*FunctionMetadata{{Input: 0, Output: 0, MaxStackHeight: 1}, {Input: 0, Output: 1, MaxStackHeight: 0}},
|
||||
metadata: []*FunctionMetadata{{Input: 0, Output: 0x80, MaxStackHeight: 1}, {Input: 0, Output: 1, MaxStackHeight: 0}},
|
||||
},
|
||||
{
|
||||
code: []byte{
|
||||
|
|
@ -268,7 +269,7 @@ func BenchmarkRJUMPI(b *testing.B) {
|
|||
}
|
||||
code = append(code, byte(STOP))
|
||||
container := &Container{
|
||||
Types: []*FunctionMetadata{{Input: 0, Output: 0, MaxStackHeight: 1}},
|
||||
Types: []*FunctionMetadata{{Input: 0, Output: 0x80, MaxStackHeight: 1}},
|
||||
Data: make([]byte, 0),
|
||||
ContainerSections: make([]*Container, 0),
|
||||
}
|
||||
|
|
@ -298,7 +299,7 @@ func BenchmarkRJUMPV(b *testing.B) {
|
|||
code = append(code, byte(PUSH0))
|
||||
code = append(code, byte(STOP))
|
||||
container := &Container{
|
||||
Types: []*FunctionMetadata{{Input: 0, Output: 0, MaxStackHeight: 1}},
|
||||
Types: []*FunctionMetadata{{Input: 0, Output: 0x80, MaxStackHeight: 1}},
|
||||
Data: make([]byte, 0),
|
||||
ContainerSections: make([]*Container, 0),
|
||||
}
|
||||
|
|
@ -330,7 +331,7 @@ func BenchmarkEOFValidation(b *testing.B) {
|
|||
|
||||
for i := 0; i < 1023; i++ {
|
||||
container.Code = append(container.Code, inner)
|
||||
container.Types = append(container.Types, &FunctionMetadata{Input: 0, Output: 0, MaxStackHeight: 0})
|
||||
container.Types = append(container.Types, &FunctionMetadata{Input: 0, Output: 0x80, MaxStackHeight: 0})
|
||||
}
|
||||
|
||||
for i := 0; i < 12; i++ {
|
||||
|
|
@ -384,7 +385,7 @@ func BenchmarkEOFValidation2(b *testing.B) {
|
|||
|
||||
for i := 0; i < 1023; i++ {
|
||||
container.Code = append(container.Code, inner)
|
||||
container.Types = append(container.Types, &FunctionMetadata{Input: 0, Output: 0, MaxStackHeight: 0})
|
||||
container.Types = append(container.Types, &FunctionMetadata{Input: 0, Output: 0x80, MaxStackHeight: 0})
|
||||
}
|
||||
|
||||
bin := container.MarshalBinary()
|
||||
|
|
@ -429,11 +430,11 @@ func BenchmarkEOFValidation3(b *testing.B) {
|
|||
|
||||
for i := 0; i < 1023; i++ {
|
||||
container.Code = append(container.Code, []byte{byte(RJUMP), 0x00, 0x00, byte(JUMPF), 0x00, 0x00})
|
||||
container.Types = append(container.Types, &FunctionMetadata{Input: 0, Output: 0, MaxStackHeight: 0})
|
||||
container.Types = append(container.Types, &FunctionMetadata{Input: 0, Output: 0x80, MaxStackHeight: 0})
|
||||
}
|
||||
for i := 0; i < 65; i++ {
|
||||
container.Code[i+1] = append(snippet, byte(STOP))
|
||||
container.Types[i+1] = &FunctionMetadata{Input: 0, Output: 0, MaxStackHeight: 1}
|
||||
container.Types[i+1] = &FunctionMetadata{Input: 0, Output: 0x80, MaxStackHeight: 1}
|
||||
}
|
||||
bin := container.MarshalBinary()
|
||||
if len(bin) > 48*1024 {
|
||||
|
|
@ -467,7 +468,7 @@ func BenchmarkRJUMPI_2(b *testing.B) {
|
|||
}
|
||||
code = append(code, byte(STOP))
|
||||
container := &Container{
|
||||
Types: []*FunctionMetadata{{Input: 0, Output: 0, MaxStackHeight: 1}},
|
||||
Types: []*FunctionMetadata{{Input: 0, Output: 0x80, MaxStackHeight: 1}},
|
||||
Data: make([]byte, 0),
|
||||
ContainerSections: make([]*Container, 0),
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue