From 38229bc850c4d5967104928bea4e57f6f2b57a36 Mon Sep 17 00:00:00 2001 From: Richard Howard Date: Thu, 13 Jan 2022 15:24:37 -0800 Subject: [PATCH] Revert "Merge/v1.10.15" --- accounts/accounts.go | 4 +-- core/asm/lexer.go | 4 +-- core/rawdb/accessors_chain.go | 7 ++-- ethclient/ethclient.go | 68 +++++++++-------------------------- graphql/graphql.go | 41 ++++++++------------- interfaces.go | 23 ++---------- les/server_handler.go | 5 +-- params/version.go | 2 +- trie/sync.go | 2 +- 9 files changed, 43 insertions(+), 113 deletions(-) diff --git a/accounts/accounts.go b/accounts/accounts.go index af870dad1573..71785780913f 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 calculated as +// The hash is calulcated 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 calculated as +// The hash is calulcated as // keccak256("\x19Ethereum Signed Message:\n"${message length}${message}). // // This gives context to the signed message and prevents signing of transactions. diff --git a/core/asm/lexer.go b/core/asm/lexer.go index ed367939d740..21cc8c465837 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", diff --git a/core/rawdb/accessors_chain.go b/core/rawdb/accessors_chain.go index 4cfb9c09d658..4028191b760c 100644 --- a/core/rawdb/accessors_chain.go +++ b/core/rawdb/accessors_chain.go @@ -415,11 +415,8 @@ func ReadCanonicalBodyRLP(db ethdb.Reader, number uint64) rlp.RawValue { if len(data) > 0 { return nil } - // 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))) + // Get it by hash from leveldb + data, _ = db.Get(blockBodyKey(number, ReadCanonicalHash(db, number))) return nil }) return data diff --git a/ethclient/ethclient.go b/ethclient/ethclient.go index e6a93c96f6a0..37680807ddb1 100644 --- a/ethclient/ethclient.go +++ b/ethclient/ethclient.go @@ -286,6 +286,14 @@ func (ec *Client) TransactionReceipt(ctx context.Context, txHash common.Hash) (* return r, err } +type rpcProgress struct { + StartingBlock hexutil.Uint64 + CurrentBlock hexutil.Uint64 + HighestBlock hexutil.Uint64 + PulledStates hexutil.Uint64 + KnownStates hexutil.Uint64 +} + // SyncProgress retrieves the current progress of the sync algorithm. If there's // no sync currently running, it returns nil. func (ec *Client) SyncProgress(ctx context.Context) (*ethereum.SyncProgress, error) { @@ -298,11 +306,17 @@ 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 p *rpcProgress - if err := json.Unmarshal(raw, &p); err != nil { + var progress *rpcProgress + if err := json.Unmarshal(raw, &progress); err != nil { return nil, err } - return p.toSyncProgress(), nil + return ðereum.SyncProgress{ + StartingBlock: uint64(progress.StartingBlock), + CurrentBlock: uint64(progress.CurrentBlock), + HighestBlock: uint64(progress.HighestBlock), + PulledStates: uint64(progress.PulledStates), + KnownStates: uint64(progress.KnownStates), + }, nil } // SubscribeNewHead subscribes to notifications about the current blockchain head @@ -542,51 +556,3 @@ 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/graphql/graphql.go b/graphql/graphql.go index e534ee50b207..af6b7dc31752 100644 --- a/graphql/graphql.go +++ b/graphql/graphql.go @@ -372,9 +372,6 @@ 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 } @@ -599,18 +596,21 @@ func (b *Block) BaseFeePerGas(ctx context.Context) (*hexutil.Big, error) { } func (b *Block) Parent(ctx context.Context) (*Block, error) { - if _, err := b.resolveHeader(ctx); err != nil { - return nil, err + // 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 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)) + return &Block{ + backend: b.backend, + numberOrHash: &num, + hash: b.header.ParentHash, + }, nil } - num := rpc.BlockNumberOrHashWithNumber(rpc.BlockNumber(b.header.Number.Uint64() - 1)) - return &Block{ - backend: b.backend, - numberOrHash: &num, - hash: b.header.ParentHash, - }, nil + return nil, nil } func (b *Block) Difficulty(ctx context.Context) (hexutil.Big, error) { @@ -1110,21 +1110,10 @@ 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) - block := &Block{ + ret = append(ret, &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 } diff --git a/interfaces.go b/interfaces.go index 76c1ef6908f2..b9d0bb880e58 100644 --- a/interfaces.go +++ b/interfaces.go @@ -101,27 +101,8 @@ type SyncProgress struct { StartingBlock uint64 // Block number where sync began CurrentBlock uint64 // Current block number where sync is at HighestBlock uint64 // Highest alleged block number in the chain - - // "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 - SyncedBytecodeBytes uint64 // Number of bytecode bytes downloaded - SyncedStorage uint64 // Number of storage slots downloaded - SyncedStorageBytes uint64 // Number of storage trie bytes persisted to disk - - HealedTrienodes uint64 // Number of state trie nodes downloaded - HealedTrienodeBytes uint64 // Number of state trie bytes persisted to disk - HealedBytecodes uint64 // Number of bytecodes downloaded - HealedBytecodeBytes uint64 // Number of bytecodes persisted to disk - - HealingTrienodes uint64 // Number of state trie nodes pending - HealingBytecode uint64 // Number of bytecodes pending + PulledStates uint64 // Number of state trie entries already downloaded + KnownStates uint64 // Total number of state trie entries known about } // ChainSyncReader wraps access to the node's current sync status. If there's no diff --git a/les/server_handler.go b/les/server_handler.go index da06ac315ef0..f36a87a51301 100644 --- a/les/server_handler.go +++ b/les/server_handler.go @@ -421,10 +421,7 @@ func (h *serverHandler) broadcastLoop() { } var reorg uint64 if lastHead != nil { - // 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() - } + reorg = lastHead.Number.Uint64() - rawdb.FindCommonAncestor(h.chainDb, header, lastHead).Number.Uint64() } lastHead, lastTd = header, td log.Debug("Announcing block to peers", "number", number, "hash", hash, "td", td, "reorg", reorg) diff --git a/params/version.go b/params/version.go index 9c463da27e22..4a5b9835fdad 100644 --- a/params/version.go +++ b/params/version.go @@ -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 = 15 // Patch version component of the current release + VersionPatch = 13 // Patch version component of the current release VersionMeta = "stable" // Version metadata to append to the version string ) diff --git a/trie/sync.go b/trie/sync.go index c1383b380a8a..3a6076ff8f7a 100644 --- a/trie/sync.go +++ b/trie/sync.go @@ -236,7 +236,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 the next item in line + // Retrieve th enext item in line item, prio := s.queue.Peek() // If we have too many already-pending tasks for this depth, throttle