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

Commit

Permalink
Added the system.setram operation, not yet used though.
Browse files Browse the repository at this point in the history
Updated base_config.ini to reflect new default file by
eosio
  • Loading branch information
abourget committed May 14, 2018
1 parent 6f33041 commit 9ffdfda
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 45 deletions.
10 changes: 8 additions & 2 deletions bios/bios.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,15 @@ func (b *BIOS) RunBootSequence() error {

if len(acts) != 0 {
for idx, chunk := range chunkifyActions(acts, 400) { // transfers max out resources higher than ~400
_, err = b.TargetNetAPI.SignPushActions(chunk...)
err := retry(5, 500*time.Millisecond, func() error {
_, err = b.TargetNetAPI.SignPushActions(chunk...)
if err != nil {
return fmt.Errorf("SignPushActions for step %q, chunk %d: %s", step.Op, idx, err)
}
return nil
})
if err != nil {
return fmt.Errorf("SignPushActions for step %q, chunk %d: %s", step.Op, idx, err)
return err
}
}
}
Expand Down
46 changes: 29 additions & 17 deletions bios/ops.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,24 @@ import (
"github.com/eoscanada/eos-go/token"
)

type Operation interface {
Actions(b *BIOS) ([]*eos.Action, error)
ResetTestnetOptions() // TODO: implement the DISABLING of all testnet options when `mainnet` is voted in the `discovery`.
}

var operationsRegistry = map[string]Operation{
"system.setcode": &OpSetCode{},
"system.setram": &OpSetRAM{},
"system.newaccount": &OpNewAccount{},
"system.setpriv": &OpSetPriv{},
"token.create": &OpCreateToken{},
"token.issue": &OpIssueToken{},
"producers.create_accounts": &OpCreateProducers{},
"system.setprods": &OpSetProds{},
"snapshot.inject": &OpInjectSnapshot{},
"system.destroy_accounts": &OpDestroyAccounts{},
}

type OperationType struct {
Op string
Label string
Expand Down Expand Up @@ -58,23 +76,6 @@ func (o *OperationType) UnmarshalJSON(data []byte) error {
return nil
}

type Operation interface {
Actions(b *BIOS) ([]*eos.Action, error)
ResetTestnetOptions() // TODO: implement the DISABLING of all testnet options when `mainnet` is voted in the `discovery`.
}

var operationsRegistry = map[string]Operation{
"system.setcode": &OpSetCode{},
"system.newaccount": &OpNewAccount{},
"system.setpriv": &OpSetPriv{},
"token.create": &OpCreateToken{},
"token.issue": &OpIssueToken{},
"producers.create_accounts": &OpCreateProducers{},
"system.setprods": &OpSetProds{},
"snapshot.inject": &OpInjectSnapshot{},
"system.destroy_accounts": &OpDestroyAccounts{},
}

//

type OpSetCode struct {
Expand Down Expand Up @@ -107,6 +108,17 @@ func (op *OpSetCode) Actions(b *BIOS) ([]*eos.Action, error) {

//

type OpSetRAM struct {
MaxRAMSize uint64 `json:"max_ram_size"`
}

func (op *OpSetRAM) ResetTestnetOptions() { return }
func (op *OpSetRAM) Actions(b *BIOS) (out []*eos.Action, err error) {
return append(out, system.NewSetRAM(op.MaxRAMSize)), nil
}

//

type OpNewAccount struct {
Creator eos.AccountName
NewAccount eos.AccountName `json:"new_account"`
Expand Down
21 changes: 21 additions & 0 deletions bios/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ package bios
import (
"bufio"
"encoding/binary"
"fmt"
"log"
"os"
"strings"
"time"

eos "github.com/eoscanada/eos-go"
)
Expand Down Expand Up @@ -44,3 +47,21 @@ func flipEndianness(in uint64) (out uint64) {
binary.LittleEndian.PutUint64(buf, in)
return binary.BigEndian.Uint64(buf)
}

func retry(attempts int, sleep time.Duration, callback func() error) (err error) {
for i := 0; ; i++ {
err = callback()
if err == nil {
return
}

if i >= (attempts - 1) {
break
}

time.Sleep(sleep)

log.Println("retrying after error:", err)
}
return fmt.Errorf("after %d attempts, last error: %s", attempts, err)
}
71 changes: 45 additions & 26 deletions sample_config/base_config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,20 @@ block-log-dir = "blocks"
# Pairs of [BLOCK_NUM,BLOCK_ID] that should be enforced as checkpoints.
# checkpoint =

# open the database in read only mode
readonly = 0

# the location of the chain shared memory files (absolute path or relative to application data dir)
shared-file-dir = "blockchain"

# Minimum size MB of database shared memory file
shared-file-size = 8192
# Maximum size MB of database shared memory file (eosio::chain_plugin)
shared-memory-size-mb = 1024

# The local IP and port to listen for incoming http connections.
http-server-address = 0.0.0.0:8888

# Tuple of [PublicKey, WIF private key] (may specify multiple times)
# peer-private-key =
# Log level: one of 'all', 'debug', 'info', 'warn', 'error', or 'off'
log-level-net-plugin = info
# The local IP and port to listen for incoming https connections; leave blank to disable. (eosio::http_plugin)
# https-server-address =

# The name supplied to identify this node amongst the peers.
agent-name = "EOS BIOS Agent"
# Filename with the certificate chain to present on https connections. PEM format. Required for https. (eosio::http_plugin)
# https-certificate-chain-file =

# True to always send full blocks, false to send block summaries
send-whole-blocks = 1
# Filename with https private key in PEM format. Required for https (eosio::http_plugin)
# https-private-key-file =

# The Access-Control-Allow-Origin http value
# access-control-allow-origin = *
Expand All @@ -37,32 +29,59 @@ send-whole-blocks = 1
# access-control-allow-headers = Content-Type

# true if Access-Control-Allow-Credentials: true should be specified in http response header
# access-control-allow-credentials = true
access-control-allow-credentials = false

# The local IP address and port to listen for incoming connections.
p2p-listen-endpoint = 0.0.0.0:9876

# The IP address and port of a remote peer to sync with.
# remote-endpoint =
# An externally accessible host:port for identifying this node. Defaults to p2p-listen-endpoint. (eosio::net_plugin)
p2p-server-address = reach.me.example.com:9876

# The public IP address and port that should be advertized to peers.
p2p-server-address = 0.0.0.0:9876
# The public endpoint of a peer node to connect to. Use multiple p2p-peer-address options as needed to compose a network. (eosio::net_plugin)
# p2p-peer-address =

# True to require exact match of peer network version.
network-version-match = 0
# Log level: one of 'all', 'debug', 'info', 'warn', 'error', or 'off'
log-level-net-plugin = info

# The name supplied to identify this node amongst the peers.
agent-name = "EOS Example"

# Can be 'any' or 'producers' or 'specified' or 'none'. If 'specified', peer-key must be specified at least once. If only 'producers', peer-key is not required. 'producers' and 'specified' may be combined. (eosio::net_plugin)
allowed-connection = any

# Optional public key of peer allowed to connect. May be used multiple times. (eosio::net_plugin)
# peer-key =

# Tuple of [PublicKey, WIF private key] (may specify multiple times) (eosio::net_plugin)
# peer-private-key =

# Maximum number of clients from which connections are accepted, use 0 for no limit (eosio::net_plugin)
max-clients = 25

# number of seconds to wait before cleaning up dead connections (eosio::net_plugin)
connection-cleanup-period = 30

# Enable block production, even if the chain is stale.
#enable-stale-production = true

# True to require exact match of peer network version.
network-version-match = 0

# number of blocks to retrieve in a chunk from any individual peer during synchronization (eosio::net_plugin)
sync-fetch-span = 100

# maximum sizes of transaction or block messages that are sent without first sending a notice (eosio::net_plugin)
max-implicit-request = 1500

# Percent of producers (0-99) that must be participating in order to produce blocks
required-participation = 33

# Plugin(s) to enable, may be specified multiple times
# plugin =
# Lag in number of blocks from the head block when selecting the reference block for transactions (-1 means Last Irreversible Block) (eosio::txn_test_gen_plugin)
txn-reference-block-lag = 0

plugin = eosio::chain_api_plugin
plugin = eosio::http_plugin
plugin = eosio::account_history_api_plugin
plugin = eosio::history_api_plugin
plugin = eosio::net_api_plugin
#plugin = eosio::wallet_api_plugin
#plugin = eosio::mongo_db_plugin

0 comments on commit 9ffdfda

Please sign in to comment.