Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor constants #26

Merged
merged 7 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .swiftformat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--extensionacl on-declarations
--maxwidth 150
8 changes: 8 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,17 @@ disabled_rules:
- trailing_comma
- todo
- large_tuple
- file_length
- nesting
- opening_brace

excluded:
- "**/.build"

identifier_name:
min_length: 1

line_length:
warning: 140
error: 140
ignores_function_declarations: true
1 change: 1 addition & 0 deletions Blockchain/Sources/Blockchain/BlockAuthor.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
public class BlockAuthor {}
6 changes: 3 additions & 3 deletions Blockchain/Sources/Blockchain/Blockchain.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ public class Blockchain {
}
}

public extension Blockchain {
subscript(hash: H256) -> StateRef? {
extension Blockchain {
public subscript(hash: H256) -> StateRef? {
stateByBlockHash[hash]
}

subscript(index: TimeslotIndex) -> [StateRef]? {
public subscript(index: TimeslotIndex) -> [StateRef]? {
stateByTimeslot[index]
}
}
78 changes: 78 additions & 0 deletions Blockchain/Sources/Blockchain/Config/ProtocolConfig+Preset.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import Utils

extension Ref where T == ProtocolConfig {
// TODO: pick some good numbers for dev env
public static let dev = Ref(ProtocolConfig(
auditTranchePeriod: 8,
additionalMinBalancePerStateItem: 10,
additionalMinBalancePerStateByte: 1,
serviceMinBalance: 100,
totalNumberOfCores: 341,
preimagePurgePeriod: 28800,
epochLength: 600,
auditBiasFactor: 2,
coreAccumulationGas: 10_000_000, // TODO: check this
workPackageAuthorizerGas: 10_000_000, // TODO: check this
workPackageRefineGas: 10_000_000, // TODO: check this
recentHistorySize: 8,
maxWorkItems: 4,
maxTicketsPerExtrinsic: 16,
maxLookupAnchorAge: 14400,
transferMemoSize: 128,
ticketEntriesPerValidator: 2,
maxAuthorizationsPoolItems: 8,
slotPeriodSeconds: 6,
maxAuthorizationsQueueItems: 80,
coreAssignmentRotationPeriod: 10,
maxServiceCodeSize: 4_000_000,
preimageReplacementPeriod: 5,
totalNumberOfValidators: 1023,
erasureCodedPieceSize: 684,
maxWorkPackageManifestEntries: 1 << 11,
maxEncodedWorkPackageSize: 12 * 1 << 20,
maxEncodedWorkReportSize: 96 * 1 << 10,
erasureCodedSegmentSize: 6,
ticketSubmissionEndSlot: 500,
pvmDynamicAddressAlignmentFactor: 4,
pvmProgramInitInputDataSize: 1 << 24,
pvmProgramInitPageSize: 1 << 14,
pvmProgramInitSegmentSize: 1 << 16
))

public static let mainnet = Ref(ProtocolConfig(
auditTranchePeriod: 8,
additionalMinBalancePerStateItem: 10,
additionalMinBalancePerStateByte: 1,
serviceMinBalance: 100,
totalNumberOfCores: 341,
preimagePurgePeriod: 28800,
epochLength: 600,
auditBiasFactor: 2,
coreAccumulationGas: 10_000_000, // TODO: check this
workPackageAuthorizerGas: 10_000_000, // TODO: check this
workPackageRefineGas: 10_000_000, // TODO: check this
recentHistorySize: 8,
maxWorkItems: 4,
maxTicketsPerExtrinsic: 16,
maxLookupAnchorAge: 14400,
transferMemoSize: 128,
ticketEntriesPerValidator: 2,
maxAuthorizationsPoolItems: 8,
slotPeriodSeconds: 6,
maxAuthorizationsQueueItems: 80,
coreAssignmentRotationPeriod: 10,
maxServiceCodeSize: 4_000_000,
preimageReplacementPeriod: 5,
totalNumberOfValidators: 1023,
erasureCodedPieceSize: 684,
maxWorkPackageManifestEntries: 1 << 11,
maxEncodedWorkPackageSize: 12 * 1 << 20,
maxEncodedWorkReportSize: 96 * 1 << 10,
erasureCodedSegmentSize: 6,
ticketSubmissionEndSlot: 500,
pvmDynamicAddressAlignmentFactor: 4,
pvmProgramInitInputDataSize: 1 << 24,
pvmProgramInitPageSize: 1 << 14,
pvmProgramInitSegmentSize: 1 << 16
))
}
Loading