Skip to content

Commit

Permalink
Merge pull request ethereum#260 from dinhln89/genesis
Browse files Browse the repository at this point in the history
Add MultisigWallet to puppeth for build new genesis.
  • Loading branch information
thanhson1085 authored Nov 6, 2018
2 parents 86314fe + 2afd4bf commit 8f4fc42
Show file tree
Hide file tree
Showing 14 changed files with 2,401 additions and 15 deletions.
48 changes: 47 additions & 1 deletion cmd/puppeth/wizard_genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/accounts/abi/bind/backends"
blockSignerContract "github.com/ethereum/go-ethereum/contracts/blocksigner"
multiSignWalletContract "github.com/ethereum/go-ethereum/contracts/multisigwallet"
randomizeContract "github.com/ethereum/go-ethereum/contracts/randomize"
validatorContract "github.com/ethereum/go-ethereum/contracts/validator"
"github.com/ethereum/go-ethereum/crypto"
Expand Down Expand Up @@ -171,7 +172,7 @@ func (w *wizard) makeGenesis() {

fmt.Println()
fmt.Println("What is foundation wallet address? (default = 0x0000000000000000000000000000000000000068)")
genesis.Config.Posv.FoudationWalletAddr = w.readDefaultAddress(common.HexToAddress("0x0000000000000000000000000000000000000068"))
genesis.Config.Posv.FoudationWalletAddr = w.readDefaultAddress(common.HexToAddress(common.FoudationAddr))

// Validator Smart Contract Code
pKey, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
Expand Down Expand Up @@ -205,6 +206,37 @@ func (w *wizard) makeGenesis() {
Storage: storage,
}

fmt.Println()
fmt.Println("Which accounts are allowed to confirm in MultiSignWallet?")
var owners []common.Address
for {
if address := w.readAddress(); address != nil {
owners = append(owners, *address)
continue
}
if len(owners) > 0 {
break
}
}
fmt.Println()
fmt.Println("How many require for confirm tx in MultiSignWallet? (default = 2)")
required := int64(w.readDefaultInt(2))

// MultiSigWallet.
multiSignWalletAddr, _, err := multiSignWalletContract.DeployMultiSigWallet(transactOpts, contractBackend, owners, big.NewInt(required))
if err != nil {
fmt.Println("Can't deploy MultiSignWallet SMC")
}
contractBackend.Commit()
code, _ = contractBackend.CodeAt(ctx, multiSignWalletAddr, nil)
storage = make(map[common.Hash]common.Hash)
contractBackend.ForEachStorageAt(ctx, multiSignWalletAddr, nil, f)
genesis.Alloc[common.HexToAddress(common.FoudationAddr)] = core.GenesisAccount{
Balance: big.NewInt(0),
Code: code,
Storage: storage,
}

// Block Signers Smart Contract
blockSignerAddress, _, err := blockSignerContract.DeployBlockSigner(transactOpts, contractBackend, big.NewInt(int64(epochNumber)))
if err != nil {
Expand Down Expand Up @@ -237,6 +269,20 @@ func (w *wizard) makeGenesis() {
Storage: storage,
}

fmt.Println()
fmt.Println("What is swap wallet address for fund 55m tomo?")
swapAddr := w.readDefaultAddress(common.HexToAddress(common.FoudationAddr))
baseBalance := big.NewInt(0) // 55m
baseBalance.Add(baseBalance, big.NewInt(55*1000*1000))
baseBalance.Mul(baseBalance, big.NewInt(1000000000000000000))
subBalance := big.NewInt(0) // 150k
subBalance.Add(subBalance, big.NewInt(150*1000))
subBalance.Mul(subBalance, big.NewInt(1000000000000000000))
baseBalance.Sub(baseBalance, subBalance) // 55m - 150k
genesis.Alloc[swapAddr] = core.GenesisAccount{
Balance: baseBalance,
}

default:
log.Crit("Invalid consensus engine choice", "choice", choice)
}
Expand Down
1 change: 1 addition & 0 deletions common/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const (
BlockSigners = "0x0000000000000000000000000000000000000089"
MasternodeVotingSMC = "0x0000000000000000000000000000000000000088"
RandomizeSMC = "0x0000000000000000000000000000000000000090"
FoudationAddr = "0x0000000000000000000000000000000000000068"
)

var (
Expand Down
Loading

0 comments on commit 8f4fc42

Please sign in to comment.