From dddf73abbddb297e61cee6a7e6aebfee87125e49 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Thu, 23 Dec 2021 11:23:07 +0100 Subject: [PATCH 01/11] params: begin v1.10.15 release cycle --- params/version.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/params/version.go b/params/version.go index d45fee55a..4cd5e05fd 100644 --- a/params/version.go +++ b/params/version.go @@ -21,10 +21,10 @@ 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 - VersionMeta = "stable" // Version metadata to append to the version string + VersionMajor = 1 // Major version component of the current release + VersionMinor = 10 // Minor version component of the current release + VersionPatch = 15 // Patch version component of the current release + VersionMeta = "unstable" // Version metadata to append to the version string ) // Version holds the textual version string. From 356bbe343a30789e77bb38f25983c8f2f2bfbb47 Mon Sep 17 00:00:00 2001 From: zgfzgf <48779939+zgfzgf@users.noreply.github.com> Date: Sun, 26 Dec 2021 21:58:17 +0800 Subject: [PATCH 02/11] core/asm: change order of items in stringtokenTypes (#24153) This orders the items in slice definition same as the enum values. --- core/asm/lexer.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/asm/lexer.go b/core/asm/lexer.go index 21cc8c465..ed367939d 100644 --- a/core/asm/lexer.go +++ b/core/asm/lexer.go @@ -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", From 98be5f9a7257a9145ccae8a7d913fb15077c6ce5 Mon Sep 17 00:00:00 2001 From: Water <44689567+codeoneline@users.noreply.github.com> Date: Tue, 4 Jan 2022 23:23:52 +0800 Subject: [PATCH 03/11] trie: fix spelling mistake (#24185) mispelled words in comments: th enext --- trie/sync.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trie/sync.go b/trie/sync.go index d6e435f93..81d38ee3a 100644 --- a/trie/sync.go +++ b/trie/sync.go @@ -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 From d0bd5017ed0281ac1b66172008c694277e4e1ac1 Mon Sep 17 00:00:00 2001 From: peter cresswell Date: Tue, 4 Jan 2022 10:24:28 -0500 Subject: [PATCH 04/11] accounts: correct comment (#24186) Change two instances of the word `calulcated` to `calculated`. --- accounts/accounts.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/accounts/accounts.go b/accounts/accounts.go index 717857809..af870dad1 100644 --- a/accounts/accounts.go +++ b/accounts/accounts.go @@ -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. From 66a908c5e87a4f38c0507ae2c7e53b242deb7128 Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Tue, 4 Jan 2022 19:02:37 +0100 Subject: [PATCH 05/11] core/rawdb: fix double-lock causing hang (#24189) Fixes #24159 Co-authored-by: Felix Lange --- core/rawdb/accessors_chain.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/core/rawdb/accessors_chain.go b/core/rawdb/accessors_chain.go index 891349d5f..8e9706ea6 100644 --- a/core/rawdb/accessors_chain.go +++ b/core/rawdb/accessors_chain.go @@ -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 From c0d17bca52bf0d2c7687b1ecae9ec52dda0074b0 Mon Sep 17 00:00:00 2001 From: Sina Mahmoodi <1591639+s1na@users.noreply.github.com> Date: Wed, 5 Jan 2022 16:11:46 +0100 Subject: [PATCH 06/11] graphql: check header first in blocks query (#24190) Fixes #24167 New behaviour is that the endpoint returns results only for available blocks without returning an error when it doesn't find a block. Note we skip any block after a non-existent block. This adds a header fetch for every block in range (even if header is not needed). Alternatively, we could do the check in every field's resolver method to avoid this overhead. --- graphql/graphql.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/graphql/graphql.go b/graphql/graphql.go index e92f1126f..711989412 100644 --- a/graphql/graphql.go +++ b/graphql/graphql.go @@ -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 } From 0169d579d0eed4f6366697985a7b0f0b99402783 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Wed, 5 Jan 2022 16:12:47 +0100 Subject: [PATCH 07/11] ethclient: fix unmarshaling of ethereum.SyncProgress (#24199) SyncProgress was modified in PR #23576 to add the fields reported for snap sync. The PR also changed ethclient to use the SyncProgress struct directly instead of wrapping it for hex-decoding. This broke the SyncProgress method. Fix it by putting back the custom wrapper. While here, also put back the fast sync related fields because SyncProgress is stable API and thus removing fields is not allowed. Fixes #24180 Fixes #24176 --- ethclient/ethclient.go | 54 +++++++++++++++++++++++++++++++++++++++--- interfaces.go | 7 +++++- 2 files changed, 57 insertions(+), 4 deletions(-) diff --git a/ethclient/ethclient.go b/ethclient/ethclient.go index 78194d04a..e6a93c96f 100644 --- a/ethclient/ethclient.go +++ b/ethclient/ethclient.go @@ -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), + } +} diff --git a/interfaces.go b/interfaces.go index daea1afb6..76c1ef690 100644 --- a/interfaces.go +++ b/interfaces.go @@ -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 From c20de3c4bd50889ed2505722e1e23d83fcefa854 Mon Sep 17 00:00:00 2001 From: Sina Mahmoodi <1591639+s1na@users.noreply.github.com> Date: Wed, 5 Jan 2022 16:21:08 +0100 Subject: [PATCH 08/11] graphql: fix pre-byzantium receipt status (#24188) Fixes #24124 --- graphql/graphql.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/graphql/graphql.go b/graphql/graphql.go index 711989412..3e23f41f7 100644 --- a/graphql/graphql.go +++ b/graphql/graphql.go @@ -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 } From 3ccd6b6dbb462755079dc8394b5c141ef397486c Mon Sep 17 00:00:00 2001 From: Sina Mahmoodi <1591639+s1na@users.noreply.github.com> Date: Wed, 5 Jan 2022 16:22:46 +0100 Subject: [PATCH 09/11] graphql: fix block resolving for parent field (#24191) Fixes #24161 --- graphql/graphql.go | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/graphql/graphql.go b/graphql/graphql.go index 3e23f41f7..16e0eb654 100644 --- a/graphql/graphql.go +++ b/graphql/graphql.go @@ -599,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) { From 335914a63afae019a2b901d88f13b28eb0d6ca58 Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Wed, 5 Jan 2022 16:40:45 +0100 Subject: [PATCH 10/11] les: fix serverHandler crash after setHead (#24200) --- les/server_handler.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/les/server_handler.go b/les/server_handler.go index f36a87a51..da06ac315 100644 --- a/les/server_handler.go +++ b/les/server_handler.go @@ -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) From 8be800ffa9c4992666e2620e0ab4725a1a83352b Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Wed, 5 Jan 2022 17:16:40 +0100 Subject: [PATCH 11/11] params: go-ethereum v1.10.15 stable --- params/version.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/params/version.go b/params/version.go index 4cd5e05fd..9c463da27 100644 --- a/params/version.go +++ b/params/version.go @@ -21,10 +21,10 @@ import ( ) const ( - VersionMajor = 1 // Major version component of the current release - VersionMinor = 10 // Minor version component of the current release - VersionPatch = 15 // Patch version component of the current release - VersionMeta = "unstable" // Version metadata to append to the version string + VersionMajor = 1 // Major version component of the current release + VersionMinor = 10 // Minor 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 ) // Version holds the textual version string.