From 09e90f8558132d61150268768a224498a5c6a92c Mon Sep 17 00:00:00 2001 From: Dallas Johnson Date: Mon, 16 Mar 2020 11:53:41 +0000 Subject: [PATCH 1/4] Exposed EosioAction from utils and added more logging to the startup script. --- src/accounts/updateAuth.ts | 8 +- src/accounts/utils.ts | 7 + src/eosio-config/config.ini | 348 ++++++++++++++++++ src/eosio-config/logging.json | 86 +++++ ...LTIN-DISALLOW_EMPTY_PRODUCER_SCHEDULE.json | 11 + .../BUILTIN-FIX_LINKAUTH_RESTRICTION.json | 11 + .../BUILTIN-FORWARD_SETCODE.json | 11 + .../protocol_features/BUILTIN-GET_SENDER.json | 11 + .../BUILTIN-NO_DUPLICATE_DEFERRED_ID.json | 13 + .../BUILTIN-ONLY_BILL_FIRST_AUTHORIZER.json | 11 + ...LTIN-ONLY_LINK_TO_EXISTING_PERMISSION.json | 11 + .../BUILTIN-PREACTIVATE_FEATURE.json | 11 + .../BUILTIN-RAM_RESTRICTIONS.json | 11 + .../BUILTIN-REPLACE_DEFERRED.json | 11 + .../BUILTIN-RESTRICT_ACTION_TO_SELF.json | 11 + src/scripts/init_blockchain.sh | 1 + 16 files changed, 566 insertions(+), 7 deletions(-) create mode 100644 src/eosio-config/config.ini create mode 100644 src/eosio-config/logging.json create mode 100644 src/eosio-config/protocol_features/BUILTIN-DISALLOW_EMPTY_PRODUCER_SCHEDULE.json create mode 100644 src/eosio-config/protocol_features/BUILTIN-FIX_LINKAUTH_RESTRICTION.json create mode 100644 src/eosio-config/protocol_features/BUILTIN-FORWARD_SETCODE.json create mode 100644 src/eosio-config/protocol_features/BUILTIN-GET_SENDER.json create mode 100644 src/eosio-config/protocol_features/BUILTIN-NO_DUPLICATE_DEFERRED_ID.json create mode 100644 src/eosio-config/protocol_features/BUILTIN-ONLY_BILL_FIRST_AUTHORIZER.json create mode 100644 src/eosio-config/protocol_features/BUILTIN-ONLY_LINK_TO_EXISTING_PERMISSION.json create mode 100644 src/eosio-config/protocol_features/BUILTIN-PREACTIVATE_FEATURE.json create mode 100644 src/eosio-config/protocol_features/BUILTIN-RAM_RESTRICTIONS.json create mode 100644 src/eosio-config/protocol_features/BUILTIN-REPLACE_DEFERRED.json create mode 100644 src/eosio-config/protocol_features/BUILTIN-RESTRICT_ACTION_TO_SELF.json diff --git a/src/accounts/updateAuth.ts b/src/accounts/updateAuth.ts index fe4aa01..99d681d 100644 --- a/src/accounts/updateAuth.ts +++ b/src/accounts/updateAuth.ts @@ -1,5 +1,6 @@ import { EOSManager } from '../eosManager'; import { Account } from './account'; +import { EosioAction } from './utils'; export namespace UpdateAuth { export interface PermissionLevel { @@ -135,10 +136,3 @@ export namespace UpdateAuth { await EOSManager.transact({ actions }); } } - -export type EosioAction = { - account: string; - name: string; - authorization: { actor: string; permission: string }[]; - data: any; -}; diff --git a/src/accounts/utils.ts b/src/accounts/utils.ts index 552d993..3885bb1 100644 --- a/src/accounts/utils.ts +++ b/src/accounts/utils.ts @@ -30,3 +30,10 @@ export const hashToEOSName = (data: string) => .substring(0, 11) .replace(digitPattern, match => digitMapping[match]) .toLowerCase()}`; + +export type EosioAction = { + account: string; + name: string; + authorization: { actor: string; permission: string }[]; + data: any; +}; diff --git a/src/eosio-config/config.ini b/src/eosio-config/config.ini new file mode 100644 index 0000000..cbfef3f --- /dev/null +++ b/src/eosio-config/config.ini @@ -0,0 +1,348 @@ +# the location of the blocks directory (absolute path or relative to application data dir) (eosio::chain_plugin) +# blocks-dir = "blocks" + +# the location of the protocol_features directory (absolute path or relative to application config dir) (eosio::chain_plugin) +# protocol-features-dir = "protocol_features" + +# Pairs of [BLOCK_NUM,BLOCK_ID] that should be enforced as checkpoints. (eosio::chain_plugin) +# checkpoint = + +# Override default WASM runtime (eosio::chain_plugin) +# wasm-runtime = + +# Override default maximum ABI serialization time allowed in ms (eosio::chain_plugin) +# abi-serializer-max-time-ms = 15000 + +# Maximum size (in MiB) of the chain state database (eosio::chain_plugin) +# chain-state-db-size-mb = 1024 + +# Safely shut down node when free space remaining in the chain state database drops below this size (in MiB). (eosio::chain_plugin) +# chain-state-db-guard-size-mb = 128 + +# Maximum size (in MiB) of the reversible blocks database (eosio::chain_plugin) +# reversible-blocks-db-size-mb = 340 + +# Safely shut down node when free space remaining in the reverseible blocks database drops below this size (in MiB). (eosio::chain_plugin) +# reversible-blocks-db-guard-size-mb = 2 + +# Percentage of actual signature recovery cpu to bill. Whole number percentages, e.g. 50 for 50% (eosio::chain_plugin) +# signature-cpu-billable-pct = 50 + +# Number of worker threads in controller thread pool (eosio::chain_plugin) +# chain-threads = 2 + +# print contract's output to console (eosio::chain_plugin) +# contracts-console = false + +# Account added to actor whitelist (may specify multiple times) (eosio::chain_plugin) +# actor-whitelist = + +# Account added to actor blacklist (may specify multiple times) (eosio::chain_plugin) +# actor-blacklist = + +# Contract account added to contract whitelist (may specify multiple times) (eosio::chain_plugin) +# contract-whitelist = + +# Contract account added to contract blacklist (may specify multiple times) (eosio::chain_plugin) +# contract-blacklist = + +# Action (in the form code::action) added to action blacklist (may specify multiple times) (eosio::chain_plugin) +# action-blacklist = + +# Public key added to blacklist of keys that should not be included in authorities (may specify multiple times) (eosio::chain_plugin) +# key-blacklist = + +# Deferred transactions sent by accounts in this list do not have any of the subjective whitelist/blacklist checks applied to them (may specify multiple times) (eosio::chain_plugin) +# sender-bypass-whiteblacklist = + +# Database read mode ("speculative", "head", "read-only", "irreversible"). +# In "speculative" mode database contains changes done up to the head block plus changes made by transactions not yet included to the blockchain. +# In "head" mode database contains changes done up to the current head block. +# In "read-only" mode database contains changes done up to the current head block and transactions cannot be pushed to the chain API. +# In "irreversible" mode database contains changes done up to the last irreversible block and transactions cannot be pushed to the chain API. +# (eosio::chain_plugin) +# read-mode = speculative + +# Chain validation mode ("full" or "light"). +# In "full" mode all incoming blocks will be fully validated. +# In "light" mode all incoming blocks headers will be fully validated; transactions in those validated blocks will be trusted +# (eosio::chain_plugin) +# validation-mode = full + +# Disable the check which subjectively fails a transaction if a contract bills more RAM to another account within the context of a notification handler (i.e. when the receiver is not the code of the action). (eosio::chain_plugin) +# disable-ram-billing-notify-checks = false + +# Indicate a producer whose blocks headers signed by it will be fully validated, but transactions in those validated blocks will be trusted. (eosio::chain_plugin) +# trusted-producer = + +# Database map mode ("mapped", "heap", or "locked"). +# In "mapped" mode database is memory mapped as a file. +# In "heap" mode database is preloaded in to swappable memory. +# In "locked" mode database is preloaded, locked in to memory, and optionally can use huge pages. +# (eosio::chain_plugin) +# database-map-mode = mapped + +# Optional path for database hugepages when in "locked" mode (may specify multiple times) (eosio::chain_plugin) +# database-hugepage-path = + +# Track actions which match receiver:action:actor. Actor may be blank to include all. Action and Actor both blank allows all from Recieiver. Receiver may not be blank. (eosio::history_plugin) +# filter-on = + +# Do not track actions which match receiver:action:actor. Action and Actor both blank excludes all from Reciever. Actor blank excludes all from reciever:action. Receiver may not be blank. (eosio::history_plugin) +# filter-out = + +# PEM encoded trusted root certificate (or path to file containing one) used to validate any TLS connections made. (may specify multiple times) +# (eosio::http_client_plugin) +# https-client-root-cert = + +# true: validate that the peer certificates are valid and trusted, false: ignore cert errors (eosio::http_client_plugin) +# https-client-validate-peers = true + +# The local IP and port to listen for incoming http connections; set blank to disable. (eosio::http_plugin) +# http-server-address = 127.0.0.1:8888 + +# The local IP and port to listen for incoming https connections; leave blank to disable. (eosio::http_plugin) +# https-server-address = + +# Filename with the certificate chain to present on https connections. PEM format. Required for https. (eosio::http_plugin) +# https-certificate-chain-file = + +# Filename with https private key in PEM format. Required for https (eosio::http_plugin) +# https-private-key-file = + +# Configure https ECDH curve to use: secp384r1 or prime256v1 (eosio::http_plugin) +# https-ecdh-curve = secp384r1 + +# Specify the Access-Control-Allow-Origin to be returned on each request. (eosio::http_plugin) +# access-control-allow-origin = + +# Specify the Access-Control-Allow-Headers to be returned on each request. (eosio::http_plugin) +# access-control-allow-headers = + +# Specify the Access-Control-Max-Age to be returned on each request. (eosio::http_plugin) +# access-control-max-age = + +# Specify if Access-Control-Allow-Credentials: true should be returned on each request. (eosio::http_plugin) +# access-control-allow-credentials = false + +# The maximum body size in bytes allowed for incoming RPC requests (eosio::http_plugin) +# max-body-size = 1048576 + +# Maximum size in megabytes http_plugin should use for processing http requests. 503 error response when exceeded. (eosio::http_plugin) +# http-max-bytes-in-flight-mb = 500 + +# Maximum time for processing a request. (eosio::http_plugin) +# http-max-response-time-ms = 30 + +# Append the error log to HTTP responses (eosio::http_plugin) +# verbose-http-errors = false + +# If set to false, then any incoming "Host" header is considered valid (eosio::http_plugin) +# http-validate-host = true + +# Additionaly acceptable values for the "Host" header of incoming HTTP requests, can be specified multiple times. Includes http/s_server_address by default. (eosio::http_plugin) +# http-alias = + +# Number of worker threads in http thread pool (eosio::http_plugin) +# http-threads = 2 + +# The maximum number of pending login requests (eosio::login_plugin) +# max-login-requests = 1000000 + +# The maximum timeout for pending login requests (in seconds) (eosio::login_plugin) +# max-login-timeout = 60 + +# The target queue size between nodeos and MongoDB plugin thread. (eosio::mongo_db_plugin) +# mongodb-queue-size = 1024 + +# The maximum size of the abi cache for serializing data. (eosio::mongo_db_plugin) +# mongodb-abi-cache-size = 2048 + +# Required with --replay-blockchain, --hard-replay-blockchain, or --delete-all-blocks to wipe mongo db.This option required to prevent accidental wipe of mongo db. (eosio::mongo_db_plugin) +# mongodb-wipe = false + +# If specified then only abi data pushed to mongodb until specified block is reached. (eosio::mongo_db_plugin) +# mongodb-block-start = 0 + +# MongoDB URI connection string, see: https://docs.mongodb.com/master/reference/connection-string/. If not specified then plugin is disabled. Default database 'EOS' is used if not specified in URI. Example: mongodb://127.0.0.1:27017/EOS (eosio::mongo_db_plugin) +# mongodb-uri = + +# Update blocks/block_state with latest via block number so that duplicates are overwritten. (eosio::mongo_db_plugin) +# mongodb-update-via-block-num = false + +# Enables storing blocks in mongodb. (eosio::mongo_db_plugin) +# mongodb-store-blocks = true + +# Enables storing block state in mongodb. (eosio::mongo_db_plugin) +# mongodb-store-block-states = true + +# Enables storing transactions in mongodb. (eosio::mongo_db_plugin) +# mongodb-store-transactions = true + +# Enables storing transaction traces in mongodb. (eosio::mongo_db_plugin) +# mongodb-store-transaction-traces = true + +# Enables storing action traces in mongodb. (eosio::mongo_db_plugin) +# mongodb-store-action-traces = true + +# Enables expiring data in mongodb after a specified number of seconds. (eosio::mongo_db_plugin) +# mongodb-expire-after-seconds = 0 + +# Track actions which match receiver:action:actor. Receiver, Action, & Actor may be blank to include all. i.e. eosio:: or :transfer: Use * or leave unspecified to include all. (eosio::mongo_db_plugin) +# mongodb-filter-on = + +# Do not track actions which match receiver:action:actor. Receiver, Action, & Actor may be blank to exclude all. (eosio::mongo_db_plugin) +# mongodb-filter-out = + +# The actual host:port used to listen for incoming p2p connections. (eosio::net_plugin) +# p2p-listen-endpoint = 0.0.0.0:9876 + +# An externally accessible host:port for identifying this node. Defaults to p2p-listen-endpoint. (eosio::net_plugin) +# p2p-server-address = + +# 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 = + +# Maximum number of client nodes from any single IP address (eosio::net_plugin) +# p2p-max-nodes-per-host = 1 + +# The name supplied to identify this node amongst the peers. (eosio::net_plugin) +# agent-name = "EOS Test Agent" + +# 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 + +# max connection cleanup time per cleanup call in millisec (eosio::net_plugin) +# max-cleanup-time-msec = 10 + +# DEPRECATED, needless restriction. True to require exact match of peer network version. (eosio::net_plugin) +# network-version-match = false + +# Number of worker threads in net_plugin thread pool (eosio::net_plugin) +# net-threads = 1 + +# number of blocks to retrieve in a chunk from any individual peer during synchronization (eosio::net_plugin) +# sync-fetch-span = 100 + +# Enable expirimental socket read watermark optimization (eosio::net_plugin) +# use-socket-read-watermark = false + +# The string used to format peers when logging messages about them. Variables are escaped with ${}. +# Available Variables: +# _name self-reported name +# +# _id self-reported ID (64 hex characters) +# +# _sid first 8 characters of _peer.id +# +# _ip remote IP address of peer +# +# _port remote port number of peer +# +# _lip local IP address connected to peer +# +# _lport local port number connected to peer +# +# (eosio::net_plugin) +# peer-log-format = ["${_name}" ${_ip}:${_port}] + +# Enable block production, even if the chain is stale. (eosio::producer_plugin) +# enable-stale-production = false + +# Start this node in a state where production is paused (eosio::producer_plugin) +# pause-on-startup = false + +# Limits the maximum time (in milliseconds) that is allowed a pushed transaction's code to execute before being considered invalid (eosio::producer_plugin) +# max-transaction-time = 30 + +# Limits the maximum age (in seconds) of the DPOS Irreversible Block for a chain this node will produce blocks on (use negative value to indicate unlimited) (eosio::producer_plugin) +# max-irreversible-block-age = -1 + +# ID of producer controlled by this node (e.g. inita; may specify multiple times) (eosio::producer_plugin) +# producer-name = + +# (DEPRECATED - Use signature-provider instead) Tuple of [public key, WIF private key] (may specify multiple times) (eosio::producer_plugin) +# private-key = + +# Key=Value pairs in the form = +# Where: +# is a string form of a vaild EOSIO public key +# +# is a string in the form : +# +# is KEY, or KEOSD +# +# KEY: is a string form of a valid EOSIO private key which maps to the provided public key +# +# KEOSD: is the URL where keosd is available and the approptiate wallet(s) are unlocked (eosio::producer_plugin) +# signature-provider = EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV=KEY:5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3 + +# Limits the maximum time (in milliseconds) that is allowed for sending blocks to a keosd provider for signing (eosio::producer_plugin) +# keosd-provider-timeout = 5 + +# account that can not access to extended CPU/NET virtual resources (eosio::producer_plugin) +# greylist-account = + +# Limit (between 1 and 1000) on the multiple that CPU/NET virtual resources can extend during low usage (only enforced subjectively; use 1000 to not enforce any limit) (eosio::producer_plugin) +# greylist-limit = 1000 + +# offset of non last block producing time in microseconds. Negative number results in blocks to go out sooner, and positive number results in blocks to go out later (eosio::producer_plugin) +# produce-time-offset-us = 0 + +# offset of last block producing time in microseconds. Negative number results in blocks to go out sooner, and positive number results in blocks to go out later (eosio::producer_plugin) +# last-block-time-offset-us = -200000 + +# Maximum wall-clock time, in milliseconds, spent retiring scheduled transactions in any block before returning to normal transaction processing. (eosio::producer_plugin) +# max-scheduled-transaction-time-per-block-ms = 100 + +# Time in microseconds allowed for a transaction that starts with insufficient CPU quota to complete and cover its CPU usage. (eosio::producer_plugin) +# subjective-cpu-leeway-us = 31000 + +# ratio between incoming transations and deferred transactions when both are exhausted (eosio::producer_plugin) +# incoming-defer-ratio = 1 + +# Number of worker threads in producer thread pool (eosio::producer_plugin) +# producer-threads = 2 + +# the location of the snapshots directory (absolute path or relative to application data dir) (eosio::producer_plugin) +# snapshots-dir = "snapshots" + +# the location of the state-history directory (absolute path or relative to application data dir) (eosio::state_history_plugin) +# state-history-dir = "state-history" + +# enable trace history (eosio::state_history_plugin) +# trace-history = false + +# enable chain state history (eosio::state_history_plugin) +# chain-state-history = false + +# the endpoint upon which to listen for incoming connections. Caution: only expose this port to your internal network. (eosio::state_history_plugin) +# state-history-endpoint = 127.0.0.1:8080 + +# enable debug mode for trace history (eosio::state_history_plugin) +# trace-history-debug-mode = false + +# 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 + +# Number of worker threads in txn_test_gen thread pool (eosio::txn_test_gen_plugin) +# txn-test-gen-threads = 2 + +# Prefix to use for accounts generated and used by this plugin (eosio::txn_test_gen_plugin) +# txn-test-gen-account-prefix = txn.test. + +# Plugin(s) to enable, may be specified multiple times +# plugin = + diff --git a/src/eosio-config/logging.json b/src/eosio-config/logging.json new file mode 100644 index 0000000..65095b6 --- /dev/null +++ b/src/eosio-config/logging.json @@ -0,0 +1,86 @@ +{ + "includes": [], + "appenders": [ + { + "name": "stderr", + "type": "console", + "args": { + "stream": "std_error", + "level_colors": [ + { + "level": "debug", + "color": "green" + }, + { + "level": "warn", + "color": "brown" + }, + { + "level": "error", + "color": "red" + } + ] + }, + "enabled": true + }, + { + "name": "stdout", + "type": "console", + "args": { + "stream": "std_out", + "level_colors": [ + { + "level": "debug", + "color": "green" + }, + { + "level": "warn", + "color": "brown" + }, + { + "level": "error", + "color": "red" + } + ] + }, + "enabled": true + } + ], + "loggers": [ + { + "name": "default", + "level": "all", + "enabled": true, + "additivity": false, + "appenders": ["stdout"] + }, + { + "name": "net_plugin_impl", + "level": "all", + "enabled": true, + "additivity": false, + "appenders": ["stdout"] + }, + { + "name": "http_plugin", + "level": "all", + "enabled": true, + "additivity": false, + "appenders": ["stdout"] + }, + { + "name": "producer_plugin", + "level": "all", + "enabled": true, + "additivity": false, + "appenders": ["stdout"] + }, + { + "name": "transaction_tracing", + "level": "all", + "enabled": true, + "additivity": false, + "appenders": ["stdout"] + } + ] +} diff --git a/src/eosio-config/protocol_features/BUILTIN-DISALLOW_EMPTY_PRODUCER_SCHEDULE.json b/src/eosio-config/protocol_features/BUILTIN-DISALLOW_EMPTY_PRODUCER_SCHEDULE.json new file mode 100644 index 0000000..cd2296b --- /dev/null +++ b/src/eosio-config/protocol_features/BUILTIN-DISALLOW_EMPTY_PRODUCER_SCHEDULE.json @@ -0,0 +1,11 @@ +{ + "protocol_feature_type": "builtin", + "dependencies": [], + "description_digest": "2853617cec3eabd41881eb48882e6fc5e81a0db917d375057864b3befbe29acd", + "subjective_restrictions": { + "earliest_allowed_activation_time": "1970-01-01T00:00:00.000", + "preactivation_required": true, + "enabled": true + }, + "builtin_feature_codename": "DISALLOW_EMPTY_PRODUCER_SCHEDULE" +} \ No newline at end of file diff --git a/src/eosio-config/protocol_features/BUILTIN-FIX_LINKAUTH_RESTRICTION.json b/src/eosio-config/protocol_features/BUILTIN-FIX_LINKAUTH_RESTRICTION.json new file mode 100644 index 0000000..de632bb --- /dev/null +++ b/src/eosio-config/protocol_features/BUILTIN-FIX_LINKAUTH_RESTRICTION.json @@ -0,0 +1,11 @@ +{ + "protocol_feature_type": "builtin", + "dependencies": [], + "description_digest": "a98241c83511dc86c857221b9372b4aa7cea3aaebc567a48604e1d3db3557050", + "subjective_restrictions": { + "earliest_allowed_activation_time": "1970-01-01T00:00:00.000", + "preactivation_required": true, + "enabled": true + }, + "builtin_feature_codename": "FIX_LINKAUTH_RESTRICTION" +} \ No newline at end of file diff --git a/src/eosio-config/protocol_features/BUILTIN-FORWARD_SETCODE.json b/src/eosio-config/protocol_features/BUILTIN-FORWARD_SETCODE.json new file mode 100644 index 0000000..ec3fa85 --- /dev/null +++ b/src/eosio-config/protocol_features/BUILTIN-FORWARD_SETCODE.json @@ -0,0 +1,11 @@ +{ + "protocol_feature_type": "builtin", + "dependencies": [], + "description_digest": "898082c59f921d0042e581f00a59d5ceb8be6f1d9c7a45b6f07c0e26eaee0222", + "subjective_restrictions": { + "earliest_allowed_activation_time": "1970-01-01T00:00:00.000", + "preactivation_required": true, + "enabled": true + }, + "builtin_feature_codename": "FORWARD_SETCODE" +} \ No newline at end of file diff --git a/src/eosio-config/protocol_features/BUILTIN-GET_SENDER.json b/src/eosio-config/protocol_features/BUILTIN-GET_SENDER.json new file mode 100644 index 0000000..f695ead --- /dev/null +++ b/src/eosio-config/protocol_features/BUILTIN-GET_SENDER.json @@ -0,0 +1,11 @@ +{ + "protocol_feature_type": "builtin", + "dependencies": [], + "description_digest": "1eab748b95a2e6f4d7cb42065bdee5566af8efddf01a55a0a8d831b823f8828a", + "subjective_restrictions": { + "earliest_allowed_activation_time": "1970-01-01T00:00:00.000", + "preactivation_required": true, + "enabled": true + }, + "builtin_feature_codename": "GET_SENDER" +} \ No newline at end of file diff --git a/src/eosio-config/protocol_features/BUILTIN-NO_DUPLICATE_DEFERRED_ID.json b/src/eosio-config/protocol_features/BUILTIN-NO_DUPLICATE_DEFERRED_ID.json new file mode 100644 index 0000000..68fe48a --- /dev/null +++ b/src/eosio-config/protocol_features/BUILTIN-NO_DUPLICATE_DEFERRED_ID.json @@ -0,0 +1,13 @@ +{ + "protocol_feature_type": "builtin", + "dependencies": [ + "ef43112c6543b88db2283a2e077278c315ae2c84719a8b25f25cc88565fbea99" + ], + "description_digest": "45967387ee92da70171efd9fefd1ca8061b5efe6f124d269cd2468b47f1575a0", + "subjective_restrictions": { + "earliest_allowed_activation_time": "1970-01-01T00:00:00.000", + "preactivation_required": true, + "enabled": true + }, + "builtin_feature_codename": "NO_DUPLICATE_DEFERRED_ID" +} \ No newline at end of file diff --git a/src/eosio-config/protocol_features/BUILTIN-ONLY_BILL_FIRST_AUTHORIZER.json b/src/eosio-config/protocol_features/BUILTIN-ONLY_BILL_FIRST_AUTHORIZER.json new file mode 100644 index 0000000..0d5f57a --- /dev/null +++ b/src/eosio-config/protocol_features/BUILTIN-ONLY_BILL_FIRST_AUTHORIZER.json @@ -0,0 +1,11 @@ +{ + "protocol_feature_type": "builtin", + "dependencies": [], + "description_digest": "2f1f13e291c79da5a2bbad259ed7c1f2d34f697ea460b14b565ac33b063b73e2", + "subjective_restrictions": { + "earliest_allowed_activation_time": "1970-01-01T00:00:00.000", + "preactivation_required": true, + "enabled": true + }, + "builtin_feature_codename": "ONLY_BILL_FIRST_AUTHORIZER" +} \ No newline at end of file diff --git a/src/eosio-config/protocol_features/BUILTIN-ONLY_LINK_TO_EXISTING_PERMISSION.json b/src/eosio-config/protocol_features/BUILTIN-ONLY_LINK_TO_EXISTING_PERMISSION.json new file mode 100644 index 0000000..039ae52 --- /dev/null +++ b/src/eosio-config/protocol_features/BUILTIN-ONLY_LINK_TO_EXISTING_PERMISSION.json @@ -0,0 +1,11 @@ +{ + "protocol_feature_type": "builtin", + "dependencies": [], + "description_digest": "f3c3d91c4603cde2397268bfed4e662465293aab10cd9416db0d442b8cec2949", + "subjective_restrictions": { + "earliest_allowed_activation_time": "1970-01-01T00:00:00.000", + "preactivation_required": true, + "enabled": true + }, + "builtin_feature_codename": "ONLY_LINK_TO_EXISTING_PERMISSION" +} \ No newline at end of file diff --git a/src/eosio-config/protocol_features/BUILTIN-PREACTIVATE_FEATURE.json b/src/eosio-config/protocol_features/BUILTIN-PREACTIVATE_FEATURE.json new file mode 100644 index 0000000..d2f905e --- /dev/null +++ b/src/eosio-config/protocol_features/BUILTIN-PREACTIVATE_FEATURE.json @@ -0,0 +1,11 @@ +{ + "protocol_feature_type": "builtin", + "dependencies": [], + "description_digest": "64fe7df32e9b86be2b296b3f81dfd527f84e82b98e363bc97e40bc7a83733310", + "subjective_restrictions": { + "earliest_allowed_activation_time": "1970-01-01T00:00:00.000", + "preactivation_required": false, + "enabled": true + }, + "builtin_feature_codename": "PREACTIVATE_FEATURE" +} \ No newline at end of file diff --git a/src/eosio-config/protocol_features/BUILTIN-RAM_RESTRICTIONS.json b/src/eosio-config/protocol_features/BUILTIN-RAM_RESTRICTIONS.json new file mode 100644 index 0000000..67b4bef --- /dev/null +++ b/src/eosio-config/protocol_features/BUILTIN-RAM_RESTRICTIONS.json @@ -0,0 +1,11 @@ +{ + "protocol_feature_type": "builtin", + "dependencies": [], + "description_digest": "1812fdb5096fd854a4958eb9d53b43219d114de0e858ce00255bd46569ad2c68", + "subjective_restrictions": { + "earliest_allowed_activation_time": "1970-01-01T00:00:00.000", + "preactivation_required": true, + "enabled": true + }, + "builtin_feature_codename": "RAM_RESTRICTIONS" +} \ No newline at end of file diff --git a/src/eosio-config/protocol_features/BUILTIN-REPLACE_DEFERRED.json b/src/eosio-config/protocol_features/BUILTIN-REPLACE_DEFERRED.json new file mode 100644 index 0000000..5dda572 --- /dev/null +++ b/src/eosio-config/protocol_features/BUILTIN-REPLACE_DEFERRED.json @@ -0,0 +1,11 @@ +{ + "protocol_feature_type": "builtin", + "dependencies": [], + "description_digest": "9908b3f8413c8474ab2a6be149d3f4f6d0421d37886033f27d4759c47a26d944", + "subjective_restrictions": { + "earliest_allowed_activation_time": "1970-01-01T00:00:00.000", + "preactivation_required": true, + "enabled": true + }, + "builtin_feature_codename": "REPLACE_DEFERRED" +} \ No newline at end of file diff --git a/src/eosio-config/protocol_features/BUILTIN-RESTRICT_ACTION_TO_SELF.json b/src/eosio-config/protocol_features/BUILTIN-RESTRICT_ACTION_TO_SELF.json new file mode 100644 index 0000000..e0b8948 --- /dev/null +++ b/src/eosio-config/protocol_features/BUILTIN-RESTRICT_ACTION_TO_SELF.json @@ -0,0 +1,11 @@ +{ + "protocol_feature_type": "builtin", + "dependencies": [], + "description_digest": "e71b6712188391994c78d8c722c1d42c477cf091e5601b5cf1befd05721a57f3", + "subjective_restrictions": { + "earliest_allowed_activation_time": "1970-01-01T00:00:00.000", + "preactivation_required": true, + "enabled": true + }, + "builtin_feature_codename": "RESTRICT_ACTION_TO_SELF" +} \ No newline at end of file diff --git a/src/scripts/init_blockchain.sh b/src/scripts/init_blockchain.sh index f923dc8..2a1e3ba 100755 --- a/src/scripts/init_blockchain.sh +++ b/src/scripts/init_blockchain.sh @@ -1,5 +1,6 @@ #!/usr/bin/env bash # set -o errexit +set -x echo "=== lamington: setup blockchain accounts and smart contract ===" From a737fcd38c2e77d7b473e21e6b11d6bbe9ad23ed Mon Sep 17 00:00:00 2001 From: Dallas Johnson Date: Sun, 12 Apr 2020 23:34:15 +0100 Subject: [PATCH 2/4] Adds state-history plugin to image --- src/scripts/init_blockchain.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/scripts/init_blockchain.sh b/src/scripts/init_blockchain.sh index 2a1e3ba..0ec867f 100755 --- a/src/scripts/init_blockchain.sh +++ b/src/scripts/init_blockchain.sh @@ -24,6 +24,11 @@ nodeos -e -p eosio -d /mnt/dev/data \ --plugin eosio::producer_api_plugin \ --plugin eosio::chain_api_plugin \ --plugin eosio::http_plugin \ + --plugin eosio::state_history_plugin \ + --disable-replay-opts \ + --trace-history-debug-mode \ + --trace-history \ + --plugin eosio::history_api_plugin \ --http-server-address=0.0.0.0:8888 \ --access-control-allow-origin=* \ --contracts-console \ From b037a5553297bc8d6ef0022f3cdbffc2fba16657 Mon Sep 17 00:00:00 2001 From: Dallas Johnson Date: Sat, 11 Jul 2020 19:54:34 +0100 Subject: [PATCH 3/4] Improve system contract loading reliability with more attempts and delays. Also adds more options to account creation with more RAM --- src/accounts/accountManager.ts | 43 +++++++++++++++++++++++++--------- src/cli/lamington-test.ts | 3 +++ src/contracts/index.ts | 1 + src/eosio-config/logging.json | 14 +++++------ src/scripts/init_blockchain.sh | 17 ++++++++++++-- 5 files changed, 58 insertions(+), 20 deletions(-) diff --git a/src/accounts/accountManager.ts b/src/accounts/accountManager.ts index 87b8141..102d849 100644 --- a/src/accounts/accountManager.ts +++ b/src/accounts/accountManager.ts @@ -5,10 +5,14 @@ import * as ecc from 'eosjs-ecc'; import { Account } from './account'; import { accountNameFromPublicKey } from './utils'; import { EOSManager } from '../eosManager'; +import { ConfigManager, LamingtonDebugLevel } from '../configManager'; +import * as chalk from 'chalk'; interface AccountCreationOptions { creator?: Account; eos?: Api; + privateKey?: string; + bytesToBuy?: Number; } export class AccountManager { @@ -41,9 +45,9 @@ export class AccountManager { const accounts = []; if (accountNames) { for (let accountName of accountNames) { - const privateKey = await ecc.unsafeRandomKey(); - const publicKey = await ecc.privateToPublic(privateKey); - const account = new Account(accountName, privateKey); + const resolvedPrivateKey = options?.privateKey ?? (await ecc.unsafeRandomKey()); + const publicKey = await ecc.privateToPublic(resolvedPrivateKey); + const account = new Account(accountName, resolvedPrivateKey); // Publish the new account and store result await AccountManager.setupAccount(account, options); accounts.push(account); @@ -51,10 +55,12 @@ export class AccountManager { } else { // Repeat account creation for specified for (let i = 0; i < numberOfAccounts; i++) { - const privateKey = await ecc.unsafeRandomKey(); - const publicKey = await ecc.privateToPublic(privateKey); + const resolvedPrivateKey = options?.privateKey ?? (await ecc.unsafeRandomKey()); + + const seedKey = await ecc.unsafeRandomKey(); + const publicKey = await ecc.privateToPublic(seedKey); const accountName = accountNameFromPublicKey(publicKey); - const account = new Account(accountName, privateKey); + const account = new Account(accountName, resolvedPrivateKey); // Publish the new account and store result await AccountManager.setupAccount(account, options); accounts.push(account); @@ -72,8 +78,13 @@ export class AccountManager { * @returns Transaction result promise */ static setupAccount = async (account: Account, options?: AccountCreationOptions) => { + let logMessage = `Create account: ${account.name}`; + if (options?.privateKey) { + logMessage += ` private key: ${options.privateKey} `; + } const { creator, eos } = AccountManager.flattenOptions(options); // Validate account contains required values + if (!account.name) throw new Error('Missing account name.'); if (!account.publicKey) throw new Error('Missing public key.'); if (!account.privateKey) throw new Error('Missing private key.'); @@ -122,19 +133,25 @@ export class AccountManager { // newaccount alone is enough. If there is a system contract with the buyrambytes action, // then we definitely need to do it, but if there isn't, then trying to call it is an error. if (systemContract.actions.has('buyrambytes')) { + const bytesToBuy = options?.bytesToBuy ?? 4000000; + logMessage += ` with ram: ${bytesToBuy}`; + actions.push({ account: 'eosio', name: 'buyrambytes', authorization: creator.active, data: { payer: creator.name, - receiver: account, - bytes: 8192, + receiver: account.name, + bytes: bytesToBuy, }, }); } // Same deal for delegatebw. Only if it's actually a thing. if (systemContract.actions.has('delegatebw')) { + const delegateAmount = '10.0000 EOS'; + logMessage += ` bandwidth: ${delegateAmount} for net and cpu`; + actions.push({ account: 'eosio', name: 'delegatebw', @@ -142,15 +159,19 @@ export class AccountManager { data: { from: creator.name, receiver: account.name, - stake_net_quantity: '10.0000 SYS', - stake_cpu_quantity: '10.0000 SYS', + stake_net_quantity: delegateAmount, + stake_cpu_quantity: delegateAmount, transfer: false, }, }); } + if (ConfigManager.debugLevelMin || ConfigManager.debugLevelVerbose) { + console.log(chalk.cyan(logMessage)); + } + // Execute the transaction return await EOSManager.transact({ actions }, eos, { - logMessage: `Creating account: ${account.name}}`, + logMessage: logMessage, }); }; diff --git a/src/cli/lamington-test.ts b/src/cli/lamington-test.ts index e9a4f2e..f25d29a 100644 --- a/src/cli/lamington-test.ts +++ b/src/cli/lamington-test.ts @@ -1,6 +1,7 @@ import { eosIsReady, startEos, runTests, stopContainer, buildAll } from './utils'; import { GitIgnoreManager } from '../gitignoreManager'; import { ConfigManager } from '../configManager'; +import { sleep } from '../utils'; /** * Executes a build and test procedure @@ -25,6 +26,8 @@ const run = async () => { // Start compiling smart contracts if (!args.includes('skip-build')) { await buildAll(); + } else { + await sleep(4000); } // Begin running tests await runTests(); diff --git a/src/contracts/index.ts b/src/contracts/index.ts index 55d0474..434230e 100644 --- a/src/contracts/index.ts +++ b/src/contracts/index.ts @@ -3,3 +3,4 @@ export * from './contractDeployer'; export * from './contractLoader'; export * from './tableRowsResult'; export * from './typeGenerator'; +export * from './typeMap'; diff --git a/src/eosio-config/logging.json b/src/eosio-config/logging.json index 65095b6..9882c16 100644 --- a/src/eosio-config/logging.json +++ b/src/eosio-config/logging.json @@ -50,28 +50,28 @@ { "name": "default", "level": "all", - "enabled": true, + "enabled": false, "additivity": false, "appenders": ["stdout"] }, { "name": "net_plugin_impl", - "level": "all", - "enabled": true, + "level": "off", + "enabled": false, "additivity": false, "appenders": ["stdout"] }, { "name": "http_plugin", - "level": "all", - "enabled": true, + "level": "off", + "enabled": false, "additivity": false, "appenders": ["stdout"] }, { "name": "producer_plugin", - "level": "all", - "enabled": true, + "level": "off", + "enabled": false, "additivity": false, "appenders": ["stdout"] }, diff --git a/src/scripts/init_blockchain.sh b/src/scripts/init_blockchain.sh index 0ec867f..f60e2c8 100755 --- a/src/scripts/init_blockchain.sh +++ b/src/scripts/init_blockchain.sh @@ -33,7 +33,7 @@ nodeos -e -p eosio -d /mnt/dev/data \ --access-control-allow-origin=* \ --contracts-console \ --verbose-http-errors & -sleep 6s + until $(curl --output /dev/null \ --silent \ --head \ @@ -62,10 +62,17 @@ done echo "=== lamington: activate protocol features ===" curl --silent --output /dev/null -X POST localhost:8888/v1/producer/schedule_protocol_feature_activations \ -d '{"protocol_features_to_activate": ["0ec7e080177b2c02b278d5088611686b49d739925a92d9bfcacd7fc6b74053bd"]}' -sleep 2s +sleep 1s echo "=== lamington: install system contracts ===" + +cleos set contract eosio "$contracts_dir/eosio.system" -p eosio@active +sleep 0.5s +cleos set contract eosio "$contracts_dir/eosio.system" -p eosio@active +sleep 0.5s cleos set contract eosio "$contracts_dir/eosio.system" -p eosio@active +sleep 0.5s + cleos set contract eosio.token "$contracts_dir/eosio.token" cleos set contract eosio.msig "$contracts_dir/eosio.msig" @@ -76,5 +83,11 @@ cleos push action eosio.token issue '["eosio", "100000000.0000 EOS", "memo"]\' - echo "=== lamington: init system contract ===" cleos push action eosio init '[0, "4,EOS"]' -p eosio@active +sleep 2s + +cleos push action eosio setpriv '["eosio.msig",1]' -p eosio + +sleeps 2s + # put the background nodeos job to foreground for docker run fg %1 \ No newline at end of file From 2546190c69bafcd705e5694408b8a9e7c8a52f92 Mon Sep 17 00:00:00 2001 From: Dallas Johnson Date: Sat, 8 Aug 2020 13:59:57 +0100 Subject: [PATCH 4/4] removed 2 second delay which doesn't seem to be needed now --- src/scripts/init_blockchain.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/scripts/init_blockchain.sh b/src/scripts/init_blockchain.sh index f60e2c8..4d63324 100755 --- a/src/scripts/init_blockchain.sh +++ b/src/scripts/init_blockchain.sh @@ -87,7 +87,5 @@ sleep 2s cleos push action eosio setpriv '["eosio.msig",1]' -p eosio -sleeps 2s - # put the background nodeos job to foreground for docker run fg %1 \ No newline at end of file