未验证 提交 8a739172 编写于 作者: Z zorba80 提交者: GitHub

Merge branch 'master' into k-system

This constitution is a multi-party contract entered into by the Members by virture of their use of this blockchain.
# Article I
No user of this blockchain shall make knowingly false or misleading statements, nor statements that constitute discrimination or harassment, nor profit thereby.
Members shall not initiate violence or the threat of violence against another Member.
# Article II
The rights of contract and of private property shall be inviolable, therefore no property shall change hands except with the consent of the owner or by a lawful Arbitrator’s order.
No Member of this blockchain shall make knowingly make false or misleading attestations nor profit thereby nor thereby cause loss to others.
# Article III
Each Member agrees to resolve disputes through the blockchain’s default arbitration process, or any other process that the parties to a transaction may mutually agree to in advance.
The Members grant the right of contract and of private property to each other, therefore no property shall change hands except with the consent of the owner, by a lawful Arbitrator’s order, or community referendum.
# Article IV
No Member shall offer nor accept anything of value in exchange for a vote of any type, including for Block Producer candidates, Amendments or Worker Proposals, nor shall any Member unduly influence the vote of another.
The Members agree to resolve disputes through the blockchain’s arbitration process, or any other process that the parties to a transaction may mutually agree.
# Article V
This EOS Blockchain has no owner, manager or fiduciary. It is governed exclusively under the terms of this Constitution.
No Member shall offer nor accept anything of value in exchange for a vote of any type, nor shall any Member unduly influence the vote of another.
# Article VI
No Member nor any Beneficial Interest shall own more than 10% of issued tokens.
No Member nor SYS token holder shall have fiduciary responsability to support the value of the SYS token. The Members do not authorize anyone to hold assets, borrow, nor contract on behalf of SYS token holders collectively. This blockchain has no owners, managers or fiduciaries; therefore, no Member shall have beneficial interest in more than 10% of the SYS token supply.
# Article VII
Each Member agrees that penalties for violations may include, but are not limited to, fines, account freezing, and reversal of transactions.
Each Member agrees that penalties for violations may include, but are not limited to, fines, account freezing, and restitution.
# Article VIII
No Member shall serve as a Block Producer who has not agreed in advance to the Block Producer Agreement provided by the Members of this blockchain.
# Article IX
No Arbitrator shall serve except within an Arbitration Forum.
Each Member who makes available a smart contract on this blockchain shall be a Developer. Each Developer shall offer their smart contracts via an free and open source license, and each smart contract shall be documented with a Ricardian Contract stating the intent of all parties and naming the Arbitration Forum that will resolve disputes arising from that contract.
# Article X
No Member shall serve as an Arbitrator who has not
* Agreed in advance to the Arbitrator Agreement provided by the Members,
* Been nominated by at least two other Members, and
* Completed the course of study of, been certified by, and be in good standing with their Forum.
Multi-lingual contracts must specify one prevailing language in case of dispute and the author is liable for losses due to ambiguity of translation.
# Article XI
Each Member who makes available a smart contract on this blockchain shall be a Developer. Each Developer shall offer their smart contracts via a license, and each smart contract shall be documented with a Ricardian Contract stating the intent of all parties and naming the Arbitration Forum that will resolve disputes arising from that contract.
This Constitution creates no positive rights for or between any Members.
# Article XII
Multi-lingual contracts must specify the prevailing language in case of dispute.
All disputes arising out of or in connection with this constitution shall be finally settled under the Rules of Arbitration of the International Chamber of Commerce by one or more arbitrators appointed in accordance with the said Rules.
# Article XIII
As Developers are able to offer services and provide interaction with the blockchain to non Members via their applications, the Developer assumes all responsibility for guaranteeing that non-Member interaction conforms to this Constitution.
This Constitution and its subordinate documents shall not be amended except by a vote of the Token Holders with no less than 15% vote participation among tokens and no fewer than 10% more Yes than No votes, sustained for 30 continuous days within a 120 day period.
# Article XIV
This Constitution creates no positive rights for or between any Members.
# Article XV
All disputes arising from this Constitution or its related governing documents shall be resolved using the EOS Core Arbitration Forum.
# Article XVI
This Constitution and its subordinate documents the Block Producer Agreement and Arbitrator Agreement shall not be amended except by a vote of the Token Holders with no less than 15% vote participation among eligible tokens and no fewer than 10% more Yes than No vote power, sustained for 30 continuous days within a 120 day period.
# Article XVII
Choice of law for disputes shall be, in order of precedence, this Constitution, the Maxims of Equity, and the laws of Malta.
Choice of law for disputes shall be, in order of precedence, this Constitution and the Maxims of Equity.
......@@ -64,7 +64,9 @@ namespace eosio { namespace chain {
Serialization::MemoryInputStream stream((const U8*)code.data(), code.size());
WASM::serialize(stream, module);
module.userSections.clear();
} catch(Serialization::FatalSerializationException& e) {
} catch(const Serialization::FatalSerializationException& e) {
EOS_ASSERT(false, wasm_serialization_error, e.message.c_str());
} catch(const IR::ValidationException& e) {
EOS_ASSERT(false, wasm_serialization_error, e.message.c_str());
}
......@@ -76,7 +78,9 @@ namespace eosio { namespace chain {
Serialization::ArrayOutputStream outstream;
WASM::serialize(outstream, module);
bytes = outstream.getBytes();
} catch(Serialization::FatalSerializationException& e) {
} catch(const Serialization::FatalSerializationException& e) {
EOS_ASSERT(false, wasm_serialization_error, e.message.c_str());
} catch(const IR::ValidationException& e) {
EOS_ASSERT(false, wasm_serialization_error, e.message.c_str());
}
it = instantiation_cache.emplace(code_id, runtime_interface->instantiate_module((const char*)bytes.data(), bytes.size(), parse_initial_memory(module))).first;
......
......@@ -36,7 +36,9 @@ namespace eosio { namespace chain {
try {
Serialization::MemoryInputStream stream((U8*)code.data(), code.size());
WASM::serialize(stream, module);
} catch(Serialization::FatalSerializationException& e) {
} catch(const Serialization::FatalSerializationException& e) {
EOS_ASSERT(false, wasm_serialization_error, e.message.c_str());
} catch(const IR::ValidationException& e) {
EOS_ASSERT(false, wasm_serialization_error, e.message.c_str());
}
......
......@@ -48,11 +48,15 @@ namespace eosio { namespace chain {
WASM::serialize(stream,module);
return stream.getBytes();
}
catch(Serialization::FatalSerializationException exception)
catch(const Serialization::FatalSerializationException& exception)
{
ss << "Error serializing WebAssembly binary file:" << std::endl;
ss << exception.message << std::endl;
FC_ASSERT( !"error converting to wasm", "${msg}", ("msg",ss.get()) );
} catch(const IR::ValidationException& e) {
ss << "Error validating WebAssembly binary file:" << std::endl;
ss << e.message << std::endl;
FC_ASSERT( !"error converting to wasm", "${msg}", ("msg",ss.get()) );
}
} FC_CAPTURE_AND_RETHROW( (wast) ) } /// wast_to_wasm
......
......@@ -113,7 +113,9 @@ std::unique_ptr<wasm_instantiated_module_interface> wavm_runtime::instantiate_mo
try {
Serialization::MemoryInputStream stream((const U8*)code_bytes, code_size);
WASM::serialize(stream, *module);
} catch(Serialization::FatalSerializationException& e) {
} catch(const Serialization::FatalSerializationException& e) {
EOS_ASSERT(false, wasm_serialization_error, e.message.c_str());
} catch(const IR::ValidationException& e) {
EOS_ASSERT(false, wasm_serialization_error, e.message.c_str());
}
......
......@@ -1055,26 +1055,22 @@ namespace eosio {
class bnet_plugin_impl : public std::enable_shared_from_this<bnet_plugin_impl> {
public:
bnet_plugin_impl() {
_peer_pk = fc::crypto::private_key::generate();
_peer_id = _peer_pk.get_public_key();
}
string _bnet_endpoint_address = "0.0.0.0";
uint16_t _bnet_endpoint_port = 4321;
bool _request_trx = true;
public_key_type _peer_id;
private_key_type _peer_pk; /// one time random key to identify this process
bnet_plugin_impl() = default;
const private_key_type _peer_pk = fc::crypto::private_key::generate(); /// one time random key to identify this process
public_key_type _peer_id = _peer_pk.get_public_key();
string _bnet_endpoint_address = "0.0.0.0";
uint16_t _bnet_endpoint_port = 4321;
bool _request_trx = true;
std::vector<std::string> _connect_to_peers; /// list of peers to connect to
std::vector<std::thread> _socket_threads;
int32_t _num_threads = 1;
std::unique_ptr<boost::asio::io_context> _ioc; // lifetime guarded by shared_ptr of bnet_plugin_impl
std::shared_ptr<listener> _listener;
std::shared_ptr<boost::asio::deadline_timer> _timer;
std::vector<std::string> _connect_to_peers; /// list of peers to connect to
std::vector<std::thread> _socket_threads;
int32_t _num_threads = 1;
std::map<const session*, std::weak_ptr<session> > _sessions;
std::unique_ptr<boost::asio::io_context> _ioc; // lifetime guarded by shared_ptr of bnet_plugin_impl
std::shared_ptr<listener> _listener;
std::shared_ptr<boost::asio::deadline_timer> _timer; // only access on app io_service
std::map<const session*, std::weak_ptr<session> > _sessions; // only access on app io_service
channels::irreversible_block::channel_type::handle _on_irb_handle;
channels::accepted_block::channel_type::handle _on_accepted_block_handle;
......@@ -1091,6 +1087,7 @@ namespace eosio {
}
void on_session_close( const session* s ) {
if( !app().get_io_service().get_executor().running_in_this_thread() ) { elog( "wrong strand"); }
auto itr = _sessions.find(s);
if( _sessions.end() != itr )
_sessions.erase(itr);
......@@ -1098,14 +1095,16 @@ namespace eosio {
template<typename Call>
void for_each_session( Call callback ) {
for( const auto& item : _sessions ) {
if( auto ses = item.second.lock() ) {
ses->_ios.post( boost::asio::bind_executor(
ses->_strand,
[ses,cb=callback](){ cb(ses); }
));
app().get_io_service().post([this, callback = callback] {
for (const auto& item : _sessions) {
if (auto ses = item.second.lock()) {
ses->_ios.post(boost::asio::bind_executor(
ses->_strand,
[ses, cb = callback]() { cb(ses); }
));
}
}
}
});
}
void on_accepted_transaction( transaction_metadata_ptr trx ) {
......@@ -1152,6 +1151,7 @@ namespace eosio {
};
void on_reconnect_peers() {
if( !app().get_io_service().get_executor().running_in_this_thread() ) { elog( "wrong strand"); }
for( const auto& peer : _connect_to_peers ) {
bool found = false;
for( const auto& con : _sessions ) {
......
......@@ -56,6 +56,7 @@ add_test(NAME distributed-transactions-test COMMAND tests/distributed-transactio
add_test(NAME distributed-transactions-remote-test COMMAND tests/distributed-transactions-remote-test.py -v --dump-error-detail WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
# TODO removed on slim: add_test(NAME restart-scenarios-test_resync COMMAND tests/restart-scenarios-test.py -c resync -p4 -v --dump-error-details WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
# add_test(NAME restart-scenarios-test_replay COMMAND tests/restart-scenarios-test.py -c replay -p4 -v --dump-error-details WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
add_test(NAME restart-scenarios-test_hard_replay COMMAND tests/restart-scenarios-test.py -c hardReplay -p4 -v --dump-error-details WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
# TODO: add_test(NAME consensus-validation-malicious-producers COMMAND tests/consensus-validation-malicious-producers.py -w 80 --dump-error-details WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
if(ENABLE_COVERAGE_TESTING)
......
......@@ -4,7 +4,6 @@ import testUtils
import argparse
import random
import signal
###############################################################
# Test for different nodes restart scenarios.
......@@ -65,8 +64,8 @@ testSuccessful=False
random.seed(seed) # Use a fixed seed for repeatability.
cluster=testUtils.Cluster()
walletMgr=testUtils.WalletMgr(False)
cluster=testUtils.Cluster(walletd=True)
walletMgr=testUtils.WalletMgr(True)
try:
cluster.setChainStrategy(chainSyncStrategyStr)
......@@ -87,6 +86,12 @@ try:
if not cluster.waitOnClusterBlockNumSync(3):
errorExit("Cluster never stabilized")
Print("Stand up EOS wallet keosd")
walletMgr.killall()
walletMgr.cleanup()
if walletMgr.launch() is False:
errorExit("Failed to stand up keosd.")
accountsCount=total_nodes
walletName="MyWallet"
Print("Creating wallet %s if one doesn't already exist." % walletName)
......@@ -99,14 +104,15 @@ try:
errorExit("Wallet initialization failed.")
defproduceraAccount=cluster.defproduceraAccount
eosioAccount=cluster.eosioAccount
Print("Importing keys for account %s into wallet %s." % (defproduceraAccount.name, wallet.name))
if not walletMgr.importKey(defproduceraAccount, wallet):
errorExit("Failed to import key for account %s" % (defproduceraAccount.name))
Print("Create accounts.")
#if not cluster.createAccounts(wallet):
if not cluster.createAccounts(defproduceraAccount):
#if not cluster.createAccounts(defproduceraAccount):
if not cluster.createAccounts(eosioAccount):
errorExit("Accounts creation failed.")
Print("Wait on cluster sync.")
......@@ -115,9 +121,9 @@ try:
# TBD: Known issue (Issue 2043) that 'get currency0000 balance' doesn't return balance.
# Uncomment when functional
# Print("Spread funds and validate")
# if not cluster.spreadFundsAndValidate(10):
# errorExit("Failed to spread and validate funds.")
Print("Spread funds and validate")
if not cluster.spreadFundsAndValidate(10):
errorExit("Failed to spread and validate funds.")
Print("Wait on cluster sync.")
if not cluster.waitOnClusterSync():
......@@ -130,9 +136,9 @@ try:
# TBD: Known issue (Issue 2043) that 'get currency0000 balance' doesn't return balance.
# Uncomment when functional
# Print("Spread funds and validate")
# if not cluster.spreadFundsAndValidate(10):
# errorExit("Failed to spread and validate funds.")
Print("Spread funds and validate")
if not cluster.spreadFundsAndValidate(10):
errorExit("Failed to spread and validate funds.")
Print("Wait on cluster sync.")
if not cluster.waitOnClusterSync():
......@@ -150,9 +156,9 @@ try:
# TBD: Known issue (Issue 2043) that 'get currency0000 balance' doesn't return balance.
# Uncomment when functional
# Print("Spread funds and validate")
# if not cluster.spreadFundsAndValidate(10):
# errorExit("Failed to spread and validate funds.")
Print("Spread funds and validate")
if not cluster.spreadFundsAndValidate(10):
errorExit("Failed to spread and validate funds.")
Print("Wait on cluster sync.")
if not cluster.waitOnClusterSync():
......@@ -173,6 +179,5 @@ finally:
Print("Cleanup cluster and wallet data.")
cluster.cleanup()
walletMgr.cleanup()
pass
exit(0)
......@@ -16,6 +16,7 @@ import sys
import random
import json
import shlex
from sys import stdout
from core_symbol import CORE_SYMBOL
......@@ -39,7 +40,7 @@ class Utils:
def Print(*args, **kwargs):
stackDepth=len(inspect.stack())-2
s=' '*stackDepth
sys.stdout.write(s)
stdout.write(s)
print(*args, **kwargs)
SyncStrategy=namedtuple("ChainSyncStrategy", "name id arg")
......@@ -47,6 +48,7 @@ class Utils:
SyncNoneTag="none"
SyncReplayTag="replay"
SyncResyncTag="resync"
SyncHardReplayTag="hardReplay"
SigKillTag="kill"
SigTermTag="term"
......@@ -78,6 +80,9 @@ class Utils:
chainSyncStrategy=Utils.SyncStrategy(Utils.SyncResyncTag, 2, "--delete-all-blocks")
chainSyncStrategies[chainSyncStrategy.name]=chainSyncStrategy
chainSyncStrategy=Utils.SyncStrategy(Utils.SyncHardReplayTag, 3, "--hard-replay-blockchain")
chainSyncStrategies[chainSyncStrategy.name]=chainSyncStrategy
return chainSyncStrategies
@staticmethod
......@@ -98,14 +103,24 @@ class Utils:
timeout=60
endTime=time.time()+timeout
while endTime > time.time():
ret=lam()
if ret is not None:
return ret
sleepTime=3
Utils.Print("cmd: sleep %d seconds, remaining time: %d seconds" %
(sleepTime, endTime - time.time()))
time.sleep(sleepTime)
needsNewLine=False
try:
while endTime > time.time():
ret=lam()
if ret is not None:
return ret
sleepTime=3
if Utils.Debug:
Utils.Print("cmd: sleep %d seconds, remaining time: %d seconds" %
(sleepTime, endTime - time.time()))
else:
stdout.write('.')
stdout.flush()
needsNewLine=True
time.sleep(sleepTime)
finally:
if needsNewLine:
Utils.Print()
return None
......@@ -170,16 +185,17 @@ class Node(object):
assert trans["processed"]["receipt"]["status"] == "executed", printTrans(trans)
@staticmethod
def runCmdReturnJson(cmd, trace=False):
def runCmdReturnJson(cmd, trace=False, silentErrors=False):
cmdArr=shlex.split(cmd)
retStr=Utils.checkOutput(cmdArr)
jStr=Node.filterJsonObject(retStr)
if trace: Utils.Print ("RAW > %s"% (retStr))
if trace: Utils.Print ("JSON> %s"% (jStr))
if not jStr:
msg="Expected JSON response"
Utils.Print ("ERROR: "+ msg)
Utils.Print ("RAW > %s"% retStr)
msg="Received empty JSON response"
if not silentErrors:
Utils.Print ("ERROR: "+ msg)
Utils.Print ("RAW > %s"% retStr)
raise TypeError(msg)
try:
......@@ -446,7 +462,7 @@ class Node(object):
refBlockNum=int(refBlockNum)+1
except (TypeError, ValueError, KeyError) as _:
Utils.Print("transaction parsing failed. Transaction: %s" % (trans))
raise
return None
headBlockNum=self.getHeadBlockNum()
assert(headBlockNum)
......@@ -1000,7 +1016,7 @@ class Node(object):
cmd="%s %s get info" % (Utils.EosClientPath, self.endpointArgs)
if Utils.Debug: Utils.Print("cmd: %s" % (cmd))
try:
trans=Node.runCmdReturnJson(cmd)
trans=Node.runCmdReturnJson(cmd, silentErrors=silentErrors)
return trans
except subprocess.CalledProcessError as ex:
if not silentErrors:
......@@ -1070,7 +1086,7 @@ class Node(object):
return False
if not Utils.waitForBool(myFunc):
Utils.Print("ERROR: Failed to kill node (%s)." % (self.cmd), ex)
Utils.Print("ERROR: Failed to validate node shutdown.")
return False
# mark node as killed
......@@ -1079,30 +1095,40 @@ class Node(object):
return True
# TBD: make nodeId an internal property
def relaunch(self, nodeId, chainArg):
def relaunch(self, nodeId, chainArg, timeout=Utils.systemWaitTimeout):
assert(self.pid is None)
assert(self.killed)
if Utils.Debug: Utils.Print("Launching node process, Id: %d" % (nodeId))
dataDir="var/lib/node_%02d" % (nodeId)
dt = datetime.datetime.now()
dateStr="%d_%02d_%02d_%02d_%02d_%02d" % (
dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second)
stdoutFile="%s/stdout.%s.txt" % (dataDir, dateStr)
stderrFile="%s/stderr.%s.txt" % (dataDir, dateStr)
with open(stdoutFile, 'w') as sout, open(stderrFile, 'w') as serr:
cmd=self.cmd + ("" if chainArg is None else (" " + chainArg))
Utils.Print("cmd: %s" % (cmd))
popen=subprocess.Popen(cmd.split(), stdout=sout, stderr=serr)
self.pid=popen.pid
running=True
try:
os.kill(self.pid, 0) #check if process with pid is running
except OSError as _:
running=False
def isNodeAlive():
"""wait for node to be responsive."""
try:
return True if self.checkPulse() else False
except (TypeError) as _:
pass
return False
if running:
Utils.Print("WARNING: A process with pid (%d) is already running." % (self.pid))
isAlive=Utils.waitForBool(isNodeAlive, timeout)
if isAlive:
Utils.Print("Node relaunch was successfull.")
else:
if Utils.Debug: Utils.Print("Launching node process, Id: %d" % (nodeId))
dataDir="var/lib/node_%02d" % (nodeId)
dt = datetime.datetime.now()
dateStr="%d_%02d_%02d_%02d_%02d_%02d" % (
dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second)
stdoutFile="%s/stdout.%s.txt" % (dataDir, dateStr)
stderrFile="%s/stderr.%s.txt" % (dataDir, dateStr)
with open(stdoutFile, 'w') as sout, open(stderrFile, 'w') as serr:
cmd=self.cmd + ("" if chainArg is None else (" " + chainArg))
Utils.Print("cmd: %s" % (cmd))
popen=subprocess.Popen(cmd.split(), stdout=sout, stderr=serr)
self.pid=popen.pid
Utils.Print("ERROR: Node relaunch Failed.")
self.pid=None
return False
self.killed=False
return True
......@@ -1726,7 +1752,7 @@ class Cluster(object):
Utils.Print("ERROR: Failed to spread funds across nodes.")
return False
Utils.Print("Funds spread across all accounts. Noew validate funds")
Utils.Print("Funds spread across all accounts. Now validate funds")
if False == self.validateSpreadFunds(initialBalances, transferAmount, self.defproduceraAccount, self.accounts):
Utils.Print("ERROR: Failed to validate funds transfer across nodes.")
......@@ -2157,7 +2183,7 @@ class Cluster(object):
for i in range(0, len(self.nodes)):
node=self.nodes[i]
if not node.relaunch(i, chainArg):
if node.killed and not node.relaunch(i, chainArg):
return False
return True
......
......@@ -28,7 +28,6 @@ systemAccounts = [
'eosio.vpay',
]
def jsonArg(a):
return " '" + json.dumps(a) + "' "
......@@ -105,7 +104,7 @@ def startNode(nodeIndex, account):
)
cmd = (
args.nodeos +
' --max-transaction-time 200'
' --max-irreversible-block-age 9999999'
' --contracts-console'
' --genesis-json ' + os.path.abspath(args.genesis) +
' --blocks-dir ' + os.path.abspath(dir) + '/blocks'
......@@ -115,6 +114,7 @@ def startNode(nodeIndex, account):
' --http-server-address 127.0.0.1:' + str(8000 + nodeIndex) +
' --p2p-listen-endpoint 127.0.0.1:' + str(9000 + nodeIndex) +
' --max-clients ' + str(maxClients) +
' --p2p-max-nodes-per-host ' + str(maxClients) +
' --enable-stale-production'
' --producer-name ' + account['name'] +
' --private-key \'["' + account['pub'] + '","' + account['pvt'] + '"]\''
......@@ -137,25 +137,40 @@ def createSystemAccounts():
def intToCurrency(i):
return '%d.%04d %s' % (i // 10000, i % 10000, args.symbol)
def fillStake(b, e):
def allocateFunds(b, e):
dist = numpy.random.pareto(1.161, e - b).tolist() # 1.161 = 80/20 rule
dist.sort()
dist.reverse()
factor = 1_000_000_000 / sum(dist)
total = 0
for i in range(b, e):
stake = round(factor * dist[i - b] * 10000 / 2)
funds = round(factor * dist[i - b] * 10000)
if i >= firstProducer and i < firstProducer + numProducers:
stake = max(stake, round(args.min_producer_stake * 10000))
total += stake * 2
accounts[i]['stake'] = stake
return total + round(args.extra_issue * 10000)
funds = max(funds, round(args.min_producer_funds * 10000))
total += funds
accounts[i]['funds'] = funds
return total
def createStakedAccounts(b, e):
ramFunds = round(args.ram_funds * 10000)
configuredMinStake = round(args.min_stake * 10000)
maxUnstaked = round(args.max_unstaked * 10000)
for i in range(b, e):
a = accounts[i]
stake = intToCurrency(a['stake'])
run(args.cleos + 'system newaccount eosio --transfer ' + a['name'] + ' ' + a['pub'] + ' --stake-net "' + stake + '" --stake-cpu "' + stake + '"')
funds = a['funds']
if funds < ramFunds:
print('skipping %s: not enough funds to cover ram' % a['name'])
continue
minStake = min(funds - ramFunds, configuredMinStake)
unstaked = min(funds - ramFunds - minStake, maxUnstaked)
stake = funds - ramFunds - unstaked
stakeNet = round(stake / 2)
stakeCpu = stake - stakeNet
print('%s: total funds=%s, ram=%s, net=%s, cpu=%s, unstaked=%s' % (a['name'], intToCurrency(a['funds']), intToCurrency(ramFunds), intToCurrency(stakeNet), intToCurrency(stakeCpu), intToCurrency(unstaked)))
assert(funds == ramFunds + stakeNet + stakeCpu + unstaked)
run(args.cleos + 'system newaccount --transfer eosio %s %s --stake-net "%s" --stake-cpu "%s" --buy-ram-EOS "%s" ' %
(a['name'], a['pub'], intToCurrency(stakeNet), intToCurrency(stakeCpu), intToCurrency(ramFunds)))
run(args.cleos + 'transfer eosio %s "%s"' % (a['name'], intToCurrency(unstaked)))
def regProducers(b, e):
for i in range(b, e):
......@@ -216,11 +231,6 @@ def resign(account, controller):
sleep(1)
run(args.cleos + 'get account ' + account)
def sendUnstakedFunds(b, e):
for i in range(b, e):
a = accounts[i]
run(args.cleos + 'transfer eosio ' + a['name'] + ' "10.0000 ' + args.symbol + '"')
def randomTransfer(b, e):
for j in range(20):
src = accounts[random.randint(b, e - 1)]['name']
......@@ -258,7 +268,7 @@ def msigReplaceSystem():
def produceNewAccounts():
with open('newusers', 'w') as f:
for i in range(0, 3000):
for i in range(3000, 30000):
x = getOutput(args.cleos + 'create key')
r = re.match('Private key: *([^ \n]*)\nPublic key: *([^ \n]*)', x, re.DOTALL | re.MULTILINE)
name = 'user'
......@@ -267,7 +277,6 @@ def produceNewAccounts():
print(i, name)
f.write(' {"name":"%s", "pvt":"%s", "pub":"%s"},\n' % (name, r[1], r[2]))
def stepKillAll():
run('killall keosd nodeos || true')
sleep(1.5)
......@@ -282,7 +291,7 @@ def stepInstallSystemContracts():
run(args.cleos + 'set contract eosio.msig ' + args.contracts_dir + 'eosio.msig/')
def stepCreateTokens():
run(args.cleos + 'push action eosio.token create \'["eosio", "10000000000.0000 %s"]\' -p eosio.token' % (args.symbol))
totalAllocation = fillStake(0, len(accounts))
totalAllocation = allocateFunds(0, len(accounts))
run(args.cleos + 'push action eosio.token issue \'["eosio", "%s", "memo"]\' -p eosio' % intToCurrency(totalAllocation))
sleep(1)
def stepSetSystemContract():
......@@ -309,9 +318,6 @@ def stepResign():
resign('eosio', 'eosio.prods')
for a in systemAccounts:
resign(a, 'eosio')
def stepIssueUnstaked():
run(args.cleos + 'push action eosio.token issue \'["eosio", "%d.0000 %s", "memo"]\' -p eosio' % ((len(accounts)) * 10, args.symbol))
sendUnstakedFunds(0, args.num_senders)
def stepTransfer():
while True:
randomTransfer(0, args.num_senders)
......@@ -338,12 +344,10 @@ commands = [
('x', 'proxy', stepProxyVotes, True, "Proxy votes"),
('q', 'resign', stepResign, True, "Resign eosio"),
('m', 'msg-replace', msigReplaceSystem, False, "Replace system contract using msig"),
('u', 'issue', stepIssueUnstaked, True, "Issue unstaked tokens"),
('X', 'xfer', stepTransfer, False, "Random transfer tokens (infinite loop)"),
('l', 'log', stepLog, True, "Show tail of node's log"),
]
parser.add_argument('--public-key', metavar='', help="EOSIO Public Key", default='EOS8Znrtgwt8TfpmbVpTKvA2oB8Nqey625CLN8bCN3TEbgx86Dsvr', dest="public_key")
parser.add_argument('--private-Key', metavar='', help="EOSIO Private Key", default='5K463ynhZoCDDa4RDcr63cUwWLTnKqmdcoTKTHBjqoKfv4u5V7p', dest="private_key")
parser.add_argument('--cleos', metavar='', help="Cleos command", default='../../build/programs/cleos/cleos --wallet-url http://localhost:6666 ')
......@@ -355,11 +359,13 @@ parser.add_argument('--genesis', metavar='', help="Path to genesis.json", defaul
parser.add_argument('--wallet-dir', metavar='', help="Path to wallet directory", default='./wallet/')
parser.add_argument('--log-path', metavar='', help="Path to log file", default='./output.log')
parser.add_argument('--symbol', metavar='', help="The eosio.system symbol", default='SYS')
parser.add_argument('--user-limit', metavar='', help="Max number of users. (0 = no limit)", type=int, default=0)
parser.add_argument('--user-limit', metavar='', help="Max number of users. (0 = no limit)", type=int, default=3000)
parser.add_argument('--max-user-keys', metavar='', help="Maximum user keys to import into wallet", type=int, default=10)
parser.add_argument('--extra-issue', metavar='', help="Extra amount to issue to cover buying ram", type=float, default=10.0000)
parser.add_argument('--ram-funds', metavar='', help="How much funds for each user to spend on ram", type=float, default=0.1)
parser.add_argument('--min-stake', metavar='', help="Minimum stake before allocating unstaked funds", type=float, default=0.9)
parser.add_argument('--max-unstaked', metavar='', help="Maximum unstaked funds", type=float, default=10)
parser.add_argument('--producer-limit', metavar='', help="Maximum number of producers. (0 = no limit)", type=int, default=0)
parser.add_argument('--min-producer-stake', metavar='', help="Minimum producer CPU and BW stake", type=float, default=200.0000)
parser.add_argument('--min-producer-funds', metavar='', help="Minimum producer funds", type=float, default=1000.0000)
parser.add_argument('--num-producers-vote', metavar='', help="Number of producers for which each user votes", type=int, default=20)
parser.add_argument('--num-voters', metavar='', help="Number of voters", type=int, default=10)
parser.add_argument('--num-senders', metavar='', help="Number of users to transfer funds randomly", type=int, default=10)
......
......@@ -1570,7 +1570,21 @@ INCBIN(fuzz9, "fuzz9.wasm");
INCBIN(fuzz10, "fuzz10.wasm");
INCBIN(fuzz11, "fuzz11.wasm");
INCBIN(fuzz12, "fuzz12.wasm");
INCBIN(fuzz13, "fuzz13.wasm");
INCBIN(fuzz14, "fuzz14.wasm");
INCBIN(fuzz15, "fuzz15.wasm");
//INCBIN(fuzz13, "fuzz13.wasm");
INCBIN(big_allocation, "big_allocation.wasm");
INCBIN(crash_section_size_too_big, "crash_section_size_too_big.wasm");
INCBIN(leak_no_destructor, "leak_no_destructor.wasm");
INCBIN(leak_readExports, "leak_readExports.wasm");
INCBIN(leak_readFunctions, "leak_readFunctions.wasm");
INCBIN(leak_readFunctions_2, "leak_readFunctions_2.wasm");
INCBIN(leak_readFunctions_3, "leak_readFunctions_3.wasm");
INCBIN(leak_readGlobals, "leak_readGlobals.wasm");
INCBIN(leak_readImports, "leak_readImports.wasm");
INCBIN(leak_wasm_binary_cpp_L1249, "leak_wasm_binary_cpp_L1249.wasm");
INCBIN(readFunctions_slowness_out_of_memory, "readFunctions_slowness_out_of_memory.wasm");
BOOST_FIXTURE_TEST_CASE( fuzz, TESTER ) try {
produce_blocks(2);
......@@ -1626,6 +1640,18 @@ BOOST_FIXTURE_TEST_CASE( fuzz, TESTER ) try {
vector<uint8_t> wasm(gfuzz12Data, gfuzz12Data + gfuzz12Size);
BOOST_CHECK_THROW(set_code(N(fuzzy), wasm), fc::exception);
}
{
vector<uint8_t> wasm(gfuzz13Data, gfuzz13Data + gfuzz13Size);
BOOST_CHECK_THROW(set_code(N(fuzzy), wasm), fc::exception);
}
{
vector<uint8_t> wasm(gfuzz14Data, gfuzz14Data + gfuzz14Size);
BOOST_CHECK_THROW(set_code(N(fuzzy), wasm), fc::exception);
}
{
vector<uint8_t> wasm(gfuzz15Data, gfuzz15Data + gfuzz15Size);
BOOST_CHECK_THROW(set_code(N(fuzzy), wasm), fc::exception);
}
/* TODO: update wasm to have apply(...) then call, claim is that this
* takes 1.6 seconds under wavm...
{
......@@ -1638,6 +1664,51 @@ BOOST_FIXTURE_TEST_CASE( fuzz, TESTER ) try {
}
*/
{
vector<uint8_t> wasm(gbig_allocationData, gbig_allocationData + gbig_allocationSize);
BOOST_CHECK_THROW(set_code(N(fuzzy), wasm), wasm_serialization_error);
}
{
vector<uint8_t> wasm(gcrash_section_size_too_bigData, gcrash_section_size_too_bigData + gcrash_section_size_too_bigSize);
BOOST_CHECK_THROW(set_code(N(fuzzy), wasm), wasm_serialization_error);
}
{
vector<uint8_t> wasm(gleak_no_destructorData, gleak_no_destructorData + gleak_no_destructorSize);
BOOST_CHECK_THROW(set_code(N(fuzzy), wasm), wasm_serialization_error);
}
{
vector<uint8_t> wasm(gleak_readExportsData, gleak_readExportsData + gleak_readExportsSize);
BOOST_CHECK_THROW(set_code(N(fuzzy), wasm), wasm_serialization_error);
}
{
vector<uint8_t> wasm(gleak_readFunctionsData, gleak_readFunctionsData + gleak_readFunctionsSize);
BOOST_CHECK_THROW(set_code(N(fuzzy), wasm), wasm_serialization_error);
}
{
vector<uint8_t> wasm(gleak_readFunctions_2Data, gleak_readFunctions_2Data + gleak_readFunctions_2Size);
BOOST_CHECK_THROW(set_code(N(fuzzy), wasm), wasm_serialization_error);
}
{
vector<uint8_t> wasm(gleak_readFunctions_3Data, gleak_readFunctions_3Data + gleak_readFunctions_3Size);
BOOST_CHECK_THROW(set_code(N(fuzzy), wasm), wasm_serialization_error);
}
{
vector<uint8_t> wasm(gleak_readGlobalsData, gleak_readGlobalsData + gleak_readGlobalsSize);
BOOST_CHECK_THROW(set_code(N(fuzzy), wasm), wasm_serialization_error);
}
{
vector<uint8_t> wasm(gleak_readImportsData, gleak_readImportsData + gleak_readImportsSize);
BOOST_CHECK_THROW(set_code(N(fuzzy), wasm), wasm_serialization_error);
}
{
vector<uint8_t> wasm(gleak_wasm_binary_cpp_L1249Data, gleak_wasm_binary_cpp_L1249Data + gleak_wasm_binary_cpp_L1249Size);
BOOST_CHECK_THROW(set_code(N(fuzzy), wasm), wasm_serialization_error);
}
{
vector<uint8_t> wasm(greadFunctions_slowness_out_of_memoryData, greadFunctions_slowness_out_of_memoryData + greadFunctions_slowness_out_of_memorySize);
BOOST_CHECK_THROW(set_code(N(fuzzy), wasm), wasm_serialization_error);
}
produce_blocks(1);
} FC_LOG_AND_RETHROW()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册