From 03a1348af24889ab20f7fb4c33fc39bc30d28a5f Mon Sep 17 00:00:00 2001 From: Alexander Sporn Date: Tue, 31 Oct 2023 11:23:54 +0100 Subject: [PATCH] Added GenesisSlot to the protocol parameters --- api.go | 4 +++- api_protocol_parameters.go | 31 +++++++++++++++++-------------- api_test.go | 3 ++- api_v3_protocol_parameters.go | 13 ++++++++++--- block_test.go | 10 +++++----- nodeclient/apimodels/core_test.go | 4 ++-- tpkg/util.go | 2 +- vm/nova/vm_test.go | 2 +- 8 files changed, 41 insertions(+), 28 deletions(-) diff --git a/api.go b/api.go index bd619bf67..b185c674a 100644 --- a/api.go +++ b/api.go @@ -110,7 +110,7 @@ type ProtocolParameters interface { NetworkID() NetworkID // Bech32HRP defines the HRP prefix used for Bech32 addresses in the network. Bech32HRP() NetworkPrefix - // StorageScoreStructure defines the storage score structure used by the given network. + // StorageScoreParameters defines the storage score structure used by the given network. StorageScoreParameters() *StorageScoreParameters // WorkScoreParameters defines the work score parameters used by the given network. WorkScoreParameters() *WorkScoreParameters @@ -119,6 +119,8 @@ type ProtocolParameters interface { // TokenSupply defines the current token supply on the network. TokenSupply() BaseToken + // GenesisSlot defines the slot of the genesis. + GenesisSlot() SlotIndex // GenesisUnixTimestamp defines the genesis timestamp at which the slots start to count. GenesisUnixTimestamp() int64 // SlotDurationInSeconds defines the duration of each slot in seconds. diff --git a/api_protocol_parameters.go b/api_protocol_parameters.go index 797a028d4..aad9e8b6b 100644 --- a/api_protocol_parameters.go +++ b/api_protocol_parameters.go @@ -19,43 +19,45 @@ type basicProtocolParameters struct { // TokenSupply defines the current token supply on the network. TokenSupply BaseToken `serix:"6,mapKey=tokenSupply"` + // GenesisSlot defines the slot of the genesis. + GenesisSlot SlotIndex `serix:"7,mapKey=genesisSlot"` // GenesisUnixTimestamp defines the genesis timestamp at which the slots start to count. - GenesisUnixTimestamp int64 `serix:"7,mapKey=genesisUnixTimestamp"` + GenesisUnixTimestamp int64 `serix:"8,mapKey=genesisUnixTimestamp"` // SlotDurationInSeconds defines the duration of each slot in seconds. - SlotDurationInSeconds uint8 `serix:"8,mapKey=slotDurationInSeconds"` + SlotDurationInSeconds uint8 `serix:"9,mapKey=slotDurationInSeconds"` // SlotsPerEpochExponent is the number of slots in an epoch expressed as an exponent of 2. // (2**SlotsPerEpochExponent) == slots in an epoch. - SlotsPerEpochExponent uint8 `serix:"9,mapKey=slotsPerEpochExponent"` + SlotsPerEpochExponent uint8 `serix:"10,mapKey=slotsPerEpochExponent"` // StakingUnbondingPeriod defines the unbonding period in epochs before an account can stop staking. - StakingUnbondingPeriod EpochIndex `serix:"10,mapKey=stakingUnbondingPeriod"` + StakingUnbondingPeriod EpochIndex `serix:"11,mapKey=stakingUnbondingPeriod"` // ValidationBlocksPerSlot is the number of validation blocks that each validator should issue each slot. - ValidationBlocksPerSlot uint8 `serix:"11,mapKey=validationBlocksPerSlot"` + ValidationBlocksPerSlot uint8 `serix:"12,mapKey=validationBlocksPerSlot"` // PunishmentEpochs is the number of epochs worth of Mana that a node is punished with for each additional validation block it issues. - PunishmentEpochs EpochIndex `serix:"12,mapKey=punishmentEpochs"` + PunishmentEpochs EpochIndex `serix:"13,mapKey=punishmentEpochs"` // LivenessThresholdLowerBound is used by tip-selection to determine if a block is eligible by evaluating issuingTimes. // and commitments in its past-cone to ATT and lastCommittedSlot respectively. - LivenessThresholdLowerBoundInSeconds uint16 `serix:"13,mapKey=livenessThresholdLowerBound"` + LivenessThresholdLowerBoundInSeconds uint16 `serix:"14,mapKey=livenessThresholdLowerBound"` // LivenessThresholdUpperBound is used by tip-selection to determine if a block is eligible by evaluating issuingTimes // and commitments in its past-cone to ATT and lastCommittedSlot respectively. - LivenessThresholdUpperBoundInSeconds uint16 `serix:"14,mapKey=livenessThresholdUpperBound"` + LivenessThresholdUpperBoundInSeconds uint16 `serix:"15,mapKey=livenessThresholdUpperBound"` // MinCommittableAge is the minimum age relative to the accepted tangle time slot index that a slot can be committed. // For example, if the last accepted slot is in slot 100, and minCommittableAge=10, then the latest committed slot can be at most 100-10=90. - MinCommittableAge SlotIndex `serix:"15,mapKey=minCommittableAge"` + MinCommittableAge SlotIndex `serix:"16,mapKey=minCommittableAge"` // MaxCommittableAge is the maximum age for a slot commitment to be included in a block relative to the slot index of the block issuing time. // For example, if the last accepted slot is in slot 100, and maxCommittableAge=20, then the oldest referencable commitment is 100-20=80. - MaxCommittableAge SlotIndex `serix:"16,mapKey=maxCommittableAge"` + MaxCommittableAge SlotIndex `serix:"17,mapKey=maxCommittableAge"` // EpochNearingThreshold is used by the epoch orchestrator to detect the slot that should trigger a new committee // selection for the next and upcoming epoch. - EpochNearingThreshold SlotIndex `serix:"17,mapKey=epochNearingThreshold"` + EpochNearingThreshold SlotIndex `serix:"18,mapKey=epochNearingThreshold"` // RMCParameters defines the parameters used by to calculate the Reference Mana Cost (RMC). - CongestionControlParameters CongestionControlParameters `serix:"18,mapKey=congestionControlParameters"` + CongestionControlParameters CongestionControlParameters `serix:"19,mapKey=congestionControlParameters"` // VersionSignaling defines the parameters used for version upgrades. - VersionSignaling VersionSignaling `serix:"19,mapKey=versionSignaling"` + VersionSignaling VersionSignaling `serix:"20,mapKey=versionSignaling"` // RewardsParameters defines the parameters used for reward calculation. - RewardsParameters RewardsParameters `serix:"20,mapKey=rewardsParameters"` + RewardsParameters RewardsParameters `serix:"21,mapKey=rewardsParameters"` } func (b basicProtocolParameters) Equals(other basicProtocolParameters) bool { @@ -66,6 +68,7 @@ func (b basicProtocolParameters) Equals(other basicProtocolParameters) bool { b.WorkScoreParameters.Equals(other.WorkScoreParameters) && b.ManaParameters.Equals(other.ManaParameters) && b.TokenSupply == other.TokenSupply && + b.GenesisSlot == other.GenesisSlot && b.GenesisUnixTimestamp == other.GenesisUnixTimestamp && b.SlotDurationInSeconds == other.SlotDurationInSeconds && b.SlotsPerEpochExponent == other.SlotsPerEpochExponent && diff --git a/api_test.go b/api_test.go index ae9e778d9..d1cd99d7a 100644 --- a/api_test.go +++ b/api_test.go @@ -100,6 +100,7 @@ func TestProtocolParametersJSONMarshalling(t *testing.T) { 10, ), iotago.WithTimeProviderOptions( + 654978, 1681373293, 10, 13, @@ -135,7 +136,7 @@ func TestProtocolParametersJSONMarshalling(t *testing.T) { iotago.WithRewardsOptions(8, 8, 31, 1154, 2, 1), ) - protoParamsJSON := `{"type":0,"version":3,"networkName":"xxxNetwork","bech32Hrp":"xxx","storageScoreParameters":{"storageCost":"6","factorData":7,"offsetOutputOverhead":"8","offsetEd25519BlockIssuerKey":"9","offsetStakingFeature":"10","offsetDelegation":"10"},"workScoreParameters":{"dataByte":1,"block":2,"input":3,"contextInput":4,"output":5,"nativeToken":6,"staking":7,"blockIssuer":8,"allotment":9,"signatureEd25519":10},"manaParameters":{"bitsCount":1,"generationRate":1,"generationRateExponent":27,"decayFactors":[10,20],"decayFactorsExponent":32,"decayFactorEpochsSum":1337,"decayFactorEpochsSumExponent":20},"tokenSupply":"1234567890987654321","genesisUnixTimestamp":"1681373293","slotDurationInSeconds":10,"slotsPerEpochExponent":13,"stakingUnbondingPeriod":11,"validationBlocksPerSlot":10,"punishmentEpochs":9,"livenessThresholdLowerBound":15,"livenessThresholdUpperBound":30,"minCommittableAge":10,"maxCommittableAge":20,"epochNearingThreshold":24,"congestionControlParameters":{"minReferenceManaCost":"500","increase":"500","decrease":"500","increaseThreshold":800000,"decreaseThreshold":500000,"schedulerRate":100000,"maxBufferSize":1000,"maxValidationBufferSize":100},"versionSignaling":{"windowSize":3,"windowTargetRatio":4,"activationOffset":1},"rewardsParameters":{"profitMarginExponent":8,"bootstrappingDuration":1154,"manaShareCoefficient":"2","decayBalancingConstantExponent":8,"decayBalancingConstant":"1","poolCoefficientExponent":31}}` + protoParamsJSON := `{"type":0,"version":3,"networkName":"xxxNetwork","bech32Hrp":"xxx","storageScoreParameters":{"storageCost":"6","factorData":7,"offsetOutputOverhead":"8","offsetEd25519BlockIssuerKey":"9","offsetStakingFeature":"10","offsetDelegation":"10"},"workScoreParameters":{"dataByte":1,"block":2,"input":3,"contextInput":4,"output":5,"nativeToken":6,"staking":7,"blockIssuer":8,"allotment":9,"signatureEd25519":10},"manaParameters":{"bitsCount":1,"generationRate":1,"generationRateExponent":27,"decayFactors":[10,20],"decayFactorsExponent":32,"decayFactorEpochsSum":1337,"decayFactorEpochsSumExponent":20},"tokenSupply":"1234567890987654321","genesisSlot":654978,"genesisUnixTimestamp":"1681373293","slotDurationInSeconds":10,"slotsPerEpochExponent":13,"stakingUnbondingPeriod":11,"validationBlocksPerSlot":10,"punishmentEpochs":9,"livenessThresholdLowerBound":15,"livenessThresholdUpperBound":30,"minCommittableAge":10,"maxCommittableAge":20,"epochNearingThreshold":24,"congestionControlParameters":{"minReferenceManaCost":"500","increase":"500","decrease":"500","increaseThreshold":800000,"decreaseThreshold":500000,"schedulerRate":100000,"maxBufferSize":1000,"maxValidationBufferSize":100},"versionSignaling":{"windowSize":3,"windowTargetRatio":4,"activationOffset":1},"rewardsParameters":{"profitMarginExponent":8,"bootstrappingDuration":1154,"manaShareCoefficient":"2","decayBalancingConstantExponent":8,"decayBalancingConstant":"1","poolCoefficientExponent":31}}` jsonProtoParams, err := tpkg.TestAPI.JSONEncode(protoParams) require.NoError(t, err) diff --git a/api_v3_protocol_parameters.go b/api_v3_protocol_parameters.go index 5e695916c..2b8864f8b 100644 --- a/api_v3_protocol_parameters.go +++ b/api_v3_protocol_parameters.go @@ -22,7 +22,7 @@ func NewV3ProtocolParameters(opts ...options.Option[V3ProtocolParameters]) *V3Pr WithNetworkOptions("testnet", PrefixTestnet), WithSupplyOptions(1813620509061365, 100, 1, 10, 100, 100, 100), WithWorkScoreOptions(0, 1, 0, 0, 0, 0, 0, 0, 0, 0), - WithTimeProviderOptions(time.Now().Unix(), 10, 13), + WithTimeProviderOptions(0, time.Now().Unix(), 10, 13), WithManaOptions(63, 1, 17, @@ -79,6 +79,11 @@ func (p *V3ProtocolParameters) NetworkID() NetworkID { return NetworkIDFromString(p.basicProtocolParameters.NetworkName) } +// GenesisUnixTimestamp defines the genesis timestamp at which the slots start to count. +func (p *V3ProtocolParameters) GenesisSlot() SlotIndex { + return p.basicProtocolParameters.GenesisSlot +} + // GenesisUnixTimestamp defines the genesis timestamp at which the slots start to count. func (p *V3ProtocolParameters) GenesisUnixTimestamp() int64 { return p.basicProtocolParameters.GenesisUnixTimestamp @@ -159,7 +164,7 @@ func (p *V3ProtocolParameters) Hash() (Identifier, error) { } func (p *V3ProtocolParameters) String() string { - return fmt.Sprintf("ProtocolParameters: {\n\tVersion: %d\n\tNetwork Name: %s\n\tBech32 HRP Prefix: %s\n\tStorageScore Structure: %v\n\tWorkScore Structure: %v\n\tMana Structure: %v\n\tToken Supply: %d\n\tGenesis Unix Timestamp: %d\n\tSlot Duration in Seconds: %d\n\tSlots per Epoch Exponent: %d\n\tStaking Unbonding Period: %d\n\tValidation Blocks per Slot: %d\n\tPunishment Epochs: %d\n\tLiveness Threshold Lower Bound: %d\n\tLiveness Threshold Upper Bound: %d\n\tMin Committable Age: %d\n\tMax Committable Age: %d\n\tEpoch Nearing Threshold: %d\n\tCongestion Control parameters: %v\n\tVersion Signaling: %v\n\tRewardsParameters: %v\n", + return fmt.Sprintf("ProtocolParameters: {\n\tVersion: %d\n\tNetwork Name: %s\n\tBech32 HRP Prefix: %s\n\tStorageScore Structure: %v\n\tWorkScore Structure: %v\n\tMana Structure: %v\n\tToken Supply: %d\n\tGenesis Slot: %d\n\tGenesis Unix Timestamp: %d\n\tSlot Duration in Seconds: %d\n\tSlots per Epoch Exponent: %d\n\tStaking Unbonding Period: %d\n\tValidation Blocks per Slot: %d\n\tPunishment Epochs: %d\n\tLiveness Threshold Lower Bound: %d\n\tLiveness Threshold Upper Bound: %d\n\tMin Committable Age: %d\n\tMax Committable Age: %d\n\tEpoch Nearing Threshold: %d\n\tCongestion Control parameters: %v\n\tVersion Signaling: %v\n\tRewardsParameters: %v\n", p.basicProtocolParameters.Version, p.basicProtocolParameters.NetworkName, p.basicProtocolParameters.Bech32HRP, @@ -167,6 +172,7 @@ func (p *V3ProtocolParameters) String() string { p.basicProtocolParameters.WorkScoreParameters, p.basicProtocolParameters.ManaParameters, p.basicProtocolParameters.TokenSupply, + p.basicProtocolParameters.GenesisSlot, p.basicProtocolParameters.GenesisUnixTimestamp, p.basicProtocolParameters.SlotDurationInSeconds, p.basicProtocolParameters.SlotsPerEpochExponent, @@ -260,8 +266,9 @@ func WithManaOptions(bitsCount uint8, generationRate uint8, generationRateExpone } } -func WithTimeProviderOptions(genesisTimestamp int64, slotDurationInSeconds uint8, slotsPerEpochExponent uint8) options.Option[V3ProtocolParameters] { +func WithTimeProviderOptions(genesisSlot SlotIndex, genesisTimestamp int64, slotDurationInSeconds uint8, slotsPerEpochExponent uint8) options.Option[V3ProtocolParameters] { return func(p *V3ProtocolParameters) { + p.basicProtocolParameters.GenesisSlot = genesisSlot p.basicProtocolParameters.GenesisUnixTimestamp = genesisTimestamp p.basicProtocolParameters.SlotDurationInSeconds = slotDurationInSeconds p.basicProtocolParameters.SlotsPerEpochExponent = slotsPerEpochExponent diff --git a/block_test.go b/block_test.go index 5c8bcbb9b..f99085681 100644 --- a/block_test.go +++ b/block_test.go @@ -154,7 +154,7 @@ func TestBlock_Commitments(t *testing.T) { apiProvider := api.NewEpochBasedProvider() apiProvider.AddProtocolParametersAtEpoch( iotago.NewV3ProtocolParameters( - iotago.WithTimeProviderOptions(time.Now().Add(-20*time.Minute).Unix(), 10, 13), + iotago.WithTimeProviderOptions(0, time.Now().Add(-20*time.Minute).Unix(), 10, 13), iotago.WithLivenessOptions(15, 30, 11, 21, 4), ), 0) @@ -174,7 +174,7 @@ func TestBlock_Commitments1(t *testing.T) { apiProvider := api.NewEpochBasedProvider() apiProvider.AddProtocolParametersAtEpoch( iotago.NewV3ProtocolParameters( - iotago.WithTimeProviderOptions(time.Now().Add(-20*time.Minute).Unix(), 10, 13), + iotago.WithTimeProviderOptions(0, time.Now().Add(-20*time.Minute).Unix(), 10, 13), iotago.WithLivenessOptions(15, 30, 7, 21, 4), ), 0) @@ -199,7 +199,7 @@ func TestBlock_TransactionCreationTime(t *testing.T) { apiProvider := api.NewEpochBasedProvider() apiProvider.AddProtocolParametersAtEpoch( iotago.NewV3ProtocolParameters( - iotago.WithTimeProviderOptions(time.Now().Add(-20*time.Minute).Unix(), 10, 13), + iotago.WithTimeProviderOptions(0, time.Now().Add(-20*time.Minute).Unix(), 10, 13), iotago.WithLivenessOptions(15, 30, 7, 21, 4), ), 0) @@ -266,7 +266,7 @@ func TestBlock_WeakParents(t *testing.T) { apiProvider := api.NewEpochBasedProvider() apiProvider.AddProtocolParametersAtEpoch( iotago.NewV3ProtocolParameters( - iotago.WithTimeProviderOptions(time.Now().Add(-20*time.Minute).Unix(), 10, 13), + iotago.WithTimeProviderOptions(0, time.Now().Add(-20*time.Minute).Unix(), 10, 13), iotago.WithLivenessOptions(15, 30, 10, 20, 4), ), 0) strongParent1 := tpkg.RandBlockID() @@ -325,7 +325,7 @@ func TestBlock_TransactionCommitmentInput(t *testing.T) { apiProvider := api.NewEpochBasedProvider() apiProvider.AddProtocolParametersAtEpoch( iotago.NewV3ProtocolParameters( - iotago.WithTimeProviderOptions(time.Now().Add(-20*time.Minute).Unix(), 10, 13), + iotago.WithTimeProviderOptions(0, time.Now().Add(-20*time.Minute).Unix(), 10, 13), iotago.WithLivenessOptions(15, 30, 11, 21, 4), ), 0) diff --git a/nodeclient/apimodels/core_test.go b/nodeclient/apimodels/core_test.go index 3f29911e0..23e9bf7e3 100644 --- a/nodeclient/apimodels/core_test.go +++ b/nodeclient/apimodels/core_test.go @@ -12,7 +12,7 @@ import ( func testAPI() iotago.API { params := iotago.NewV3ProtocolParameters( - iotago.WithTimeProviderOptions(time.Unix(1690879505, 0).UTC().Unix(), 10, 13), + iotago.WithTimeProviderOptions(65898, time.Unix(1690879505, 0).UTC().Unix(), 10, 13), ) return iotago.V3API(params) @@ -61,7 +61,7 @@ func Test_InfoResponse(t *testing.T) { jsonResponse, err := api.JSONEncode(response) require.NoError(t, err) - expected := `{"name":"test","version":"2.0.0","status":{"isHealthy":false,"acceptedTangleTime":"1690879505000000000","relativeAcceptedTangleTime":"1690879505000000000","confirmedTangleTime":"1690879505000000000","relativeConfirmedTangleTime":"1690879505000000000","latestCommitmentId":"0x000000000000000000000000000000000000000000000000000000000000000000000000","latestFinalizedSlot":1,"latestAcceptedBlockSlot":2,"latestConfirmedBlockSlot":3,"pruningEpoch":4},"metrics":{"blocksPerSecond":"1.1E+00","confirmedBlocksPerSecond":"2.2E+00","confirmationRate":"3.3E+00"},"protocolParameters":[{"startEpoch":0,"parameters":{"type":0,"version":3,"networkName":"testnet","bech32Hrp":"rms","storageScoreParameters":{"storageCost":"100","factorData":1,"offsetOutputOverhead":"10","offsetEd25519BlockIssuerKey":"100","offsetStakingFeature":"100","offsetDelegation":"100"},"workScoreParameters":{"dataByte":0,"block":1,"input":0,"contextInput":0,"output":0,"nativeToken":0,"staking":0,"blockIssuer":0,"allotment":0,"signatureEd25519":0},"manaParameters":{"bitsCount":63,"generationRate":1,"generationRateExponent":17,"decayFactors":[4291249941,4287535805,4283824883,4280117173,4276412671,4272711377,4269013285,4265318395,4261626702,4257938205,4254252900,4250570785,4246891856,4243216112,4239543550,4235874166,4232207957,4228544922,4224885058,4221228361,4217574829,4213924459,4210277249,4206633195,4202992295,4199354547,4195719947,4192088493,4188460182,4184835011,4181212978,4177594080,4173978314,4170365677,4166756168,4163149782,4159546518,4155946372,4152349343,4148755427,4145164621,4141576923,4137992331,4134410840,4130832450,4127257157,4123684959,4120115852,4116549834,4112986903,4109427055,4105870289,4102316601,4098765988,4095218449,4091673981,4088132580,4084594244,4081058971,4077526757,4073997601,4070471499,4066948449,4063428449,4059911495,4056397585,4052886716,4049378886,4045874092,4042372332,4038873602,4035377901,4031885225,4028395572,4024908939,4021425325,4017944725,4014467138,4010992560,4007520990,4004052425,4000586862,3997124298,3993664731,3990208159,3986754578,3983303986,3979856381,3976411760,3972970120,3969531459,3966095774,3962663063,3959233323,3955806551,3952382745,3948961903,3945544021,3942129098,3938717130,3935308116,3931902052,3928498936,3925098765,3921701537,3918307250,3914915900,3911527486,3908142004,3904759453,3901379829,3898003131,3894629355,3891258499,3887890560,3884525537,3881163426,3877804224,3874447931,3871094542,3867744056,3864396469,3861051780,3857709986,3854371084,3851035072,3847701948,3844371708,3841044351,3837719873,3834398273,3831079548,3827763695,3824450713,3821140597,3817833347,3814528959,3811227431,3807928760,3804632945,3801339982,3798049869,3794762604,3791478184,3788196607,3784917870,3781641970,3778368907,3775098676,3771831275,3768566702,3765304955,3762046031,3758789928,3755536643,3752286174,3749038518,3745793673,3742551636,3739312405,3736075978,3732842352,3729611525,3726383494,3723158258,3719935812,3716716156,3713499286,3710285201,3707073897,3703865373,3700659626,3697456653,3694256453,3691059023,3687864360,3684672462,3681483326,3678296951,3675113334,3671932472,3668754363,3665579005,3662406395,3659236531,3656069411,3652905032,3649743392,3646584488,3643428318,3640274880,3637124172,3633976190,3630830933,3627688398,3624548583,3621411486,3618277104,3615145434,3612016476,3608890225,3605766680,3602645839,3599527699,3596412257,3593299512,3590189461,3587082102,3583977433,3580875450,3577776153,3574679537,3571585602,3568494345,3565405764,3562319855,3559236618,3556156049,3553078146,3550002907,3546930330,3543860413,3540793152,3537728546,3534666593,3531607290,3528550634,3525496624,3522445258,3519396533,3516350446,3513306995,3510266179,3507227995,3504192440,3501159513,3498129210,3495101531,3492076472,3489054031,3486034206,3483016995,3480002395,3476990404,3473981020,3470974241,3467970065,3464968488,3461969510,3458973127,3455979337,3452988139,3449999530,3447013507,3444030069,3441049213,3438070937,3435095238,3432122115,3429151566,3426183587,3423218178,3420255335,3417295056,3414337339,3411382183,3408429584,3405479541,3402532051,3399587112,3396644722,3393704878,3390767579,3387832823,3384900606,3381970927,3379043784,3376119175,3373197097,3370277548,3367360525,3364446028,3361534053,3358624598,3355717662,3352813241,3349911335,3347011940,3344115054,3341220676,3338328803,3335439433,3332552563,3329668193,3326786318,3323906939,3321030051,3318155653,3315283743,3312414319,3309547378,3306682918,3303820938,3300961435,3298104407,3295249852,3292397767,3289548151,3286701001,3283856315,3281014092,3278174328,3275337023,3272502173,3269669777,3266839832,3264012336,3261187288,3258364685,3255544525,3252726806,3249911526,3247098682,3244288273,3241480296,3238674749,3235871631,3233070939,3230272671,3227476825,3224683399,3221892391,3219103798,3216317619,3213533851,3210752492,3207973541,3205196995,3202422853,3199651111,3196881768,3194114823,3191350272,3188588114,3185828346,3183070967,3180315975,3177563367,3174813142,3172065297,3169319830,3166576739,3163836023,3161097679,3158361705,3155628099,3152896859,3150167982,3147441468,3144717314,3141995517,3139276076,3136558989,3133844253,3131131867],"decayFactorsExponent":32,"decayFactorEpochsSum":2420916375,"decayFactorEpochsSumExponent":21},"tokenSupply":"1813620509061365","genesisUnixTimestamp":"1690879505","slotDurationInSeconds":10,"slotsPerEpochExponent":13,"stakingUnbondingPeriod":10,"validationBlocksPerSlot":10,"punishmentEpochs":10,"livenessThresholdLowerBound":15,"livenessThresholdUpperBound":30,"minCommittableAge":10,"maxCommittableAge":20,"epochNearingThreshold":24,"congestionControlParameters":{"minReferenceManaCost":"1","increase":"0","decrease":"0","increaseThreshold":800000,"decreaseThreshold":500000,"schedulerRate":100000,"maxBufferSize":1000,"maxValidationBufferSize":100},"versionSignaling":{"windowSize":7,"windowTargetRatio":5,"activationOffset":7},"rewardsParameters":{"profitMarginExponent":8,"bootstrappingDuration":1154,"manaShareCoefficient":"2","decayBalancingConstantExponent":8,"decayBalancingConstant":"1","poolCoefficientExponent":31}}}],"baseToken":{"name":"Shimmer","tickerSymbol":"SMR","unit":"SMR","subunit":"glow","decimals":6,"useMetricPrefix":false},"features":["test"]}` + expected := `{"name":"test","version":"2.0.0","status":{"isHealthy":false,"acceptedTangleTime":"1690879505000000000","relativeAcceptedTangleTime":"1690879505000000000","confirmedTangleTime":"1690879505000000000","relativeConfirmedTangleTime":"1690879505000000000","latestCommitmentId":"0x000000000000000000000000000000000000000000000000000000000000000000000000","latestFinalizedSlot":1,"latestAcceptedBlockSlot":2,"latestConfirmedBlockSlot":3,"pruningEpoch":4},"metrics":{"blocksPerSecond":"1.1E+00","confirmedBlocksPerSecond":"2.2E+00","confirmationRate":"3.3E+00"},"protocolParameters":[{"startEpoch":0,"parameters":{"type":0,"version":3,"networkName":"testnet","bech32Hrp":"rms","storageScoreParameters":{"storageCost":"100","factorData":1,"offsetOutputOverhead":"10","offsetEd25519BlockIssuerKey":"100","offsetStakingFeature":"100","offsetDelegation":"100"},"workScoreParameters":{"dataByte":0,"block":1,"input":0,"contextInput":0,"output":0,"nativeToken":0,"staking":0,"blockIssuer":0,"allotment":0,"signatureEd25519":0},"manaParameters":{"bitsCount":63,"generationRate":1,"generationRateExponent":17,"decayFactors":[4291249941,4287535805,4283824883,4280117173,4276412671,4272711377,4269013285,4265318395,4261626702,4257938205,4254252900,4250570785,4246891856,4243216112,4239543550,4235874166,4232207957,4228544922,4224885058,4221228361,4217574829,4213924459,4210277249,4206633195,4202992295,4199354547,4195719947,4192088493,4188460182,4184835011,4181212978,4177594080,4173978314,4170365677,4166756168,4163149782,4159546518,4155946372,4152349343,4148755427,4145164621,4141576923,4137992331,4134410840,4130832450,4127257157,4123684959,4120115852,4116549834,4112986903,4109427055,4105870289,4102316601,4098765988,4095218449,4091673981,4088132580,4084594244,4081058971,4077526757,4073997601,4070471499,4066948449,4063428449,4059911495,4056397585,4052886716,4049378886,4045874092,4042372332,4038873602,4035377901,4031885225,4028395572,4024908939,4021425325,4017944725,4014467138,4010992560,4007520990,4004052425,4000586862,3997124298,3993664731,3990208159,3986754578,3983303986,3979856381,3976411760,3972970120,3969531459,3966095774,3962663063,3959233323,3955806551,3952382745,3948961903,3945544021,3942129098,3938717130,3935308116,3931902052,3928498936,3925098765,3921701537,3918307250,3914915900,3911527486,3908142004,3904759453,3901379829,3898003131,3894629355,3891258499,3887890560,3884525537,3881163426,3877804224,3874447931,3871094542,3867744056,3864396469,3861051780,3857709986,3854371084,3851035072,3847701948,3844371708,3841044351,3837719873,3834398273,3831079548,3827763695,3824450713,3821140597,3817833347,3814528959,3811227431,3807928760,3804632945,3801339982,3798049869,3794762604,3791478184,3788196607,3784917870,3781641970,3778368907,3775098676,3771831275,3768566702,3765304955,3762046031,3758789928,3755536643,3752286174,3749038518,3745793673,3742551636,3739312405,3736075978,3732842352,3729611525,3726383494,3723158258,3719935812,3716716156,3713499286,3710285201,3707073897,3703865373,3700659626,3697456653,3694256453,3691059023,3687864360,3684672462,3681483326,3678296951,3675113334,3671932472,3668754363,3665579005,3662406395,3659236531,3656069411,3652905032,3649743392,3646584488,3643428318,3640274880,3637124172,3633976190,3630830933,3627688398,3624548583,3621411486,3618277104,3615145434,3612016476,3608890225,3605766680,3602645839,3599527699,3596412257,3593299512,3590189461,3587082102,3583977433,3580875450,3577776153,3574679537,3571585602,3568494345,3565405764,3562319855,3559236618,3556156049,3553078146,3550002907,3546930330,3543860413,3540793152,3537728546,3534666593,3531607290,3528550634,3525496624,3522445258,3519396533,3516350446,3513306995,3510266179,3507227995,3504192440,3501159513,3498129210,3495101531,3492076472,3489054031,3486034206,3483016995,3480002395,3476990404,3473981020,3470974241,3467970065,3464968488,3461969510,3458973127,3455979337,3452988139,3449999530,3447013507,3444030069,3441049213,3438070937,3435095238,3432122115,3429151566,3426183587,3423218178,3420255335,3417295056,3414337339,3411382183,3408429584,3405479541,3402532051,3399587112,3396644722,3393704878,3390767579,3387832823,3384900606,3381970927,3379043784,3376119175,3373197097,3370277548,3367360525,3364446028,3361534053,3358624598,3355717662,3352813241,3349911335,3347011940,3344115054,3341220676,3338328803,3335439433,3332552563,3329668193,3326786318,3323906939,3321030051,3318155653,3315283743,3312414319,3309547378,3306682918,3303820938,3300961435,3298104407,3295249852,3292397767,3289548151,3286701001,3283856315,3281014092,3278174328,3275337023,3272502173,3269669777,3266839832,3264012336,3261187288,3258364685,3255544525,3252726806,3249911526,3247098682,3244288273,3241480296,3238674749,3235871631,3233070939,3230272671,3227476825,3224683399,3221892391,3219103798,3216317619,3213533851,3210752492,3207973541,3205196995,3202422853,3199651111,3196881768,3194114823,3191350272,3188588114,3185828346,3183070967,3180315975,3177563367,3174813142,3172065297,3169319830,3166576739,3163836023,3161097679,3158361705,3155628099,3152896859,3150167982,3147441468,3144717314,3141995517,3139276076,3136558989,3133844253,3131131867],"decayFactorsExponent":32,"decayFactorEpochsSum":2420916375,"decayFactorEpochsSumExponent":21},"tokenSupply":"1813620509061365","genesisSlot":65898,"genesisUnixTimestamp":"1690879505","slotDurationInSeconds":10,"slotsPerEpochExponent":13,"stakingUnbondingPeriod":10,"validationBlocksPerSlot":10,"punishmentEpochs":10,"livenessThresholdLowerBound":15,"livenessThresholdUpperBound":30,"minCommittableAge":10,"maxCommittableAge":20,"epochNearingThreshold":24,"congestionControlParameters":{"minReferenceManaCost":"1","increase":"0","decrease":"0","increaseThreshold":800000,"decreaseThreshold":500000,"schedulerRate":100000,"maxBufferSize":1000,"maxValidationBufferSize":100},"versionSignaling":{"windowSize":7,"windowTargetRatio":5,"activationOffset":7},"rewardsParameters":{"profitMarginExponent":8,"bootstrappingDuration":1154,"manaShareCoefficient":"2","decayBalancingConstantExponent":8,"decayBalancingConstant":"1","poolCoefficientExponent":31}}}],"baseToken":{"name":"Shimmer","tickerSymbol":"SMR","unit":"SMR","subunit":"glow","decimals":6,"useMetricPrefix":false},"features":["test"]}` require.Equal(t, expected, string(jsonResponse)) decoded := new(apimodels.InfoResponse) diff --git a/tpkg/util.go b/tpkg/util.go index 9bee08455..14f743989 100644 --- a/tpkg/util.go +++ b/tpkg/util.go @@ -1058,7 +1058,7 @@ func RandProtocolParameters() iotago.ProtocolParameters { RandWorkScore(math.MaxUint32), RandWorkScore(math.MaxUint32), ), - iotago.WithTimeProviderOptions(time.Now().Unix(), RandUint8(math.MaxUint8), RandUint8(math.MaxUint8)), + iotago.WithTimeProviderOptions(RandSlot(), time.Now().Unix(), RandUint8(math.MaxUint8), RandUint8(math.MaxUint8)), iotago.WithLivenessOptions(RandUint16(math.MaxUint16), RandUint16(math.MaxUint16), RandSlot(), RandSlot(), RandSlot()), iotago.WithCongestionControlOptions( RandMana(iotago.MaxMana), diff --git a/vm/nova/vm_test.go b/vm/nova/vm_test.go index 73c74cfb5..0544199b9 100644 --- a/vm/nova/vm_test.go +++ b/vm/nova/vm_test.go @@ -41,7 +41,7 @@ var ( iotago.WithNetworkOptions("test", "test"), iotago.WithSupplyOptions(tpkg.TestTokenSupply, 100, 1, 10, 100, 100, 100), iotago.WithWorkScoreOptions(1, 100, 20, 20, 20, 20, 100, 100, 100, 200), - iotago.WithTimeProviderOptions(100, slotDurationSeconds, slotsPerEpochExponent), + iotago.WithTimeProviderOptions(0, 100, slotDurationSeconds, slotsPerEpochExponent), iotago.WithManaOptions(bitsCount, generationRate, generationRateExponent,