Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 16 additions & 15 deletions eth/downloader/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (

"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/state/snapshot"
"github.com/ethereum/go-ethereum/core/types"
Expand Down Expand Up @@ -250,21 +251,21 @@ func (d *Downloader) Progress() ethereum.SyncProgress {
progress, pending := d.SnapSyncer.Progress()

return ethereum.SyncProgress{
StartingBlock: d.syncStatsChainOrigin,
CurrentBlock: current,
HighestBlock: d.syncStatsChainHeight,
SyncedAccounts: progress.AccountSynced,
SyncedAccountBytes: uint64(progress.AccountBytes),
SyncedBytecodes: progress.BytecodeSynced,
SyncedBytecodeBytes: uint64(progress.BytecodeBytes),
SyncedStorage: progress.StorageSynced,
SyncedStorageBytes: uint64(progress.StorageBytes),
HealedTrienodes: progress.TrienodeHealSynced,
HealedTrienodeBytes: uint64(progress.TrienodeHealBytes),
HealedBytecodes: progress.BytecodeHealSynced,
HealedBytecodeBytes: uint64(progress.BytecodeHealBytes),
HealingTrienodes: pending.TrienodeHeal,
HealingBytecode: pending.BytecodeHeal,
StartingBlock: hexutil.Uint64(d.syncStatsChainOrigin),
CurrentBlock: hexutil.Uint64(current),
HighestBlock: hexutil.Uint64(d.syncStatsChainHeight),
SyncedAccounts: hexutil.Uint64(progress.AccountSynced),
SyncedAccountBytes: hexutil.Uint64(progress.AccountBytes),
SyncedBytecodes: hexutil.Uint64(progress.BytecodeSynced),
SyncedBytecodeBytes: hexutil.Uint64(progress.BytecodeBytes),
SyncedStorage: hexutil.Uint64(progress.StorageSynced),
SyncedStorageBytes: hexutil.Uint64(progress.StorageBytes),
HealedTrienodes: hexutil.Uint64(progress.TrienodeHealSynced),
HealedTrienodeBytes: hexutil.Uint64(progress.TrienodeHealBytes),
HealedBytecodes: hexutil.Uint64(progress.BytecodeHealSynced),
HealedBytecodeBytes: hexutil.Uint64(progress.BytecodeHealBytes),
HealingTrienodes: hexutil.Uint64(pending.TrienodeHeal),
HealingBytecode: hexutil.Uint64(pending.BytecodeHeal),
}
}

Expand Down
43 changes: 22 additions & 21 deletions eth/downloader/downloader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (

"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/consensus/ethash"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/rawdb"
Expand Down Expand Up @@ -1013,7 +1014,7 @@ func testSyncProgress(t *testing.T, protocol uint, mode SyncMode) {
}()
<-starting
checkProgress(t, tester.downloader, "initial", ethereum.SyncProgress{
HighestBlock: uint64(len(chain.blocks)/2 - 1),
HighestBlock: hexutil.Uint64(len(chain.blocks)/2 - 1),
})
progress <- struct{}{}
pending.Wait()
Expand All @@ -1029,18 +1030,18 @@ func testSyncProgress(t *testing.T, protocol uint, mode SyncMode) {
}()
<-starting
checkProgress(t, tester.downloader, "completing", ethereum.SyncProgress{
StartingBlock: uint64(len(chain.blocks)/2 - 1),
CurrentBlock: uint64(len(chain.blocks)/2 - 1),
HighestBlock: uint64(len(chain.blocks) - 1),
StartingBlock: hexutil.Uint64(len(chain.blocks)/2 - 1),
CurrentBlock: hexutil.Uint64(len(chain.blocks)/2 - 1),
HighestBlock: hexutil.Uint64(len(chain.blocks) - 1),
})

// Check final progress after successful sync
progress <- struct{}{}
pending.Wait()
checkProgress(t, tester.downloader, "final", ethereum.SyncProgress{
StartingBlock: uint64(len(chain.blocks)/2 - 1),
CurrentBlock: uint64(len(chain.blocks) - 1),
HighestBlock: uint64(len(chain.blocks) - 1),
StartingBlock: hexutil.Uint64(len(chain.blocks)/2 - 1),
CurrentBlock: hexutil.Uint64(len(chain.blocks) - 1),
HighestBlock: hexutil.Uint64(len(chain.blocks) - 1),
})
}

Expand Down Expand Up @@ -1091,7 +1092,7 @@ func testForkedSyncProgress(t *testing.T, protocol uint, mode SyncMode) {
<-starting

checkProgress(t, tester.downloader, "initial", ethereum.SyncProgress{
HighestBlock: uint64(len(chainA.blocks) - 1),
HighestBlock: hexutil.Uint64(len(chainA.blocks) - 1),
})
progress <- struct{}{}
pending.Wait()
Expand All @@ -1110,18 +1111,18 @@ func testForkedSyncProgress(t *testing.T, protocol uint, mode SyncMode) {
}()
<-starting
checkProgress(t, tester.downloader, "forking", ethereum.SyncProgress{
StartingBlock: uint64(len(testChainBase.blocks)) - 1,
CurrentBlock: uint64(len(chainA.blocks) - 1),
HighestBlock: uint64(len(chainB.blocks) - 1),
StartingBlock: hexutil.Uint64(len(testChainBase.blocks)) - 1,
CurrentBlock: hexutil.Uint64(len(chainA.blocks) - 1),
HighestBlock: hexutil.Uint64(len(chainB.blocks) - 1),
})

// Check final progress after successful sync
progress <- struct{}{}
pending.Wait()
checkProgress(t, tester.downloader, "final", ethereum.SyncProgress{
StartingBlock: uint64(len(testChainBase.blocks)) - 1,
CurrentBlock: uint64(len(chainB.blocks) - 1),
HighestBlock: uint64(len(chainB.blocks) - 1),
StartingBlock: hexutil.Uint64(len(testChainBase.blocks)) - 1,
CurrentBlock: hexutil.Uint64(len(chainB.blocks) - 1),
HighestBlock: hexutil.Uint64(len(chainB.blocks) - 1),
})
}

Expand Down Expand Up @@ -1164,7 +1165,7 @@ func testFailedSyncProgress(t *testing.T, protocol uint, mode SyncMode) {
}()
<-starting
checkProgress(t, tester.downloader, "initial", ethereum.SyncProgress{
HighestBlock: uint64(len(chain.blocks) - 1),
HighestBlock: hexutil.Uint64(len(chain.blocks) - 1),
})
progress <- struct{}{}
pending.Wait()
Expand All @@ -1187,8 +1188,8 @@ func testFailedSyncProgress(t *testing.T, protocol uint, mode SyncMode) {
progress <- struct{}{}
pending.Wait()
checkProgress(t, tester.downloader, "final", ethereum.SyncProgress{
CurrentBlock: uint64(len(chain.blocks) - 1),
HighestBlock: uint64(len(chain.blocks) - 1),
CurrentBlock: hexutil.Uint64(len(chain.blocks) - 1),
HighestBlock: hexutil.Uint64(len(chain.blocks) - 1),
})
}

Expand Down Expand Up @@ -1229,7 +1230,7 @@ func testFakedSyncProgress(t *testing.T, protocol uint, mode SyncMode) {
}()
<-starting
checkProgress(t, tester.downloader, "initial", ethereum.SyncProgress{
HighestBlock: uint64(len(chain.blocks) - 1),
HighestBlock: hexutil.Uint64(len(chain.blocks) - 1),
})
progress <- struct{}{}
pending.Wait()
Expand All @@ -1250,14 +1251,14 @@ func testFakedSyncProgress(t *testing.T, protocol uint, mode SyncMode) {
<-starting
checkProgress(t, tester.downloader, "completing", ethereum.SyncProgress{
CurrentBlock: afterFailedSync.CurrentBlock,
HighestBlock: uint64(len(validChain.blocks) - 1),
HighestBlock: hexutil.Uint64(len(validChain.blocks) - 1),
})
// Check final progress after successful sync.
progress <- struct{}{}
pending.Wait()
checkProgress(t, tester.downloader, "final", ethereum.SyncProgress{
CurrentBlock: uint64(len(validChain.blocks) - 1),
HighestBlock: uint64(len(validChain.blocks) - 1),
CurrentBlock: hexutil.Uint64(len(validChain.blocks) - 1),
HighestBlock: hexutil.Uint64(len(validChain.blocks) - 1),
})
}

Expand Down
4 changes: 2 additions & 2 deletions ethstats/ethstats.go
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ func (s *Service) reportStats(conn *connWrapper) error {
hashrate = int(fullBackend.Miner().Hashrate())

sync := fullBackend.SyncProgress()
syncing = fullBackend.CurrentHeader().Number.Uint64() >= sync.HighestBlock
syncing = fullBackend.CurrentHeader().Number.Uint64() >= uint64(sync.HighestBlock)

price, _ := fullBackend.SuggestGasTipCap(context.Background())
gasprice = int(price.Uint64())
Expand All @@ -787,7 +787,7 @@ func (s *Service) reportStats(conn *connWrapper) error {
}
} else {
sync := s.backend.SyncProgress()
syncing = s.backend.CurrentHeader().Number.Uint64() >= sync.HighestBlock
syncing = s.backend.CurrentHeader().Number.Uint64() >= uint64(sync.HighestBlock)
}
// Assemble the node stats and send it to the server
log.Trace("Sending node details to ethstats")
Expand Down
30 changes: 15 additions & 15 deletions graphql/graphql.go
Original file line number Diff line number Diff line change
Expand Up @@ -1218,49 +1218,49 @@ type SyncState struct {
}

func (s *SyncState) StartingBlock() hexutil.Uint64 {
return hexutil.Uint64(s.progress.StartingBlock)
return s.progress.StartingBlock
}
func (s *SyncState) CurrentBlock() hexutil.Uint64 {
return hexutil.Uint64(s.progress.CurrentBlock)
return s.progress.CurrentBlock
}
func (s *SyncState) HighestBlock() hexutil.Uint64 {
return hexutil.Uint64(s.progress.HighestBlock)
return s.progress.HighestBlock
}
func (s *SyncState) SyncedAccounts() hexutil.Uint64 {
return hexutil.Uint64(s.progress.SyncedAccounts)
return s.progress.SyncedAccounts
}
func (s *SyncState) SyncedAccountBytes() hexutil.Uint64 {
return hexutil.Uint64(s.progress.SyncedAccountBytes)
return s.progress.SyncedAccountBytes
}
func (s *SyncState) SyncedBytecodes() hexutil.Uint64 {
return hexutil.Uint64(s.progress.SyncedBytecodes)
return s.progress.SyncedBytecodes
}
func (s *SyncState) SyncedBytecodeBytes() hexutil.Uint64 {
return hexutil.Uint64(s.progress.SyncedBytecodeBytes)
return s.progress.SyncedBytecodeBytes
}
func (s *SyncState) SyncedStorage() hexutil.Uint64 {
return hexutil.Uint64(s.progress.SyncedStorage)
return s.progress.SyncedStorage
}
func (s *SyncState) SyncedStorageBytes() hexutil.Uint64 {
return hexutil.Uint64(s.progress.SyncedStorageBytes)
return s.progress.SyncedStorageBytes
}
func (s *SyncState) HealedTrienodes() hexutil.Uint64 {
return hexutil.Uint64(s.progress.HealedTrienodes)
return s.progress.HealedTrienodes
}
func (s *SyncState) HealedTrienodeBytes() hexutil.Uint64 {
return hexutil.Uint64(s.progress.HealedTrienodeBytes)
return s.progress.HealedTrienodeBytes
}
func (s *SyncState) HealedBytecodes() hexutil.Uint64 {
return hexutil.Uint64(s.progress.HealedBytecodes)
return s.progress.HealedBytecodes
}
func (s *SyncState) HealedBytecodeBytes() hexutil.Uint64 {
return hexutil.Uint64(s.progress.HealedBytecodeBytes)
return s.progress.HealedBytecodeBytes
}
func (s *SyncState) HealingTrienodes() hexutil.Uint64 {
return hexutil.Uint64(s.progress.HealingTrienodes)
return s.progress.HealingTrienodes
}
func (s *SyncState) HealingBytecode() hexutil.Uint64 {
return hexutil.Uint64(s.progress.HealingBytecode)
return s.progress.HealingBytecode
}

// Syncing returns false in case the node is currently not syncing with the network. It can be up to date or has not
Expand Down
35 changes: 18 additions & 17 deletions interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"math/big"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/core/types"
)

Expand Down Expand Up @@ -98,25 +99,25 @@ type ChainStateReader interface {
// SyncProgress gives progress indications when the node is synchronising with
// the Ethereum network.
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
StartingBlock hexutil.Uint64 // Block number where sync began
CurrentBlock hexutil.Uint64 // Current block number where sync is at
HighestBlock hexutil.Uint64 // Highest alleged block number in the chain

// Fields belonging to snap sync
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
SyncedAccounts hexutil.Uint64 // Number of accounts downloaded
SyncedAccountBytes hexutil.Uint64 // Number of account trie bytes persisted to disk
SyncedBytecodes hexutil.Uint64 // Number of bytecodes downloaded
SyncedBytecodeBytes hexutil.Uint64 // Number of bytecode bytes downloaded
SyncedStorage hexutil.Uint64 // Number of storage slots downloaded
SyncedStorageBytes hexutil.Uint64 // Number of storage trie bytes persisted to disk

HealedTrienodes hexutil.Uint64 // Number of state trie nodes downloaded
HealedTrienodeBytes hexutil.Uint64 // Number of state trie bytes persisted to disk
HealedBytecodes hexutil.Uint64 // Number of bytecodes downloaded
HealedBytecodeBytes hexutil.Uint64 // Number of bytecodes persisted to disk

HealingTrienodes hexutil.Uint64 // Number of state trie nodes pending
HealingBytecode hexutil.Uint64 // Number of bytecodes pending
}

// ChainSyncReader wraps access to the node's current sync status. If there's no
Expand Down
30 changes: 15 additions & 15 deletions internal/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,21 +131,21 @@ func (s *PublicEthereumAPI) Syncing() (interface{}, error) {
}
// Otherwise gather the block sync stats
return map[string]interface{}{
"startingBlock": hexutil.Uint64(progress.StartingBlock),
"currentBlock": hexutil.Uint64(progress.CurrentBlock),
"highestBlock": hexutil.Uint64(progress.HighestBlock),
"syncedAccounts": hexutil.Uint64(progress.SyncedAccounts),
"syncedAccountBytes": hexutil.Uint64(progress.SyncedAccountBytes),
"syncedBytecodes": hexutil.Uint64(progress.SyncedBytecodes),
"syncedBytecodeBytes": hexutil.Uint64(progress.SyncedBytecodeBytes),
"syncedStorage": hexutil.Uint64(progress.SyncedStorage),
"syncedStorageBytes": hexutil.Uint64(progress.SyncedStorageBytes),
"healedTrienodes": hexutil.Uint64(progress.HealedTrienodes),
"healedTrienodeBytes": hexutil.Uint64(progress.HealedTrienodeBytes),
"healedBytecodes": hexutil.Uint64(progress.HealedBytecodes),
"healedBytecodeBytes": hexutil.Uint64(progress.HealedBytecodeBytes),
"healingTrienodes": hexutil.Uint64(progress.HealingTrienodes),
"healingBytecode": hexutil.Uint64(progress.HealingBytecode),
"startingBlock": progress.StartingBlock,
"currentBlock": progress.CurrentBlock,
"highestBlock": progress.HighestBlock,
"syncedAccounts": progress.SyncedAccounts,
"syncedAccountBytes": progress.SyncedAccountBytes,
"syncedBytecodes": progress.SyncedBytecodes,
"syncedBytecodeBytes": progress.SyncedBytecodeBytes,
"syncedStorage": progress.SyncedStorage,
"syncedStorageBytes": progress.SyncedStorageBytes,
"healedTrienodes": progress.HealedTrienodes,
"healedTrienodeBytes": progress.HealedTrienodeBytes,
"healedBytecodes": progress.HealedBytecodes,
"healedBytecodeBytes": progress.HealedBytecodeBytes,
"healingTrienodes": progress.HealingTrienodes,
"healingBytecode": progress.HealingBytecode,
}, nil
}

Expand Down
7 changes: 4 additions & 3 deletions les/downloader/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (

"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/state/snapshot"
"github.com/ethereum/go-ethereum/core/types"
Expand Down Expand Up @@ -262,9 +263,9 @@ func (d *Downloader) Progress() ethereum.SyncProgress {
log.Error("Unknown downloader chain/mode combo", "light", d.lightchain != nil, "full", d.blockchain != nil, "mode", mode)
}
return ethereum.SyncProgress{
StartingBlock: d.syncStatsChainOrigin,
CurrentBlock: current,
HighestBlock: d.syncStatsChainHeight,
StartingBlock: hexutil.Uint64(d.syncStatsChainOrigin),
CurrentBlock: hexutil.Uint64(current),
HighestBlock: hexutil.Uint64(d.syncStatsChainHeight),
//PulledStates: d.syncStatsState.processed,
//KnownStates: d.syncStatsState.processed + d.syncStatsState.pending,
}
Expand Down
Loading