Skip to content

Commit

Permalink
Revert "Merge/v1.10.15"
Browse files Browse the repository at this point in the history
  • Loading branch information
zeroecco authored Jan 13, 2022
1 parent 216e55e commit 38229bc
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 113 deletions.
4 changes: 2 additions & 2 deletions accounts/accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions core/asm/lexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 2 additions & 5 deletions core/rawdb/accessors_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
68 changes: 17 additions & 51 deletions ethclient/ethclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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 &ethereum.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
Expand Down Expand Up @@ -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 &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),
}
}
41 changes: 15 additions & 26 deletions graphql/graphql.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
}
Expand Down
23 changes: 2 additions & 21 deletions interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions les/server_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion params/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down
2 changes: 1 addition & 1 deletion trie/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 38229bc

Please sign in to comment.