Skip to content

Commit

Permalink
upgrade all deps and go version to 1.23 (deso-protocol#1417)
Browse files Browse the repository at this point in the history
* upgrade all deps and go version to 1.23

* import new go-deadlock

* dwongrade dd-trace-go to 1.66.0 for other repo support

* bump dd trace again

* go mod tidy

* replace holiman uint256 w/ deso protocol uint256 for hex marshaling

* upgrade deps again and go mod tidy

* address DH feedback

* add old btcec ciphering to core

* upgrade deps and go mod tidy
  • Loading branch information
lazynina authored Oct 18, 2024
1 parent 9973977 commit bc64e75
Show file tree
Hide file tree
Showing 109 changed files with 1,929 additions and 1,950 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: "1.20"
go-version: "1.23"

- name: Checkout branch
uses: actions/checkout@v3
Expand Down Expand Up @@ -52,7 +52,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: "1.20"
go-version: "1.23"

- name: Checkout branch
uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM alpine:latest AS core
RUN apk update && apk upgrade
RUN apk add --update bash cmake g++ gcc git make vips vips-dev

COPY --from=golang:1.20-alpine /usr/local/go/ /usr/local/go/
COPY --from=golang:1.23-alpine /usr/local/go/ /usr/local/go/
ENV PATH="/usr/local/go/bin:${PATH}"

WORKDIR /deso/src/core
Expand Down
9 changes: 4 additions & 5 deletions cmd/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/hex"
"flag"
"fmt"
"github.com/deso-protocol/go-deadlock"
"net"
"os"
"os/signal"
Expand All @@ -17,8 +18,7 @@ import (
"github.com/davecgh/go-spew/spew"
"github.com/deso-protocol/core/lib"
"github.com/deso-protocol/core/migrate"
"github.com/deso-protocol/go-deadlock"
"github.com/dgraph-io/badger/v3"
"github.com/dgraph-io/badger/v4"
"github.com/go-pg/pg/v10"
"github.com/golang/glog"
migrations "github.com/robinjoseph08/go-pg-migrations/v3"
Expand Down Expand Up @@ -529,13 +529,13 @@ func addIPsForHost(desoAddrMgr *addrmgr.AddrManager, host string, params *lib.De
glog.V(1).Infof("_addSeedAddrs: Adding seed IPs from seed %s: %v\n", host, ipAddrs)

// Convert addresses to NetAddress'es.
netAddrs, err := lib.SafeMakeSliceWithLength[*wire.NetAddress](uint64(len(ipAddrs)))
netAddrs, err := lib.SafeMakeSliceWithLength[*wire.NetAddressV2](uint64(len(ipAddrs)))
if err != nil {
glog.V(2).Infof("_addSeedAddrs: Problem creating netAddrs slice with length %d", len(ipAddrs))
return
}
for ii, ip := range ipAddrs {
netAddrs[ii] = wire.NewNetAddressTimestamp(
netAddrs[ii] = wire.NetAddressV2FromBytes(
// We initialize addresses with a
// randomly selected "last seen time" between 3
// and 7 days ago similar to what bitcoind does.
Expand All @@ -558,7 +558,6 @@ func addIPsForHost(desoAddrMgr *addrmgr.AddrManager, host string, params *lib.De
// [0, 10]
func addSeedAddrsFromPrefixes(desoAddrMgr *addrmgr.AddrManager, params *lib.DeSoParams) {
MaxIterations := 20

go func() {
for dnsNumber := 0; dnsNumber < MaxIterations; dnsNumber++ {
var wg deadlock.WaitGroup
Expand Down
18 changes: 9 additions & 9 deletions consensus/event_loop.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"fmt"
"time"

"github.com/deso-protocol/uint256"
"github.com/golang/glog"
"github.com/holiman/uint256"
"github.com/pkg/errors"

"github.com/deso-protocol/core/bls"
Expand Down Expand Up @@ -695,8 +695,8 @@ func (fe *fastHotStuffEventLoop) tryConstructVoteQCInCurrentView() *FastHotStuff
votesByValidator := fe.votesSeenByBlockHash[voteSignaturePayload]

// Compute the total stake and total stake with votes
totalStake := uint256.NewInt()
totalVotingStake := uint256.NewInt()
totalStake := uint256.NewInt(0)
totalVotingStake := uint256.NewInt(0)

// Track the signatures and signers list for the chain tip
signersList := bitset.NewBitset()
Expand All @@ -705,7 +705,7 @@ func (fe *fastHotStuffEventLoop) tryConstructVoteQCInCurrentView() *FastHotStuff
// Iterate through the entire validator list and check if each one has voted for the tip block. Track
// all voters and their stakes.
for ii, validator := range validatorList {
totalStake = uint256.NewInt().Add(totalStake, validator.GetStakeAmount())
totalStake = uint256.NewInt(0).Add(totalStake, validator.GetStakeAmount())

// Skip the validator if it hasn't voted for the block
vote, hasVoted := votesByValidator[validator.GetPublicKey().ToString()]
Expand All @@ -714,7 +714,7 @@ func (fe *fastHotStuffEventLoop) tryConstructVoteQCInCurrentView() *FastHotStuff
}

// Track the vote's signature, stake, and place in the validator list
totalVotingStake = uint256.NewInt().Add(totalVotingStake, validator.GetStakeAmount())
totalVotingStake = uint256.NewInt(0).Add(totalVotingStake, validator.GetStakeAmount())
signersList.Set(ii, true)
signatures = append(signatures, vote.GetSignature())
}
Expand Down Expand Up @@ -819,8 +819,8 @@ func (fe *fastHotStuffEventLoop) tryConstructTimeoutQCInCurrentView() *FastHotSt
}

// Compute the total stake and total stake with timeouts
totalStake := uint256.NewInt()
totalTimedOutStake := uint256.NewInt()
totalStake := uint256.NewInt(0)
totalTimedOutStake := uint256.NewInt(0)

// Track the high QC view for each validator
highQCViews := make([]uint64, len(validatorList))
Expand All @@ -835,7 +835,7 @@ func (fe *fastHotStuffEventLoop) tryConstructTimeoutQCInCurrentView() *FastHotSt
// for the signersList bitset. In practice, the validator list is expected to be <= 1000 in size, so
// this loop will be fast.
for ii, validator := range validatorList {
totalStake = uint256.NewInt().Add(totalStake, validator.GetStakeAmount())
totalStake = uint256.NewInt(0).Add(totalStake, validator.GetStakeAmount())

// Skip the validator if it hasn't timed out for the previous view
timeout, hasTimedOut := timeoutsByValidator[validator.GetPublicKey().ToString()]
Expand All @@ -844,7 +844,7 @@ func (fe *fastHotStuffEventLoop) tryConstructTimeoutQCInCurrentView() *FastHotSt
}

// Track the signatures, timed out stake, and high QC views for the validator
totalTimedOutStake = uint256.NewInt().Add(totalTimedOutStake, validator.GetStakeAmount())
totalTimedOutStake = uint256.NewInt(0).Add(totalTimedOutStake, validator.GetStakeAmount())
signersList.Set(ii, true)
signatures = append(signatures, timeout.GetSignature())
highQCViews[ii] = timeout.GetHighQC().GetView()
Expand Down
10 changes: 5 additions & 5 deletions consensus/event_loop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

"github.com/deso-protocol/core/bls"
"github.com/deso-protocol/core/collections/bitset"
"github.com/holiman/uint256"
"github.com/deso-protocol/uint256"
"github.com/stretchr/testify/require"
)

Expand Down Expand Up @@ -878,11 +878,11 @@ func TestVoteQCConstructionSignal(t *testing.T) {
validatorList := []Validator{
&validator{
publicKey: validatorPrivateKey1.PublicKey(),
stakeAmount: uint256.NewInt().SetUint64(70),
stakeAmount: uint256.NewInt(70),
},
&validator{
publicKey: validatorPrivateKey2.PublicKey(),
stakeAmount: uint256.NewInt().SetUint64(30),
stakeAmount: uint256.NewInt(30),
},
}

Expand Down Expand Up @@ -1064,11 +1064,11 @@ func TestTimeoutQCConstructionSignal(t *testing.T) {
validatorList := []Validator{
&validator{
publicKey: validatorPrivateKey1.PublicKey(),
stakeAmount: uint256.NewInt().SetUint64(70),
stakeAmount: uint256.NewInt(70),
},
&validator{
publicKey: validatorPrivateKey2.PublicKey(),
stakeAmount: uint256.NewInt().SetUint64(30),
stakeAmount: uint256.NewInt(30),
},
}

Expand Down
24 changes: 12 additions & 12 deletions consensus/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"time"

"github.com/deso-protocol/core/collections"
"github.com/holiman/uint256"
"github.com/deso-protocol/uint256"
"github.com/stretchr/testify/require"
)

Expand All @@ -16,10 +16,10 @@ import (
func TestNetworkWithOfflineValidators(t *testing.T) {
// Create 4 nodes with equal stake. The network has super-majority of stake online
// as long as 3 out of 4 nodes are online.
node1 := newValidatorNode(uint256.NewInt().SetUint64(50), true) // block proposer
node2 := newValidatorNode(uint256.NewInt().SetUint64(50), false) // validator
node3 := newValidatorNode(uint256.NewInt().SetUint64(50), false) // validator
node4 := newValidatorNode(uint256.NewInt().SetUint64(50), false) // validator
node1 := newValidatorNode(uint256.NewInt(50), true) // block proposer
node2 := newValidatorNode(uint256.NewInt(50), false) // validator
node3 := newValidatorNode(uint256.NewInt(50), false) // validator
node4 := newValidatorNode(uint256.NewInt(50), false) // validator

allNodes := []*validatorNode{node1, node2, node3, node4}

Expand Down Expand Up @@ -104,10 +104,10 @@ func TestNetworkWithOfflineValidators(t *testing.T) {
func TestNetworkWithOfflineBlockProposer(t *testing.T) {
// Create 4 nodes with equal stake. The network has super-majority of stake online
// as long as 3 out of 4 nodes are online.
node1 := newValidatorNode(uint256.NewInt().SetUint64(50), true) // block proposer
node2 := newValidatorNode(uint256.NewInt().SetUint64(50), false) // validator
node3 := newValidatorNode(uint256.NewInt().SetUint64(50), false) // validator
node4 := newValidatorNode(uint256.NewInt().SetUint64(50), false) // validator
node1 := newValidatorNode(uint256.NewInt(50), true) // block proposer
node2 := newValidatorNode(uint256.NewInt(50), false) // validator
node3 := newValidatorNode(uint256.NewInt(50), false) // validator
node4 := newValidatorNode(uint256.NewInt(50), false) // validator

allNodes := []*validatorNode{node1, node2, node3, node4}

Expand Down Expand Up @@ -181,9 +181,9 @@ func TestNetworkWithOfflineBlockProposer(t *testing.T) {
func TestNetworkRecoveryAfterCatastrophicFailure(t *testing.T) {
// Create 3 nodes with equal stake. Node 3 has a super-majority of the the stake
// and needs to stay online for the network to remain live.
node1 := newValidatorNode(uint256.NewInt().SetUint64(10), true) // block proposer
node2 := newValidatorNode(uint256.NewInt().SetUint64(10), false) // validator
node3 := newValidatorNode(uint256.NewInt().SetUint64(80), false) // validator
node1 := newValidatorNode(uint256.NewInt(10), true) // block proposer
node2 := newValidatorNode(uint256.NewInt(10), false) // validator
node3 := newValidatorNode(uint256.NewInt(80), false) // validator

allNodes := []*validatorNode{node1, node2, node3}

Expand Down
2 changes: 1 addition & 1 deletion consensus/integration_test_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

"github.com/deso-protocol/core/bls"
"github.com/deso-protocol/core/collections"
"github.com/holiman/uint256"
"github.com/deso-protocol/uint256"
)

// validatorNode is a simplified implementation of a Fast-HotStuff node that runs the Fast-HotStuff
Expand Down
2 changes: 1 addition & 1 deletion consensus/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"github.com/deso-protocol/core/bls"
"github.com/deso-protocol/core/collections/bitset"
"github.com/holiman/uint256"
"github.com/deso-protocol/uint256"
)

// FastHotStuffEventType is a way for FastHotStuffEventLoop to send messages back to the Server.
Expand Down
2 changes: 1 addition & 1 deletion consensus/types_internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package consensus
import (
"github.com/deso-protocol/core/bls"
"github.com/deso-protocol/core/collections/bitset"
"github.com/holiman/uint256"
"github.com/deso-protocol/uint256"
)

//////////////////////////////////////////////////////////
Expand Down
16 changes: 8 additions & 8 deletions consensus/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/deso-protocol/core/bls"
"github.com/deso-protocol/core/collections"
"github.com/deso-protocol/core/collections/bitset"
"github.com/holiman/uint256"
"github.com/deso-protocol/uint256"
"golang.org/x/crypto/sha3"
)

Expand Down Expand Up @@ -132,8 +132,8 @@ func IsValidSuperMajorityAggregateQuorumCertificate(aggQC AggregateQuorumCertifi

func isSuperMajorityStakeSignersList(signersList *bitset.Bitset, validators []Validator) (bool, []*bls.PublicKey) {
// Compute the total stake in the QC and the total stake in the network
stakeInQC := uint256.NewInt()
totalStake := uint256.NewInt()
stakeInQC := uint256.NewInt(0)
totalStake := uint256.NewInt(0)

// Fetch the validators in the QC
validatorPublicKeysInQC := []*bls.PublicKey{}
Expand Down Expand Up @@ -392,11 +392,11 @@ func isSuperMajorityStake(stake *uint256.Int, totalStake *uint256.Int) bool {
}

// Compute 3Cq
honestStakeComponent := uint256.NewInt().Mul(stake, uint256.NewInt().SetUint64(3))
honestStakeComponent := uint256.NewInt(0).Mul(stake, uint256.NewInt(3))

// Compute 2N + 1
totalStakeComponent := uint256.NewInt().Mul(totalStake, uint256.NewInt().SetUint64(2))
totalStakeComponent = uint256.NewInt().Add(totalStakeComponent, uint256.NewInt().SetUint64(1))
totalStakeComponent := uint256.NewInt(0).Mul(totalStake, uint256.NewInt(2))
totalStakeComponent = uint256.NewInt(0).Add(totalStakeComponent, uint256.NewInt(1))

// Check if 3Cq >= 2N + 1
return honestStakeComponent.Cmp(totalStakeComponent) >= 0
Expand Down Expand Up @@ -450,11 +450,11 @@ func createValidatorListForPrivateKeys(pk1 *bls.PrivateKey, pk2 *bls.PrivateKey)
validators := []*validator{
{
publicKey: pk1.PublicKey(),
stakeAmount: uint256.NewInt().SetUint64(100),
stakeAmount: uint256.NewInt(100),
},
{
publicKey: pk2.PublicKey(),
stakeAmount: uint256.NewInt().SetUint64(50),
stakeAmount: uint256.NewInt(50),
},
}
// Cast the slice of concrete structs []*validators to a slice of interfaces []Validator
Expand Down
Loading

0 comments on commit bc64e75

Please sign in to comment.