Skip to content

Commit

Permalink
Merge branch 'develop' into opt-filter-use-eligibility
Browse files Browse the repository at this point in the history
  • Loading branch information
countvonzero committed Aug 30, 2023
2 parents 43eaf7b + 391cb83 commit c6cc9e0
Show file tree
Hide file tree
Showing 63 changed files with 1,590 additions and 1,971 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ jobs:
- name: Clear test cache
run: make clear-test-cache
- name: unit tests
timeout-minutes: 25
timeout-minutes: 35
env:
GOTESTSUM_FORMAT: standard-verbose
GOTESTSUM_JUNITFILE: unit-tests.xml
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ jobs:
- macOS arm64: https://storage.googleapis.com/${{ secrets.GCP_BUCKET }}/${{ github.ref_name }}/macOS_ARM64.zip
- Linux: https://storage.googleapis.com/${{ secrets.GCP_BUCKET }}/${{ github.ref_name }}/Linux.zip
- Linux arm64: https://storage.googleapis.com/${{ secrets.GCP_BUCKET }}/${{ github.ref_name }}/Linux_ARM64.zip
For information about changes in this release see the [changelog](https://github.com/spacemeshos/go-spacemesh/blob/${{ github.ref_name }}/CHANGELOG.md).
generate_release_notes: true
draft: false
prerelease: true
78 changes: 78 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Changelog

See [RELEASE](./RELEASE.md) for workflow instructions.

## UNRELEASED

### Upgrade information

### Highlights

### Features

### Improvements

## v1.1.2

### Upgrade information

Legacy discovery protocol was removed in [#4836](https://github.com/spacemeshos/go-spacemesh/pull/4836).
Config option and flag `p2p-disable-legacy-discovery` is noop, and will be completely removed in future versions.

### Highlights

With [#4893](https://github.com/spacemeshos/go-spacemesh/pull/4893) Nodes are given more time to publish an ATX
Nodes still need to publish an ATX before the new PoET round starts (within 12h on mainnet) to make it into the
next PoET round, but if they miss that deadline they will now continue to publish an ATX to receive rewards for
the upcoming epoch and skip one after that.

### Features

* [#4845](https://github.com/spacemeshos/go-spacemesh/pull/4845) API to fetch opened connections.

> grpcurl -plaintext 127.0.0.1:9093 spacemesh.v1.AdminService.PeerInfoStream
```json
{
"id": "12D3KooWEcgADBR4zHirw7YAt6nUtCNhbPWkB2fnHAemnG5cGf2n",
"connections": [
{
"address": "/ip4/46.4.81.145/tcp/5001",
"uptime": "1359.186975782s",
"outbound": true
}
]
}
{
"id": "12D3KooWHK5m83sNj2eNMJMGAngcS9gBja27ho83t79Q2CD4iRjQ",
"connections": [
{
"address": "/ip4/34.86.244.124/tcp/5000",
"uptime": "1108.414456262s",
"outbound": true
}
],
"tags": [
"bootnode"
]
}
```

* [4795](https://github.com/spacemeshos/go-spacemesh/pull/4795) p2p: add ip4/ip6 blocklists

Doesn't affect direct peers. In order to disable:

```json
{
"p2p": {
"ip4-blocklist": [],
"ip6-blocklist": []
}
}
```

### Improvements

* [#4882](https://github.com/spacemeshos/go-spacemesh/pull/4882) Increase cache size and parametrize datastore.
* [#4887](https://github.com/spacemeshos/go-spacemesh/pull/4887) Fixed crashes on API call.
* [#4871](https://github.com/spacemeshos/go-spacemesh/pull/4871) Add jitter to spread out requests to get poet proof and submit challenge
41 changes: 41 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Release

## Releasing a major version

Rename UNRELEASED to a concrete <version> and create a PR with commit: Release <version>.
Branch name should match the <version> set in CHANGELOG.
Additionally tag that same commit with 0 as a patch version (if branch is v1.1 - tag is v1.1.0).

## Releasing a minor version

### Latest

Rename UNRELEASED to a concrete <version>. If previous major was v1.1.0, new version will
be v1.1.1.
Commit changes, create pr, and create a tag.
Rebase released branch onto develop.

This is a simplified workflow to avoid cherry-picks and maintaining changelog in several branches.

### Previous

Cherry-pick selected commits to major release branch.
Copy selected commits to CHANGELOG.md.
Rename UNRELEASED to a concrete <version>.
Commit changes, and create a tag.

## Preparing for next release

After releasing a new major or minor version, create a new UNRELEASED section at the top of CHANGELOG.md:

```markdown
## UNRELEASED

### Upgrade information

### Highlights

### Features

### Improvements
```
47 changes: 28 additions & 19 deletions activation/activation.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,15 @@ func DefaultPoetConfig() PoetConfig {
}
}

const defaultPoetRetryInterval = 5 * time.Second
const (
defaultPoetRetryInterval = 5 * time.Second

// Jitter added to the wait time before building a nipost challenge.
// It's expressed as % of poet grace period which translates to:
// mainnet (grace period 1h) -> 36s
// systest (grace period 10s) -> 0.1s
maxNipostChallengeBuildJitter = 1.0
)

// Config defines configuration for Builder.
type Config struct {
Expand Down Expand Up @@ -432,8 +440,8 @@ func (b *Builder) buildNIPostChallenge(ctx context.Context) (*types.NIPostChalle
ErrATXChallengeExpired, current, -until)
}
metrics.PublishOntimeWindowLatency.Observe(until.Seconds())
if until > b.poetCfg.GracePeriod {
wait := until - b.poetCfg.GracePeriod
wait := timeToWaitToBuildNipostChallenge(until, b.poetCfg.GracePeriod)
if wait >= 0 {
b.log.WithContext(ctx).With().Debug("waiting for fresh atxs",
log.Duration("till poet round", until),
log.Uint32("current epoch", current.Uint32()),
Expand Down Expand Up @@ -529,9 +537,8 @@ func (b *Builder) loadChallenge() (*types.NIPostChallenge, error) {
if err != nil {
return nil, err
}
if nipost.TargetEpoch() < b.currentEpoch() {
if nipost.PublishEpoch < b.currentEpoch() {
b.log.With().Info("atx nipost challenge is stale - discarding it",
log.Stringer("target_epoch", nipost.TargetEpoch()),
log.Stringer("publish_epoch", nipost.PublishEpoch),
log.Stringer("current_epoch", b.currentEpoch()),
)
Expand Down Expand Up @@ -569,6 +576,8 @@ func (b *Builder) PublishActivationTx(ctx context.Context) error {

if b.pendingATX == nil {
var err error
ctx, cancel := context.WithDeadline(ctx, b.layerClock.LayerToTime((challenge.TargetEpoch()).FirstLayer()))
defer cancel()
b.pendingATX, err = b.createAtx(ctx, challenge)
if err != nil {
return fmt.Errorf("create ATX: %w", err)
Expand All @@ -594,17 +603,17 @@ func (b *Builder) PublishActivationTx(ctx context.Context) error {
select {
case <-atxReceived:
logger.With().Info("received atx in db", atx.ID())
case <-b.layerClock.AwaitLayer((atx.TargetEpoch() + 1).FirstLayer()):
if err = b.discardChallenge(); err != nil {
return fmt.Errorf("%w: target epoch has passed", err)
if err := b.discardChallenge(); err != nil {
return fmt.Errorf("%w: after published atx", err)
}
case <-b.layerClock.AwaitLayer((atx.TargetEpoch()).FirstLayer()):
if err := b.discardChallenge(); err != nil {
return fmt.Errorf("%w: publish epoch has passed", err)
}
return fmt.Errorf("%w: target epoch has passed", ErrATXChallengeExpired)
return fmt.Errorf("%w: publish epoch has passed", ErrATXChallengeExpired)
case <-ctx.Done():
return ctx.Err()
}
if err = b.discardChallenge(); err != nil {
return fmt.Errorf("%w: after published atx", err)
}
return nil
}

Expand All @@ -614,16 +623,11 @@ func (b *Builder) poetRoundStart(epoch types.EpochID) time.Time {

func (b *Builder) createAtx(ctx context.Context, challenge *types.NIPostChallenge) (*types.ActivationTx, error) {
pubEpoch := challenge.PublishEpoch
nextPoetRoundStart := b.poetRoundStart(pubEpoch)

// NiPoST must be ready before start of the next poet round.
buildingNipostCtx, cancel := context.WithDeadline(ctx, nextPoetRoundStart)
defer cancel()
nipost, postDuration, err := b.nipostBuilder.BuildNIPost(buildingNipostCtx, challenge)
nipost, err := b.nipostBuilder.BuildNIPost(ctx, challenge)
if err != nil {
return nil, fmt.Errorf("build NIPost: %w", err)
}
metrics.PostDuration.Set(float64(postDuration.Nanoseconds()))

b.log.With().Info("awaiting atx publication epoch",
log.Stringer("pub_epoch", pubEpoch),
Expand All @@ -637,7 +641,7 @@ func (b *Builder) createAtx(ctx context.Context, challenge *types.NIPostChalleng
}
b.log.Debug("publication epoch has arrived!")

if challenge.TargetEpoch() < b.currentEpoch() {
if challenge.PublishEpoch < b.currentEpoch() {
if err = b.discardChallenge(); err != nil {
return nil, fmt.Errorf("%w: atx publish epoch has passed during nipost construction", err)
}
Expand Down Expand Up @@ -721,3 +725,8 @@ func SignAndFinalizeAtx(signer *signing.EdSigner, atx *types.ActivationTx) error
atx.SmesherID = signer.NodeID()
return atx.Initialize()
}

func timeToWaitToBuildNipostChallenge(untilRoundStart, gracePeriod time.Duration) time.Duration {
jitter := randomDurationInRange(time.Duration(0), gracePeriod*maxNipostChallengeBuildJitter/100.0)
return untilRoundStart + jitter - gracePeriod
}

0 comments on commit c6cc9e0

Please sign in to comment.