Skip to content
This repository has been archived by the owner on May 23, 2024. It is now read-only.

Commit

Permalink
Increase num of supported ATXs (#5802)
Browse files Browse the repository at this point in the history
## Motivation

2.7 Mio ATXs might not be enough for the next epoch already. This increases limits of types to support up to 3.5 Mio ATXs per epoch.
  • Loading branch information
fasmat committed Apr 4, 2024
1 parent e3e5a61 commit 9c87d63
Show file tree
Hide file tree
Showing 14 changed files with 46 additions and 44 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ See [RELEASE](./RELEASE.md) for workflow instructions.

* [#5797](https://github.com/spacemeshos/go-spacemesh/pull/5797) Improve logging around ATX building process.

* [#5802](https://github.com/spacemeshos/go-spacemesh/pull/5802) Increase the number of supported ATX per epoch to 3.5 Mio.

### Features

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

type EpochActiveSet struct {
Epoch EpochID
Set []ATXID `scale:"max=2700000"` // to be in line with `EpochData` in fetch/wire_types.go
Set []ATXID `scale:"max=3500000"` // 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: 1 addition & 1 deletion common/types/ballot.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ 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
ActiveSet []ATXID `scale:"max=2700000"`
ActiveSet []ATXID `scale:"max=3500000"`

// the following fields are kept private and from being serialized
ballotID BallotID
Expand Down
4 changes: 2 additions & 2 deletions common/types/ballot_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 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 2.7 Mio ATXs that would be a total of 2.7 Mio + 50 * 4032 = 2 901 600 slots.
// If we expect 3.5 Mio ATXs that would be a total of 3.5 Mio + 50 * 4032 = 3 701 600 slots.
// Since these are randomly distributed across the epoch, we can expect an average of n * p =
// 2 901 600 / 4032 = 719.6 rewards in a block with a standard deviation of sqrt(n * p * (1 - p)) =
// sqrt(2 901 600 * 1/4032 * 4031/4032) = 26.8
// 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
//
// This means that we can expect a maximum of 719.6 + 6*26.8 = 880.6 rewards per block with
// This means that we can expect a maximum of 918.1 + 6*30.3 = 1100.0 rewards per block with
// > 99.9997% probability.
Rewards []AnyReward `scale:"max=900"`
Rewards []AnyReward `scale:"max=1100"`
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.

3 changes: 1 addition & 2 deletions fetch/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -549,8 +549,7 @@ func (f *Fetch) receiveResponse(data []byte, batch *batchInfo) {
f.mu.Unlock()

if !ok {
f.logger.With().Warning("response received for unknown hash",
log.Stringer("hash", resp.Hash))
f.logger.With().Warning("response received for unknown hash", log.Stringer("hash", resp.Hash))
continue
}

Expand Down
22 changes: 11 additions & 11 deletions fetch/wire_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ type RequestMessage struct {
// ResponseMessage is sent to the node as a response.
type ResponseMessage struct {
Hash types.Hash32
Data []byte `scale:"max=104857600"` // limit to 100 MiB - keep in line with Response.Data in `p2p/server/server.go`
// 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
}

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

type MaliciousIDs struct {
NodeIDs []types.NodeID `scale:"max=100000"` // max. expected number of ATXs per epoch is 100_000
NodeIDs []types.NodeID `scale:"max=3500000"` // to be in line with `EpochData.AtxIDs` below
}

type EpochData struct {
// to be in line with `EpochActiveSet` in common/types/activation.go
// and DefaultConfig in datastore/store.go
//
// 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 `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=2700000"`
AtxIDs []types.ATXID `scale:"max=3500000"`
}

// 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 = 2 901 600 slots.
// If we expect 2.7 Mio ATXs that would be a total of 2.7 Mio + 50 * 4032 = 3 701 600 slots.
// Since these are randomly distributed across the epoch, we can expect an average of n * p =
// 2 901 600 / 4032 = 719.6 ballots in a layer with a standard deviation of sqrt(n * p * (1 - p)) =
// sqrt(2 901 600 * 1/4032 * 4031/4032) = 26.8
// 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
//
// This means that we can expect a maximum of 719.6 + 6*26.8 = 880.6 ballots per layer with
// This means that we can expect a maximum of 918.1 + 6*30.3 = 1100.0 ballots per layer with
// > 99.9997% probability.
Ballots []types.BallotID `scale:"max=900"`
Ballots []types.BallotID `scale:"max=1100"`
}

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 @@ -81,14 +81,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 = 2 901 600 slots.
// If we expect 2.7 Mio ATXs that would be a total of 2.7 Mio + 50 * 4032 = 3 701 600 slots.
// Since these are randomly distributed across the epoch, we can expect an average of n * p =
// 2 901 600 / 4032 = 719.6 eligibilities in a layer with a standard deviation of sqrt(n * p * (1 - p)) =
// sqrt(2 901 600 * 1/4032 * 4031/4032) = 26.8
// 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
//
// This means that we can expect a maximum of 719.6 + 6*26.8 = 880.6 eligibilities in a layer with
// This means that we can expect a maximum of 918.1 + 6*1100.0 = 880.6 eligibilities in a layer with
// > 99.9997% probability.
Proposals []types.ProposalID `scale:"max=900"`
Proposals []types.ProposalID `scale:"max=1100"`
// 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.

3 changes: 2 additions & 1 deletion p2p/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ func (err *ServerError) Error() string {

// Response is a server response.
type Response struct {
Data []byte `scale:"max=104857600"` // 100 MiB - keep in line with ResponseMessage.Data in `fetch/wire_types.go`
// keep in line with limit of ResponseMessage.Data in `fetch/wire_types.go`
Data []byte `scale:"max=125829120"` // 120 MiB > 3.5 mio ATX * 32 bytes per ID
Error string `scale:"max=1024"` // TODO(mafa): make error code instead of string
}

Expand Down
4 changes: 2 additions & 2 deletions p2p/server/server_scale.go

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

0 comments on commit 9c87d63

Please sign in to comment.