Skip to content

Commit

Permalink
Deal with contributors that lost their star1 private key (iov-one#298)
Browse files Browse the repository at this point in the history
* Add lostKeysWithStar1

* Fix `Should patch iovns-galaxynet.`

A test account for Cosmostation was added.

Co-authored-by: Dave Puchyr <dave@slim.avaritia.com>
  • Loading branch information
davepuchyr and Dave Puchyr authored Jul 31, 2020
1 parent 9c1b62d commit 96faca1
Show file tree
Hide file tree
Showing 2 changed files with 155 additions and 5 deletions.
34 changes: 30 additions & 4 deletions scripts/genesis/lib/migrate.js
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ export const patchMainnet = genesis => {
if ( genesis.chain_id != "iov-mainnet-2" ) throw new Error( `Wrong chain_id: ${genesis.chain_id} != iov-mainnet-2.` );

const custodian = genesis.app_state.auth.accounts.find( account => account["//id"] == "Custodian of missing star1 accounts" );
const lostKeys = { // lost keys/ledger firmware upgraded
const lostKeysInCustody = { // lost keys/ledger firmware upgraded
iov1jq8z8xl9tqdwjsp44gtkd2c5rpq33e556kg0ft: {
star1: "star1k9ktkefsdxtydga262re596agdklwjmrf9et90",
id: 2033,
Expand All @@ -668,12 +668,12 @@ export const patchMainnet = genesis => {
},
};

Object.keys( lostKeys ).forEach( iov1 => {
Object.keys( lostKeysInCustody ).forEach( iov1 => {
const recover = custodian[`//no star1 ${iov1}`];
const iov = recover[0];
const amount = 1.e6 * iov;
const address = lostKeys[iov1].star1;
const id = lostKeys[iov1].id;
const address = lostKeysInCustody[iov1].star1;
const id = lostKeysInCustody[iov1].id;
const [ name, domain ] = recover[1].split( "*" );

// remove custody of tokens
Expand All @@ -691,6 +691,32 @@ export const patchMainnet = genesis => {
genesis.app_state.auth.accounts.push( account );
} );

const lostKeysWithStar1 = { // lost keys after star1 address generation
iov1lfjspe4x5u404sskmv5md4q7u9jcz96zya8krw: {
star1: "star1lsk9ckth2s870kjqcyl6x5af7gazj6eg7msluq",
id: 2191,
},
iov1ja0syy203qncn28cqmz5zh9kh2xl0xxt36m4qx: {
star1: "star1f2jpr2guzq3y5yjv667axr26pl6qzyn2hzthfa",
id: 2192,
},
iov1axxtqae3x9jtvv7wavg6fnjgpc27dx7a9jlp9r: {
star1: "star1xnzwj34e8zefm7g7vtgnphfj6x2qgnq723rq0j",
id: 2193,
},
};

Object.keys( lostKeysWithStar1 ).forEach( iov1 => {
const account = genesis.app_state.auth.accounts.find( account => account["//iov1"] == iov1 );
const starname = genesis.app_state.starname.accounts.find( account => account["//iov1"] == iov1 );
const resource = starname.resources.find( resource => resource.uri.indexOf( ":iov" ) != -1 );
const star1 = lostKeysWithStar1[iov1].star1;

account.value.address = star1;
starname.owner = star1;
resource.resource = star1;
} );

const getAmount = account => {
return +account.value.coins[0];
};
Expand Down
126 changes: 125 additions & 1 deletion scripts/genesis/test/lib/migrate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1031,7 +1031,7 @@ describe( "Tests ../../lib/migrate.js.", () => {
const current = genesisCopy.app_state.auth.accounts;

expect( current.length ).not.toEqual( previous.length );
expect( current.length ).toEqual( 12 );
expect( current.length ).toEqual( 13 );

const antoine = current.find( account => account["//name"] == "antoine" );
const dave = current.find( account => account["//name"] == "dave*iov" );
Expand Down Expand Up @@ -1139,6 +1139,60 @@ describe( "Tests ../../lib/migrate.js.", () => {
"public_key": "",
"sequence": 0
}
},
{
"//id": 2191,
"//iov1": "iov1lfjspe4x5u404sskmv5md4q7u9jcz96zya8krw",
"type": "cosmos-sdk/Account",
"value": {
"account_number": "0",
"address": "star1alx5xdyws6hzeynewdzm4x5wg0v6tjl3wcq34g",
"coins": [
{
"//IOV": 49998,
"amount": "49998000000",
"denom": "uvoi"
}
],
"public_key": null,
"sequence": "0"
}
},
{
"//id": 2192,
"//iov1": "iov1ja0syy203qncn28cqmz5zh9kh2xl0xxt36m4qx",
"type": "cosmos-sdk/Account",
"value": {
"account_number": "0",
"address": "star16yqeeqp26h64rldcql7cpsz0zte7rwx9jc8s6x",
"coins": [
{
"//IOV": 22220,
"amount": "22220000000",
"denom": "uvoi"
}
],
"public_key": null,
"sequence": "0"
}
},
{
"//id": 2193,
"//iov1": "iov1axxtqae3x9jtvv7wavg6fnjgpc27dx7a9jlp9r",
"type": "cosmos-sdk/Account",
"value": {
"account_number": "0",
"address": "star1myg5g0uvsjdq20atrjv5t49ffflwz2m7d7u677",
"coins": [
{
"//IOV": 235925.5,
"amount": "235925500000",
"denom": "uvoi"
}
],
"public_key": null,
"sequence": "0"
}
} );
genesisCopy.app_state.starname.accounts.push( {
"//iov1": "iov14qk7zrz2ewhdmy7cjj68sk6jn3rst4vd7u930y",
Expand Down Expand Up @@ -1172,6 +1226,54 @@ describe( "Tests ../../lib/migrate.js.", () => {
"owner": "star1xc7tn8szhtvcat2k29t6072235gsqcrujd60wy",
"targets": null,
"valid_until": "1609415999"
},
{
"//iov1": "iov1axxtqae3x9jtvv7wavg6fnjgpc27dx7a9jlp9r",
"broker": null,
"certificates": null,
"domain": "iov",
"metadata_uri": "",
"name": "de26",
"owner": "star1myg5g0uvsjdq20atrjv5t49ffflwz2m7d7u677",
"resources": [
{
"resource": "star1myg5g0uvsjdq20atrjv5t49ffflwz2m7d7u677",
"uri": "asset:iov"
}
],
"valid_until": "1609415999"
},
{
"//iov1": "iov1lfjspe4x5u404sskmv5md4q7u9jcz96zya8krw",
"broker": null,
"certificates": null,
"domain": "iov",
"metadata_uri": "",
"name": "jean501",
"owner": "star1alx5xdyws6hzeynewdzm4x5wg0v6tjl3wcq34g",
"resources": [
{
"resource": "star1alx5xdyws6hzeynewdzm4x5wg0v6tjl3wcq34g",
"uri": "asset:iov"
}
],
"valid_until": "1609415999"
},
{
"//iov1": "iov1ja0syy203qncn28cqmz5zh9kh2xl0xxt36m4qx",
"broker": null,
"certificates": null,
"domain": "iov",
"metadata_uri": "",
"name": "mam",
"owner": "star16yqeeqp26h64rldcql7cpsz0zte7rwx9jc8s6x",
"resources": [
{
"resource": "star16yqeeqp26h64rldcql7cpsz0zte7rwx9jc8s6x",
"uri": "asset:iov"
}
],
"valid_until": "1609415999"
} );

const accounts0 = [].concat( genesisCopy.app_state.auth.accounts );
Expand All @@ -1183,6 +1285,7 @@ describe( "Tests ../../lib/migrate.js.", () => {
expect( genesisCopy.app_state.auth.accounts.length ).toEqual( accounts0.length + 3 ); // charlie, gilles, misang
expect( genesisCopy.app_state.starname.accounts.length ).toEqual( starnames0.length );

// lostKeysInCustody
const custodian = genesisCopy.app_state.auth.accounts.find( account => account["//id"] == "Custodian of missing star1 accounts" );
const charliefAmount = 700666 * 1e6;
const charliestar1 = "star1k9ktkefsdxtydga262re596agdklwjmrf9et90";
Expand All @@ -1204,6 +1307,27 @@ describe( "Tests ../../lib/migrate.js.", () => {
expect( gillesdiov ).toBeTruthy();
expect( misang.value.coins[0].amount ).toEqual( String( misangAmount ) );
expect( misangiov ).toBeTruthy();

// lostKeysWithStar1
const de26star1 = "star1xnzwj34e8zefm7g7vtgnphfj6x2qgnq723rq0j";
const de26 = genesisCopy.app_state.auth.accounts.find( account => account.value.address == de26star1 );
const de26iov = genesisCopy.app_state.starname.accounts.find( account => account.owner == de26star1 );
const jean501star1 = "star1lsk9ckth2s870kjqcyl6x5af7gazj6eg7msluq";
const jean501 = genesisCopy.app_state.auth.accounts.find( account => account.value.address == jean501star1 );
const jean501iov = genesisCopy.app_state.starname.accounts.find( account => account.owner == jean501star1 );
const mamstar1 = "star1f2jpr2guzq3y5yjv667axr26pl6qzyn2hzthfa";
const mam = genesisCopy.app_state.auth.accounts.find( account => account.value.address == mamstar1 );
const mamiov = genesisCopy.app_state.starname.accounts.find( account => account.owner == mamstar1 );

expect( de26 ).toBeTruthy();
expect( de26iov.name ).toEqual( "de26" );
expect( de26iov.resources[0].resource ).toEqual( de26star1 );
expect( jean501 ).toBeTruthy();
expect( jean501iov.name ).toEqual( "jean501" );
expect( jean501iov.resources[0].resource ).toEqual( jean501star1 );
expect( mam ).toBeTruthy();
expect( mamiov.name ).toEqual( "mam" );
expect( mamiov.resources[0].resource ).toEqual( mamstar1 );
} );

it( `Should migrate.`, async () => {
Expand Down

0 comments on commit 96faca1

Please sign in to comment.