Merge tag 'v1.10.15' into develop

This commit is contained in:
philip-morlier 2022-01-05 09:49:16 -08:00
commit 3c32c1f732
9 changed files with 98 additions and 28 deletions

View File

@ -176,7 +176,7 @@ type Backend interface {
// TextHash is a helper function that calculates a hash for the given message that can be // TextHash is a helper function that calculates a hash for the given message that can be
// safely used to calculate a signature from. // 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}). // keccak256("\x19Ethereum Signed Message:\n"${message length}${message}).
// //
// This gives context to the signed message and prevents signing of transactions. // 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 // TextAndHash is a helper function that calculates a hash for the given message that can be
// safely used to calculate a signature from. // 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}). // keccak256("\x19Ethereum Signed Message:\n"${message length}${message}).
// //
// This gives context to the signed message and prevents signing of transactions. // This gives context to the signed message and prevents signing of transactions.

View File

@ -68,10 +68,10 @@ func (it tokenType) String() string {
var stringtokenTypes = []string{ var stringtokenTypes = []string{
eof: "EOF", eof: "EOF",
lineStart: "new line",
lineEnd: "end of line",
invalidStatement: "invalid statement", invalidStatement: "invalid statement",
element: "element", element: "element",
lineEnd: "end of line",
lineStart: "new line",
label: "label", label: "label",
labelDef: "label definition", labelDef: "label definition",
number: "number", number: "number",

View File

@ -447,8 +447,11 @@ func ReadCanonicalBodyRLP(db ethdb.Reader, number uint64) rlp.RawValue {
if len(data) > 0 { if len(data) > 0 {
return nil return nil
} }
// Get it by hash from leveldb // Block is not in ancients, read from leveldb by hash and number.
data, _ = db.Get(blockBodyKey(number, ReadCanonicalHash(db, 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 nil
}) })
return data return data

View File

@ -298,11 +298,11 @@ func (ec *Client) SyncProgress(ctx context.Context) (*ethereum.SyncProgress, err
if err := json.Unmarshal(raw, &syncing); err == nil { if err := json.Unmarshal(raw, &syncing); err == nil {
return nil, nil // Not syncing (always false) return nil, nil // Not syncing (always false)
} }
var progress *ethereum.SyncProgress var p *rpcProgress
if err := json.Unmarshal(raw, &progress); err != nil { if err := json.Unmarshal(raw, &p); err != nil {
return nil, err return nil, err
} }
return progress, nil return p.toSyncProgress(), nil
} }
// SubscribeNewHead subscribes to notifications about the current blockchain head // SubscribeNewHead subscribes to notifications about the current blockchain head
@ -542,3 +542,51 @@ func toCallArg(msg ethereum.CallMsg) interface{} {
} }
return arg 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 &ethereum.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),
}
}

View File

@ -372,6 +372,9 @@ func (t *Transaction) Status(ctx context.Context) (*Long, error) {
if err != nil || receipt == nil { if err != nil || receipt == nil {
return nil, err return nil, err
} }
if len(receipt.PostState) != 0 {
return nil, nil
}
ret := Long(receipt.Status) ret := Long(receipt.Status)
return &ret, nil return &ret, nil
} }
@ -596,13 +599,12 @@ func (b *Block) BaseFeePerGas(ctx context.Context) (*hexutil.Big, error) {
} }
func (b *Block) Parent(ctx context.Context) (*Block, 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 { if _, err := b.resolveHeader(ctx); err != nil {
return nil, err return nil, err
} }
if b.header == nil || b.header.Number.Uint64() < 1 {
return nil, nil
} }
if b.header != nil && b.header.Number.Uint64() > 0 {
num := rpc.BlockNumberOrHashWithNumber(rpc.BlockNumber(b.header.Number.Uint64() - 1)) num := rpc.BlockNumberOrHashWithNumber(rpc.BlockNumber(b.header.Number.Uint64() - 1))
return &Block{ return &Block{
backend: b.backend, backend: b.backend,
@ -610,8 +612,6 @@ func (b *Block) Parent(ctx context.Context) (*Block, error) {
hash: b.header.ParentHash, hash: b.header.ParentHash,
}, nil }, nil
} }
return nil, nil
}
func (b *Block) Difficulty(ctx context.Context) (hexutil.Big, error) { func (b *Block) Difficulty(ctx context.Context) (hexutil.Big, error) {
header, err := b.resolveHeader(ctx) header, err := b.resolveHeader(ctx)
@ -1110,10 +1110,21 @@ func (r *Resolver) Blocks(ctx context.Context, args struct {
ret := make([]*Block, 0, to-from+1) ret := make([]*Block, 0, to-from+1)
for i := from; i <= to; i++ { for i := from; i <= to; i++ {
numberOrHash := rpc.BlockNumberOrHashWithNumber(i) numberOrHash := rpc.BlockNumberOrHashWithNumber(i)
ret = append(ret, &Block{ block := &Block{
backend: r.backend, backend: r.backend,
numberOrHash: &numberOrHash, 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 return ret, nil
} }

View File

@ -102,7 +102,12 @@ type SyncProgress struct {
CurrentBlock uint64 // Current block number where sync is at CurrentBlock uint64 // Current block number where sync is at
HighestBlock uint64 // Highest alleged block number in the chain 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 SyncedAccounts uint64 // Number of accounts downloaded
SyncedAccountBytes uint64 // Number of account trie bytes persisted to disk SyncedAccountBytes uint64 // Number of account trie bytes persisted to disk
SyncedBytecodes uint64 // Number of bytecodes downloaded SyncedBytecodes uint64 // Number of bytecodes downloaded

View File

@ -421,7 +421,10 @@ func (h *serverHandler) broadcastLoop() {
} }
var reorg uint64 var reorg uint64
if lastHead != nil { 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 lastHead, lastTd = header, td
log.Debug("Announcing block to peers", "number", number, "hash", hash, "td", td, "reorg", reorg) log.Debug("Announcing block to peers", "number", number, "hash", hash, "td", td, "reorg", reorg)

View File

@ -23,7 +23,7 @@ import (
const ( const (
VersionMajor = 1 // Major version component of the current release VersionMajor = 1 // Major version component of the current release
VersionMinor = 10 // Minor 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 VersionMeta = "stable" // Version metadata to append to the version string
) )