Skip to content

Commit 27fdbd9

Browse files
authored
Upgrade to go 1.19 (kaspanet#2191)
* Upgrade to go 1.19 * fmt
1 parent 377d9aa commit 27fdbd9

File tree

37 files changed

+178
-157
lines changed

37 files changed

+178
-157
lines changed

.github/workflows/deploy.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- name: Setup Go
2424
uses: actions/setup-go@v2
2525
with:
26-
go-version: 1.18
26+
go-version: 1.19
2727

2828
- name: Build on Linux
2929
if: runner.os == 'Linux'

.github/workflows/race.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- name: Setup Go
2323
uses: actions/setup-go@v2
2424
with:
25-
go-version: 1.18
25+
go-version: 1.19
2626

2727
- name: Set scheduled branch name
2828
shell: bash

.github/workflows/tests.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
- name: Setup Go
3434
uses: actions/setup-go@v2
3535
with:
36-
go-version: 1.18
36+
go-version: 1.19
3737

3838

3939
# Source: https://github.com/actions/cache/blob/main/examples.md#go---modules
@@ -58,7 +58,7 @@ jobs:
5858
- name: Setup Go
5959
uses: actions/setup-go@v2
6060
with:
61-
go-version: 1.18
61+
go-version: 1.19
6262

6363
- name: Checkout
6464
uses: actions/checkout@v2
@@ -86,7 +86,7 @@ jobs:
8686
- name: Setup Go
8787
uses: actions/setup-go@v2
8888
with:
89-
go-version: 1.18
89+
go-version: 1.19
9090

9191
- name: Delete the stability tests from coverage
9292
run: rm -r stability-tests

app/appmessage/doc.go

+13-13
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ supported kaspa messages to and from the appmessage. This package does not deal
66
with the specifics of message handling such as what to do when a message is
77
received. This provides the caller with a high level of flexibility.
88
9-
Kaspa Message Overview
9+
# Kaspa Message Overview
1010
1111
The kaspa protocol consists of exchanging messages between peers. Each
1212
message is preceded by a header which identifies information about it such as
@@ -22,7 +22,7 @@ messages, all of the details of marshalling and unmarshalling to and from the
2222
appmessage using kaspa encoding are handled so the caller doesn't have to concern
2323
themselves with the specifics.
2424
25-
Message Interaction
25+
# Message Interaction
2626
2727
The following provides a quick summary of how the kaspa messages are intended
2828
to interact with one another. As stated above, these interactions are not
@@ -45,13 +45,13 @@ interactions in no particular order.
4545
notfound message (MsgNotFound)
4646
ping message (MsgPing) pong message (MsgPong)
4747
48-
Common Parameters
48+
# Common Parameters
4949
5050
There are several common parameters that arise when using this package to read
5151
and write kaspa messages. The following sections provide a quick overview of
5252
these parameters so the next sections can build on them.
5353
54-
Protocol Version
54+
# Protocol Version
5555
5656
The protocol version should be negotiated with the remote peer at a higher
5757
level than this package via the version (MsgVersion) message exchange, however,
@@ -60,18 +60,18 @@ latest protocol version this package supports and is typically the value to use
6060
for all outbound connections before a potentially lower protocol version is
6161
negotiated.
6262
63-
Kaspa Network
63+
# Kaspa Network
6464
6565
The kaspa network is a magic number which is used to identify the start of a
6666
message and which kaspa network the message applies to. This package provides
6767
the following constants:
6868
69-
appmessage.Mainnet
70-
appmessage.Testnet (Test network)
71-
appmessage.Simnet (Simulation test network)
72-
appmessage.Devnet (Development network)
69+
appmessage.Mainnet
70+
appmessage.Testnet (Test network)
71+
appmessage.Simnet (Simulation test network)
72+
appmessage.Devnet (Development network)
7373
74-
Determining Message Type
74+
# Determining Message Type
7575
7676
As discussed in the kaspa message overview section, this package reads
7777
and writes kaspa messages using a generic interface named Message. In
@@ -89,7 +89,7 @@ switch or type assertion. An example of a type switch follows:
8989
fmt.Printf("Number of tx in block: %d", msg.Header.TxnCount)
9090
}
9191
92-
Reading Messages
92+
# Reading Messages
9393
9494
In order to unmarshall kaspa messages from the appmessage, use the ReadMessage
9595
function. It accepts any io.Reader, but typically this will be a net.Conn to
@@ -104,7 +104,7 @@ a remote node running a kaspa peer. Example syntax is:
104104
// Log and handle the error
105105
}
106106
107-
Writing Messages
107+
# Writing Messages
108108
109109
In order to marshall kaspa messages to the appmessage, use the WriteMessage
110110
function. It accepts any io.Writer, but typically this will be a net.Conn to
@@ -122,7 +122,7 @@ from a remote peer is:
122122
// Log and handle the error
123123
}
124124
125-
Errors
125+
# Errors
126126
127127
Errors returned by this package are either the raw errors provided by underlying
128128
calls to read/write from streams such as io.EOF, io.ErrUnexpectedEOF, and

app/appmessage/p2p_msgblock_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ func TestConvertToPartial(t *testing.T) {
132132
}
133133
}
134134

135-
//blockOne is the first block in the mainnet block DAG.
135+
// blockOne is the first block in the mainnet block DAG.
136136
var blockOne = MsgBlock{
137137
Header: MsgBlockHeader{
138138
Version: 0,

cmd/kaspactl/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ kaspactl is an RPC client for kaspad
44

55
## Requirements
66

7-
Go 1.18 or later.
7+
Go 1.19 or later.
88

99
## Installation
1010

cmd/kaspactl/docker/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -- multistage docker build: stage #1: build stage
2-
FROM golang:1.18-alpine AS build
2+
FROM golang:1.19-alpine AS build
33

44
RUN mkdir -p /go/src/github.com/kaspanet/kaspad
55

cmd/kaspaminer/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Kaspaminer is a CPU-based miner for kaspad
44

55
## Requirements
66

7-
Go 1.18 or later.
7+
Go 1.19 or later.
88

99
## Installation
1010

cmd/kaspaminer/docker/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -- multistage docker build: stage #1: build stage
2-
FROM golang:1.18-alpine AS build
2+
FROM golang:1.19-alpine AS build
33

44
RUN mkdir -p /go/src/github.com/kaspanet/kaspad
55

cmd/kaspawallet/libkaspawallet/bip32/base58/doc.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
Package base58 provides an API for working with modified base58 and Base58Check
77
encodings.
88
9-
Modified Base58 Encoding
9+
# Modified Base58 Encoding
1010
1111
Standard base58 encoding is similar to standard base64 encoding except, as the
1212
name implies, it uses a 58 character alphabet which results in an alphanumeric
@@ -17,7 +17,7 @@ The modified base58 alphabet used by Bitcoin, and hence this package, omits the
1717
0, O, I, and l characters that look the same in many fonts and are therefore
1818
hard to humans to distinguish.
1919
20-
Base58Check Encoding Scheme
20+
# Base58Check Encoding Scheme
2121
2222
The Base58Check encoding scheme is primarily used for Bitcoin addresses at the
2323
time of this writing, however it can be used to generically encode arbitrary

cmd/kaspawallet/libkaspawallet/converters.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"github.com/kaspanet/kaspad/domain/consensus/utils/utxo"
1111
)
1212

13-
//KaspawalletdUTXOsTolibkaspawalletUTXOs converts a []*pb.UtxosByAddressesEntry to a []*libkaspawallet.UTXO
13+
// KaspawalletdUTXOsTolibkaspawalletUTXOs converts a []*pb.UtxosByAddressesEntry to a []*libkaspawallet.UTXO
1414
func KaspawalletdUTXOsTolibkaspawalletUTXOs(kaspawalletdUtxoEntires []*pb.UtxosByAddressesEntry) ([]*UTXO, error) {
1515
UTXOs := make([]*UTXO, len(kaspawalletdUtxoEntires))
1616
for i, entry := range kaspawalletdUtxoEntires {

cmd/kaspawallet/libkaspawallet/serialization/serialization.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func SerializePartiallySignedTransaction(partiallySignedTransaction *PartiallySi
8888
return proto.Marshal(partiallySignedTransactionToProto(partiallySignedTransaction))
8989
}
9090

91-
//DeserializeDomainTransaction Deserialize a Transaction to an *externalapi.DomainTransaction
91+
// DeserializeDomainTransaction Deserialize a Transaction to an *externalapi.DomainTransaction
9292
func DeserializeDomainTransaction(serializedTransactionMessage []byte) (*externalapi.DomainTransaction, error) {
9393
protoTransactionMessage := &protoserialization.TransactionMessage{}
9494
err := proto.Unmarshal(serializedTransactionMessage, protoTransactionMessage)

doc.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ the box' for most users. However, there are also a wide variety of flags that
1313
can be used to control it.
1414
1515
Usage:
16-
kaspad [OPTIONS]
16+
17+
kaspad [OPTIONS]
1718
1819
For an up-to-date help message:
19-
kaspad --help
20+
21+
kaspad --help
2022
2123
The long form of all option flags (except -C) can be specified in a configuration
2224
file that is automatically parsed when kaspad starts up. By default, the

docker/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -- multistage docker build: stage #1: build stage
2-
FROM golang:1.18-alpine AS build
2+
FROM golang:1.19-alpine AS build
33

44
RUN mkdir -p /go/src/github.com/kaspanet/kaspad
55

domain/consensus/model/externalapi/blocklocator.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ package externalapi
1010
//
1111
// For example, assume a selected parent chain with IDs as depicted below, and the
1212
// stop block is genesis:
13-
// genesis -> 1 -> 2 -> ... -> 15 -> 16 -> 17 -> 18
13+
//
14+
// genesis -> 1 -> 2 -> ... -> 15 -> 16 -> 17 -> 18
1415
//
1516
// The block locator for block 17 would be the hashes of blocks:
16-
// [17 16 14 11 7 2 genesis]
17+
//
18+
// [17 16 14 11 7 2 genesis]
1719
type BlockLocator []*DomainHash
1820

1921
// Clone returns a clone of BlockLocator

domain/consensus/processes/blockvalidator/pruning_violation_proof_of_work_and_difficulty.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ func (v *blockValidator) validateDifficulty(stagingArea *model.StagingArea,
146146
// target difficulty as claimed.
147147
//
148148
// The flags modify the behavior of this function as follows:
149-
// - BFNoPoWCheck: The check to ensure the block hash is less than the target
150-
// difficulty is not performed.
149+
// - BFNoPoWCheck: The check to ensure the block hash is less than the target
150+
// difficulty is not performed.
151151
func (v *blockValidator) checkProofOfWork(header externalapi.BlockHeader) error {
152152
// The target difficulty must be larger than zero.
153153
state := pow.NewState(header.ToMutable())

domain/consensus/processes/coinbasemanager/coinbasemanager.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,8 @@ func (c *coinbaseManager) calcDeflationaryPeriodBlockSubsidy(blockDaaScore uint6
204204
}
205205

206206
/*
207-
This table was pre-calculated by calling `calcDeflationaryPeriodBlockSubsidyFloatCalc` for all months until reaching 0 subsidy.
208-
To regenerate this table, run `TestBuildSubsidyTable` in coinbasemanager_test.go (note the `deflationaryPhaseBaseSubsidy` therein)
207+
This table was pre-calculated by calling `calcDeflationaryPeriodBlockSubsidyFloatCalc` for all months until reaching 0 subsidy.
208+
To regenerate this table, run `TestBuildSubsidyTable` in coinbasemanager_test.go (note the `deflationaryPhaseBaseSubsidy` therein)
209209
*/
210210
var subsidyByDeflationaryMonthTable = []uint64{
211211
44000000000, 41530469757, 39199543598, 36999442271, 34922823143, 32962755691, 31112698372, 29366476791, 27718263097, 26162556530, 24694165062, 23308188075, 22000000000, 20765234878, 19599771799, 18499721135, 17461411571, 16481377845, 15556349186, 14683238395, 13859131548, 13081278265, 12347082531, 11654094037, 11000000000,

domain/consensus/processes/consensusstatemanager/resolve_block_status_test.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,9 @@ func TestDoubleSpends(t *testing.T) {
159159
// TestTransactionAcceptance checks that block transactions are accepted correctly when the merge set is sorted topologically.
160160
// DAG diagram:
161161
// genesis <- blockA <- blockB <- blockC <- ..(chain of k-blocks).. lastBlockInChain <- blockD <- blockE <- blockF <- blockG
162-
// ^ ^ |
163-
// | redBlock <------------------------ blueChildOfRedBlock <-------------------------------
162+
//
163+
// ^ ^ |
164+
// | redBlock <------------------------ blueChildOfRedBlock <-------------------------------
164165
func TestTransactionAcceptance(t *testing.T) {
165166
testutils.ForAllNets(t, true, func(t *testing.T, consensusConfig *consensus.Config) {
166167
stagingArea := model.NewStagingArea()

domain/consensus/processes/ghostdagmanager/ghostdag.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ func (bg *blockGHOSTDAGData) toModel() *externalapi.BlockGHOSTDAGData {
3030
//
3131
// 1) |anticone-of-candidate-block ∩ blue-set-of-newBlock| ≤ K
3232
//
33-
// 2) For every blue block in blue-set-of-newBlock:
34-
// |(anticone-of-blue-block ∩ blue-set-newBlock) ∪ {candidate-block}| ≤ K.
35-
// We validate this condition by maintaining a map BluesAnticoneSizes for
36-
// each block which holds all the blue anticone sizes that were affected by
37-
// the new added blue blocks.
38-
// So to find out what is |anticone-of-blue ∩ blue-set-of-newBlock| we just iterate in
39-
// the selected parent chain of the new block until we find an existing entry in
40-
// BluesAnticoneSizes.
33+
// 2. For every blue block in blue-set-of-newBlock:
34+
// |(anticone-of-blue-block ∩ blue-set-newBlock) ∪ {candidate-block}| ≤ K.
35+
// We validate this condition by maintaining a map BluesAnticoneSizes for
36+
// each block which holds all the blue anticone sizes that were affected by
37+
// the new added blue blocks.
38+
// So to find out what is |anticone-of-blue ∩ blue-set-of-newBlock| we just iterate in
39+
// the selected parent chain of the new block until we find an existing entry in
40+
// BluesAnticoneSizes.
4141
//
4242
// For further details see the article https://eprint.iacr.org/2018/104.pdf
4343
func (gm *ghostdagManager) GHOSTDAG(stagingArea *model.StagingArea, blockHash *externalapi.DomainHash) error {

domain/consensus/processes/reachabilitymanager/future_covering_set.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ import (
1212
// interval contains B's interval, it replaces it.
1313
//
1414
// Notes:
15-
// * Intervals never intersect unless one contains the other
16-
// (this follows from the tree structure and the indexing rule).
17-
// * Since node.FutureCoveringSet is kept ordered, a binary search can be
18-
// used for insertion/queries.
19-
// * Although reindexing may change a block's interval, the
20-
// is-superset relation will by definition
21-
// be always preserved.
15+
// - Intervals never intersect unless one contains the other
16+
// (this follows from the tree structure and the indexing rule).
17+
// - Since node.FutureCoveringSet is kept ordered, a binary search can be
18+
// used for insertion/queries.
19+
// - Although reindexing may change a block's interval, the
20+
// is-superset relation will by definition
21+
// be always preserved.
2222
func (rt *reachabilityManager) insertToFutureCoveringSet(stagingArea *model.StagingArea, node, futureNode *externalapi.DomainHash) error {
2323
reachabilityData, err := rt.reachabilityDataForInsertion(stagingArea, node)
2424
if err != nil {

domain/consensus/processes/reachabilitymanager/interval.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,9 @@ func intervalSplitWithExponentialBias(ri *model.ReachabilityInterval, sizes []ui
161161

162162
// exponentialFractions returns a fraction of each size in sizes
163163
// as follows:
164-
// fraction[i] = 2^size[i] / sum_j(2^size[j])
164+
//
165+
// fraction[i] = 2^size[i] / sum_j(2^size[j])
166+
//
165167
// In the code below the above equation is divided by 2^max(size)
166168
// to avoid exploding numbers. Note that in 1 / 2^(max(size)-size[i])
167169
// we divide 1 by potentially a very large number, which will

domain/consensus/processes/reachabilitymanager/reindex_context.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ Core (BFS) algorithms used during reindexing
4242
// and populates the provided subTreeSizeMap with the results.
4343
// It is equivalent to the following recursive implementation:
4444
//
45-
// func (rt *reachabilityManager) countSubtrees(node *model.ReachabilityTreeNode) uint64 {
46-
// subtreeSize := uint64(0)
47-
// for _, child := range node.children {
48-
// subtreeSize += child.countSubtrees()
49-
// }
50-
// return subtreeSize + 1
51-
// }
45+
// func (rt *reachabilityManager) countSubtrees(node *model.ReachabilityTreeNode) uint64 {
46+
// subtreeSize := uint64(0)
47+
// for _, child := range node.children {
48+
// subtreeSize += child.countSubtrees()
49+
// }
50+
// return subtreeSize + 1
51+
// }
5252
//
5353
// However, we are expecting (linearly) deep trees, and so a
5454
// recursive stack-based approach is inefficient and will hit

domain/consensus/utils/txscript/doc.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Package txscript implements the kaspa transaction script language.
44
This package provides data structures and functions to parse and execute
55
kaspa transaction scripts.
66
7-
Script Overview
7+
# Script Overview
88
99
Kaspa transaction scripts are written in a stack-base, FORTH-like language.
1010
@@ -22,7 +22,7 @@ is used to prove the the spender is authorized to perform the transaction.
2222
One benefit of using a scripting language is added flexibility in specifying
2323
what conditions must be met in order to spend kaspa.
2424
25-
Errors
25+
# Errors
2626
2727
Errors returned by this package are of type txscript.Error. This allows the
2828
caller to programmatically determine the specific error by examining the

domain/consensus/utils/txscript/error.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -272,10 +272,10 @@ func (e ErrorCode) String() string {
272272

273273
// Error identifies a script-related error. It is used to indicate three
274274
// classes of errors:
275-
// 1) Script execution failures due to violating one of the many requirements
276-
// imposed by the script engine or evaluating to false
277-
// 2) Improper API usage by callers
278-
// 3) Internal consistency check failures
275+
// 1. Script execution failures due to violating one of the many requirements
276+
// imposed by the script engine or evaluating to false
277+
// 2. Improper API usage by callers
278+
// 3. Internal consistency check failures
279279
//
280280
// The caller can use type assertions on the returned errors to access the
281281
// ErrorCode field to ascertain the specific reason for the error. As an

0 commit comments

Comments
 (0)