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:
+13
-9
@@ -142,15 +142,19 @@ func NewConsensusAPI(eth *eth.Ethereum) *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 engine API 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 try to assemble a block with the payloadAttributes and return its payloadID
|
||||
//
|
||||
// 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 engine API 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 try to assemble a block with the payloadAttributes
|
||||
// and return its payloadID.
|
||||
func (api *ConsensusAPI) ForkchoiceUpdatedV1(update beacon.ForkchoiceStateV1, payloadAttributes *beacon.PayloadAttributesV1) (beacon.ForkChoiceResponse, error) {
|
||||
api.forkchoiceLock.Lock()
|
||||
defer api.forkchoiceLock.Unlock()
|
||||
|
||||
@@ -519,18 +519,18 @@ func TestExchangeTransitionConfig(t *testing.T) {
|
||||
TestNewPayloadOnInvalidChain sets up a valid chain and tries to feed blocks
|
||||
from an invalid chain to test if latestValidHash (LVH) works correctly.
|
||||
|
||||
We set up the following chain where P1 ... Pn and P1'' are valid while
|
||||
We set up the following chain where P1 ... Pn and P1” are valid while
|
||||
P1' is invalid.
|
||||
We expect
|
||||
(1) The LVH to point to the current inserted payload if it was valid.
|
||||
(2) The LVH to point to the valid parent on an invalid payload (if the parent is available).
|
||||
(3) If the parent is unavailable, the LVH should not be set.
|
||||
|
||||
CommonAncestor◄─▲── P1 ◄── P2 ◄─ P3 ◄─ ... ◄─ Pn
|
||||
│
|
||||
└── P1' ◄─ P2' ◄─ P3' ◄─ ... ◄─ Pn'
|
||||
│
|
||||
└── P1''
|
||||
CommonAncestor◄─▲── P1 ◄── P2 ◄─ P3 ◄─ ... ◄─ Pn
|
||||
│
|
||||
└── P1' ◄─ P2' ◄─ P3' ◄─ ... ◄─ Pn'
|
||||
│
|
||||
└── P1''
|
||||
*/
|
||||
func TestNewPayloadOnInvalidChain(t *testing.T) {
|
||||
genesis, preMergeBlocks := generatePreMergeChain(10)
|
||||
|
||||
@@ -741,9 +741,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) {
|
||||
|
||||
@@ -480,9 +480,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()
|
||||
|
||||
@@ -208,10 +208,11 @@ func (oracle *Oracle) resolveBlockRange(ctx context.Context, reqEnd rpc.BlockNum
|
||||
// actually processed range is returned to avoid ambiguity when parts of the requested range
|
||||
// are not available or when the head has changed during processing this request.
|
||||
// Three arrays are returned based on the processed blocks:
|
||||
// - reward: the requested percentiles of effective priority fees per gas of transactions in each
|
||||
// block, sorted in ascending order and weighted by gas used.
|
||||
// - baseFee: base fee per gas in the given block
|
||||
// - gasUsedRatio: gasUsed/gasLimit in the given block
|
||||
// - reward: the requested percentiles of effective priority fees per gas of transactions in each
|
||||
// block, sorted in ascending order and weighted by gas used.
|
||||
// - baseFee: base fee per gas in the given block
|
||||
// - gasUsedRatio: gasUsed/gasLimit in the given block
|
||||
//
|
||||
// Note: baseFee includes the next block after the newest of the returned range, because this
|
||||
// value can be derived from the newest block.
|
||||
func (oracle *Oracle) FeeHistory(ctx context.Context, blocks int, unresolvedLastBlock rpc.BlockNumber, rewardPercentiles []float64) (*big.Int, [][]*big.Int, []*big.Int, []float64, error) {
|
||||
|
||||
@@ -368,8 +368,8 @@ func createStorageRequestResponse(t *testPeer, root common.Hash, accounts []comm
|
||||
return hashes, slots, proofs
|
||||
}
|
||||
|
||||
// the createStorageRequestResponseAlwaysProve tests a cornercase, where it always
|
||||
// supplies the proof for the last account, even if it is 'complete'.h
|
||||
// createStorageRequestResponseAlwaysProve tests a cornercase, where the peer always
|
||||
// supplies the proof for the last account, even if it is 'complete'.
|
||||
func createStorageRequestResponseAlwaysProve(t *testPeer, root common.Hash, accounts []common.Hash, bOrigin, bLimit []byte, max uint64) (hashes [][]common.Hash, slots [][][]byte, proofs [][]byte) {
|
||||
var size uint64
|
||||
max = max * 3 / 4
|
||||
|
||||
+10
-10
@@ -46,16 +46,16 @@ var noopReleaser = tracers.StateReleaseFunc(func() {})
|
||||
// Its purpose is to prevent resource leaking. Though it can be noop in some cases.
|
||||
//
|
||||
// Parameters:
|
||||
// - block: The block for which we want the state(state = block.Root)
|
||||
// - reexec: The maximum number of blocks to reprocess trying to obtain the desired state
|
||||
// - base: If the caller is tracing multiple blocks, the caller can provide the parent
|
||||
// state continuously from the callsite.
|
||||
// - readOnly: If true, then the live 'blockchain' state database is used. No mutation should
|
||||
// be made from caller, e.g. perform Commit or other 'save-to-disk' changes.
|
||||
// Otherwise, the trash generated by caller may be persisted permanently.
|
||||
// - preferDisk: this arg can be used by the caller to signal that even though the 'base' is
|
||||
// provided, it would be preferable to start from a fresh state, if we have it
|
||||
// on disk.
|
||||
// - block: The block for which we want the state(state = block.Root)
|
||||
// - reexec: The maximum number of blocks to reprocess trying to obtain the desired state
|
||||
// - base: If the caller is tracing multiple blocks, the caller can provide the parent
|
||||
// state continuously from the callsite.
|
||||
// - readOnly: If true, then the live 'blockchain' state database is used. No mutation should
|
||||
// be made from caller, e.g. perform Commit or other 'save-to-disk' changes.
|
||||
// Otherwise, the trash generated by caller may be persisted permanently.
|
||||
// - preferDisk: this arg can be used by the caller to signal that even though the 'base' is
|
||||
// provided, it would be preferable to start from a fresh state, if we have it
|
||||
// on disk.
|
||||
func (eth *Ethereum) StateAtBlock(block *types.Block, reexec uint64, base *state.StateDB, readOnly bool, preferDisk bool) (statedb *state.StateDB, release tracers.StateReleaseFunc, err error) {
|
||||
var (
|
||||
current *types.Block
|
||||
|
||||
@@ -37,14 +37,15 @@ func init() {
|
||||
// a reversed signature can be matched against the size of the data.
|
||||
//
|
||||
// Example:
|
||||
// > debug.traceTransaction( "0x214e597e35da083692f5386141e69f47e973b2c56e7a8073b1ea08fd7571e9de", {tracer: "4byteTracer"})
|
||||
// {
|
||||
// 0x27dc297e-128: 1,
|
||||
// 0x38cc4831-0: 2,
|
||||
// 0x524f3889-96: 1,
|
||||
// 0xadf59f99-288: 1,
|
||||
// 0xc281d19e-0: 1
|
||||
// }
|
||||
//
|
||||
// > debug.traceTransaction( "0x214e597e35da083692f5386141e69f47e973b2c56e7a8073b1ea08fd7571e9de", {tracer: "4byteTracer"})
|
||||
// {
|
||||
// 0x27dc297e-128: 1,
|
||||
// 0x38cc4831-0: 2,
|
||||
// 0x524f3889-96: 1,
|
||||
// 0xadf59f99-288: 1,
|
||||
// 0xc281d19e-0: 1
|
||||
// }
|
||||
type fourByteTracer struct {
|
||||
env *vm.EVM
|
||||
ids map[string]int // ids aggregates the 4byte ids found
|
||||
|
||||
@@ -14,24 +14,20 @@
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/*
|
||||
Package native is a collection of tracers written in go.
|
||||
|
||||
In order to add a native tracer and have it compiled into the binary, a new
|
||||
file needs to be added to this folder, containing an implementation of the
|
||||
`eth.tracers.Tracer` interface.
|
||||
|
||||
Aside from implementing the tracer, it also needs to register itself, using the
|
||||
`register` method -- and this needs to be done in the package initialization.
|
||||
|
||||
Example:
|
||||
|
||||
```golang
|
||||
func init() {
|
||||
register("noopTracerNative", newNoopTracer)
|
||||
}
|
||||
```
|
||||
*/
|
||||
// Package native is a collection of tracers written in go.
|
||||
//
|
||||
// In order to add a native tracer and have it compiled into the binary, a new
|
||||
// file needs to be added to this folder, containing an implementation of the
|
||||
// `eth.tracers.Tracer` interface.
|
||||
//
|
||||
// Aside from implementing the tracer, it also needs to register itself, using the
|
||||
// `register` method -- and this needs to be done in the package initialization.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// func init() {
|
||||
// register("noopTracerNative", newNoopTracer)
|
||||
// }
|
||||
package native
|
||||
|
||||
import (
|
||||
|
||||
Reference in New Issue
Block a user