Skip to content

Commit

Permalink
Merge pull request EOSIO#158 from enumivo/staging
Browse files Browse the repository at this point in the history
Staging
  • Loading branch information
Enumivo authored May 28, 2018
2 parents 9009e0e + 2b1a6f9 commit c24b85a
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 32 deletions.
12 changes: 6 additions & 6 deletions Docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,28 +173,28 @@ run `docker pull enumivo/enumivo:latest`

run `docker-compose up`

### Dawn 4.0 Testnet
### Dawn 4.2 Testnet

We can easily set up a Dawn 4.0 local testnet using docker images. Just run the following commands:
We can easily set up a Dawn 4.2 local testnet using docker images. Just run the following commands:

Note: if you want to use the mongo db plugin, you have to enable it in your `data-dir/config.ini` first.

```
# pull images
docker pull enumivo/enumivo:latest
docker pull enumivo/enumivo:20180528
docker pull mongo:latest
# create volume
docker volume create --name=enunode-data-volume
docker volume create --name=enuwallet-data-volume
docker volume create --name=mongo-data-volume
# start containers
docker-compose -f docker-compose-dawn4.0.yaml up -d
docker-compose -f docker-compose-dawn4.2.yaml up -d
# get chain info
curl http://127.0.0.1:8888/v1/chain/get_info
# get logs
docker-compose logs enunoded
docker-compose logs -f enunoded
# stop containers
docker-compose -f docker-compose-dawn4.0.yaml down
docker-compose -f docker-compose-dawn4.2.yaml down
```

The `blocks` data are stored under `--data-dir` by default, and the wallet files are stored under `--wallet-dir` by default, of course you can change these as you want.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ services:
- mongo-data-volume:/data/db

enunoded:
image: enumivo/enumivo:latest
image: enumivo/enumivo:20180528
command: /opt/enumivo/bin/enunoded.sh --data-dir /opt/enumivo/bin/data-dir --delete-all-blocks #--mongodb-uri mongodb://mongo:27017/ENU
hostname: enunoded
links:
Expand All @@ -24,7 +24,7 @@ services:
- enunode-data-volume:/opt/enumivo/bin/data-dir

enuwallet:
image: enumivo/enumivo:latest
image: enumivo/enumivo:20180528
command: /opt/enumivo/bin/enuwallet --wallet-dir /opt/enumivo/bin/data-dir --http-server-address=127.0.0.1:8900
hostname: enuwallet
links:
Expand Down
6 changes: 3 additions & 3 deletions libraries/chain/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ struct controller_impl {
FC_ASSERT( log_head );
auto lh_block_num = log_head->block_num();

emit( self.irreversible_block, s );
db.commit( s->block_num );

if( s->block_num <= lh_block_num ) {
// edump((s->block_num)("double call to on_irr"));
// edump((s->block_num)(s->block->previous)(log_head->id()));
Expand All @@ -173,9 +176,6 @@ struct controller_impl {
FC_ASSERT( s->block->previous == log_head->id(), "irreversible doesn't link to block log head" );
blog.append(s->block);

emit( self.irreversible_block, s );
db.commit( s->block_num );

const auto& ubi = reversible_blocks.get_index<reversible_block_index,by_num>();
auto objitr = ubi.begin();
while( objitr != ubi.end() && objitr->blocknum <= s->block_num ) {
Expand Down
13 changes: 7 additions & 6 deletions libraries/chain/enumivo_contract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,16 @@ void apply_enumivo_setcode(apply_context& context) {
auto& db = context.db;
auto act = context.act.data_as<setcode>();
context.require_authorization(act.account);
// context.require_write_lock( config::enumivo_auth_scope );

FC_ASSERT( act.vmtype == 0 );
FC_ASSERT( act.vmversion == 0 );


auto code_id = fc::sha256::hash( act.code.data(), (uint32_t)act.code.size() );

wasm_interface::validate(act.code);
fc::sha256 code_id; /// default ID == 0

if( act.code.size() > 0 ) {
code_id = fc::sha256::hash( act.code.data(), (uint32_t)act.code.size() );
wasm_interface::validate(act.code);
}

const auto& account = db.get<account_object,by_name>(act.account);

Expand All @@ -142,7 +143,7 @@ void apply_enumivo_setcode(apply_context& context) {
int64_t new_size = code_size * config::setcode_ram_bytes_multiplier;

FC_ASSERT( account.code_version != code_id, "contract is already running this version of code" );
// wlog( "set code: ${size}", ("size",act.code.size()));

db.modify( account, [&]( auto& a ) {
/** TODO: consider whether a microsecond level local timestamp is sufficient to detect code version changes*/
#warning TODO: update setcode message to include the hash, then validate it in validate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <iterator>
#include <memory>
#include <fc/optional.hpp>
#include <fc/exception/exception.hpp>
#include <string>
#include <unordered_map>
#include <utility>
Expand Down Expand Up @@ -662,14 +663,14 @@ struct ENUMIVO_OperatorDecoderStream
operator bool() const { return nextByte < end; }

instr* decodeOp() {
assert(nextByte + sizeof(IR::Opcode) <= end);
FC_ASSERT(nextByte + sizeof(IR::Opcode) <= end);
IR::Opcode opcode = *(IR::Opcode*)nextByte;
switch(opcode)
{
#define VISIT_OPCODE(opcode,name,nameString,Imm,...) \
case IR::Opcode::name: \
{ \
assert(nextByte + sizeof(IR::OpcodeAndImm<IR::Imm>) <= end); \
FC_ASSERT(nextByte + sizeof(IR::OpcodeAndImm<IR::Imm>) <= end); \
IR::OpcodeAndImm<IR::Imm>* encodedOperator = (IR::OpcodeAndImm<IR::Imm>*)nextByte; \
nextByte += sizeof(IR::OpcodeAndImm<IR::Imm>); \
auto op = _cached_ops->at(BOOST_PP_CAT(name, _code)); \
Expand Down
2 changes: 1 addition & 1 deletion libraries/chain/wasm_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ namespace enumivo { namespace chain {
//there are a couple opportunties for improvement here--
//Easy: Cache the Module created here so it can be reused for instantiaion
//Hard: Kick off instantiation in a separate thread at this location
}
}

void wasm_interface::apply( const digest_type& code_id, const shared_string& code, apply_context& context ) {
my->get_instantiated_module(code_id, code, context.trx_context)->apply(context);
Expand Down
2 changes: 1 addition & 1 deletion libraries/chain/webassembly/binaryen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ std::unique_ptr<wasm_instantiated_module_interface> binaryen_runtime::instantiat
table.resize(module->table.initial);
for (auto& segment : module->table.segments) {
Address offset = ConstantExpressionRunner<TrivialGlobalManager>(globals).visit(segment.offset).value.geti32();
assert(offset + segment.data.size() <= module->table.initial);
FC_ASSERT(offset + segment.data.size() <= module->table.initial);
for (size_t i = 0; i != segment.data.size(); ++i) {
table[offset + i] = segment.data[i];
}
Expand Down
31 changes: 27 additions & 4 deletions plugins/http_plugin/http_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ namespace enumivo {
optional<tcp::endpoint> listen_endpoint;
string access_control_allow_origin;
string access_control_allow_headers;
string access_control_max_age;
bool access_control_allow_credentials = false;

websocket_server_type server;
Expand Down Expand Up @@ -170,9 +171,19 @@ namespace enumivo {
if( !access_control_allow_headers.empty()) {
con->append_header( "Access-Control-Allow-Headers", access_control_allow_headers );
}
if( !access_control_max_age.empty()) {
con->append_header( "Access-Control-Max-Age", access_control_max_age );
}
if( access_control_allow_credentials ) {
con->append_header( "Access-Control-Allow-Credentials", "true" );
}

auto& req = con->get_request();
if(req.get_method() == "OPTIONS") {
con->set_status(websocketpp::http::status_code::ok);
return;
}

con->append_header( "Content-type", "application/json" );
auto body = con->get_request_body();
auto resource = con->get_uri()->get_resource();
Expand Down Expand Up @@ -243,6 +254,12 @@ namespace enumivo {
}),
"Specify the Access-Control-Allow-Headers to be returned on each request.")

("access-control-max-age", bpo::value<string>()->notifier([this](const string& v) {
my->access_control_max_age = v;
ilog("configured http with Access-Control-Max-Age : ${o}", ("o", my->access_control_max_age));
}),
"Specify the Access-Control-Max-Age to be returned on each request.")

("access-control-allow-credentials",
bpo::bool_switch()->notifier([this](bool v) {
my->access_control_allow_credentials = v;
Expand Down Expand Up @@ -303,11 +320,14 @@ namespace enumivo {
my->server.listen(*my->listen_endpoint);
my->server.start_accept();
} catch ( const fc::exception& e ){
elog( "http: ${e}", ("e",e.to_detail_string()));
elog( "http service failed to start: ${e}", ("e",e.to_detail_string()));
throw;
} catch ( const std::exception& e ){
elog( "http: ${e}", ("e",e.what()));
elog( "http service failed to start: ${e}", ("e",e.what()));
throw;
} catch (...) {
elog("error thrown from http io service");
throw;
}
}

Expand All @@ -322,11 +342,14 @@ namespace enumivo {
my->https_server.listen(*my->https_listen_endpoint);
my->https_server.start_accept();
} catch ( const fc::exception& e ){
elog( "https: ${e}", ("e",e.to_detail_string()));
elog( "https service failed to start: ${e}", ("e",e.to_detail_string()));
throw;
} catch ( const std::exception& e ){
elog( "https: ${e}", ("e",e.what()));
elog( "https service failed to start: ${e}", ("e",e.what()));
throw;
} catch (...) {
elog("error thrown from https io service");
throw;
}
}
}
Expand Down
3 changes: 0 additions & 3 deletions plugins/producer_plugin/producer_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -648,9 +648,6 @@ producer_plugin_impl::start_block_result producer_plugin_impl::start_block() {
} else if ( _pause_production ) {
elog("Not producing block because production is explicitly paused");
_pending_block_mode = pending_block_mode::speculating;
} else if ( irreversible_block_age >= _max_irreversible_block_age_us ) {
elog("Not producing block because the irreversible block is too old [age:${age}s, max:${max}s]", ("age", irreversible_block_age.count() / 1'000'000)( "max", _max_irreversible_block_age_us.count() / 1'000'000 ));
_pending_block_mode = pending_block_mode::speculating;
}

if (_pending_block_mode == pending_block_mode::producing) {
Expand Down
8 changes: 4 additions & 4 deletions programs/enucli/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,13 +281,11 @@ fc::variant push_transaction( signed_transaction& trx, int32_t extra_kcpu = 1000
trx.context_free_actions.emplace_back( generate_nonce_action() );
}

auto required_keys = determine_required_keys(trx);
size_t num_keys = required_keys.is_array() ? required_keys.get_array().size() : 1;

trx.max_cpu_usage_ms = tx_max_net_usage;
trx.max_net_usage_words = (tx_max_net_usage + 7)/8;

if (!tx_skip_sign) {
auto required_keys = determine_required_keys(trx);
sign_transaction(trx, required_keys, info.chain_id);
}

Expand Down Expand Up @@ -731,8 +729,10 @@ void try_port( uint16_t port, uint32_t duration ) {
}

void ensure_enuwallet_running() {
if (tx_skip_sign)
return;
auto parsed_url = parse_url(wallet_url);
if (parsed_url.server != "localhost" && parsed_url.server == "127.0.0.1")
if (parsed_url.server != "localhost" && parsed_url.server != "127.0.0.1")
return;

auto wallet_port = std::stoi(parsed_url.port);
Expand Down
9 changes: 9 additions & 0 deletions scripts/enumivo_build_darwin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,15 @@
printf "\\tExiting now.\\n\\n"
exit 1;
fi

if [ -d "$BUILD_DIR" ]; then
if ! rm -rf "$BUILD_DIR"
then
printf "\\tUnable to remove directory %s. Please remove this directory and run this script %s again. 0\\n" "$BUILD_DIR" "${BASH_SOURCE[0]}"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
fi
printf "\\tBoost 1.67.0 successfully installed @ /usr/local.\\n"
else
printf "\\tBoost 1.67.0 found at /usr/local.\\n"
Expand Down

0 comments on commit c24b85a

Please sign in to comment.