mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-03 02:23:48 +00:00
Merge branch 'ethereum:master' into portal
This commit is contained in:
commit
c203f9ac8e
23 changed files with 163 additions and 56 deletions
|
|
@ -244,6 +244,8 @@ type BlockChain struct {
|
|||
bodyRLPCache *lru.Cache[common.Hash, rlp.RawValue]
|
||||
receiptsCache *lru.Cache[common.Hash, []*types.Receipt]
|
||||
blockCache *lru.Cache[common.Hash, *types.Block]
|
||||
|
||||
txLookupLock sync.RWMutex
|
||||
txLookupCache *lru.Cache[common.Hash, txLookup]
|
||||
|
||||
wg sync.WaitGroup
|
||||
|
|
@ -2290,14 +2292,14 @@ func (bc *BlockChain) reorg(oldHead *types.Header, newHead *types.Block) error {
|
|||
// rewind the canonical chain to a lower point.
|
||||
log.Error("Impossible reorg, please file an issue", "oldnum", oldBlock.Number(), "oldhash", oldBlock.Hash(), "oldblocks", len(oldChain), "newnum", newBlock.Number(), "newhash", newBlock.Hash(), "newblocks", len(newChain))
|
||||
}
|
||||
// Reset the tx lookup cache in case to clear stale txlookups.
|
||||
// This is done before writing any new chain data to avoid the
|
||||
// weird scenario that canonical chain is changed while the
|
||||
// stale lookups are still cached.
|
||||
bc.txLookupCache.Purge()
|
||||
// Acquire the tx-lookup lock before mutation. This step is essential
|
||||
// as the txlookups should be changed atomically, and all subsequent
|
||||
// reads should be blocked until the mutation is complete.
|
||||
bc.txLookupLock.Lock()
|
||||
|
||||
// Insert the new chain(except the head block(reverse order)),
|
||||
// taking care of the proper incremental order.
|
||||
// Insert the new chain segment in incremental order, from the old
|
||||
// to the new. The new chain head (newChain[0]) is not inserted here,
|
||||
// as it will be handled separately outside of this function
|
||||
for i := len(newChain) - 1; i >= 1; i-- {
|
||||
// Insert the block in the canonical way, re-writing history
|
||||
bc.writeHeadBlock(newChain[i])
|
||||
|
|
@ -2334,6 +2336,11 @@ func (bc *BlockChain) reorg(oldHead *types.Header, newHead *types.Block) error {
|
|||
if err := indexesBatch.Write(); err != nil {
|
||||
log.Crit("Failed to delete useless indexes", "err", err)
|
||||
}
|
||||
// Reset the tx lookup cache to clear stale txlookup cache.
|
||||
bc.txLookupCache.Purge()
|
||||
|
||||
// Release the tx-lookup lock after mutation.
|
||||
bc.txLookupLock.Unlock()
|
||||
|
||||
// Send out events for logs from the old canon chain, and 'reborn'
|
||||
// logs from the new canon chain. The number of logs can be very
|
||||
|
|
|
|||
|
|
@ -266,6 +266,9 @@ func (bc *BlockChain) GetAncestor(hash common.Hash, number, ancestor uint64, max
|
|||
// transaction indexing is already finished. The transaction is not existent
|
||||
// from the node's perspective.
|
||||
func (bc *BlockChain) GetTransactionLookup(hash common.Hash) (*rawdb.LegacyTxLookupEntry, *types.Transaction, error) {
|
||||
bc.txLookupLock.RLock()
|
||||
defer bc.txLookupLock.RUnlock()
|
||||
|
||||
// Short circuit if the txlookup already in the cache, retrieve otherwise
|
||||
if item, exist := bc.txLookupCache.Get(hash); exist {
|
||||
return item.lookup, item.transaction, nil
|
||||
|
|
|
|||
|
|
@ -596,6 +596,9 @@ func (s *MatcherSession) deliverSections(bit uint, sections []uint64, bitsets []
|
|||
// of the session, any request in-flight need to be responded to! Empty responses
|
||||
// are fine though in that case.
|
||||
func (s *MatcherSession) Multiplex(batch int, wait time.Duration, mux chan chan *Retrieval) {
|
||||
waitTimer := time.NewTimer(wait)
|
||||
defer waitTimer.Stop()
|
||||
|
||||
for {
|
||||
// Allocate a new bloom bit index to retrieve data for, stopping when done
|
||||
bit, ok := s.allocateRetrieval()
|
||||
|
|
@ -604,6 +607,7 @@ func (s *MatcherSession) Multiplex(batch int, wait time.Duration, mux chan chan
|
|||
}
|
||||
// Bit allocated, throttle a bit if we're below our batch limit
|
||||
if s.pendingSections(bit) < batch {
|
||||
waitTimer.Reset(wait)
|
||||
select {
|
||||
case <-s.quit:
|
||||
// Session terminating, we can't meaningfully service, abort
|
||||
|
|
@ -611,7 +615,7 @@ func (s *MatcherSession) Multiplex(batch int, wait time.Duration, mux chan chan
|
|||
s.deliverSections(bit, []uint64{}, [][]byte{})
|
||||
return
|
||||
|
||||
case <-time.After(wait):
|
||||
case <-waitTimer.C:
|
||||
// Throttling up, fetch whatever is available
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ func NewEVMBlockContext(header *types.Header, chain ChainContext, author *common
|
|||
if header.ExcessBlobGas != nil {
|
||||
blobBaseFee = eip4844.CalcBlobFee(*header.ExcessBlobGas)
|
||||
}
|
||||
if header.Difficulty.Cmp(common.Big0) == 0 {
|
||||
if header.Difficulty.Sign() == 0 {
|
||||
random = &header.MixDigest
|
||||
}
|
||||
return vm.BlockContext{
|
||||
|
|
|
|||
69
core/tracing/CHANGELOG.md
Normal file
69
core/tracing/CHANGELOG.md
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
# Changelog
|
||||
|
||||
All notable changes to the tracing interface will be documented in this file.
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
There has been a major breaking change in the tracing interface for custom native tracers. JS and built-in tracers are not affected by this change and tracing API methods may be used as before. This overhaul has been done as part of the new live tracing feature ([#29189](https://github.com/ethereum/go-ethereum/pull/29189)). To learn more about live tracing please refer to the [docs](https://geth.ethereum.org/docs/developers/evm-tracing/live-tracing).
|
||||
|
||||
**The `EVMLogger` interface which the tracers implemented has been removed.** It has been replaced by a new struct `tracing.Hooks`. `Hooks` keeps pointers to event listening functions. Internally the EVM will use these function pointers to emit events and can skip an event if the tracer has opted not to implement it. In fact this is the main reason for this change of approach. Another benefit is the ease of adding new hooks in future, and dynamically assigning event receivers.
|
||||
|
||||
The consequence of this change can be seen in the constructor of a tracer. Let's take the 4byte tracer as an example. Previously the constructor return an instance which satisfied the interface. Now it should return a pointer to `tracers.Tracer` (which is now also a struct as opposed to an interface) and explicitly assign the event listeners. As a side-benefit the tracers will not have to provide empty implementation of methods just to satisfy the interface:
|
||||
|
||||
```go
|
||||
func newFourByteTracer(ctx *tracers.Context, _ json.RawMessage) (tracers.Tracer, error) {
|
||||
t := &fourByteTracer{
|
||||
ids: make(map[string]int),
|
||||
}
|
||||
return t, nil
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
And now:
|
||||
|
||||
```go
|
||||
func newFourByteTracer(ctx *tracers.Context, _ json.RawMessage) (*tracers.Tracer, error) {
|
||||
t := &fourByteTracer{
|
||||
ids: make(map[string]int),
|
||||
}
|
||||
return &tracers.Tracer{
|
||||
Hooks: &tracing.Hooks{
|
||||
OnTxStart: t.onTxStart,
|
||||
OnEnter: t.onEnter,
|
||||
},
|
||||
GetResult: t.getResult,
|
||||
Stop: t.stop,
|
||||
}, nil
|
||||
}
|
||||
```
|
||||
|
||||
### Event listeners
|
||||
|
||||
If you have sharp eyes you might have noticed the new names for `OnTxStart` and `OnEnter`, previously called `CaptureTxStart` and `CaptureEnter`. Indeed there have been various modifications to the signatures of the event listeners. All method names now follow the `On*` pattern instead of `Capture*`. However the modifications are not limited to the names.
|
||||
|
||||
#### New methods
|
||||
|
||||
The live tracing feature was half about adding more observability into the state of the blockchain. As such there have been a host of method additions. Please consult the [Hooks](./hooks.go) struct for the full list of methods. Custom tracers which are invoked through the API (as opposed to "live" tracers) can benefit from the following new methods:
|
||||
|
||||
- `OnGasChange(old, new uint64, reason GasChangeReason)`: This hook tracks the lifetime of gas within a transaction and its subcalls. It will first track the initial purchase of gas with ether, then the following consumptions and refunds of gas until at the end the rest is returned.
|
||||
- `OnBalanceChange(addr common.Address, prev, new *big.Int, reason BalanceChangeReason)`: This hook tracks the balance changes of accounts. Where possible a reason is provided for the change (e.g. a transfer, gas purchase, withdrawal deposit etc).
|
||||
- `OnNonceChange(addr common.Address, prev, new uint64)`: This hook tracks the nonce changes of accounts.
|
||||
- `OnCodeChange(addr common.Address, prevCodeHash common.Hash, prevCode []byte, codeHash common.Hash, code []byte)`: This hook tracks the code changes of accounts.
|
||||
- `OnStorageChange(addr common.Address, slot common.Hash, prev, new common.Hash)`: This hook tracks the storage changes of accounts.
|
||||
- `OnLogChange(log *types.Log)`: This hook tracks the logs emitted by the EVM.
|
||||
|
||||
#### Removed methods
|
||||
|
||||
The hooks `CaptureStart` and `CaptureEnd` have been removed. These hooks signaled the top-level call frame of a transaction. The relevant info will be now emitted by `OnEnter` and `OnExit` which are emitted for every call frame. They now contain a `depth` parameter which can be used to distinguish the top-level call frame when necessary. The `create bool` parameter to `CaptureStart` can now be inferred from `typ byte` in `OnEnter`, i.e. `vm.OpCode(typ) == vm.CREATE`.
|
||||
|
||||
#### Modified methods
|
||||
|
||||
- `CaptureTxStart` -> `OnTxStart(vm *VMContext, tx *types.Transaction, from common.Address)`. It now emits the full transaction object as well as `from` which should be used to get the sender address. The `*VMContext` is a replacement for the `*vm.EVM` object previously passed to `CaptureStart`.
|
||||
- `CaptureTxEnd` -> `OnTxEnd(receipt *types.Receipt, err error)`. It now returns the full receipt object.
|
||||
- `CaptureEnter` -> `OnEnter(depth int, typ byte, from common.Address, to common.Address, input []byte, gas uint64, value *big.Int)`. The new `depth int` parameter indicates the call stack depth. It is 0 for the top-level call. Furthermore, the location where `OnEnter` is called in the EVM is now made a soon as a call is started. This means some specific error cases that were not before calling `OnEnter/OnExit` will now do so, leading some transaction to have an extra call traced.
|
||||
- `CaptureExit` -> `OnExit(depth int, output []byte, gasUsed uint64, err error, reverted bool)`. It has the new `depth` parameter, same as `OnEnter`. The new `reverted` parameter indicates whether the call frame was reverted.
|
||||
- `CaptureState` -> `OnOpcode(pc uint64, op byte, gas, cost uint64, scope tracing.OpContext, rData []byte, depth int, err error)`. `op` is of type `byte` which can be cast to `vm.OpCode` when necessary. A `*vm.ScopeContext` is not passed anymore. It is replaced by `tracing.OpContext` which offers access to the memory, stack and current contract.
|
||||
- `CaptureFault` -> `OnFault(pc uint64, op byte, gas, cost uint64, scope tracing.OpContext, depth int, err error)`. Similar to above.
|
||||
|
||||
[unreleased]: https://github.com/ethereum/go-ethereum/compare/v1.13.14...master
|
||||
|
|
@ -111,15 +111,15 @@ var PrecompiledContractsCancun = map[common.Address]PrecompiledContract{
|
|||
// PrecompiledContractsBLS contains the set of pre-compiled Ethereum
|
||||
// contracts specified in EIP-2537. These are exported for testing purposes.
|
||||
var PrecompiledContractsBLS = map[common.Address]PrecompiledContract{
|
||||
common.BytesToAddress([]byte{10}): &bls12381G1Add{},
|
||||
common.BytesToAddress([]byte{11}): &bls12381G1Mul{},
|
||||
common.BytesToAddress([]byte{12}): &bls12381G1MultiExp{},
|
||||
common.BytesToAddress([]byte{13}): &bls12381G2Add{},
|
||||
common.BytesToAddress([]byte{14}): &bls12381G2Mul{},
|
||||
common.BytesToAddress([]byte{15}): &bls12381G2MultiExp{},
|
||||
common.BytesToAddress([]byte{16}): &bls12381Pairing{},
|
||||
common.BytesToAddress([]byte{17}): &bls12381MapG1{},
|
||||
common.BytesToAddress([]byte{18}): &bls12381MapG2{},
|
||||
common.BytesToAddress([]byte{11}): &bls12381G1Add{},
|
||||
common.BytesToAddress([]byte{12}): &bls12381G1Mul{},
|
||||
common.BytesToAddress([]byte{13}): &bls12381G1MultiExp{},
|
||||
common.BytesToAddress([]byte{14}): &bls12381G2Add{},
|
||||
common.BytesToAddress([]byte{15}): &bls12381G2Mul{},
|
||||
common.BytesToAddress([]byte{16}): &bls12381G2MultiExp{},
|
||||
common.BytesToAddress([]byte{17}): &bls12381Pairing{},
|
||||
common.BytesToAddress([]byte{18}): &bls12381MapG1{},
|
||||
common.BytesToAddress([]byte{19}): &bls12381MapG2{},
|
||||
}
|
||||
|
||||
var (
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
|
|||
if !config.SyncMode.IsValid() {
|
||||
return nil, fmt.Errorf("invalid sync mode %d", config.SyncMode)
|
||||
}
|
||||
if config.Miner.GasPrice == nil || config.Miner.GasPrice.Cmp(common.Big0) <= 0 {
|
||||
if config.Miner.GasPrice == nil || config.Miner.GasPrice.Sign() <= 0 {
|
||||
log.Warn("Sanitizing invalid miner gas price", "provided", config.Miner.GasPrice, "updated", ethconfig.Defaults.Miner.GasPrice)
|
||||
config.Miner.GasPrice = new(big.Int).Set(ethconfig.Defaults.Miner.GasPrice)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -289,6 +289,9 @@ func (d *Downloader) fetchBeaconHeaders(from uint64) error {
|
|||
localHeaders = d.readHeaderRange(tail, int(count))
|
||||
log.Warn("Retrieved beacon headers from local", "from", from, "count", count)
|
||||
}
|
||||
fsHeaderContCheckTimer := time.NewTimer(fsHeaderContCheck)
|
||||
defer fsHeaderContCheckTimer.Stop()
|
||||
|
||||
for {
|
||||
// Some beacon headers might have appeared since the last cycle, make
|
||||
// sure we're always syncing to all available ones
|
||||
|
|
@ -381,8 +384,9 @@ func (d *Downloader) fetchBeaconHeaders(from uint64) error {
|
|||
}
|
||||
// State sync still going, wait a bit for new headers and retry
|
||||
log.Trace("Pivot not yet committed, waiting...")
|
||||
fsHeaderContCheckTimer.Reset(fsHeaderContCheck)
|
||||
select {
|
||||
case <-time.After(fsHeaderContCheck):
|
||||
case <-fsHeaderContCheckTimer.C:
|
||||
case <-d.cancelCh:
|
||||
return errCanceled
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1276,7 +1276,10 @@ func (d *Downloader) processHeaders(origin uint64, td, ttd *big.Int, beaconMode
|
|||
var (
|
||||
mode = d.getMode()
|
||||
gotHeaders = false // Wait for batches of headers to process
|
||||
timer = time.NewTimer(time.Second)
|
||||
)
|
||||
defer timer.Stop()
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-d.cancelCh:
|
||||
|
|
@ -1397,10 +1400,11 @@ func (d *Downloader) processHeaders(origin uint64, td, ttd *big.Int, beaconMode
|
|||
if mode == FullSync || mode == SnapSync {
|
||||
// If we've reached the allowed number of pending headers, stall a bit
|
||||
for d.queue.PendingBodies() >= maxQueuedHeaders || d.queue.PendingReceipts() >= maxQueuedHeaders {
|
||||
timer.Reset(time.Second)
|
||||
select {
|
||||
case <-d.cancelCh:
|
||||
return errCanceled
|
||||
case <-time.After(time.Second):
|
||||
case <-timer.C:
|
||||
}
|
||||
}
|
||||
// Otherwise insert the headers for content retrieval
|
||||
|
|
@ -1567,7 +1571,10 @@ func (d *Downloader) processSnapSyncContent() error {
|
|||
var (
|
||||
oldPivot *fetchResult // Locked in pivot block, might change eventually
|
||||
oldTail []*fetchResult // Downloaded content after the pivot
|
||||
timer = time.NewTimer(time.Second)
|
||||
)
|
||||
defer timer.Stop()
|
||||
|
||||
for {
|
||||
// Wait for the next batch of downloaded data to be available. If we have
|
||||
// not yet reached the pivot point, wait blockingly as there's no need to
|
||||
|
|
@ -1650,6 +1657,7 @@ func (d *Downloader) processSnapSyncContent() error {
|
|||
oldPivot = P
|
||||
}
|
||||
// Wait for completion, occasionally checking for pivot staleness
|
||||
timer.Reset(time.Second)
|
||||
select {
|
||||
case <-sync.done:
|
||||
if sync.err != nil {
|
||||
|
|
@ -1660,7 +1668,7 @@ func (d *Downloader) processSnapSyncContent() error {
|
|||
}
|
||||
oldPivot = nil
|
||||
|
||||
case <-time.After(time.Second):
|
||||
case <-timer.C:
|
||||
oldTail = afterP
|
||||
continue
|
||||
}
|
||||
|
|
|
|||
|
|
@ -299,7 +299,7 @@ func testGetProofNonExistent(t *testing.T, client *rpc.Client) {
|
|||
t.Fatalf("invalid nonce, want: %v got: %v", 0, result.Nonce)
|
||||
}
|
||||
// test balance
|
||||
if result.Balance.Cmp(big.NewInt(0)) != 0 {
|
||||
if result.Balance.Sign() != 0 {
|
||||
t.Fatalf("invalid balance, want: %v got: %v", 0, result.Balance)
|
||||
}
|
||||
// test storage
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ func WithCallGasLimit(gaslimit uint64) func(nodeConf *node.Config, ethConf *ethc
|
|||
// 0 is not possible as a live Geth node would reject that due to DoS protection,
|
||||
// so the simulated backend will replicate that behavior for consistency.
|
||||
func WithMinerMinTip(tip *big.Int) func(nodeConf *node.Config, ethConf *ethconfig.Config) {
|
||||
if tip == nil || tip.Cmp(new(big.Int)) <= 0 {
|
||||
if tip == nil || tip.Sign() <= 0 {
|
||||
panic("invalid miner minimum tip")
|
||||
}
|
||||
return func(nodeConf *node.Config, ethConf *ethconfig.Config) {
|
||||
|
|
|
|||
|
|
@ -544,10 +544,13 @@ func (s *Service) reportLatency(conn *connWrapper) error {
|
|||
return err
|
||||
}
|
||||
// Wait for the pong request to arrive back
|
||||
timer := time.NewTimer(5 * time.Second)
|
||||
defer timer.Stop()
|
||||
|
||||
select {
|
||||
case <-s.pongCh:
|
||||
// Pong delivered, report the latency
|
||||
case <-time.After(5 * time.Second):
|
||||
case <-timer.C:
|
||||
// Ping timeout, abort
|
||||
return errors.New("ping timed out")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ import (
|
|||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
|
@ -112,7 +111,7 @@ func RunGit(args ...string) string {
|
|||
|
||||
// readGitFile returns content of file in .git directory.
|
||||
func readGitFile(file string) string {
|
||||
content, err := os.ReadFile(path.Join(".git", file))
|
||||
content, err := os.ReadFile(filepath.Join(".git", file))
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1497,7 +1497,7 @@ func AccessList(ctx context.Context, b Backend, blockNrOrHash rpc.BlockNumberOrH
|
|||
} else {
|
||||
to = crypto.CreateAddress(args.from(), uint64(*args.Nonce))
|
||||
}
|
||||
isPostMerge := header.Difficulty.Cmp(common.Big0) == 0
|
||||
isPostMerge := header.Difficulty.Sign() == 0
|
||||
// Retrieve the precompiles since they don't need to be added to the access list
|
||||
precompiles := vm.ActivePrecompiles(b.ChainConfig().Rules(header.Number, isPostMerge, header.Time))
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ package jsre
|
|||
|
||||
import (
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"testing"
|
||||
"time"
|
||||
|
|
@ -42,7 +42,7 @@ func (no *testNativeObjectBinding) TestMethod(call goja.FunctionCall) goja.Value
|
|||
func newWithTestJS(t *testing.T, testjs string) *JSRE {
|
||||
dir := t.TempDir()
|
||||
if testjs != "" {
|
||||
if err := os.WriteFile(path.Join(dir, "test.js"), []byte(testjs), os.ModePerm); err != nil {
|
||||
if err := os.WriteFile(filepath.Join(dir, "test.js"), []byte(testjs), os.ModePerm); err != nil {
|
||||
t.Fatal("cannot create test.js:", err)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -303,10 +303,13 @@ func (n *ExecNode) Stop() error {
|
|||
go func() {
|
||||
waitErr <- n.Cmd.Wait()
|
||||
}()
|
||||
timer := time.NewTimer(5 * time.Second)
|
||||
defer timer.Stop()
|
||||
|
||||
select {
|
||||
case err := <-waitErr:
|
||||
return err
|
||||
case <-time.After(5 * time.Second):
|
||||
case <-timer.C:
|
||||
return n.Cmd.Process.Kill()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,8 +65,13 @@ func startStop(net *Network, quit chan struct{}, nodeCount int) {
|
|||
if err != nil {
|
||||
panic("Could not startup node network for mocker")
|
||||
}
|
||||
tick := time.NewTicker(10 * time.Second)
|
||||
var (
|
||||
tick = time.NewTicker(10 * time.Second)
|
||||
timer = time.NewTimer(3 * time.Second)
|
||||
)
|
||||
defer tick.Stop()
|
||||
defer timer.Stop()
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-quit:
|
||||
|
|
@ -80,11 +85,12 @@ func startStop(net *Network, quit chan struct{}, nodeCount int) {
|
|||
return
|
||||
}
|
||||
|
||||
timer.Reset(3 * time.Second)
|
||||
select {
|
||||
case <-quit:
|
||||
log.Info("Terminating simulation loop")
|
||||
return
|
||||
case <-time.After(3 * time.Second):
|
||||
case <-timer.C:
|
||||
}
|
||||
|
||||
log.Debug("starting node", "id", id)
|
||||
|
|
|
|||
|
|
@ -1028,11 +1028,14 @@ func (net *Network) Load(snap *Snapshot) error {
|
|||
}
|
||||
}
|
||||
|
||||
timeout := time.NewTimer(snapshotLoadTimeout)
|
||||
defer timeout.Stop()
|
||||
|
||||
select {
|
||||
// Wait until all connections from the snapshot are established.
|
||||
case <-allConnected:
|
||||
// Make sure that we do not wait forever.
|
||||
case <-time.After(snapshotLoadTimeout):
|
||||
case <-timeout.C:
|
||||
return errors.New("snapshot connections not established")
|
||||
}
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -158,17 +158,17 @@ func makeDecoder(typ reflect.Type, tags rlpstruct.Tags) (dec decoder, err error)
|
|||
switch {
|
||||
case typ == rawValueType:
|
||||
return decodeRawValue, nil
|
||||
case typ.AssignableTo(reflect.PtrTo(bigInt)):
|
||||
case typ.AssignableTo(reflect.PointerTo(bigInt)):
|
||||
return decodeBigInt, nil
|
||||
case typ.AssignableTo(bigInt):
|
||||
return decodeBigIntNoPtr, nil
|
||||
case typ == reflect.PtrTo(u256Int):
|
||||
case typ == reflect.PointerTo(u256Int):
|
||||
return decodeU256, nil
|
||||
case typ == u256Int:
|
||||
return decodeU256NoPtr, nil
|
||||
case kind == reflect.Ptr:
|
||||
return makePtrDecoder(typ, tags)
|
||||
case reflect.PtrTo(typ).Implements(decoderInterface):
|
||||
case reflect.PointerTo(typ).Implements(decoderInterface):
|
||||
return decodeDecoder, nil
|
||||
case isUint(kind):
|
||||
return decodeUint, nil
|
||||
|
|
@ -262,7 +262,7 @@ func decodeU256(s *Stream, val reflect.Value) error {
|
|||
|
||||
func makeListDecoder(typ reflect.Type, tag rlpstruct.Tags) (decoder, error) {
|
||||
etype := typ.Elem()
|
||||
if etype.Kind() == reflect.Uint8 && !reflect.PtrTo(etype).Implements(decoderInterface) {
|
||||
if etype.Kind() == reflect.Uint8 && !reflect.PointerTo(etype).Implements(decoderInterface) {
|
||||
if typ.Kind() == reflect.Array {
|
||||
return decodeByteArray, nil
|
||||
}
|
||||
|
|
@ -474,7 +474,7 @@ func makeSimplePtrDecoder(etype reflect.Type, etypeinfo *typeinfo) decoder {
|
|||
//
|
||||
// This decoder is used for pointer-typed struct fields with struct tag "nil".
|
||||
func makeNilPtrDecoder(etype reflect.Type, etypeinfo *typeinfo, ts rlpstruct.Tags) decoder {
|
||||
typ := reflect.PtrTo(etype)
|
||||
typ := reflect.PointerTo(etype)
|
||||
nilPtr := reflect.Zero(typ)
|
||||
|
||||
// Determine the value kind that results in nil pointer.
|
||||
|
|
|
|||
|
|
@ -141,17 +141,17 @@ func makeWriter(typ reflect.Type, ts rlpstruct.Tags) (writer, error) {
|
|||
switch {
|
||||
case typ == rawValueType:
|
||||
return writeRawValue, nil
|
||||
case typ.AssignableTo(reflect.PtrTo(bigInt)):
|
||||
case typ.AssignableTo(reflect.PointerTo(bigInt)):
|
||||
return writeBigIntPtr, nil
|
||||
case typ.AssignableTo(bigInt):
|
||||
return writeBigIntNoPtr, nil
|
||||
case typ == reflect.PtrTo(u256Int):
|
||||
case typ == reflect.PointerTo(u256Int):
|
||||
return writeU256IntPtr, nil
|
||||
case typ == u256Int:
|
||||
return writeU256IntNoPtr, nil
|
||||
case kind == reflect.Ptr:
|
||||
return makePtrWriter(typ, ts)
|
||||
case reflect.PtrTo(typ).Implements(encoderInterface):
|
||||
case reflect.PointerTo(typ).Implements(encoderInterface):
|
||||
return makeEncoderWriter(typ), nil
|
||||
case isUint(kind):
|
||||
return writeUint, nil
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ import (
|
|||
"fmt"
|
||||
"math/big"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
|
@ -386,7 +385,7 @@ func TestJsonFiles(t *testing.T) {
|
|||
continue
|
||||
}
|
||||
expectedFailure := strings.HasPrefix(fInfo.Name(), "expfail")
|
||||
data, err := os.ReadFile(path.Join("testdata", fInfo.Name()))
|
||||
data, err := os.ReadFile(filepath.Join("testdata", fInfo.Name()))
|
||||
if err != nil {
|
||||
t.Errorf("Failed to read file %v: %v", fInfo.Name(), err)
|
||||
continue
|
||||
|
|
@ -419,7 +418,7 @@ func TestFuzzerFiles(t *testing.T) {
|
|||
}
|
||||
verbose := false
|
||||
for i, fInfo := range testfiles {
|
||||
data, err := os.ReadFile(path.Join(corpusdir, fInfo.Name()))
|
||||
data, err := os.ReadFile(filepath.Join(corpusdir, fInfo.Name()))
|
||||
if err != nil {
|
||||
t.Errorf("Failed to read file %v: %v", fInfo.Name(), err)
|
||||
continue
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ import (
|
|||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math/big"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/signer/core/apitypes"
|
||||
|
|
@ -57,7 +56,7 @@ func (db *Database) ValidateTransaction(selector *string, tx *apitypes.SendTxArg
|
|||
// e.g. https://github.com/ethereum/go-ethereum/issues/16106.
|
||||
if len(data) == 0 {
|
||||
// Prevent sending ether into black hole (show stopper)
|
||||
if tx.Value.ToInt().Cmp(big.NewInt(0)) > 0 {
|
||||
if tx.Value.ToInt().Sign() > 0 {
|
||||
return nil, errors.New("transaction will create a contract with value but empty code")
|
||||
}
|
||||
// No value submitted at least, critically Warn, but don't blow up
|
||||
|
|
|
|||
|
|
@ -25,15 +25,15 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
blsG1Add = byte(10)
|
||||
blsG1Mul = byte(11)
|
||||
blsG1MultiExp = byte(12)
|
||||
blsG2Add = byte(13)
|
||||
blsG2Mul = byte(14)
|
||||
blsG2MultiExp = byte(15)
|
||||
blsPairing = byte(16)
|
||||
blsMapG1 = byte(17)
|
||||
blsMapG2 = byte(18)
|
||||
blsG1Add = byte(11)
|
||||
blsG1Mul = byte(12)
|
||||
blsG1MultiExp = byte(13)
|
||||
blsG2Add = byte(14)
|
||||
blsG2Mul = byte(15)
|
||||
blsG2MultiExp = byte(16)
|
||||
blsPairing = byte(17)
|
||||
blsMapG1 = byte(18)
|
||||
blsMapG2 = byte(19)
|
||||
)
|
||||
|
||||
func checkInput(id byte, inputLen int) bool {
|
||||
|
|
|
|||
Loading…
Reference in a new issue