Skip to content

Commit

Permalink
make desired_pool_number optional as it does not make sense in byron
Browse files Browse the repository at this point in the history
  • Loading branch information
paweljakubas committed Jul 1, 2020
1 parent ce054d7 commit 8864a37
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 94 deletions.
2 changes: 2 additions & 0 deletions lib/byron/src/Cardano/Wallet/Byron/Compatibility.hs
Expand Up @@ -189,6 +189,7 @@ mainnetNetworkParameters = W.NetworkParameters
, getTxMaxSize =
Quantity 4096
}
, desiredNumberOfStakePools = Nothing
}
}

Expand Down Expand Up @@ -429,6 +430,7 @@ protocolParametersFromPP pp = W.ProtocolParameters
{ getFeePolicy = fromTxFeePolicy $ Update.ppTxFeePolicy pp
, getTxMaxSize = fromMaxTxSize $ Update.ppMaxTxSize pp
}
, desiredNumberOfStakePools = Nothing
}

-- | Extract the protocol parameters relevant to the wallet out of the
Expand Down
2 changes: 1 addition & 1 deletion lib/core/src/Cardano/Wallet/Api/Types.hs
Expand Up @@ -502,7 +502,7 @@ data ApiNetworkParameters = ApiNetworkParameters
, epochStability :: !(Quantity "block" Word32)
, activeSlotCoefficient :: !(Quantity "percent" Double)
, decentralizationLevel :: !(Quantity "percent" Percentage)
, desiredPoolNumber :: !Word16
, desiredPoolNumber :: !(Maybe Word16)
} deriving (Eq, Generic, Show)

toApiNetworkParameters :: NetworkParameters -> ApiNetworkParameters
Expand Down
10 changes: 5 additions & 5 deletions lib/core/src/Cardano/Wallet/DB/Sqlite/TH.hs
Expand Up @@ -147,11 +147,11 @@ Checkpoint
deriving Show Generic

ProtocolParameters
protocolParametersWalletId W.WalletId sql=wallet_id
protocolParametersFeePolicy W.FeePolicy sql=fee_policy
protocolParametersTxMaxSize Word16 sql=tx_max_size
protocolParametersDecentralizationLevel Percentage sql=decentralization_level
protocolParametersDesiredNumberOfPools Word16 sql=desired_pool_number
protocolParametersWalletId W.WalletId sql=wallet_id
protocolParametersFeePolicy W.FeePolicy sql=fee_policy
protocolParametersTxMaxSize Word16 sql=tx_max_size
protocolParametersDecentralizationLevel Percentage sql=decentralization_level
protocolParametersDesiredNumberOfPools Word16 Maybe sql=desired_pool_number
Primary protocolParametersWalletId
Foreign Wallet fk_wallet_protocol_parameters protocolParametersWalletId ! ON DELETE CASCADE
deriving Show Generic
Expand Down
4 changes: 2 additions & 2 deletions lib/core/src/Cardano/Wallet/Primitive/Types.hs
Expand Up @@ -1402,9 +1402,9 @@ data ProtocolParameters = ProtocolParameters
:: TxParameters
-- ^ Parameters that affect transaction construction.
, desiredNumberOfStakePools
:: Word16
:: Maybe Word16
-- ^ The current desired number of stakepools in the network.
-- Also known as k parameter.
-- Also known as k parameter. If specified has to be bigger than 0.
} deriving (Eq, Generic, Show)

instance NFData ProtocolParameters
Expand Down
158 changes: 77 additions & 81 deletions lib/core/test/data/Cardano/Wallet/Api/ApiNetworkParameters.json
@@ -1,253 +1,249 @@
{
"seed": 1783641201901976871,
"seed": 6501795791117850161,
"samples": [
{
"slot_length": {
"quantity": 4898,
"quantity": 2082,
"unit": "second"
},
"decentralization_level": {
"quantity": 5.85,
"quantity": 95.5,
"unit": "percent"
},
"epoch_stability": {
"quantity": 528,
"quantity": 28376,
"unit": "block"
},
"genesis_block_hash": "374ca035306ae5516835045e4b233b5971c9840127700f6d20752d4439024740",
"blockchain_start_time": "1869-05-07T07:10:00Z",
"desired_pool_number": 246,
"genesis_block_hash": "66c2793479f0671742231a03035f4f6e5355594a34546f57f050015714227c0b",
"blockchain_start_time": "1876-10-06T05:38:40.833248904705Z",
"epoch_length": {
"quantity": 20945,
"quantity": 5336,
"unit": "slot"
},
"active_slot_coefficient": {
"quantity": 94.55547664569349,
"quantity": 33.963623549260305,
"unit": "percent"
}
},
{
"slot_length": {
"quantity": 5803,
"quantity": 1187,
"unit": "second"
},
"decentralization_level": {
"quantity": 91.83,
"quantity": 88.02,
"unit": "percent"
},
"epoch_stability": {
"quantity": 15302,
"quantity": 11857,
"unit": "block"
},
"genesis_block_hash": "7d3cf56b896e087ddc6f2e793d77224f7c742ff065463a16bb4a6b437443327b",
"blockchain_start_time": "1880-03-03T09:00:00Z",
"desired_pool_number": 1332,
"genesis_block_hash": "39152a094036b807a21976b56030204d206d4348600c516d365c23581d1e1450",
"blockchain_start_time": "1880-09-11T07:00:00Z",
"epoch_length": {
"quantity": 14005,
"quantity": 22920,
"unit": "slot"
},
"active_slot_coefficient": {
"quantity": 29.678701480196924,
"quantity": 97.68438021439569,
"unit": "percent"
}
},
{
"slot_length": {
"quantity": 1210,
"quantity": 3950,
"unit": "second"
},
"decentralization_level": {
"quantity": 84.39,
"quantity": 85.42,
"unit": "percent"
},
"epoch_stability": {
"quantity": 24490,
"quantity": 30424,
"unit": "block"
},
"genesis_block_hash": "b2d75f565952443844295b853eb3045c0a1817366e5c2e293596093f4dd02854",
"blockchain_start_time": "1864-05-18T18:07:13.640068095679Z",
"desired_pool_number": 907,
"genesis_block_hash": "34286e96f677354d57147c5a0925b96e716f333f1b06440db95e7d846a083c7f",
"blockchain_start_time": "1891-11-26T02:07:13.105316497171Z",
"epoch_length": {
"quantity": 8497,
"quantity": 8507,
"unit": "slot"
},
"active_slot_coefficient": {
"quantity": 41.0009989127716,
"quantity": 50.100302778181586,
"unit": "percent"
}
},
{
"slot_length": {
"quantity": 4155,
"quantity": 7012,
"unit": "second"
},
"decentralization_level": {
"quantity": 25.84,
"quantity": 29.99,
"unit": "percent"
},
"epoch_stability": {
"quantity": 10252,
"quantity": 18641,
"unit": "block"
},
"genesis_block_hash": "5a59c67da96f38177509e8023306205a62ab3b504d0963532e1333380d113961",
"blockchain_start_time": "1901-10-16T12:05:49Z",
"desired_pool_number": 670,
"genesis_block_hash": "42242af27a39265835471e5826446a6e1bab1718e87d1c03440a322c29244e25",
"blockchain_start_time": "1875-10-26T09:59:54.477906634455Z",
"desired_pool_number": 1119,
"epoch_length": {
"quantity": 261,
"quantity": 11030,
"unit": "slot"
},
"active_slot_coefficient": {
"quantity": 58.28661284335994,
"quantity": 88.81357965738106,
"unit": "percent"
}
},
{
"slot_length": {
"quantity": 566,
"quantity": 912,
"unit": "second"
},
"decentralization_level": {
"quantity": 30.33,
"quantity": 12.03,
"unit": "percent"
},
"epoch_stability": {
"quantity": 472,
"quantity": 21744,
"unit": "block"
},
"genesis_block_hash": "24721c606c6919353377db135c08603f68ec495d0935502731ff8e4e1b5a0c4f",
"blockchain_start_time": "1866-03-22T03:01:21.729708338291Z",
"desired_pool_number": 24,
"genesis_block_hash": "503f460c43542c085b2e0c5e1760035b646b006821e82f5e1f4552d153675d58",
"blockchain_start_time": "1866-05-12T17:00:12Z",
"desired_pool_number": 1518,
"epoch_length": {
"quantity": 29237,
"quantity": 2915,
"unit": "slot"
},
"active_slot_coefficient": {
"quantity": 67.80354754258157,
"quantity": 93.33027763903885,
"unit": "percent"
}
},
{
"slot_length": {
"quantity": 5956,
"quantity": 5083,
"unit": "second"
},
"decentralization_level": {
"quantity": 21.87,
"quantity": 62.71,
"unit": "percent"
},
"epoch_stability": {
"quantity": 1687,
"quantity": 21660,
"unit": "block"
},
"genesis_block_hash": "ad31d660575c2504372e950862042a764b074b31da225d63fc4e4f7f43183e6a",
"blockchain_start_time": "1903-10-15T12:17:45.5065572951Z",
"desired_pool_number": 29,
"genesis_block_hash": "292e2d6bddbc1b657b673f4c2b017d690a061c4c5f383a3e3c551133cfc22058",
"blockchain_start_time": "1864-06-03T00:00:00Z",
"desired_pool_number": 1357,
"epoch_length": {
"quantity": 14271,
"quantity": 18333,
"unit": "slot"
},
"active_slot_coefficient": {
"quantity": 83.43727081721306,
"quantity": 23.341837917629405,
"unit": "percent"
}
},
{
"slot_length": {
"quantity": 3908,
"quantity": 3331,
"unit": "second"
},
"decentralization_level": {
"quantity": 48.46,
"quantity": 2.73,
"unit": "percent"
},
"epoch_stability": {
"quantity": 22186,
"quantity": 25628,
"unit": "block"
},
"genesis_block_hash": "b8be756e7f4d75045f02ed031170165a1376506432a0271a5d73583223091f36",
"blockchain_start_time": "1859-06-20T02:53:30.051677675312Z",
"desired_pool_number": 131,
"genesis_block_hash": "006b956740be6b25933cc6010d6661e46814705e760c7c0e07152b6280283d68",
"blockchain_start_time": "1898-02-06T10:05:05Z",
"desired_pool_number": 1148,
"epoch_length": {
"quantity": 26820,
"quantity": 21211,
"unit": "slot"
},
"active_slot_coefficient": {
"quantity": 99.86983178290603,
"quantity": 14.569490138736608,
"unit": "percent"
}
},
{
"slot_length": {
"quantity": 6162,
"quantity": 7132,
"unit": "second"
},
"decentralization_level": {
"quantity": 77.42,
"quantity": 73.55,
"unit": "percent"
},
"epoch_stability": {
"quantity": 3633,
"quantity": 19746,
"unit": "block"
},
"genesis_block_hash": "8dfb5e5d261e25785877564e1560c06b4f55207c5b160a4f054d51af1f00306d",
"blockchain_start_time": "1882-01-28T01:08:48Z",
"desired_pool_number": 1742,
"genesis_block_hash": "8d45f8067f50477137813f1a5107948c3f9e672e0fcf0775370f15053f7b6649",
"blockchain_start_time": "1860-12-09T05:00:00Z",
"desired_pool_number": 396,
"epoch_length": {
"quantity": 17463,
"quantity": 5265,
"unit": "slot"
},
"active_slot_coefficient": {
"quantity": 41.24160362212043,
"quantity": 56.77289414783849,
"unit": "percent"
}
},
{
"slot_length": {
"quantity": 7121,
"quantity": 1705,
"unit": "second"
},
"decentralization_level": {
"quantity": 64.87,
"quantity": 7.33,
"unit": "percent"
},
"epoch_stability": {
"quantity": 26035,
"quantity": 4135,
"unit": "block"
},
"genesis_block_hash": "645b5c3820a62a72190b397340498f2c15793c4d19234a692637d257d55f207f",
"blockchain_start_time": "1868-07-20T19:00:00Z",
"desired_pool_number": 1253,
"genesis_block_hash": "190b7a59614f0349383f3973156f0e6644eb0a791b495dea8b3527905d9d6a4a",
"blockchain_start_time": "1899-05-09T10:40:44.56590500803Z",
"epoch_length": {
"quantity": 22546,
"quantity": 8066,
"unit": "slot"
},
"active_slot_coefficient": {
"quantity": 75.4233809757601,
"quantity": 88.4364008357964,
"unit": "percent"
}
},
{
"slot_length": {
"quantity": 5096,
"quantity": 6749,
"unit": "second"
},
"decentralization_level": {
"quantity": 16.74,
"quantity": 77.28,
"unit": "percent"
},
"epoch_stability": {
"quantity": 29252,
"quantity": 23699,
"unit": "block"
},
"genesis_block_hash": "42612d053e2a9b1e6d122e74223c65015f7342432f7960137e75271a2a537d1d",
"blockchain_start_time": "1907-03-24T21:54:55.587984051255Z",
"desired_pool_number": 1873,
"genesis_block_hash": "de10370b086e7d3e4733205561457b57006a2a0e632c9c78b44b32435d6e4951",
"blockchain_start_time": "1900-07-06T08:14:59.595751126258Z",
"desired_pool_number": 1604,
"epoch_length": {
"quantity": 28293,
"quantity": 7038,
"unit": "slot"
},
"active_slot_coefficient": {
"quantity": 91.91285590796747,
"quantity": 48.378902424719584,
"unit": "percent"
}
}
Expand Down
Expand Up @@ -98,7 +98,7 @@ dummyProtocolParameters :: ProtocolParameters
dummyProtocolParameters = ProtocolParameters
{ decentralizationLevel = minBound
, txParameters = dummyTxParameters
, desiredNumberOfStakePools = 100
, desiredNumberOfStakePools = Just 100
}

-- | Construct a @Tx@, computing its hash using the dummy @mkTxId@.
Expand Down

0 comments on commit 8864a37

Please sign in to comment.