未验证 提交 2bb562c2 编写于 作者: D Daniel Larimer 提交者: GitHub

Merge branch 'master' into more_fuzz

......@@ -176,6 +176,26 @@ if( options.count(name) ) { \
std::copy(ops.begin(), ops.end(), std::inserter(container, container.end())); \
}
fc::time_point calculate_genesis_timestamp( string tstr ) {
fc::time_point genesis_timestamp;
if( strcasecmp (tstr.c_str(), "now") == 0 ) {
genesis_timestamp = fc::time_point::now();
} else {
genesis_timestamp = time_point::from_iso_string( tstr );
}
auto epoch_us = genesis_timestamp.time_since_epoch().count();
auto diff_us = epoch_us % config::block_interval_us;
if (diff_us > 0) {
auto delay_us = (config::block_interval_us - diff_us);
genesis_timestamp += fc::microseconds(delay_us);
dlog("pausing ${us} microseconds to the next interval",("us",delay_us));
}
ilog( "Adjusting genesis timestamp to ${timestamp}", ("timestamp", genesis_timestamp) );
return genesis_timestamp;
}
void chain_plugin::plugin_initialize(const variables_map& options) {
ilog("initializing chain plugin");
......@@ -299,7 +319,7 @@ void chain_plugin::plugin_initialize(const variables_map& options) {
}
if( options.count("genesis-json") ) {
FC_ASSERT( !fc::exists( my->blocks_dir / "blocks.log" ), "Genesis State can only be specified on a fresh blockchain." );
FC_ASSERT( !fc::exists( my->blocks_dir / "blocks.log" ), "Genesis state can only be set on a fresh blockchain." );
auto genesis_file = options.at("genesis-json").as<bfs::path>();
if( genesis_file.is_relative() ) {
......@@ -315,23 +335,16 @@ void chain_plugin::plugin_initialize(const variables_map& options) {
ilog( "Using genesis state provided in '${genesis}'", ("genesis", genesis_file.generic_string()) );
if( options.count("genesis-timestamp") ) {
string tstr = options.at("genesis-timestamp").as<string>();
if( strcasecmp (tstr.c_str(), "now") == 0 ) {
my->chain_config->genesis.initial_timestamp = fc::time_point::now();
auto epoch_us = my->chain_config->genesis.initial_timestamp.time_since_epoch().count();
auto diff_us = epoch_us % config::block_interval_us;
if (diff_us > 0) {
auto delay_us = (config::block_interval_us - diff_us);
my->chain_config->genesis.initial_timestamp += fc::microseconds(delay_us);
dlog("pausing ${us} microseconds to the next interval",("us",delay_us));
}
} else {
my->chain_config->genesis.initial_timestamp = time_point::from_iso_string( tstr );
}
ilog( "Adjusting genesis timestamp to ${timestamp}", ("timestamp", my->chain_config->genesis.initial_timestamp) );
my->chain_config->genesis.initial_timestamp = calculate_genesis_timestamp( options.at("genesis-timestamp").as<string>() );
}
wlog( "Starting up fresh blockchain with provided genesis state." );
} else if( options.count("genesis-timestamp") ) {
FC_ASSERT( !fc::exists( my->blocks_dir / "blocks.log" ), "Genesis state can only be set on a fresh blockchain." );
my->chain_config->genesis.initial_timestamp = calculate_genesis_timestamp( options.at("genesis-timestamp").as<string>() );
wlog( "Starting up fresh blockchain with default genesis state but with adjusted genesis timestamp." );
} else if( fc::is_regular_file( my->blocks_dir / "blocks.log" ) ) {
my->chain_config->genesis = block_log::extract_genesis_state( my->blocks_dir );
} else {
......
......@@ -448,7 +448,7 @@ class Node(object):
Utils.Print("transaction parsing failed. Transaction: %s" % (trans))
raise
headBlockNum=self.getIrreversibleBlockNum()
headBlockNum=self.getHeadBlockNum()
assert(headBlockNum)
try:
headBlockNum=int(headBlockNum)
......@@ -706,8 +706,8 @@ class Node(object):
return ret
def waitForNextBlock(self, timeout=None):
num=self.getIrreversibleBlockNum()
lam = lambda: self.getIrreversibleBlockNum() > num
num=self.getHeadBlockNum()
lam = lambda: self.getHeadBlockNum() > num
ret=Utils.waitForBool(lam, timeout)
return ret
......@@ -833,7 +833,7 @@ class Node(object):
msg=ex.output.decode("utf-8")
Utils.Print("ERROR: Exception during actions by account retrieval. %s" % (msg))
return None
# Gets accounts mapped to key. Returns array
def getAccountsArrByKey(self, key):
trans=self.getAccountsByKey(key)
......@@ -1032,6 +1032,7 @@ class Node(object):
headBlockNumTag="head_block_num"
return info[headBlockNumTag]
else:
# Either this implementation or the one in getIrreversibleBlockNum are likely wrong.
block=self.getBlockFromDb(-1)
if block is not None:
blockNum=block["block_num"]
......@@ -1044,6 +1045,7 @@ class Node(object):
if info is not None:
return info["last_irreversible_block_num"]
else:
# Either this implementation or the one in getHeadBlockNum are likely wrong.
block=self.getBlockFromDb(-1)
if block is not None:
blockNum=block["block_num"]
......@@ -1104,7 +1106,7 @@ class Node(object):
self.killed=False
return True
###########################################################################################
Wallet=namedtuple("Wallet", "name password host port")
......@@ -1291,7 +1293,7 @@ class Cluster(object):
__localHost="localhost"
__BiosHost="localhost"
__BiosPort=8788
# pylint: disable=too-many-arguments
# walletd [True|False] Is keosd running. If not load the wallet plugin
def __init__(self, walletd=False, localCluster=True, host="localhost", port=8888, walletHost="localhost", walletPort=8899, enableMongo=False, mongoHost="localhost", mongoPort=27017, mongoDb="EOStest", defproduceraPrvtKey=None, defproducerbPrvtKey=None, staging=False):
......@@ -1370,8 +1372,8 @@ class Cluster(object):
if len(self.nodes) > 0:
raise RuntimeError("Cluster already running.")
cmd="%s -p %s -n %s -s %s -d %s -f --p2p-plugin bnet" % (
Utils.EosLauncherPath, pnodes, totalNodes, topo, delay)
cmd="%s -p %s -n %s -s %s -d %s -i %s -f --p2p-plugin bnet" % (
Utils.EosLauncherPath, pnodes, totalNodes, topo, delay, datetime.datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%S.%f")[:-3])
cmdArr=cmd.split()
if self.staging:
cmdArr.append("--nogen")
......@@ -1782,7 +1784,7 @@ class Cluster(object):
m=re.search(r"node_([\d]+)", name)
return int(m.group(1))
@staticmethod
def parseProducerKeys(configFile, nodeName):
"""Parse node config file for producer keys. Returns dictionary. (Keys: account name; Values: dictionary objects (Keys: ["name", "node", "private","public"]; Values: account name, node id returned by nodeNameToId(nodeName), private key(string)and public key(string)))."""
......@@ -1975,7 +1977,7 @@ class Cluster(object):
if trans is None:
Utils.Print("ERROR: Failed to create account %s" % (eosioTokenAccount.name))
return False
eosioRamAccount=copy.deepcopy(eosioAccount)
eosioRamAccount.name="eosio.ram"
trans=biosNode.createAccount(eosioRamAccount, eosioAccount, 0)
......@@ -2010,7 +2012,7 @@ class Cluster(object):
if trans is None:
Utils.Print("ERROR: Failed to publish contract %s." % (contract))
return False
# Create currency0000, followed by issue currency0000
contract=eosioTokenAccount.name
Utils.Print("push create action to %s contract" % (contract))
......@@ -2089,7 +2091,7 @@ class Cluster(object):
return True
# Populates list of EosInstanceInfo objects, matched to actual running instances
def discoverLocalNodes(self, totalNodes, timeout=0):
nodes=[]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册