mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-12 15:03:45 +00:00
Merge branch 'ethereum:master' into portal
This commit is contained in:
commit
766d2d8ece
6 changed files with 26 additions and 46 deletions
|
|
@ -1552,17 +1552,6 @@ func (bc *BlockChain) writeBlockWithState(block *types.Block, receipts []*types.
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// WriteBlockAndSetHead writes the given block and all associated state to the database,
|
|
||||||
// and applies the block as the new chain head.
|
|
||||||
func (bc *BlockChain) WriteBlockAndSetHead(block *types.Block, receipts []*types.Receipt, logs []*types.Log, state *state.StateDB, emitHeadEvent bool) (status WriteStatus, err error) {
|
|
||||||
if !bc.chainmu.TryLock() {
|
|
||||||
return NonStatTy, errChainStopped
|
|
||||||
}
|
|
||||||
defer bc.chainmu.Unlock()
|
|
||||||
|
|
||||||
return bc.writeBlockAndSetHead(block, receipts, logs, state, emitHeadEvent)
|
|
||||||
}
|
|
||||||
|
|
||||||
// writeBlockAndSetHead is the internal implementation of WriteBlockAndSetHead.
|
// writeBlockAndSetHead is the internal implementation of WriteBlockAndSetHead.
|
||||||
// This function expects the chain mutex to be held.
|
// This function expects the chain mutex to be held.
|
||||||
func (bc *BlockChain) writeBlockAndSetHead(block *types.Block, receipts []*types.Receipt, logs []*types.Log, state *state.StateDB, emitHeadEvent bool) (status WriteStatus, err error) {
|
func (bc *BlockChain) writeBlockAndSetHead(block *types.Block, receipts []*types.Receipt, logs []*types.Log, state *state.StateDB, emitHeadEvent bool) (status WriteStatus, err error) {
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ package state
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/big"
|
"math/big"
|
||||||
|
"slices"
|
||||||
"sort"
|
"sort"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
|
@ -243,9 +244,7 @@ func (s *StateDB) Logs() []*types.Log {
|
||||||
func (s *StateDB) AddPreimage(hash common.Hash, preimage []byte) {
|
func (s *StateDB) AddPreimage(hash common.Hash, preimage []byte) {
|
||||||
if _, ok := s.preimages[hash]; !ok {
|
if _, ok := s.preimages[hash]; !ok {
|
||||||
s.journal.append(addPreimageChange{hash: hash})
|
s.journal.append(addPreimageChange{hash: hash})
|
||||||
pi := make([]byte, len(preimage))
|
s.preimages[hash] = slices.Clone(preimage)
|
||||||
copy(pi, preimage)
|
|
||||||
s.preimages[hash] = pi
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -677,11 +677,11 @@ func (mo *memoryObj) Length() int {
|
||||||
return len(mo.memory)
|
return len(mo.memory)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *memoryObj) setupObject() *goja.Object {
|
func (mo *memoryObj) setupObject() *goja.Object {
|
||||||
o := m.vm.NewObject()
|
o := mo.vm.NewObject()
|
||||||
o.Set("slice", m.vm.ToValue(m.Slice))
|
o.Set("slice", mo.vm.ToValue(mo.Slice))
|
||||||
o.Set("getUint", m.vm.ToValue(m.GetUint))
|
o.Set("getUint", mo.vm.ToValue(mo.GetUint))
|
||||||
o.Set("length", m.vm.ToValue(m.Length))
|
o.Set("length", mo.vm.ToValue(mo.Length))
|
||||||
return o
|
return o
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -863,12 +863,12 @@ func (co *contractObj) GetInput() goja.Value {
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *contractObj) setupObject() *goja.Object {
|
func (co *contractObj) setupObject() *goja.Object {
|
||||||
o := c.vm.NewObject()
|
o := co.vm.NewObject()
|
||||||
o.Set("getCaller", c.vm.ToValue(c.GetCaller))
|
o.Set("getCaller", co.vm.ToValue(co.GetCaller))
|
||||||
o.Set("getAddress", c.vm.ToValue(c.GetAddress))
|
o.Set("getAddress", co.vm.ToValue(co.GetAddress))
|
||||||
o.Set("getValue", c.vm.ToValue(c.GetValue))
|
o.Set("getValue", co.vm.ToValue(co.GetValue))
|
||||||
o.Set("getInput", c.vm.ToValue(c.GetInput))
|
o.Set("getInput", co.vm.ToValue(co.GetInput))
|
||||||
return o
|
return o
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,8 @@
|
||||||
package logger
|
package logger
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"maps"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/core/tracing"
|
"github.com/ethereum/go-ethereum/core/tracing"
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
|
|
@ -71,17 +73,9 @@ func (al accessList) equal(other accessList) bool {
|
||||||
// Accounts match, cross reference the storage slots too
|
// Accounts match, cross reference the storage slots too
|
||||||
for addr, slots := range al {
|
for addr, slots := range al {
|
||||||
otherslots := other[addr]
|
otherslots := other[addr]
|
||||||
|
if !maps.Equal(slots, otherslots) {
|
||||||
if len(slots) != len(otherslots) {
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
// Given that len(slots) == len(otherslots), we only need to check that
|
|
||||||
// all the items from slots are in otherslots.
|
|
||||||
for hash := range slots {
|
|
||||||
if _, ok := otherslots[hash]; !ok {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@ package dbtest
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"reflect"
|
|
||||||
"slices"
|
"slices"
|
||||||
"sort"
|
"sort"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
@ -149,7 +148,7 @@ func TestDatabaseSuite(t *testing.T, New func() ethdb.KeyValueStore) {
|
||||||
if err := it.Error(); err != nil {
|
if err := it.Error(); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(got, want) {
|
if !slices.Equal(got, want) {
|
||||||
t.Errorf("Iterator: got: %s; want: %s", got, want)
|
t.Errorf("Iterator: got: %s; want: %s", got, want)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -160,7 +159,7 @@ func TestDatabaseSuite(t *testing.T, New func() ethdb.KeyValueStore) {
|
||||||
if err := it.Error(); err != nil {
|
if err := it.Error(); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(got, want) {
|
if !slices.Equal(got, want) {
|
||||||
t.Errorf("IteratorWith(1,nil): got: %s; want: %s", got, want)
|
t.Errorf("IteratorWith(1,nil): got: %s; want: %s", got, want)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -171,7 +170,7 @@ func TestDatabaseSuite(t *testing.T, New func() ethdb.KeyValueStore) {
|
||||||
if err := it.Error(); err != nil {
|
if err := it.Error(); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(got, want) {
|
if !slices.Equal(got, want) {
|
||||||
t.Errorf("IteratorWith(5,nil): got: %s; want: %s", got, want)
|
t.Errorf("IteratorWith(5,nil): got: %s; want: %s", got, want)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -182,7 +181,7 @@ func TestDatabaseSuite(t *testing.T, New func() ethdb.KeyValueStore) {
|
||||||
if err := it.Error(); err != nil {
|
if err := it.Error(); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(got, want) {
|
if !slices.Equal(got, want) {
|
||||||
t.Errorf("IteratorWith(nil,2): got: %s; want: %s", got, want)
|
t.Errorf("IteratorWith(nil,2): got: %s; want: %s", got, want)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -193,7 +192,7 @@ func TestDatabaseSuite(t *testing.T, New func() ethdb.KeyValueStore) {
|
||||||
if err := it.Error(); err != nil {
|
if err := it.Error(); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(got, want) {
|
if !slices.Equal(got, want) {
|
||||||
t.Errorf("IteratorWith(nil,5): got: %s; want: %s", got, want)
|
t.Errorf("IteratorWith(nil,5): got: %s; want: %s", got, want)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -262,7 +261,7 @@ func TestDatabaseSuite(t *testing.T, New func() ethdb.KeyValueStore) {
|
||||||
|
|
||||||
{
|
{
|
||||||
it := db.NewIterator(nil, nil)
|
it := db.NewIterator(nil, nil)
|
||||||
if got, want := iterateKeys(it), []string{"1", "2", "3", "4"}; !reflect.DeepEqual(got, want) {
|
if got, want := iterateKeys(it), []string{"1", "2", "3", "4"}; !slices.Equal(got, want) {
|
||||||
t.Errorf("got: %s; want: %s", got, want)
|
t.Errorf("got: %s; want: %s", got, want)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -286,7 +285,7 @@ func TestDatabaseSuite(t *testing.T, New func() ethdb.KeyValueStore) {
|
||||||
|
|
||||||
{
|
{
|
||||||
it := db.NewIterator(nil, nil)
|
it := db.NewIterator(nil, nil)
|
||||||
if got, want := iterateKeys(it), []string{"2", "3", "4", "5", "6"}; !reflect.DeepEqual(got, want) {
|
if got, want := iterateKeys(it), []string{"2", "3", "4", "5", "6"}; !slices.Equal(got, want) {
|
||||||
t.Errorf("got: %s; want: %s", got, want)
|
t.Errorf("got: %s; want: %s", got, want)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -314,7 +313,7 @@ func TestDatabaseSuite(t *testing.T, New func() ethdb.KeyValueStore) {
|
||||||
}
|
}
|
||||||
|
|
||||||
it := db.NewIterator(nil, nil)
|
it := db.NewIterator(nil, nil)
|
||||||
if got := iterateKeys(it); !reflect.DeepEqual(got, want) {
|
if got := iterateKeys(it); !slices.Equal(got, want) {
|
||||||
t.Errorf("got: %s; want: %s", got, want)
|
t.Errorf("got: %s; want: %s", got, want)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"crypto/ecdsa"
|
"crypto/ecdsa"
|
||||||
"errors"
|
"errors"
|
||||||
|
"maps"
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
@ -453,9 +454,7 @@ func (mr mapResolver) clear() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mr mapResolver) add(m map[string]string) {
|
func (mr mapResolver) add(m map[string]string) {
|
||||||
for k, v := range m {
|
maps.Copy(mr, m)
|
||||||
mr[k] = v
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mr mapResolver) LookupTXT(ctx context.Context, name string) ([]string, error) {
|
func (mr mapResolver) LookupTXT(ctx context.Context, name string) ([]string, error) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue