Skip to content

Commit

Permalink
Merge pull request EOSIO#166 from enumivo/staging
Browse files Browse the repository at this point in the history
Staging
  • Loading branch information
Enumivo authored May 30, 2018
2 parents ff0e069 + 508caa9 commit 1a6f114
Show file tree
Hide file tree
Showing 24 changed files with 227 additions and 105 deletions.
51 changes: 29 additions & 22 deletions governance/constitution.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,44 @@

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 Enumivo 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 20% of issued tokens.
No Member nor ENU token holder shall have fiduciary responsability to support the value of the ENU token. The Members do not authorize anyone to hold assets, borrow, nor contract on behalf of ENU token holders collectively. This blockchain has no owners, managers or fiduciaries; therefore, no Member shall have beneficial interest in more than 20% of the ENU 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 Enumivo 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, and the Maxims of Equity.
Choice of law for disputes shall be, in order of precedence, this Constitution and the Maxims of Equity.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ namespace enumivo { 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) {
ENU_ASSERT(false, wasm_serialization_error, e.message.c_str());
} catch(const IR::ValidationException& e) {
ENU_ASSERT(false, wasm_serialization_error, e.message.c_str());
}

Expand All @@ -76,7 +78,9 @@ namespace enumivo { namespace chain {
Serialization::ArrayOutputStream outstream;
WASM::serialize(outstream, module);
bytes = outstream.getBytes();
} catch(Serialization::FatalSerializationException& e) {
} catch(const Serialization::FatalSerializationException& e) {
ENU_ASSERT(false, wasm_serialization_error, e.message.c_str());
} catch(const IR::ValidationException& e) {
ENU_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;
Expand Down
4 changes: 3 additions & 1 deletion libraries/chain/wasm_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ namespace enumivo { namespace chain {
try {
Serialization::MemoryInputStream stream((U8*)code.data(), code.size());
WASM::serialize(stream, module);
} catch(Serialization::FatalSerializationException& e) {
} catch(const Serialization::FatalSerializationException& e) {
ENU_ASSERT(false, wasm_serialization_error, e.message.c_str());
} catch(const IR::ValidationException& e) {
ENU_ASSERT(false, wasm_serialization_error, e.message.c_str());
}

Expand Down
6 changes: 5 additions & 1 deletion libraries/chain/wast_to_wasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,15 @@ namespace enumivo { 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
Expand Down
4 changes: 3 additions & 1 deletion libraries/chain/webassembly/wavm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
ENU_ASSERT(false, wasm_serialization_error, e.message.c_str());
} catch(const IR::ValidationException& e) {
ENU_ASSERT(false, wasm_serialization_error, e.message.c_str());
}

Expand Down
48 changes: 24 additions & 24 deletions plugins/bnet_plugin/bnet_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1055,26 +1055,22 @@ namespace enumivo {

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;
Expand All @@ -1091,21 +1087,24 @@ namespace enumivo {
}

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);
}

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 ) {
Expand Down Expand Up @@ -1152,6 +1151,7 @@ namespace enumivo {
};

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 ) {
Expand Down
1 change: 1 addition & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
35 changes: 20 additions & 15 deletions tests/restart-scenarios-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import argparse
import random
import signal

###############################################################
# Test for different nodes restart scenarios.
Expand Down Expand Up @@ -65,8 +64,8 @@ def errorExit(msg="", errorCode=1):


random.seed(seed) # Use a fixed seed for repeatability.
cluster=testUtils.Cluster()
walletMgr=testUtils.WalletMgr(False)
cluster=testUtils.Cluster(enuwalletd=True)
walletMgr=testUtils.WalletMgr(True)

try:
cluster.setChainStrategy(chainSyncStrategyStr)
Expand All @@ -87,6 +86,12 @@ def errorExit(msg="", errorCode=1):
if not cluster.waitOnClusterBlockNumSync(3):
errorExit("Cluster never stabilized")

Print("Stand up ENU wallet enuwallet")
walletMgr.killall()
walletMgr.cleanup()
if walletMgr.launch() is False:
errorExit("Failed to stand up enuwallet.")

accountsCount=total_nodes
walletName="MyWallet"
Print("Creating wallet %s if one doesn't already exist." % walletName)
Expand All @@ -99,14 +104,15 @@ def errorExit(msg="", errorCode=1):
errorExit("Wallet initialization failed.")

defproduceraAccount=cluster.defproduceraAccount
enumivoAccount=cluster.enumivoAccount

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(enumivoAccount):
errorExit("Accounts creation failed.")

Print("Wait on cluster sync.")
Expand All @@ -115,9 +121,9 @@ def errorExit(msg="", errorCode=1):

# 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():
Expand All @@ -130,9 +136,9 @@ def errorExit(msg="", errorCode=1):

# 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():
Expand All @@ -150,9 +156,9 @@ def errorExit(msg="", errorCode=1):

# 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():
Expand All @@ -173,6 +179,5 @@ def errorExit(msg="", errorCode=1):
Print("Cleanup cluster and wallet data.")
cluster.cleanup()
walletMgr.cleanup()
pass

exit(0)
Loading

0 comments on commit 1a6f114

Please sign in to comment.