Skip to content

Commit

Permalink
Increase supported number of ATXs to 4.5 Mio (#5896) (#5898)
Browse files Browse the repository at this point in the history
Another round of increasing limits to support more ATXs per epoch.
  • Loading branch information
fasmat authored Apr 29, 2024
1 parent 936f977 commit 4587585
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 43 deletions.
14 changes: 8 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,23 @@

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

## UNRELEASED (v1.5.0)
## Release v1.5.1

### Improvements

* [#5896](https://github.com/spacemeshos/go-spacemesh/pull/5896) Increase supported number of ATXs to 4.5 Mio.

## Release v1.5.0

### Upgrade information

* [#5814](https://github.com/spacemeshos/go-spacemesh/pull/5814) Removed in-code local DB migrations.
Updating to this version requires going through v1.4 first.

### Highlights

### Features

### Improvements

* [#5807](https://github.com/spacemeshos/go-spacemesh/pull/5807) Implement SMIP-0002: remove vesting vault cliff.

* [#5840](https://github.com/spacemeshos/go-spacemesh/pull/5840) Allow vaults to spend received (as well as vested)
coins. Fixes an oversight in the genesis VM implementation.

Expand Down
2 changes: 1 addition & 1 deletion common/types/activation.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ func ATXIDsToHashes(ids []ATXID) []Hash32 {

type EpochActiveSet struct {
Epoch EpochID
Set []ATXID `scale:"max=3500000"` // to be in line with `EpochData` in fetch/wire_types.go
Set []ATXID `scale:"max=4500000"` // to be in line with `EpochData` in fetch/wire_types.go
}

var MaxEpochActiveSetSize = scale.MustGetMaxElements[EpochActiveSet]("Set")
4 changes: 2 additions & 2 deletions common/types/activation_scale.go

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

2 changes: 2 additions & 0 deletions common/types/ballot.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ type Ballot struct {
EligibilityProofs []VotingEligibility `scale:"max=25000"`
// from the smesher's view, the set of ATXs eligible to vote and propose block content in this epoch
// only present in smesher's first ballot of the epoch
// this field isn't actually used any more (replaced by InnerBallot.EpochData)
// TODO (mafa): remove this field in Ballot v2
ActiveSet []ATXID `scale:"max=3500000"`

// the following fields are kept private and from being serialized
Expand Down
10 changes: 5 additions & 5 deletions common/types/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@ type InnerBlock struct {
// In this case they will get all 50 available slots in all 4032 layers of the epoch.
// Additionally every other identity on the network that successfully published an ATX will get 1 slot.
//
// If we expect 3.5 Mio ATXs that would be a total of 3.5 Mio + 50 * 4032 = 3 701 600 slots.
// If we expect 4.5 Mio ATXs that would be a total of 4.5 Mio + 50 * 4032 = 4 701 600 slots.
// Since these are randomly distributed across the epoch, we can expect an average of n * p =
// 3 701 600 / 4032 = 918.1 rewards in a block with a standard deviation of sqrt(n * p * (1 - p)) =
// sqrt(3 701 600 * 1/4032 * 4031/4032) = 30.3
// 4 701 600 / 4032 = 1166.1 rewards in a block with a standard deviation of sqrt(n * p * (1 - p)) =
// sqrt(3 701 600 * 1/4032 * 4031/4032) = 34.1
//
// This means that we can expect a maximum of 918.1 + 6*30.3 = 1100.0 rewards per block with
// This means that we can expect a maximum of 1166.1 + 6*34.1 = 1370.9 rewards per block with
// > 99.9997% probability.
Rewards []AnyReward `scale:"max=1100"`
Rewards []AnyReward `scale:"max=1370"`
TxIDs []TransactionID `scale:"max=100000"`
}

Expand Down
4 changes: 2 additions & 2 deletions common/types/block_scale.go

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

2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func DefaultConfig() Config {
Sync: syncer.DefaultConfig(),
Recovery: checkpoint.DefaultConfig(),
Cache: datastore.DefaultConfig(),
ActiveSet: miner.DefaultActiveSetPrepartion(),
ActiveSet: miner.DefaultActiveSetPreparation(),
}
}

Expand Down
18 changes: 9 additions & 9 deletions fetch/wire_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type RequestMessage struct {
type ResponseMessage struct {
Hash types.Hash32
// keep in line with limit of Response.Data in `p2p/server/server.go`
Data []byte `scale:"max=125829120"` // 120 MiB > 3.5 mio ATX * 32 bytes per ID
Data []byte `scale:"max=157286400"` // 150 MiB > 4.5 mio ATX * 32 bytes per ID
}

// RequestBatch is a batch of requests and a hash of all requests as ID.
Expand Down Expand Up @@ -116,19 +116,19 @@ type MeshHashes struct {
}

type MaliciousIDs struct {
NodeIDs []types.NodeID `scale:"max=3500000"` // to be in line with `EpochData.AtxIDs` below
NodeIDs []types.NodeID `scale:"max=4500000"` // to be in line with `EpochData.AtxIDs` below
}

type EpochData struct {
// When changing this value also check
// - the size of `ResponseMessage` above
// - the size of `NodeIDs` in `MaliciousIDs` above
// - the size of `Set` in `EpochActiveSet` in common/types/activation.go
// - the fields `EligibilityProofs` and `ActiveSet` in the type `Ballot` in common/types/ballot.go
// - the size of `EligibilityProofs` in the type `Ballot` in common/types/ballot.go
// - the size of `Rewards` in the type `InnerBlock` in common/types/block.go
// - the size of `Ballots` in the type `LayerData` below
// - the size of `Proposals` in the type `Value` in hare3/types.go
AtxIDs []types.ATXID `scale:"max=3500000"`
AtxIDs []types.ATXID `scale:"max=4500000"`
}

// LayerData is the data response for a given layer ID.
Expand All @@ -139,14 +139,14 @@ type LayerData struct {
// In this case they will get all 50 available slots in all 4032 layers of the epoch.
// Additionally every other identity on the network that successfully published an ATX will get 1 slot.
//
// If we expect 2.7 Mio ATXs that would be a total of 2.7 Mio + 50 * 4032 = 3 701 600 slots.
// If we expect 4.5 Mio ATXs that would be a total of 4.5 Mio + 50 * 4032 = 4 701 600 slots.
// Since these are randomly distributed across the epoch, we can expect an average of n * p =
// 3 701 600 / 4032 = 918.1 ballots in a layer with a standard deviation of sqrt(n * p * (1 - p)) =
// sqrt(3 701 600 * 1/4032 * 4031/4032) = 30.3
// 4 701 600 / 4032 = 1166.1 ballots in a layer with a standard deviation of sqrt(n * p * (1 - p)) =
// sqrt(3 701 600 * 1/4032 * 4031/4032) = 34.1
//
// This means that we can expect a maximum of 918.1 + 6*30.3 = 1100.0 ballots per layer with
// This means that we can expect a maximum of 1166.1 + 6*34.1 = 1370.9 ballots per layer with
// > 99.9997% probability.
Ballots []types.BallotID `scale:"max=1100"`
Ballots []types.BallotID `scale:"max=1370"`
}

type OpinionRequest struct {
Expand Down
16 changes: 8 additions & 8 deletions fetch/wire_types_scale.go

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

10 changes: 5 additions & 5 deletions hare3/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@ type Value struct {
// In this case they will get all 50 available slots in all 4032 layers of the epoch.
// Additionally every other identity on the network that successfully published an ATX will get 1 slot.
//
// If we expect 2.7 Mio ATXs that would be a total of 2.7 Mio + 50 * 4032 = 3 701 600 slots.
// If we expect 4.5 Mio ATXs that would be a total of 4.5 Mio + 50 * 4032 = 4 701 600 slots.
// Since these are randomly distributed across the epoch, we can expect an average of n * p =
// 3 701 600 / 4032 = 918.1 eligibilities in a layer with a standard deviation of sqrt(n * p * (1 - p)) =
// sqrt(3 701 600 * 1/4032 * 4031/4032) = 1100.0
// 4 701 600 / 4032 = 1166.1 eligibilities in a layer with a standard deviation of sqrt(n * p * (1 - p)) =
// sqrt(3 701 600 * 1/4032 * 4031/4032) = 34.1
//
// This means that we can expect a maximum of 918.1 + 6*1100.0 = 880.6 eligibilities in a layer with
// This means that we can expect a maximum of 1166.1 + 6*34.1 = 1370.9 eligibilities in a layer with
// > 99.9997% probability.
Proposals []types.ProposalID `scale:"max=1100"`
Proposals []types.ProposalID `scale:"max=1370"`
// 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.

4 changes: 2 additions & 2 deletions miner/proposal_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ type ActiveSetPreparation struct {
Tries int `mapstructure:"tries"`
}

func DefaultActiveSetPrepartion() ActiveSetPreparation {
func DefaultActiveSetPreparation() ActiveSetPreparation {
return ActiveSetPreparation{
Window: 1 * time.Second,
RetryInterval: 1 * time.Second,
Expand Down Expand Up @@ -273,7 +273,7 @@ func New(
pb := &ProposalBuilder{
cfg: config{
workersLimit: runtime.NumCPU(),
activeSet: DefaultActiveSetPrepartion(),
activeSet: DefaultActiveSetPreparation(),
},
logger: log.NewNop(),
clock: clock,
Expand Down

0 comments on commit 4587585

Please sign in to comment.