Implementing Milestones
Milestones are objects that dictate how ARK Core behaves after certain heights are reached. Lets have a look at the mainnet milestones to understand this better.
1[ 2 { 3 "height": 1, 4 "reward": 0, 5 "activeDelegates": 51, 6 "blocktime": 8, 7 "block": { 8 "version": 0, 9 "maxTransactions": 50,10 "maxPayload": 2097152,11 "acceptExpiredTransactionTimestamps": true12 },13 "epoch": "2017-03-21T13:00:00.000Z",14 "fees": {15 "staticFees": {16 "transfer": 10000000,17 "secondSignature": 500000000,18 "delegateRegistration": 2500000000,19 "vote": 100000000,20 "multiSignature": 500000000,21 "ipfs": 500000000,22 "multiPayment": 10000000,23 "delegateResignation": 2500000000,24 "htlcLock": 10000000,25 "htlcClaim": 0,26 "htlcRefund": 027 }28 },29 "vendorFieldLength": 6430 },31 {32 "height": 75600,33 "reward": 20000000034 },35 {36 "height": 6600000,37 "block": {38 "maxTransactions": 150,39 "maxPayload": 630000040 }41 },42 {43 "height": 8128000,44 "vendorFieldLength": 25545 },46 {47 "height": 8204000,48 "block": {49 "idFullSha256": true50 }51 }52]
The first milestone starts at height 1, which is the genesis block which gets generated when you create a new network configuration.
1{ 2 "height": 1, 3 "reward": 0, // Each forged block yields 0 rewards for the forger 4 "activeDelegates": 51, // 51 delegates can forge at any given time 5 "blocktime": 8, // Time in which a block is expected to be forged 6 "block": { 7 "version": 0, 8 "maxTransactions": 50, // Maximum of transactions allowed to be forged per block 9 "maxPayload": 2097152, // Maximum size of a block in bytes10 "acceptExpiredTransactionTimestamps": true11 },12 "epoch": "2017-03-21T13:00:00.000Z", // Start time of the network13 "fees": {14 "staticFees": {15 "transfer": 10000000, // Fee for type 016 "secondSignature": 500000000, // Fee for type 117 "delegateRegistration": 2500000000, // Fee for type 218 "vote": 100000000, // Fee for type 319 "multiSignature": 500000000, // Fee for type 420 "ipfs": 500000000, // Fee for type 521 "multiPayment": 10000000, // Fee for type 622 "delegateResignation": 2500000000, // Fee for type 723 "htlcLock": 10000000, // Fee for type 824 "htlcClaim": 0, // Fee for type 925 "htlcRefund": 0 // Fee for type 1026 }27 },28 "vendorFieldLength": 64 // Maximum length of the vendor field for type 0 transactions29}
This first milestone serves as the base for all future milestones. Lets take a look at what below milestones do.
1[ 2 { 3 // From height 75600 onwards we will reward 2 ARK for every forged block 4 "height": 75600, 5 "reward": 200000000 6 }, 7 { 8 // From height 6600000 onwards we will allow 150 transactions 9 // to be forged per block with a maximum size of 6300000 bytes10 "height": 6600000,11 "block": {12 "maxTransactions": 150,13 "maxPayload": 630000014 }15 },16 {17 // From height 8128000 onwards we will allow the vendor field18 // for type 0 transactions to be 255 characters long19 "height": 8128000,20 "vendorFieldLength": 25521 },22 {23 // From height 8204000 onwards we will require that24 // all block IDs are SHA256 strings instead of numerical IDs25 "height": 8204000,26 "block": {27 "idFullSha256": true28 }29 }30]
Each future milestone will be merged with its predecessors to ensure all values necessary are present.
Working With Milestones
Sometimes you might have the need to get a milestone for a specific height or need all of them to perform some statistical calculations. The @arkecosystem/crypto
package makes this easy through its configuration manager that manages the state of the configuration and related milestones.
Getting All Milestones
1import { Managers } from "@arkecosystem/config";2 3const milestones: object[] = Managers.configManagers.getMilestones();
Getting The Milestone For A Given Height
1import { Managers } from "@arkecosystem/config";2 3const milestone: object = Managers.configManagers.getMilestone(75600);
Determining If A Given Height Is A Milestone
1import { Managers } from "@arkecosystem/config";2 3const isNewMilestone: boolean = Managers.configManagers.isNewMilestone(75600);