From a888b6320c892541152430b11318842bf52f10e0 Mon Sep 17 00:00:00 2001 From: "Andrew Jackson (Ajax)" Date: Fri, 22 Sep 2023 18:06:26 -0500 Subject: [PATCH 1/2] harmonytask bump http protocol spec & lints --- blockstore/splitstore/splitstore_test.go | 2 +- chain/consensus/common.go | 3 ++- chain/messagepool/block_proba_test.go | 2 -- chain/state/statetree.go | 3 ++- chain/vectors/gen/main.go | 2 +- lib/harmony/harmonytask/harmonytask.go | 4 ++++ storage/sealer/ffiwrapper/sealer_cgo.go | 10 ++++++---- 7 files changed, 16 insertions(+), 10 deletions(-) diff --git a/blockstore/splitstore/splitstore_test.go b/blockstore/splitstore/splitstore_test.go index 63e77b47e..1b821654d 100644 --- a/blockstore/splitstore/splitstore_test.go +++ b/blockstore/splitstore/splitstore_test.go @@ -3,9 +3,9 @@ package splitstore import ( "context" + "crypto/rand" "errors" "fmt" - "math/rand" "sync" "sync/atomic" "testing" diff --git a/chain/consensus/common.go b/chain/consensus/common.go index 1d9fb3646..a7e5c40d2 100644 --- a/chain/consensus/common.go +++ b/chain/consensus/common.go @@ -362,7 +362,8 @@ func CreateBlockHeader(ctx context.Context, sm *stmgr.StateManager, pts *types.T var blsMsgCids, secpkMsgCids []cid.Cid var blsSigs []crypto.Signature nv := sm.GetNetworkVersion(ctx, bt.Epoch) - for _, msg := range bt.Messages { + for _, msgTmp := range bt.Messages { + msg := msgTmp if msg.Signature.Type == crypto.SigTypeBLS { blsSigs = append(blsSigs, msg.Signature) blsMessages = append(blsMessages, &msg.Message) diff --git a/chain/messagepool/block_proba_test.go b/chain/messagepool/block_proba_test.go index 6d121d222..2dc1dc25d 100644 --- a/chain/messagepool/block_proba_test.go +++ b/chain/messagepool/block_proba_test.go @@ -5,7 +5,6 @@ import ( "math" "math/rand" "testing" - "time" ) func TestBlockProbability(t *testing.T) { @@ -23,7 +22,6 @@ func TestBlockProbability(t *testing.T) { func TestWinnerProba(t *testing.T) { //stm: @OTHER_IMPLEMENTATION_BLOCK_PROB_002 - rand.Seed(time.Now().UnixNano()) const N = 1000000 winnerProba := noWinnersProb() sum := 0 diff --git a/chain/state/statetree.go b/chain/state/statetree.go index c71473e8f..b527fc1ac 100644 --- a/chain/state/statetree.go +++ b/chain/state/statetree.go @@ -438,7 +438,8 @@ func (st *StateTree) Flush(ctx context.Context) (cid.Cid, error) { return cid.Undef, xerrors.Errorf("tried to flush state tree with snapshots on the stack") } - for addr, sto := range st.snaps.layers[0].actors { + for addr, stoTmp := range st.snaps.layers[0].actors { + sto := stoTmp if sto.Delete { if err := st.root.Delete(abi.AddrKey(addr)); err != nil { return cid.Undef, err diff --git a/chain/vectors/gen/main.go b/chain/vectors/gen/main.go index ce9f1baf8..8df4ef429 100644 --- a/chain/vectors/gen/main.go +++ b/chain/vectors/gen/main.go @@ -2,9 +2,9 @@ package main import ( "context" + "crypto/rand" "encoding/json" "fmt" - "math/rand" "os" "golang.org/x/xerrors" diff --git a/lib/harmony/harmonytask/harmonytask.go b/lib/harmony/harmonytask/harmonytask.go index 66283d1bd..5a7fb48cf 100644 --- a/lib/harmony/harmonytask/harmonytask.go +++ b/lib/harmony/harmonytask/harmonytask.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "strconv" + "strings" "sync" "sync/atomic" "time" @@ -379,6 +380,9 @@ func (e *TaskEngine) bump(taskType string) { return } for _, url := range res { + if !strings.HasPrefix(strings.ToLower(url), "http") { + url = "http://" + } resp, err := hClient.Get(url + "/scheduler/bump/" + taskType) if err != nil { log.Info("Server unreachable to bump: ", err) diff --git a/storage/sealer/ffiwrapper/sealer_cgo.go b/storage/sealer/ffiwrapper/sealer_cgo.go index b11dec9ce..fb4a6e42e 100644 --- a/storage/sealer/ffiwrapper/sealer_cgo.go +++ b/storage/sealer/ffiwrapper/sealer_cgo.go @@ -147,8 +147,9 @@ func (sb *Sealer) DataCid(ctx context.Context, pieceSize abi.UnpaddedPieceSize, }) } - if len(piecePromises) == 1 { - return piecePromises[0]() + if len(piecePromises) > 0 && len(piecePromises) == 1 { // weird for linter + p := piecePromises[0] + return p() } var payloadRoundedBytes abi.PaddedPieceSize @@ -347,8 +348,9 @@ func (sb *Sealer) AddPiece(ctx context.Context, sector storiface.SectorRef, exis } stagedFile = nil - if len(piecePromises) == 1 { - return piecePromises[0]() + if len(piecePromises) > 0 && len(piecePromises) == 1 { // weird for linter + p := piecePromises[0] + return p() } var payloadRoundedBytes abi.PaddedPieceSize From 632bf15b82ccc632d97ebc08aa9b2869c90dee97 Mon Sep 17 00:00:00 2001 From: "Andrew Jackson (Ajax)" Date: Fri, 22 Sep 2023 18:08:19 -0500 Subject: [PATCH 2/2] build oops --- chain/vectors/gen/main.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/chain/vectors/gen/main.go b/chain/vectors/gen/main.go index 8df4ef429..658a41dc9 100644 --- a/chain/vectors/gen/main.go +++ b/chain/vectors/gen/main.go @@ -2,9 +2,10 @@ package main import ( "context" - "crypto/rand" + crand "crypto/rand" "encoding/json" "fmt" + "math/rand" "os" "golang.org/x/xerrors" @@ -145,7 +146,7 @@ func MakeUnsignedMessageVectors() []vectors.UnsignedMessageVector { } params := make([]byte, 32) - rand.Read(params) + crand.Read(params) msg := &types.Message{ To: to,