Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[future] Move core-1 vesting -> contracts #660

Closed
wants to merge 10 commits into from

Conversation

Reecepbcups
Copy link
Contributor

@Reecepbcups Reecepbcups commented May 3, 2023

Closes #648

POSTPONED While we put the SDK v47 upgrade as top priority.

NOTE: scrap most of this in favor of PR 725 approach in the future.

TODO:

  • get core-1 vest accounts
  • Test (locally)
  • Write e2e with modified genesis for initial vesting accounts (take from exports.reece.sh)
  • Remove Lobo from Core-1 subDAO

Flow:

  • Removes all delegations & redelegations + held balance & sends to subdao for each member
  • output how much each person had
  • send funds to core-1 subDao contract addr
  • init contract for each member (WIP)

@Reecepbcups Reecepbcups mentioned this pull request May 3, 2023
12 tasks
app/upgrades/v15/upgrades.go Fixed Show fixed Hide fixed
app/upgrades/v15/upgrades.go Fixed Show resolved Hide resolved
Comment on lines 106 to 161
for address, memberName := range vestingAccounts {
fmt.Println(address, memberName)

addr, err := sdk.AccAddressFromBech32(address)
if err != nil {
panic(err)
}

acc := keepers.AccountKeeper.GetAccount(ctx, addr)
if acc == nil {
panic("account not found")
}
// ensure this is a vesting account.

// Does this work for vesting accounts as well under the hood?
preVestedCoin := MoveVestingCoinFromVestingAccount(ctx, addr, keepers, core1SubDaoAddr)
fmt.Printf("moved %d ujuno from %s to %s\n", preVestedCoin.Amount.Int64(), address, core1SubDaoAddr)

// delete the old vesting base account
keepers.AccountKeeper.RemoveAccount(ctx, acc)

// Now funds are in Core-1 Subdao Control, and we can instantiate a vesting contract on behalf of the subdao for the amount stated

// start_time is NOT set as it is Optional. Sets when it is instantiated in nano seconds.
msg := fmt.Sprintf(`{"owner":"%s","recipient":"%s","title":"%s","description":"Core-1 Vesting","total":%d,"denom":{"native":"ujuno"}},"schedule":"saturating_linear","unbonding_duration_seconds":%d,"vesting_duration_seconds":%d}`,
core1SubDaoAddr,
address,
memberName,
preVestedCoin.Amount.Int64(),
junoUnbondingSeconds,
vestingDurationSeconds,
)

// set as label vest_to_juno1addr_1682213004408 where the ending is the current epoch time of prev block
// also pass through funds which must == total.

coins := []sdk.Coin{
sdk.NewCoin("ujuno", sdk.NewInt(preVestedCoin.Amount.Int64())),
}

// use wasmtypes.ContractOpsKeeper here instead of permissioned keeper? or does it matter since we are permissionless anyways
contractAddr, _, err := keepers.ContractKeeper.Instantiate(
ctx,
uint64(vestingCodeID),
sdk.MustAccAddressFromBech32(core1SubDaoAddr),
sdk.MustAccAddressFromBech32(core1SubDaoAddr),
[]byte(msg),
fmt.Sprintf("vest_to_%s_%d", address, currentUnixSeconds),
coins,
)
fmt.Println("Contract Created for:", contractAddr, address, memberName, "With ujuno Amount:", preVestedCoin.Amount.Int64())
if err != nil {
panic(err)
}

}

Check warning

Code scanning / CodeQL

Iteration over map

Iteration over map may be a possible source of non-determinism
@Reecepbcups
Copy link
Contributor Author

Archive, will do after v47 upgrade

@Reecepbcups Reecepbcups changed the title [v15] Move core-1 vesting -> contracts [future] Move core-1 vesting -> contracts May 10, 2023
@faddat
Copy link
Contributor

faddat commented Jun 17, 2023

note: the "changes" commit refers to changes after the merge. Attempted to make zero changes to the migration of c1 vesting -> contracts

@Reecepbcups
Copy link
Contributor Author

Reecepbcups commented Jul 3, 2023

Using new logic in PR 741

@Reecepbcups Reecepbcups closed this Jul 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrate core-1 SDK vesting -> contracts
2 participants