Skip to content

Commit

Permalink
Merge branch 'develop' into api-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
lrettig authored Jan 4, 2024
2 parents 56aa3cd + e0af17e commit a05776e
Show file tree
Hide file tree
Showing 31 changed files with 232 additions and 177 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# CODEOWNERS: https://help.github.com/articles/about-codeowners/

* @countvonzero @dshulyak @fasmat @poszu
* @dshulyak @fasmat @poszu @ivan4th
13 changes: 8 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,15 @@ jobs:
os:
- ubuntu-latest
- [self-hosted, linux, arm64]
- macos-latest
- [self-hosted, macos, arm64]
- macos-12-large
- macos-13-xlarge
- windows-latest
steps:
- name: Add OpenCL support - Ubuntu
if: ${{ matrix.os == 'ubuntu-latest' }}
run: sudo apt-get update -q && sudo apt-get install -qy ocl-icd-opencl-dev libpocl2


- name: disable Windows Defender - Windows
if: ${{ matrix.os == 'windows-latest' }}
run: |
Expand Down Expand Up @@ -142,8 +144,8 @@ jobs:
os:
- ubuntu-latest
- [self-hosted, linux, arm64]
- macos-latest
- [self-hosted, macos, arm64]
- macos-12-large
- macos-13-xlarge
- windows-latest
steps:
# as we use some request to localhost, sometimes it gives us flaky tests. try to disable tcp offloading for fix it
Expand All @@ -153,8 +155,9 @@ jobs:
run: |
sudo ethtool -K eth0 tx off
sudo ethtool -K eth0 rx off
- name: disable TCP/UDP offload - MacOS
if: ${{ matrix.os == 'macos-latest' }}
if: ${{ matrix.os == 'macos-12-large' || matrix.os == 'macos-13-xlarge' }}
run: |
sudo sysctl -w net.link.generic.system.hwcksum_tx=0
sudo sysctl -w net.link.generic.system.hwcksum_rx=0
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ jobs:
outname_sufix: "linux-amd64"
- os: [self-hosted, linux, arm64]
outname_sufix: "linux-arm64"
- os: macos-latest
- os: macos-12-large
outname_sufix: "mac-amd64"
- os: [self-hosted, macos, arm64]
- os: macos-13-xlarge

outname_sufix: "mac-arm64"
- os: windows-latest
outname_sufix: "win-amd64"
Expand All @@ -33,9 +34,11 @@ jobs:
- name: Install dependencies in windows
if: ${{ matrix.os == 'windows-latest' }}
run: choco install make wget zip

- name: Add OpenCL support - Ubuntu
if: ${{ matrix.os == 'ubuntu-latest' }}
run: sudo apt-get update -q && sudo apt-get install -qy ocl-icd-opencl-dev libpocl2

- name: disable Windows Defender - Windows
if: ${{ matrix.os == 'windows-latest' }}
run: |
Expand Down Expand Up @@ -82,7 +85,7 @@ jobs:
destination: ${{ secrets.GCP_BUCKET }}/${{ github.ref_name }}/

- name: Install coreutils
if: ${{ matrix.os == 'macos-latest' }}
if: ${{ matrix.os == 'macos-12-large' || matrix.os == 'macos-13-xlarge' }}
run: brew install coreutils

- name: Calculate the hashsum of the zip file
Expand Down
5 changes: 1 addition & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

## UNRELEASED
## Release v1.3

### Upgrade information

Expand All @@ -11,9 +11,6 @@ The migration will take place at the first startup after the upgrade. Be aware t
downgrading isn't supported and might result in at least one epoch of missed rewards. See change #5207 for more
information.

Current release is expected to be adopted by majority of the network participants before epoch 11 starts.
Nodes that do not update before epoch 11 risk their proposals being rejected by the rest of the network.

This release is the first step towards separating PoST from the node. Proof generation is now done via a dedicated
service. This service is started automatically by the node and is shut down when the node shuts down. In most
setups this should work out of the box, but if you are running into issues please check the README.md file
Expand Down
2 changes: 1 addition & 1 deletion Makefile-libs.Inc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ else
endif
endif

POSTRS_SETUP_REV = 0.6.1
POSTRS_SETUP_REV = 0.6.4
POSTRS_SETUP_ZIP = libpost-$(platform)-v$(POSTRS_SETUP_REV).zip
POSTRS_SETUP_URL_ZIP ?= https://github.com/spacemeshos/post-rs/releases/download/v$(POSTRS_SETUP_REV)/$(POSTRS_SETUP_ZIP)
POSTRS_PROFILER_ZIP = profiler-$(platform)-v$(POSTRS_SETUP_REV).zip
Expand Down
29 changes: 3 additions & 26 deletions activation/activation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,6 @@ func TestBuilder_StartSmeshingCoinbase(t *testing.T) {
}

func TestBuilder_RestartSmeshing(t *testing.T) {
now := time.Now()
getBuilder := func(t *testing.T) *Builder {
tab := newTestBuilder(t)
tab.mpostClient.EXPECT().Proof(gomock.Any(), shared.ZeroChallenge).AnyTimes().DoAndReturn(
Expand All @@ -309,43 +308,21 @@ func TestBuilder_RestartSmeshing(t *testing.T) {
return nil, nil, ctx.Err()
},
)
tab.mValidator.EXPECT().Post(
gomock.Any(),
gomock.Any(),
gomock.Any(),
gomock.Any(),
gomock.Any(),
gomock.Any(),
).AnyTimes().Return(nil)

ch := make(chan struct{})
close(ch)
tab.mclock.EXPECT().AwaitLayer(gomock.Any()).Return(ch).AnyTimes()
tab.mclock.EXPECT().CurrentLayer().Return(types.LayerID(0)).AnyTimes()
tab.mclock.EXPECT().LayerToTime(gomock.Any()).Return(now).AnyTimes()
return tab.Builder
}

t.Run("Single threaded", func(t *testing.T) {
builder := getBuilder(t)
for i := 0; i < 50; i++ {
require.NoError(t, builder.StartSmeshing(types.Address{}))
require.Never(
t,
func() bool { return !builder.Smeshing() },
400*time.Microsecond,
50*time.Microsecond,
"failed on execution %d",
i,
)
require.True(t, builder.Smeshing())
require.NoError(t, builder.StopSmeshing(true))
require.Eventually(
t,
func() bool { return !builder.Smeshing() },
500*time.Millisecond,
time.Millisecond,
"failed on execution %d",
i,
)
require.False(t, builder.Smeshing())
}
})

Expand Down
2 changes: 1 addition & 1 deletion activation/post_verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func (v *OffloadingPostVerifier) Autoscale(min, target int) {
// Scale the number of workers to the given number.
//
// SAFETY: Must not be called concurrently.
// This is satisified by the fact that the only caller is the autoscaler,
// This is satisfied by the fact that the only caller is the autoscaler,
// which executes scale() serially.
func (v *OffloadingPostVerifier) scale(target int) {
v.log.Info("scaling post verifier", zap.Int("current", len(v.workers)), zap.Int("new", target))
Expand Down
4 changes: 2 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,11 +280,11 @@ func AddCommands(cmd *cobra.Command) {

cmd.PersistentFlags().IntVar(
&cfg.SMESHING.VerifyingOpts.MinWorkers,
"smeshing-opts-verifying-min-threads",
"smeshing-opts-verifying-min-workers",
cfg.SMESHING.VerifyingOpts.MinWorkers,
"Minimal number of threads to use for verifying PoSTs (used while PoST is generated)",
)
cmd.PersistentFlags().IntVar(&cfg.SMESHING.VerifyingOpts.Workers, "smeshing-opts-verifying-threads",
cmd.PersistentFlags().IntVar(&cfg.SMESHING.VerifyingOpts.Workers, "smeshing-opts-verifying-workers",
cfg.SMESHING.VerifyingOpts.Workers, "")
cmd.PersistentFlags().AddFlag(&pflag.Flag{
Name: "smeshing-opts-verifying-powflags",
Expand Down
2 changes: 2 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ type BaseConfig struct {
DatabaseLatencyMetering bool `mapstructure:"db-latency-metering"`
DatabaseSizeMeteringInterval time.Duration `mapstructure:"db-size-metering-interval"`
DatabasePruneInterval time.Duration `mapstructure:"db-prune-interval"`
DatabaseVacuumState int `mapstructure:"db-vacuum-state"`
DatabaseSkipMigrations []int `mapstructure:"db-skip-migrations"`

PruneActivesetsFrom types.EpochID `mapstructure:"prune-activesets-from"`

Expand Down
7 changes: 2 additions & 5 deletions config/mainnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ func MainnetConfig() Config {
MetricsPort: 1010,
DatabaseConnections: 16,
DatabasePruneInterval: 30 * time.Minute,
PruneActivesetsFrom: 11, // starting from epoch 12 activesets below 11 will be pruned
DatabaseVacuumState: 8,
PruneActivesetsFrom: 12, // starting from epoch 13 activesets below 12 will be pruned
NetworkHRP: "sm",

LayerDuration: 5 * time.Minute,
Expand Down Expand Up @@ -106,10 +107,6 @@ func MainnetConfig() Config {
BadBeaconVoteDelayLayers: 4032,
MinimalActiveSetWeight: []types.EpochMinimalActiveWeight{
{Weight: 1_000_000},
// generated using ./cmd/activeset for publish epoch 6
// it will be used starting from epoch 11, so that there is plenty of time
// for participants to update software
{Epoch: 11, Weight: 7_879_129_244},
},
},
HARE3: hare3conf,
Expand Down
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ require (
github.com/multiformats/go-varint v0.0.7
github.com/natefinch/atomic v1.0.1
github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a
github.com/prometheus/client_golang v1.17.0
github.com/prometheus/client_golang v1.18.0
github.com/prometheus/common v0.45.0
github.com/quic-go/quic-go v0.40.1
github.com/santhosh-tekuri/jsonschema/v5 v5.3.1
Expand All @@ -56,7 +56,7 @@ require (
golang.org/x/time v0.5.0
google.golang.org/genproto/googleapis/rpc v0.0.0-20231212172506-995d672761c0
google.golang.org/grpc v1.60.1
google.golang.org/protobuf v1.31.0
google.golang.org/protobuf v1.32.0
k8s.io/api v0.29.0
k8s.io/apimachinery v0.29.0
k8s.io/client-go v0.29.0
Expand Down Expand Up @@ -176,8 +176,8 @@ require (
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/polydawn/refmt v0.89.0 // indirect
github.com/prometheus/client_model v0.4.1-0.20230718164431-9a2bf3000d16 // indirect
github.com/prometheus/procfs v0.11.1 // indirect
github.com/prometheus/client_model v0.5.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/quic-go/qpack v0.4.0 // indirect
github.com/quic-go/qtls-go1-20 v0.4.1 // indirect
github.com/quic-go/webtransport-go v0.6.0 // indirect
Expand Down
16 changes: 8 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -546,18 +546,18 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH
github.com/polydawn/refmt v0.89.0 h1:ADJTApkvkeBZsN0tBTx8QjpD9JkmxbKp0cxfr9qszm4=
github.com/polydawn/refmt v0.89.0/go.mod h1:/zvteZs/GwLtCgZ4BL6CBsk9IKIlexP43ObX9AxTqTw=
github.com/prometheus/client_golang v0.8.0/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v1.17.0 h1:rl2sfwZMtSthVU752MqfjQozy7blglC+1SOtjMAMh+Q=
github.com/prometheus/client_golang v1.17.0/go.mod h1:VeL+gMmOAxkS2IqfCq0ZmHSL+LjWfWDUmp1mBz9JgUY=
github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk=
github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.4.1-0.20230718164431-9a2bf3000d16 h1:v7DLqVdK4VrYkVD5diGdl4sxJurKJEMnODWRJlxV9oM=
github.com/prometheus/client_model v0.4.1-0.20230718164431-9a2bf3000d16/go.mod h1:oMQmHW1/JoDwqLtg57MGgP/Fb1CJEYF2imWWhWtMkYU=
github.com/prometheus/client_model v0.5.0 h1:VQw1hfvPvk3Uv6Qf29VrPF32JB6rtbgI6cYPYQjL0Qw=
github.com/prometheus/client_model v0.5.0/go.mod h1:dTiFglRmd66nLR9Pv9f0mZi7B7fk5Pm3gvsjB5tr+kI=
github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro=
github.com/prometheus/common v0.45.0 h1:2BGz0eBc2hdMDLnO/8n0jeB3oPrt2D08CekT0lneoxM=
github.com/prometheus/common v0.45.0/go.mod h1:YJmSTw9BoKxJplESWWxlbyttQR4uaEcGyv9MZjVOJsY=
github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/prometheus/procfs v0.11.1 h1:xRC8Iq1yyca5ypa9n1EZnWZkt7dwcoRPQwX/5gwaUuI=
github.com/prometheus/procfs v0.11.1/go.mod h1:eesXgaPo1q7lBpVMoMy0ZOFTth9hBn4W/y0/p/ScXhY=
github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo=
github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo=
github.com/quic-go/qpack v0.4.0 h1:Cr9BXA1sQS2SmDUWjSofMPNKmvF6IiIfDRmgU0w1ZCo=
github.com/quic-go/qpack v0.4.0/go.mod h1:UZVnYIfi5GRk+zI9UMaCPsmZ2xKJP7XBUvVyT1Knj9A=
github.com/quic-go/qtls-go1-20 v0.4.1 h1:D33340mCNDAIKBqXuAvexTNMUByrYmFYVfKfDN5nfFs=
Expand Down Expand Up @@ -1091,8 +1091,8 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I=
google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
2 changes: 1 addition & 1 deletion hare3/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (ir IterRound) Absolute() uint32 {

type Value struct {
// Proposals is set in messages for preround and propose rounds.
Proposals []types.ProposalID `scale:"max=200"`
Proposals []types.ProposalID `scale:"max=500"`
// Reference is set in messages for commit and notify rounds.
Reference *types.Hash32
}
Expand Down
4 changes: 2 additions & 2 deletions hare3/types_scale.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 12 additions & 4 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ import (
"github.com/spacemeshos/go-spacemesh/signing"
"github.com/spacemeshos/go-spacemesh/sql"
"github.com/spacemeshos/go-spacemesh/sql/activesets"
"github.com/spacemeshos/go-spacemesh/sql/ballots/util"
"github.com/spacemeshos/go-spacemesh/sql/layers"
"github.com/spacemeshos/go-spacemesh/sql/localsql"
dbmetrics "github.com/spacemeshos/go-spacemesh/sql/metrics"
Expand Down Expand Up @@ -1176,6 +1175,11 @@ func (app *App) listenToUpdates(ctx context.Context) {
app.proposalBuilder.UpdateActiveSet(epoch, set)

app.eg.Go(func() error {
select {
case <-app.syncer.RegisterForATXSynced():
case <-ctx.Done():
return nil
}
if err := atxsync.Download(
ctx,
10*time.Second,
Expand Down Expand Up @@ -1571,12 +1575,16 @@ func (app *App) setupDBs(ctx context.Context, lg log.Log) error {
if err != nil {
return fmt.Errorf("failed to load migrations: %w", err)
}
sqlDB, err := sql.Open("file:"+filepath.Join(dbPath, dbFile),
dbopts := []sql.Opt{
sql.WithMigrations(migrations),
sql.WithConnections(app.Config.DatabaseConnections),
sql.WithLatencyMetering(app.Config.DatabaseLatencyMetering),
sql.WithV5Migration(util.ExtractActiveSet),
)
sql.WithVacuumState(app.Config.DatabaseVacuumState),
}
if len(app.Config.DatabaseSkipMigrations) > 0 {
dbopts = append(dbopts, sql.WithSkipMigrations(app.Config.DatabaseSkipMigrations...))
}
sqlDB, err := sql.Open("file:"+filepath.Join(dbPath, dbFile), dbopts...)
if err != nil {
return fmt.Errorf("open sqlite db %w", err)
}
Expand Down
15 changes: 4 additions & 11 deletions proposals/eligibility_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func NewEligibilityValidator(
}

// CheckEligibility checks that a ballot is eligible in the layer that it specifies.
func (v *Validator) CheckEligibility(ctx context.Context, ballot *types.Ballot, actives []types.ATXID) (bool, error) {
func (v *Validator) CheckEligibility(ctx context.Context, ballot *types.Ballot, weight uint64) (bool, error) {
if len(ballot.EligibilityProofs) == 0 {
return false, fmt.Errorf("empty eligibility list is invalid (ballot %s)", ballot.ID())
}
Expand All @@ -93,7 +93,7 @@ func (v *Validator) CheckEligibility(ctx context.Context, ballot *types.Ballot,
err error
)
if ballot.EpochData != nil && ballot.Layer.GetEpoch() == v.clock.CurrentLayer().GetEpoch() {
data, err = v.validateReference(ballot, actives, atx.Weight)
data, err = v.validateReference(ballot, atx.Weight, weight)
} else {
data, err = v.validateSecondary(ballot)
}
Expand Down Expand Up @@ -135,21 +135,14 @@ func (v *Validator) CheckEligibility(ctx context.Context, ballot *types.Ballot,
// validateReference executed for reference ballots in latest epoch.
func (v *Validator) validateReference(
ballot *types.Ballot,
actives []types.ATXID,
weight uint64,
weight, totalWeight uint64,
) (*types.EpochData, error) {
if ballot.EpochData.Beacon == types.EmptyBeacon {
return nil, fmt.Errorf("%w: ref ballot %v", errMissingBeacon, ballot.ID())
}
if len(actives) == 0 {
if totalWeight == 0 {
return nil, fmt.Errorf("%w: ref ballot %v", errEmptyActiveSet, ballot.ID())
}
totalWeight, used := v.atxsdata.WeightForSet(ballot.Layer.GetEpoch(), actives)
for i := range used {
if !used[i] {
return nil, fmt.Errorf("atx in active set is missing in cache %v", actives[i].ShortString())
}
}
numEligibleSlots, err := GetNumEligibleSlots(
weight,
minweight.Select(ballot.Layer.GetEpoch(), v.minActiveSetWeight),
Expand Down
Loading

0 comments on commit a05776e

Please sign in to comment.