forked from cerc-io/plugeth
build: upgrade to go 1.19 (#25726)
This changes the CI / release builds to use the latest Go version. It also upgrades golangci-lint to a newer version compatible with Go 1.19. In Go 1.19, godoc has gained official support for links and lists. The syntax for code blocks in doc comments has changed and now requires a leading tab character. gofmt adapts comments to the new syntax automatically, so there are a lot of comment re-formatting changes in this PR. We need to apply the new format in order to pass the CI lint stage with Go 1.19. With the linter upgrade, I have decided to disable 'gosec' - it produces too many false-positive warnings. The 'deadcode' and 'varcheck' linters have also been removed because golangci-lint warns about them being unmaintained. 'unused' provides similar coverage and we already have it enabled, so we don't lose much with this change.
This commit is contained in:
+9
-7
@@ -366,10 +366,11 @@ func NewLightAPI(backend *lesCommons) *LightAPI {
|
||||
// LatestCheckpoint returns the latest local checkpoint package.
|
||||
//
|
||||
// The checkpoint package consists of 4 strings:
|
||||
// result[0], hex encoded latest section index
|
||||
// result[1], 32 bytes hex encoded latest section head hash
|
||||
// result[2], 32 bytes hex encoded latest section canonical hash trie root hash
|
||||
// result[3], 32 bytes hex encoded latest section bloom trie root hash
|
||||
//
|
||||
// result[0], hex encoded latest section index
|
||||
// result[1], 32 bytes hex encoded latest section head hash
|
||||
// result[2], 32 bytes hex encoded latest section canonical hash trie root hash
|
||||
// result[3], 32 bytes hex encoded latest section bloom trie root hash
|
||||
func (api *LightAPI) LatestCheckpoint() ([4]string, error) {
|
||||
var res [4]string
|
||||
cp := api.backend.latestLocalCheckpoint()
|
||||
@@ -384,9 +385,10 @@ func (api *LightAPI) LatestCheckpoint() ([4]string, error) {
|
||||
// GetLocalCheckpoint returns the specific local checkpoint package.
|
||||
//
|
||||
// The checkpoint package consists of 3 strings:
|
||||
// result[0], 32 bytes hex encoded latest section head hash
|
||||
// result[1], 32 bytes hex encoded latest section canonical hash trie root hash
|
||||
// result[2], 32 bytes hex encoded latest section bloom trie root hash
|
||||
//
|
||||
// result[0], 32 bytes hex encoded latest section head hash
|
||||
// result[1], 32 bytes hex encoded latest section canonical hash trie root hash
|
||||
// result[2], 32 bytes hex encoded latest section bloom trie root hash
|
||||
func (api *LightAPI) GetCheckpoint(index uint64) ([3]string, error) {
|
||||
var res [3]string
|
||||
cp := api.backend.localCheckpoint(index)
|
||||
|
||||
+13
-9
@@ -56,15 +56,19 @@ func NewConsensusAPI(les *les.LightEthereum) *ConsensusAPI {
|
||||
}
|
||||
|
||||
// ForkchoiceUpdatedV1 has several responsibilities:
|
||||
// If the method is called with an empty head block:
|
||||
// we return success, which can be used to check if the catalyst mode is enabled
|
||||
// If the total difficulty was not reached:
|
||||
// we return INVALID
|
||||
// If the finalizedBlockHash is set:
|
||||
// we check if we have the finalizedBlockHash in our db, if not we start a sync
|
||||
// We try to set our blockchain to the headBlock
|
||||
// If there are payloadAttributes:
|
||||
// we return an error since block creation is not supported in les mode
|
||||
//
|
||||
// We try to set our blockchain to the headBlock.
|
||||
//
|
||||
// If the method is called with an empty head block: we return success, which can be used
|
||||
// to check if the catalyst mode is enabled.
|
||||
//
|
||||
// If the total difficulty was not reached: we return INVALID.
|
||||
//
|
||||
// If the finalizedBlockHash is set: we check if we have the finalizedBlockHash in our db,
|
||||
// if not we start a sync.
|
||||
//
|
||||
// If there are payloadAttributes: we return an error since block creation is not
|
||||
// supported in les mode.
|
||||
func (api *ConsensusAPI) ForkchoiceUpdatedV1(heads beacon.ForkchoiceStateV1, payloadAttributes *beacon.PayloadAttributesV1) (beacon.ForkChoiceResponse, error) {
|
||||
if heads.HeadBlockHash == (common.Hash{}) {
|
||||
log.Warn("Forkchoice requested update to zero hash")
|
||||
|
||||
@@ -693,9 +693,11 @@ func (d *Downloader) fetchHead(p *peerConnection) (head *types.Header, pivot *ty
|
||||
// calculateRequestSpan calculates what headers to request from a peer when trying to determine the
|
||||
// common ancestor.
|
||||
// It returns parameters to be used for peer.RequestHeadersByNumber:
|
||||
// from - starting block number
|
||||
// count - number of headers to request
|
||||
// skip - number of headers to skip
|
||||
//
|
||||
// from - starting block number
|
||||
// count - number of headers to request
|
||||
// skip - number of headers to skip
|
||||
//
|
||||
// and also returns 'max', the last block which is expected to be returned by the remote peers,
|
||||
// given the (from,count,skip)
|
||||
func calculateRequestSpan(remoteHeight, localHeight uint64) (int64, int, int, uint64) {
|
||||
@@ -1310,22 +1312,22 @@ func (d *Downloader) fetchReceipts(from uint64) error {
|
||||
// various callbacks to handle the slight differences between processing them.
|
||||
//
|
||||
// The instrumentation parameters:
|
||||
// - errCancel: error type to return if the fetch operation is cancelled (mostly makes logging nicer)
|
||||
// - deliveryCh: channel from which to retrieve downloaded data packets (merged from all concurrent peers)
|
||||
// - deliver: processing callback to deliver data packets into type specific download queues (usually within `queue`)
|
||||
// - wakeCh: notification channel for waking the fetcher when new tasks are available (or sync completed)
|
||||
// - expire: task callback method to abort requests that took too long and return the faulty peers (traffic shaping)
|
||||
// - pending: task callback for the number of requests still needing download (detect completion/non-completability)
|
||||
// - inFlight: task callback for the number of in-progress requests (wait for all active downloads to finish)
|
||||
// - throttle: task callback to check if the processing queue is full and activate throttling (bound memory use)
|
||||
// - reserve: task callback to reserve new download tasks to a particular peer (also signals partial completions)
|
||||
// - fetchHook: tester callback to notify of new tasks being initiated (allows testing the scheduling logic)
|
||||
// - fetch: network callback to actually send a particular download request to a physical remote peer
|
||||
// - cancel: task callback to abort an in-flight download request and allow rescheduling it (in case of lost peer)
|
||||
// - capacity: network callback to retrieve the estimated type-specific bandwidth capacity of a peer (traffic shaping)
|
||||
// - idle: network callback to retrieve the currently (type specific) idle peers that can be assigned tasks
|
||||
// - setIdle: network callback to set a peer back to idle and update its estimated capacity (traffic shaping)
|
||||
// - kind: textual label of the type being downloaded to display in log messages
|
||||
// - errCancel: error type to return if the fetch operation is cancelled (mostly makes logging nicer)
|
||||
// - deliveryCh: channel from which to retrieve downloaded data packets (merged from all concurrent peers)
|
||||
// - deliver: processing callback to deliver data packets into type specific download queues (usually within `queue`)
|
||||
// - wakeCh: notification channel for waking the fetcher when new tasks are available (or sync completed)
|
||||
// - expire: task callback method to abort requests that took too long and return the faulty peers (traffic shaping)
|
||||
// - pending: task callback for the number of requests still needing download (detect completion/non-completability)
|
||||
// - inFlight: task callback for the number of in-progress requests (wait for all active downloads to finish)
|
||||
// - throttle: task callback to check if the processing queue is full and activate throttling (bound memory use)
|
||||
// - reserve: task callback to reserve new download tasks to a particular peer (also signals partial completions)
|
||||
// - fetchHook: tester callback to notify of new tasks being initiated (allows testing the scheduling logic)
|
||||
// - fetch: network callback to actually send a particular download request to a physical remote peer
|
||||
// - cancel: task callback to abort an in-flight download request and allow rescheduling it (in case of lost peer)
|
||||
// - capacity: network callback to retrieve the estimated type-specific bandwidth capacity of a peer (traffic shaping)
|
||||
// - idle: network callback to retrieve the currently (type specific) idle peers that can be assigned tasks
|
||||
// - setIdle: network callback to set a peer back to idle and update its estimated capacity (traffic shaping)
|
||||
// - kind: textual label of the type being downloaded to display in log messages
|
||||
func (d *Downloader) fetchParts(deliveryCh chan dataPack, deliver func(dataPack) (int, error), wakeCh chan bool,
|
||||
expire func() map[string]int, pending func() int, inFlight func() bool, reserve func(*peerConnection, int) (*fetchRequest, bool, bool),
|
||||
fetchHook func([]*types.Header), fetch func(*peerConnection, *fetchRequest) error, cancel func(*fetchRequest), capacity func(*peerConnection) int,
|
||||
|
||||
@@ -477,9 +477,10 @@ func (q *queue) ReserveReceipts(p *peerConnection, count int) (*fetchRequest, bo
|
||||
// to access the queue, so they already need a lock anyway.
|
||||
//
|
||||
// Returns:
|
||||
// item - the fetchRequest
|
||||
// progress - whether any progress was made
|
||||
// throttle - if the caller should throttle for a while
|
||||
//
|
||||
// item - the fetchRequest
|
||||
// progress - whether any progress was made
|
||||
// throttle - if the caller should throttle for a while
|
||||
func (q *queue) reserveHeaders(p *peerConnection, count int, taskPool map[common.Hash]*types.Header, taskQueue *prque.Prque,
|
||||
pendPool map[string]*fetchRequest, kind uint) (*fetchRequest, bool, bool) {
|
||||
// Short circuit if the pool has been depleted, or if the peer's already
|
||||
|
||||
@@ -71,10 +71,11 @@ func (r *resultStore) SetThrottleThreshold(threshold uint64) uint64 {
|
||||
// wants to reserve headers for fetching.
|
||||
//
|
||||
// It returns the following:
|
||||
// stale - if true, this item is already passed, and should not be requested again
|
||||
// throttled - if true, the store is at capacity, this particular header is not prio now
|
||||
// item - the result to store data into
|
||||
// err - any error that occurred
|
||||
//
|
||||
// stale - if true, this item is already passed, and should not be requested again
|
||||
// throttled - if true, the store is at capacity, this particular header is not prio now
|
||||
// item - the result to store data into
|
||||
// err - any error that occurred
|
||||
func (r *resultStore) AddFetch(header *types.Header, fastSync bool) (stale, throttled bool, item *fetchResult, err error) {
|
||||
r.lock.Lock()
|
||||
defer r.lock.Unlock()
|
||||
|
||||
+12
-10
@@ -242,18 +242,20 @@ func (f *lightFetcher) forEachPeer(check func(id enode.ID, p *fetcherPeer) bool)
|
||||
}
|
||||
|
||||
// mainloop is the main event loop of the light fetcher, which is responsible for
|
||||
// - announcement maintenance(ulc)
|
||||
// If we are running in ultra light client mode, then all announcements from
|
||||
// the trusted servers are maintained. If the same announcements from trusted
|
||||
// servers reach the threshold, then the relevant header is requested for retrieval.
|
||||
//
|
||||
// - block header retrieval
|
||||
// Whenever we receive announce with higher td compared with local chain, the
|
||||
// request will be made for header retrieval.
|
||||
// - announcement maintenance(ulc)
|
||||
//
|
||||
// - re-sync trigger
|
||||
// If the local chain lags too much, then the fetcher will enter "synchronise"
|
||||
// mode to retrieve missing headers in batch.
|
||||
// If we are running in ultra light client mode, then all announcements from
|
||||
// the trusted servers are maintained. If the same announcements from trusted
|
||||
// servers reach the threshold, then the relevant header is requested for retrieval.
|
||||
//
|
||||
// - block header retrieval
|
||||
// Whenever we receive announce with higher td compared with local chain, the
|
||||
// request will be made for header retrieval.
|
||||
//
|
||||
// - re-sync trigger
|
||||
// If the local chain lags too much, then the fetcher will enter "synchronise"
|
||||
// mode to retrieve missing headers in batch.
|
||||
func (f *lightFetcher) mainloop() {
|
||||
defer f.wg.Done()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user