Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into poet-issue-501
Browse files Browse the repository at this point in the history
  • Loading branch information
fasmat committed Nov 16, 2024
2 parents 8302f4c + c4e59b6 commit ae2617b
Show file tree
Hide file tree
Showing 86 changed files with 9,837 additions and 1,254 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ jobs:
make test-fmt
make test-tidy
make test-generate
- name: Check for vulnerabilities
run: make vulncheck

lint:
runs-on: ubuntu-22.04
Expand Down Expand Up @@ -203,7 +205,7 @@ jobs:
- name: test coverage
run: make cover
- name: Upload to codecov.io
uses: codecov/codecov-action@v4
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}

Expand Down
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ See [RELEASE](./RELEASE.md) for workflow instructions.

### Improvements

* [#6431](https://github.com/spacemeshos/go-spacemesh/pull/6431) Fix db-allow-schema-drift handling
* [#6408](https://github.com/spacemeshos/go-spacemesh/pull/6408) Prevent empty DB connection pool by freeing connections
upon errors during DB operations. This mostly fixes issues when a node is under heavy load from the API.

Expand All @@ -15,6 +14,12 @@ See [RELEASE](./RELEASE.md) for workflow instructions.

* [#6422](https://github.com/spacemeshos/go-spacemesh/pull/6422) Further improved performance of the proposal building
process to avoid late proposals.
* [#6443](https://github.com/spacemeshos/go-spacemesh/pull/6443) Improve eviction of ineffectual transactions in the database
which will now show up as ineffectual when querying them from the API.

* [#6431](https://github.com/spacemeshos/go-spacemesh/pull/6431) Fix db-allow-schema-drift handling

* [#6451](https://github.com/spacemeshos/go-spacemesh/pull/6451) Fix a possible deadloop in the beacon protocol.

## v1.7.6

Expand Down
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD)

GOLANGCI_LINT_VERSION := v1.61.0
GOTESTSUM_VERSION := v1.12.0
GOVULNCHECK_VERSION := v1.1.3
GOSCALE_VERSION := v1.2.0
MOCKGEN_VERSION := v0.5.0

Expand Down Expand Up @@ -68,6 +69,7 @@ install:
go install github.com/spacemeshos/go-scale/scalegen@$(GOSCALE_VERSION)
go install go.uber.org/mock/mockgen@$(MOCKGEN_VERSION)
go install gotest.tools/gotestsum@$(GOTESTSUM_VERSION)
go install golang.org/x/vuln/cmd/govulncheck@$(GOVULNCHECK_VERSION)
.PHONY: install

build: go-spacemesh get-profiler get-postrs-service
Expand Down Expand Up @@ -146,6 +148,10 @@ cover: get-libs
@$(ULIMIT) CGO_LDFLAGS="$(CGO_TEST_LDFLAGS)" go test -coverprofile=cover.out -p 1 -timeout 30m -coverpkg=./... $(UNIT_TESTS)
.PHONY: cover

vulncheck: get-libs
govulncheck ./...
.PHONY: vulncheck

list-versions:
@echo "Latest 5 tagged versions:\n"
@git for-each-ref --sort=-creatordate --count=5 --format '%(creatordate:short): %(refname:short)' refs/tags
Expand Down
2 changes: 1 addition & 1 deletion activation/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func NewHandler(
fetcher: fetcher,
beacon: beacon,
tortoise: tortoise,
malPublisher: &MalfeasancePublisher{},
malPublisher: &MalfeasancePublisher{}, // TODO(mafa): pass real publisher when available
},
}

Expand Down
19 changes: 14 additions & 5 deletions activation/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"slices"
"sort"
"testing"
"testing/quick"
Expand Down Expand Up @@ -128,7 +129,7 @@ type handlerMocks struct {
mValidator *MocknipostValidator
mbeacon *MockAtxReceiver
mtortoise *mocks.MockTortoise
mMalPublish *MockmalfeasancePublisher
mMalPublish *MockatxMalfeasancePublisher
}

type testHandler struct {
Expand Down Expand Up @@ -159,6 +160,7 @@ func (h *handlerMocks) expectAtxV1(atx *wire.ActivationTxV1, nodeId types.NodeID
}
h.mockFetch.EXPECT().RegisterPeerHashes(gomock.Any(), gomock.Any())
h.mockFetch.EXPECT().GetPoetProof(gomock.Any(), types.BytesToHash(atx.NIPost.PostMetadata.Challenge))
deps := []types.ATXID{atx.PrevATXID, atx.PositioningATXID}
if atx.PrevATXID == types.EmptyATXID {
h.mValidator.EXPECT().InitialNIPostChallengeV1(gomock.Any(), gomock.Any(), h.goldenATXID)
h.mValidator.EXPECT().
Expand All @@ -170,9 +172,17 @@ func (h *handlerMocks) expectAtxV1(atx *wire.ActivationTxV1, nodeId types.NodeID
time.Sleep(settings.postVerificationDuration)
return nil
})
deps = append(deps, *atx.CommitmentATXID)
} else {
h.mValidator.EXPECT().NIPostChallengeV1(gomock.Any(), gomock.Any(), nodeId)
}
deps = slices.Compact(deps)
deps = slices.DeleteFunc(deps, func(dep types.ATXID) bool {
return dep == types.EmptyATXID || dep == h.goldenATXID
})
if len(deps) > 0 {
h.mockFetch.EXPECT().GetAtxs(gomock.Any(), deps, gomock.Any())
}
h.mValidator.EXPECT().PositioningAtx(atx.PositioningATXID, gomock.Any(), h.goldenATXID, atx.PublishEpoch)
h.mValidator.EXPECT().
NIPost(gomock.Any(), nodeId, h.goldenATXID, gomock.Any(), gomock.Any(), atx.NumUnits, gomock.Any()).
Expand All @@ -194,7 +204,7 @@ func newTestHandlerMocks(tb testing.TB, golden types.ATXID) handlerMocks {
mValidator: NewMocknipostValidator(ctrl),
mbeacon: NewMockAtxReceiver(ctrl),
mtortoise: mocks.NewMockTortoise(ctrl),
mMalPublish: NewMockmalfeasancePublisher(ctrl),
mMalPublish: NewMockatxMalfeasancePublisher(ctrl),
}
}

Expand All @@ -205,6 +215,8 @@ func newTestHandler(tb testing.TB, goldenATXID types.ATXID, opts ...HandlerOptio
edVerifier := signing.NewEdVerifier()

mocks := newTestHandlerMocks(tb, goldenATXID)
// TODO(mafa): make mandatory parameter when real publisher is available
opts = append(opts, func(h *Handler) { h.v2.malPublisher = mocks.mMalPublish })
atxHdlr := NewHandler(
"localID",
cdb,
Expand Down Expand Up @@ -341,7 +353,6 @@ func TestHandler_ProcessAtxStoresNewVRFNonce(t *testing.T) {
atx2.VRFNonce = (*uint64)(&nonce2)
atx2.Sign(sig)
atxHdlr.expectAtxV1(atx2, sig.NodeID())
atxHdlr.mockFetch.EXPECT().GetAtxs(gomock.Any(), gomock.Any(), gomock.Any())
require.NoError(t, atxHdlr.HandleGossipAtx(context.Background(), "", codec.MustEncode(atx2)))

got, err = atxs.VRFNonce(atxHdlr.cdb, sig.NodeID(), atx2.PublishEpoch+1)
Expand Down Expand Up @@ -391,7 +402,6 @@ func TestHandler_HandleGossipAtx(t *testing.T) {

// second is now valid (deps are in)
atxHdlr.expectAtxV1(second, sig.NodeID())
atxHdlr.mockFetch.EXPECT().GetAtxs(gomock.Any(), []types.ATXID{second.PrevATXID}, gomock.Any())
require.NoError(t, atxHdlr.HandleGossipAtx(context.Background(), "", codec.MustEncode(second)))
}

Expand Down Expand Up @@ -695,7 +705,6 @@ func TestHandler_AtxWeight(t *testing.T) {
buf = codec.MustEncode(atx2)

atxHdlr.expectAtxV1(atx2, sig.NodeID(), func(o *atxHandleOpts) { o.poetLeaves = leaves })
atxHdlr.mockFetch.EXPECT().GetAtxs(gomock.Any(), []types.ATXID{atx1.ID()}, gomock.Any())
require.NoError(t, atxHdlr.HandleSyncedAtx(context.Background(), atx2.ID().Hash32(), peer, buf))

stored2, err := atxHdlr.cdb.GetAtx(atx2.ID())
Expand Down
Loading

0 comments on commit ae2617b

Please sign in to comment.