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

Commit

Permalink
Merge pull request #171 from LiskHQ/update-lip-0063-migration
Browse files Browse the repository at this point in the history
Update LIP 0063 "Define mainnet configuration and migration for Lisk Core v4" with respect to the last module updates
  • Loading branch information
Oliver Beddows authored Sep 29, 2022
2 parents cfbafe6 + c7c3d96 commit f753a10
Showing 1 changed file with 39 additions and 29 deletions.
68 changes: 39 additions & 29 deletions proposals/lip-0063.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Discussions-To: https://research.lisk.com/t/define-mainnet-configuration-and-mig
Status: Draft
Type: Standards Track
Created: 2022-04-06
Updated: 2022-07-22
Updated: 2022-09-29
Requires: 0060
```

Expand Down Expand Up @@ -55,13 +55,13 @@ This value will be used for every delegate account in the snapshot block.
</td>
</tr>
<tr>
<td><code><a href="https://github.com/LiskHQ/lips/blob/main/proposals/lip-0051.md#constants-and-notations">TOKEN_ID_LSK_MAINCHAIN</a></code>
<td><code><a href="https://github.com/LiskHQ/lips/blob/main/proposals/lip-0051.md#constants-and-notations">TOKEN_ID_LSK</a></code>
</td>
<td>bytes
</td>
<td><code>0x 00 00 00 00 00 00 00 00</code>
</td>
<td>Token ID of the LSK token on mainchain.
<td>Token ID of the LSK token.
</td>
</tr>
<tr>
Expand All @@ -71,47 +71,57 @@ This value will be used for every delegate account in the snapshot block.
</td>
<td><code>0x 00 00 00 00</code>
</td>
<td>The local ID of the LSK token on mainchain.
<td>The local ID of the LSK token.
</td>
</tr>
<tr>
<td><code>MODULE_ID_DPOS</code>
<td><code>MAINCHAIN_ID</code>
</td>
<td>bytes
</td>
<td>TBD
<td><code>0x 00 00 00 00</code>
</td>
<td>Module ID of the <a href="https://github.com/LiskHQ/lips/blob/main/proposals/lip-0057.md">DPoS Module</a>.
<td>The chain ID of the mainchain.
</td>
</tr>
<tr>
<td><code>MODULE_ID_AUTH</code>
<td><code>MODULE_NAME_DPOS</code>
</td>
<td>bytes
<td>string
</td>
<td>TBD
<td>"dpos"
</td>
<td>Module ID of the <a href="https://github.com/LiskHQ/lips/blob/main/proposals/lip-0041.md">Auth Module</a>.
<td>Module name of the <a href="https://github.com/LiskHQ/lips/blob/main/proposals/lip-0057.md">DPoS Module</a>.
</td>
</tr>
<tr>
<td><code>MODULE_ID_TOKEN</code>
<td><code>MODULE_NAME_AUTH</code>
</td>
<td>bytes
<td>string
</td>
<td>TBD
<td>"auth"
</td>
<td>Module ID of the <a href="https://github.com/LiskHQ/lips/blob/main/proposals/lip-0051.md">Token Module</a>.
<td>Module name of the <a href="https://github.com/LiskHQ/lips/blob/main/proposals/lip-0041.md">Auth Module</a>.
</td>
</tr>
<tr>
<td><code>MODULE_ID_LEGACY</code>
<td><code>MODULE_NAME_TOKEN</code>
</td>
<td>bytes
<td>string
</td>
<td>TBD
<td>"token"
</td>
<td>Module name of the <a href="https://github.com/LiskHQ/lips/blob/main/proposals/lip-0051.md">Token Module</a>.
</td>
</tr>
<tr>
<td><code>MODULE_NAME_LEGACY</code>
</td>
<td>string
</td>
<td>"legacy"
</td>
<td>Module ID of the <a href="https://github.com/LiskHQ/lips/blob/main/proposals/lip-0050.md">Legacy Module</a>.
<td>Module name of the <a href="https://github.com/LiskHQ/lips/blob/main/proposals/lip-0050.md">Legacy Module</a>.
</td>
</tr>
<tr>
Expand Down Expand Up @@ -351,7 +361,7 @@ def addLegacyModuleEntry():
userObj.balance = account.token.balance
legacyObj.accounts.append(userObj)
data = serialization of legacyObj using genesisLegacyStoreSchema
append {"moduleID": MODULE_ID_LEGACY, "data": data} to b.assets
append {"module": MODULE_NAME_LEGACY, "data": data} to b.assets
```

###### Assets Entry for Token Module
Expand All @@ -369,15 +379,15 @@ def addTokenModuleEntry():
# Where the function nextLexicographicalOrder returns the next byte value, in lexicographical order
# this is equivalent to doing localID + 1 if the byte value is viewed as a big endian integer.
data = serialization of tokenObj using genesisTokenStoreSchema
append {"moduleID": MODULE_ID_TOKEN, "data": data} to b.assets
append {"module": MODULE_NAME_TOKEN, "data": data} to b.assets

def createUserSubstoreArray():
userSubstore = []
for every account in accounts:
if account.address != ADDRESS_LEGACY_RESERVE:
userObj = {}
userObj.address = account.address
userObj.tokenID = TOKEN_ID_LSK_MAINCHAIN
userObj.tokenID = TOKEN_ID_LSK
userObj.availableBalance = account.token.balance
userObj.lockedBalances = getLockedBalances(account)
userSubstore.append(userObj)
Expand All @@ -391,13 +401,13 @@ def createLegacyReserveAccount():
isEmpty = legacyReserveAmount is empty
legacyReserve = {}
legacyReserve.address = ADDRESS_LEGACY_RESERVE
legacyReserve.tokenID = TOKEN_ID_LSK_MAINCHAIN
legacyReserve.tokenID = TOKEN_ID_LSK
legacyReserve.availableBalance = isEmpty ? 0 : legacyReserveAccount.token.balance
legacyReserveAmount = 0
for every account in legacyAccounts:
legacyReserveAmount += account.token.balance
lockedBalances = isEmpty ? [] : getLockedBalances(legacyReserveAccount)
legacyReserve.lockedBalances = lockedBalances.append({"moduleID": MODULE_ID_LEGACY, "amount": legacyReserveAmount})
legacyReserve.lockedBalances = lockedBalances.append({"module": MODULE_NAME_LEGACY, "amount": legacyReserveAmount})
return legacyReserve

def getLockedBalances(account):
Expand All @@ -407,7 +417,7 @@ def getLockedBalances(account):
for unlockingObj in account.dpos.unlocking:
amount += unlockingObj.amount
if amount > 0:
return [{"moduleID": MODULE_ID_DPOS, "amount": amount}]
return [{"module": MODULE_NAME_DPOS, "amount": amount}]
else:
return []

Expand All @@ -418,7 +428,7 @@ def createSupplySubstoreArray():
lockedBalances = getLockedBalances(account)
if lockedBalances is not empty:
totalLSKSupply += lockedBalances[0].amount
LSKSupply = {"localID": LOCAL_ID_LSK, "totalSupply": totalLSKSupply}
LSKSupply = {"tokenID": TOKEN_ID_LSK, "totalSupply": totalLSKSupply}
return [LSKSupply]
```

Expand All @@ -436,10 +446,10 @@ def addAuthModuleEntry():
authObj.mandatoryKeys = account.keys.mandatoryKeys.sort()
authObj.optionalKeys = account.keys.optionalKeys.sort()
authObj.nonce = account.sequence.nonce
entry = {address: account.address, authAccount: authObj}
entry = {"address": account.address, "authAccount": authObj}
authDataSubstore.append(entry)
data = serialization of authDataSubstore using genesisAuthStoreSchema
append {"moduleID": MODULE_ID_AUTH, "data": data} to b.assets
append {"module": MODULE_NAME_AUTH, "data": data} to b.assets
```

###### Assets Entry for DPoS Module
Expand All @@ -454,7 +464,7 @@ def addDPoSModuleEntry():
DPoSObj.snapshots = []
DPoSObj.genesisData = createGenesisDataObj()
data = serialization of DPoSObj using genesisDPoSStoreSchema
append {"moduleID": MODULE_ID_DPOS, "data": data} to b.assets
append {"module": MODULE_NAME_DPOS, "data": data} to b.assets

def createValidatorsArray():
validators = []
Expand Down

0 comments on commit f753a10

Please sign in to comment.