forked from cerc-io/plugeth
Merge tag 'v1.10.15' into develop
This commit is contained in:
commit
3c32c1f732
@ -176,7 +176,7 @@ type Backend interface {
|
||||
// TextHash is a helper function that calculates a hash for the given message that can be
|
||||
// safely used to calculate a signature from.
|
||||
//
|
||||
// The hash is calulcated as
|
||||
// The hash is calculated as
|
||||
// keccak256("\x19Ethereum Signed Message:\n"${message length}${message}).
|
||||
//
|
||||
// This gives context to the signed message and prevents signing of transactions.
|
||||
@ -188,7 +188,7 @@ func TextHash(data []byte) []byte {
|
||||
// TextAndHash is a helper function that calculates a hash for the given message that can be
|
||||
// safely used to calculate a signature from.
|
||||
//
|
||||
// The hash is calulcated as
|
||||
// The hash is calculated as
|
||||
// keccak256("\x19Ethereum Signed Message:\n"${message length}${message}).
|
||||
//
|
||||
// This gives context to the signed message and prevents signing of transactions.
|
||||
|
@ -68,10 +68,10 @@ func (it tokenType) String() string {
|
||||
|
||||
var stringtokenTypes = []string{
|
||||
eof: "EOF",
|
||||
lineStart: "new line",
|
||||
lineEnd: "end of line",
|
||||
invalidStatement: "invalid statement",
|
||||
element: "element",
|
||||
lineEnd: "end of line",
|
||||
lineStart: "new line",
|
||||
label: "label",
|
||||
labelDef: "label definition",
|
||||
number: "number",
|
||||
|
@ -447,8 +447,11 @@ func ReadCanonicalBodyRLP(db ethdb.Reader, number uint64) rlp.RawValue {
|
||||
if len(data) > 0 {
|
||||
return nil
|
||||
}
|
||||
// Get it by hash from leveldb
|
||||
data, _ = db.Get(blockBodyKey(number, ReadCanonicalHash(db, number)))
|
||||
// Block is not in ancients, read from leveldb by hash and number.
|
||||
// Note: ReadCanonicalHash cannot be used here because it also
|
||||
// calls ReadAncients internally.
|
||||
hash, _ := db.Get(headerHashKey(number))
|
||||
data, _ = db.Get(blockBodyKey(number, common.BytesToHash(hash)))
|
||||
return nil
|
||||
})
|
||||
return data
|
||||
|
@ -298,11 +298,11 @@ func (ec *Client) SyncProgress(ctx context.Context) (*ethereum.SyncProgress, err
|
||||
if err := json.Unmarshal(raw, &syncing); err == nil {
|
||||
return nil, nil // Not syncing (always false)
|
||||
}
|
||||
var progress *ethereum.SyncProgress
|
||||
if err := json.Unmarshal(raw, &progress); err != nil {
|
||||
var p *rpcProgress
|
||||
if err := json.Unmarshal(raw, &p); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return progress, nil
|
||||
return p.toSyncProgress(), nil
|
||||
}
|
||||
|
||||
// SubscribeNewHead subscribes to notifications about the current blockchain head
|
||||
@ -542,3 +542,51 @@ func toCallArg(msg ethereum.CallMsg) interface{} {
|
||||
}
|
||||
return arg
|
||||
}
|
||||
|
||||
// rpcProgress is a copy of SyncProgress with hex-encoded fields.
|
||||
type rpcProgress struct {
|
||||
StartingBlock hexutil.Uint64
|
||||
CurrentBlock hexutil.Uint64
|
||||
HighestBlock hexutil.Uint64
|
||||
|
||||
PulledStates hexutil.Uint64
|
||||
KnownStates hexutil.Uint64
|
||||
|
||||
SyncedAccounts hexutil.Uint64
|
||||
SyncedAccountBytes hexutil.Uint64
|
||||
SyncedBytecodes hexutil.Uint64
|
||||
SyncedBytecodeBytes hexutil.Uint64
|
||||
SyncedStorage hexutil.Uint64
|
||||
SyncedStorageBytes hexutil.Uint64
|
||||
HealedTrienodes hexutil.Uint64
|
||||
HealedTrienodeBytes hexutil.Uint64
|
||||
HealedBytecodes hexutil.Uint64
|
||||
HealedBytecodeBytes hexutil.Uint64
|
||||
HealingTrienodes hexutil.Uint64
|
||||
HealingBytecode hexutil.Uint64
|
||||
}
|
||||
|
||||
func (p *rpcProgress) toSyncProgress() *ethereum.SyncProgress {
|
||||
if p == nil {
|
||||
return nil
|
||||
}
|
||||
return ðereum.SyncProgress{
|
||||
StartingBlock: uint64(p.StartingBlock),
|
||||
CurrentBlock: uint64(p.CurrentBlock),
|
||||
HighestBlock: uint64(p.HighestBlock),
|
||||
PulledStates: uint64(p.PulledStates),
|
||||
KnownStates: uint64(p.KnownStates),
|
||||
SyncedAccounts: uint64(p.SyncedAccounts),
|
||||
SyncedAccountBytes: uint64(p.SyncedAccountBytes),
|
||||
SyncedBytecodes: uint64(p.SyncedBytecodes),
|
||||
SyncedBytecodeBytes: uint64(p.SyncedBytecodeBytes),
|
||||
SyncedStorage: uint64(p.SyncedStorage),
|
||||
SyncedStorageBytes: uint64(p.SyncedStorageBytes),
|
||||
HealedTrienodes: uint64(p.HealedTrienodes),
|
||||
HealedTrienodeBytes: uint64(p.HealedTrienodeBytes),
|
||||
HealedBytecodes: uint64(p.HealedBytecodes),
|
||||
HealedBytecodeBytes: uint64(p.HealedBytecodeBytes),
|
||||
HealingTrienodes: uint64(p.HealingTrienodes),
|
||||
HealingBytecode: uint64(p.HealingBytecode),
|
||||
}
|
||||
}
|
||||
|
@ -372,6 +372,9 @@ func (t *Transaction) Status(ctx context.Context) (*Long, error) {
|
||||
if err != nil || receipt == nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(receipt.PostState) != 0 {
|
||||
return nil, nil
|
||||
}
|
||||
ret := Long(receipt.Status)
|
||||
return &ret, nil
|
||||
}
|
||||
@ -596,21 +599,18 @@ func (b *Block) BaseFeePerGas(ctx context.Context) (*hexutil.Big, error) {
|
||||
}
|
||||
|
||||
func (b *Block) Parent(ctx context.Context) (*Block, error) {
|
||||
// If the block header hasn't been fetched, and we'll need it, fetch it.
|
||||
if b.numberOrHash == nil && b.header == nil {
|
||||
if _, err := b.resolveHeader(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if _, err := b.resolveHeader(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if b.header != nil && b.header.Number.Uint64() > 0 {
|
||||
num := rpc.BlockNumberOrHashWithNumber(rpc.BlockNumber(b.header.Number.Uint64() - 1))
|
||||
return &Block{
|
||||
backend: b.backend,
|
||||
numberOrHash: &num,
|
||||
hash: b.header.ParentHash,
|
||||
}, nil
|
||||
if b.header == nil || b.header.Number.Uint64() < 1 {
|
||||
return nil, nil
|
||||
}
|
||||
return nil, nil
|
||||
num := rpc.BlockNumberOrHashWithNumber(rpc.BlockNumber(b.header.Number.Uint64() - 1))
|
||||
return &Block{
|
||||
backend: b.backend,
|
||||
numberOrHash: &num,
|
||||
hash: b.header.ParentHash,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (b *Block) Difficulty(ctx context.Context) (hexutil.Big, error) {
|
||||
@ -1110,10 +1110,21 @@ func (r *Resolver) Blocks(ctx context.Context, args struct {
|
||||
ret := make([]*Block, 0, to-from+1)
|
||||
for i := from; i <= to; i++ {
|
||||
numberOrHash := rpc.BlockNumberOrHashWithNumber(i)
|
||||
ret = append(ret, &Block{
|
||||
block := &Block{
|
||||
backend: r.backend,
|
||||
numberOrHash: &numberOrHash,
|
||||
})
|
||||
}
|
||||
// Resolve the header to check for existence.
|
||||
// Note we don't resolve block directly here since it will require an
|
||||
// additional network request for light client.
|
||||
h, err := block.resolveHeader(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if h == nil {
|
||||
// Blocks after must be non-existent too, break.
|
||||
break
|
||||
}
|
||||
ret = append(ret, block)
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
@ -102,7 +102,12 @@ type SyncProgress struct {
|
||||
CurrentBlock uint64 // Current block number where sync is at
|
||||
HighestBlock uint64 // Highest alleged block number in the chain
|
||||
|
||||
// Fields belonging to snap sync
|
||||
// "fast sync" fields. These used to be sent by geth, but are no longer used
|
||||
// since version v1.10.
|
||||
PulledStates uint64 // Number of state trie entries already downloaded
|
||||
KnownStates uint64 // Total number of state trie entries known about
|
||||
|
||||
// "snap sync" fields.
|
||||
SyncedAccounts uint64 // Number of accounts downloaded
|
||||
SyncedAccountBytes uint64 // Number of account trie bytes persisted to disk
|
||||
SyncedBytecodes uint64 // Number of bytecodes downloaded
|
||||
|
@ -421,7 +421,10 @@ func (h *serverHandler) broadcastLoop() {
|
||||
}
|
||||
var reorg uint64
|
||||
if lastHead != nil {
|
||||
reorg = lastHead.Number.Uint64() - rawdb.FindCommonAncestor(h.chainDb, header, lastHead).Number.Uint64()
|
||||
// If a setHead has been performed, the common ancestor can be nil.
|
||||
if ancestor := rawdb.FindCommonAncestor(h.chainDb, header, lastHead); ancestor != nil {
|
||||
reorg = lastHead.Number.Uint64() - ancestor.Number.Uint64()
|
||||
}
|
||||
}
|
||||
lastHead, lastTd = header, td
|
||||
log.Debug("Announcing block to peers", "number", number, "hash", hash, "td", td, "reorg", reorg)
|
||||
|
@ -23,7 +23,7 @@ import (
|
||||
const (
|
||||
VersionMajor = 1 // Major version component of the current release
|
||||
VersionMinor = 10 // Minor version component of the current release
|
||||
VersionPatch = 14 // Patch version component of the current release
|
||||
VersionPatch = 15 // Patch version component of the current release
|
||||
VersionMeta = "stable" // Version metadata to append to the version string
|
||||
)
|
||||
|
||||
|
@ -224,7 +224,7 @@ func (s *Sync) Missing(max int) (nodes []common.Hash, paths []SyncPath, codes []
|
||||
codeHashes []common.Hash
|
||||
)
|
||||
for !s.queue.Empty() && (max == 0 || len(nodeHashes)+len(codeHashes) < max) {
|
||||
// Retrieve th enext item in line
|
||||
// Retrieve the next item in line
|
||||
item, prio := s.queue.Peek()
|
||||
|
||||
// If we have too many already-pending tasks for this depth, throttle
|
||||
|
Loading…
Reference in New Issue
Block a user