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

Commit 8f836ec

Browse files
committed
Implemented --hack-voting-accounts .. to steal ERC-20 accounts for testing.
Set a full schedule with a single `eosio` account.
1 parent 396c410 commit 8f836ec

File tree

4 files changed

+31
-28
lines changed

4 files changed

+31
-28
lines changed

bios/bios.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,12 @@ type BIOS struct {
2929
OverrideBootSequenceFile string
3030
Log *Logger
3131

32-
LaunchDisco *disco.Discovery
33-
TargetNetAPI *eos.API
34-
Snapshot Snapshot
35-
BootSequence []*OperationType
36-
WriteActions bool
32+
LaunchDisco *disco.Discovery
33+
TargetNetAPI *eos.API
34+
Snapshot Snapshot
35+
BootSequence []*OperationType
36+
WriteActions bool
37+
HackVotingAccounts bool
3738

3839
Genesis *GenesisJSON
3940

bios/ops.go

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,8 @@ func (op *OpSnapshotCreateAccounts) Actions(b *BIOS) (out []*eos.Action, err err
350350
return nil, fmt.Errorf("snapshot is empty or not loaded")
351351
}
352352

353+
wellKnownPubkey, _ := ecc.NewPublicKey("EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV")
354+
353355
for idx, hodler := range snapshotData {
354356
if trunc := op.TestnetTruncateSnapshot; trunc != 0 {
355357
if idx == trunc {
@@ -359,12 +361,16 @@ func (op *OpSnapshotCreateAccounts) Actions(b *BIOS) (out []*eos.Action, err err
359361
}
360362

361363
destAccount := AN(hodler.AccountName)
364+
destPubKey := hodler.EOSPublicKey
365+
if b.HackVotingAccounts {
366+
destPubKey = wellKnownPubkey
367+
}
362368

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

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

505511
//
506512

507-
type OpSetProds struct {
508-
IsMainnet bool
509-
}
513+
type OpSetProds struct{}
510514

511-
func (op *OpSetProds) ResetTestnetOptions() {
512-
op.IsMainnet = true
513-
}
515+
func (op *OpSetProds) ResetTestnetOptions() {}
514516

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

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

525-
if !op.IsMainnet {
526-
//prodkeys := []system.ProducerKey{}
527-
for idx, prod := range b.ShuffledProducers {
528-
if idx == 0 {
529-
continue
530-
}
531-
targetKey := prod.Discovery.TargetAppointedBlockProducerSigningKey
532-
targetAcct := prod.Discovery.TargetAccountName
533-
if targetAcct == AN("eosio") {
534-
targetKey = b.EphemeralPublicKey
535-
}
536-
prodkeys = append(prodkeys, system.ProducerKey{targetAcct, targetKey})
537-
if len(prodkeys) >= 21 {
538-
break
539-
}
527+
//prodkeys := []system.ProducerKey{}
528+
for idx, prod := range b.ShuffledProducers {
529+
if idx == 0 {
530+
continue
531+
}
532+
targetKey := prod.Discovery.TargetAppointedBlockProducerSigningKey
533+
targetAcct := prod.Discovery.TargetAccountName
534+
if targetAcct == AN("eosio") {
535+
targetKey = b.EphemeralPublicKey
536+
}
537+
prodkeys = append(prodkeys, system.ProducerKey{targetAcct, targetKey})
538+
if len(prodkeys) >= 21 {
539+
break
540540
}
541541
}
542542

eos-bios/cmd/common.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,5 +100,6 @@ func setupBIOS(net *bios.Network) (b *bios.BIOS, err error) {
100100

101101
b = bios.NewBIOS(net.Log, net, targetNetAPI)
102102
b.WriteActions = viper.GetBool("write-actions")
103+
b.HackVotingAccounts = viper.GetBool("hack-voting-accounts")
103104
return b, nil
104105
}

eos-bios/cmd/root.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,14 @@ func init() {
6666
RootCmd.PersistentFlags().StringP("seednet-keys", "", "./seed_network.keys", "File containing private keys to your account on the seed network")
6767
RootCmd.PersistentFlags().StringP("target-api", "", "", "HTTP address to reach the node you are starting (for injection and validation)")
6868
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.")
69+
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.")
6970

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

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

0 commit comments

Comments
 (0)