Skip to content
This repository has been archived by the owner on Mar 5, 2020. It is now read-only.

Commit

Permalink
Implemented --hack-voting-accounts .. to steal ERC-20 accounts for te…
Browse files Browse the repository at this point in the history
…sting.

Set a full schedule with a single `eosio` account.
  • Loading branch information
abourget committed Jun 2, 2018
1 parent 396c410 commit 8f836ec
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 28 deletions.
11 changes: 6 additions & 5 deletions bios/bios.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ type BIOS struct {
OverrideBootSequenceFile string
Log *Logger

LaunchDisco *disco.Discovery
TargetNetAPI *eos.API
Snapshot Snapshot
BootSequence []*OperationType
WriteActions bool
LaunchDisco *disco.Discovery
TargetNetAPI *eos.API
Snapshot Snapshot
BootSequence []*OperationType
WriteActions bool
HackVotingAccounts bool

Genesis *GenesisJSON

Expand Down
44 changes: 22 additions & 22 deletions bios/ops.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,8 @@ func (op *OpSnapshotCreateAccounts) Actions(b *BIOS) (out []*eos.Action, err err
return nil, fmt.Errorf("snapshot is empty or not loaded")
}

wellKnownPubkey, _ := ecc.NewPublicKey("EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV")

for idx, hodler := range snapshotData {
if trunc := op.TestnetTruncateSnapshot; trunc != 0 {
if idx == trunc {
Expand All @@ -359,12 +361,16 @@ func (op *OpSnapshotCreateAccounts) Actions(b *BIOS) (out []*eos.Action, err err
}

destAccount := AN(hodler.AccountName)
destPubKey := hodler.EOSPublicKey
if b.HackVotingAccounts {
destPubKey = wellKnownPubkey
}

// we should have created the account before loading `eosio.system`, otherwise
// b1 wouldn't have been accepted.
if hodler.EthereumAddress != "0x00000000000000000000000000000000000000b1" {
// create all other accounts, but not `b1`.. because it's a short name..
out = append(out, system.NewNewAccount(AN("eosio"), destAccount, hodler.EOSPublicKey))
out = append(out, system.NewNewAccount(AN("eosio"), destAccount, destPubKey))
}

cpuStake, netStake := splitSnapshotStakes(hodler.Balance)
Expand Down Expand Up @@ -504,13 +510,9 @@ func (op *OpInjectUnregdSnapshot) Actions(b *BIOS) (out []*eos.Action, err error

//

type OpSetProds struct {
IsMainnet bool
}
type OpSetProds struct{}

func (op *OpSetProds) ResetTestnetOptions() {
op.IsMainnet = true
}
func (op *OpSetProds) ResetTestnetOptions() {}

func (op *OpSetProds) Actions(b *BIOS) (out []*eos.Action, err error) {
// We he can at least process the last few blocks, that wrap up
Expand All @@ -522,21 +524,19 @@ func (op *OpSetProds) Actions(b *BIOS) (out []*eos.Action, err error) {

// WARN: this makes it a SOLO producer on mainnet.

if !op.IsMainnet {
//prodkeys := []system.ProducerKey{}
for idx, prod := range b.ShuffledProducers {
if idx == 0 {
continue
}
targetKey := prod.Discovery.TargetAppointedBlockProducerSigningKey
targetAcct := prod.Discovery.TargetAccountName
if targetAcct == AN("eosio") {
targetKey = b.EphemeralPublicKey
}
prodkeys = append(prodkeys, system.ProducerKey{targetAcct, targetKey})
if len(prodkeys) >= 21 {
break
}
//prodkeys := []system.ProducerKey{}
for idx, prod := range b.ShuffledProducers {
if idx == 0 {
continue
}
targetKey := prod.Discovery.TargetAppointedBlockProducerSigningKey
targetAcct := prod.Discovery.TargetAccountName
if targetAcct == AN("eosio") {
targetKey = b.EphemeralPublicKey
}
prodkeys = append(prodkeys, system.ProducerKey{targetAcct, targetKey})
if len(prodkeys) >= 21 {
break
}
}

Expand Down
1 change: 1 addition & 0 deletions eos-bios/cmd/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,5 +100,6 @@ func setupBIOS(net *bios.Network) (b *bios.BIOS, err error) {

b = bios.NewBIOS(net.Log, net, targetNetAPI)
b.WriteActions = viper.GetBool("write-actions")
b.HackVotingAccounts = viper.GetBool("hack-voting-accounts")
return b, nil
}
3 changes: 2 additions & 1 deletion eos-bios/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,14 @@ func init() {
RootCmd.PersistentFlags().StringP("seednet-keys", "", "./seed_network.keys", "File containing private keys to your account on the seed network")
RootCmd.PersistentFlags().StringP("target-api", "", "", "HTTP address to reach the node you are starting (for injection and validation)")
RootCmd.PersistentFlags().BoolP("fast-inject", "", false, "Inject the boot sequence assuming an HTTP/1.1 API endpoint (nodeos does only 1.0 and closes connections). You can use that if you front your nodeos node with some reverse proxy.")
RootCmd.PersistentFlags().BoolP("hack-voting-accounts", "", false, "This will take accounts with large stakes and put a well known public key in place, so the community can test voting.")

RootCmd.PersistentFlags().BoolP("write-actions", "", false, "Write actions to actions.jsonl upon join or boot")
RootCmd.PersistentFlags().StringP("cache-path", "", filepath.Join(homedir, ".eos-bios-cache"), "directory to store cached data from discovered network")
RootCmd.PersistentFlags().BoolP("verbose", "v", false, "Display verbose output (also see 'output.log')")
RootCmd.PersistentFlags().String("elect", "", "Force the election of the given BIOS Boot node")

for _, flag := range []string{"cache-path", "my-discovery", "ipfs", "seednet-keys", "write-actions", "seednet-api", "target-api", "verbose", "elect", "fast-inject"} {
for _, flag := range []string{"cache-path", "my-discovery", "ipfs", "seednet-keys", "write-actions", "seednet-api", "target-api", "verbose", "elect", "fast-inject", "hack-voting-accounts"} {
if err := viper.BindPFlag(flag, RootCmd.PersistentFlags().Lookup(flag)); err != nil {
panic(err)
}
Expand Down

0 comments on commit 8f836ec

Please sign in to comment.