Skip to content

Commit

Permalink
Merge pull request EOSIO#11 from Game-X-Coin/upstream-1.6.1
Browse files Browse the repository at this point in the history
Merge changes from upstream v1.6.1
  • Loading branch information
conr2d authored Feb 7, 2019
2 parents 720c857 + e232d24 commit 568f52f
Show file tree
Hide file tree
Showing 15 changed files with 463 additions and 336 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ set( CXX_STANDARD_REQUIRED ON)

set(VERSION_MAJOR 1)
set(VERSION_MINOR 6)
set(VERSION_PATCH 0)
set(VERSION_PATCH 1)
set(VERSION_SUFFIX rc1)

if(VERSION_SUFFIX)
Expand Down
44 changes: 3 additions & 41 deletions Docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ cd eos/Docker
docker build . -t eosio/eos
```

The above will build off the most recent commit to the master branch by default. If you would like to target a specific branch/tag, you may use a build argument. For example, if you wished to generate a docker image based off of the 1.6.0 tag, you could do the following:
The above will build off the most recent commit to the master branch by default. If you would like to target a specific branch/tag, you may use a build argument. For example, if you wished to generate a docker image based off of the 1.6.1 tag, you could do the following:

```bash
docker build -t eosio/eos:1.6.0 --build-arg branch=1.6.0 .
docker build -t eosio/eos:v1.6.1 --build-arg branch=1.6.1 .
```

By default, the symbol in eosio.system is set to SYS. You can override this using the symbol argument while building the docker image.
Expand Down Expand Up @@ -133,45 +133,7 @@ docker volume rm keosd-data-volume

### Docker Hub

Docker Hub image available from [docker hub](https://hub.docker.com/r/eosio/eos/).
Create a new `docker-compose.yaml` file with the content below

```bash
version: "3"

services:
nodeosd:
image: eosio/eos:latest
command: /opt/eosio/bin/nodeosd.sh --data-dir /opt/eosio/bin/data-dir -e --http-alias=nodeosd:8888 --http-alias=127.0.0.1:8888 --http-alias=localhost:8888
hostname: nodeosd
ports:
- 8888:8888
- 9876:9876
expose:
- "8888"
volumes:
- nodeos-data-volume:/opt/eosio/bin/data-dir

keosd:
image: eosio/eos:latest
command: /opt/eosio/bin/keosd --wallet-dir /opt/eosio/bin/data-dir --http-server-address=127.0.0.1:8900 --http-alias=localhost:8900 --http-alias=keosd:8900
hostname: keosd
links:
- nodeosd
volumes:
- keosd-data-volume:/opt/eosio/bin/data-dir

volumes:
nodeos-data-volume:
keosd-data-volume:

```

*NOTE:* the default version is the latest, you can change it to what you want

run `docker pull eosio/eos:latest`

run `docker-compose up`
Docker Hub images are now deprecated. New build images were discontinued on January 1st, 2019. The existing old images will be removed on June 1st, 2019.

### EOSIO Testnet

Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,31 +39,31 @@ $ brew remove eosio
```
#### Ubuntu 18.04 Debian Package Install
```sh
$ wget https://github.com/eosio/eos/releases/download/v1.6.0/eosio_1.6.0-1-ubuntu-18.04_amd64.deb
$ sudo apt install ./eosio_1.6.0-1-ubuntu-18.04_amd64.deb
$ wget https://github.com/eosio/eos/releases/download/v1.6.1/eosio_1.6.1-1-ubuntu-18.04_amd64.deb
$ sudo apt install ./eosio_1.6.1-1-ubuntu-18.04_amd64.deb
```
#### Ubuntu 16.04 Debian Package Install
```sh
$ wget https://github.com/eosio/eos/releases/download/v1.6.0/eosio_1.6.0-1-ubuntu-16.04_amd64.deb
$ sudo apt install ./eosio_1.6.0-1-ubuntu-16.04_amd64.deb
$ wget https://github.com/eosio/eos/releases/download/v1.6.1/eosio_1.6.1-1-ubuntu-16.04_amd64.deb
$ sudo apt install ./eosio_1.6.1-1-ubuntu-16.04_amd64.deb
```
#### Debian Package Uninstall
```sh
$ sudo apt remove eosio
```
#### Centos RPM Package Install
```sh
$ wget https://github.com/eosio/eos/releases/download/v1.6.0/eosio-1.6.0-1.el7.x86_64.rpm
$ sudo yum install ./eosio-1.6.0-1.el7.x86_64.rpm
$ wget https://github.com/eosio/eos/releases/download/v1.6.1/eosio-1.6.1-1.el7.x86_64.rpm
$ sudo yum install ./eosio-1.6.1-1.el7.x86_64.rpm
```
#### Centos RPM Package Uninstall
```sh
$ sudo yum remove eosio.cdt
```
#### Fedora RPM Package Install
```sh
$ wget https://github.com/eosio/eos/releases/download/v1.6.0/eosio-1.6.0-1.fc27.x86_64.rpm
$ sudo yum install ./eosio-1.6.0-1.fc27.x86_64.rpm
$ wget https://github.com/eosio/eos/releases/download/v1.6.1/eosio-1.6.1-1.fc27.x86_64.rpm
$ sudo yum install ./eosio-1.6.1-1.fc27.x86_64.rpm
```
#### Fedora RPM Package Uninstall
```sh
Expand Down
18 changes: 18 additions & 0 deletions libraries/chain/asset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,22 @@ asset asset::from_string(const string& from)
FC_CAPTURE_LOG_AND_RETHROW( (from) )
}

string extended_asset::to_string()const {
return quantity.to_string() + "@" + contract.to_string();
}

extended_asset extended_asset::from_string(const string& from)
{ try {
auto s = fc::trim(from);

// Find at sign in order to split asset and contract
auto at_pos = s.find('@');
EOS_ASSERT((at_pos != string::npos), asset_type_exception, "Extended asset's asset and contract should be separated with '@'");

auto asset_str = s.substr(0, at_pos);
auto contract_str = fc::trim(s.substr(at_pos + 1));

return extended_asset(asset::from_string(asset_str), name(contract_str));
} FC_CAPTURE_LOG_AND_RETHROW( (from) ) }

} } // eosio::types
41 changes: 6 additions & 35 deletions libraries/chain/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ struct controller_impl {
* are removed from this list if they are re-applied in other blocks. Producers
* can query this list when scheduling new transactions into blocks.
*/
map<digest_type, transaction_metadata_ptr> unapplied_transactions;
unapplied_transactions_type unapplied_transactions;

void pop_block() {
auto prev = fork_db.get_block( head->header.previous );
Expand Down Expand Up @@ -2106,41 +2106,12 @@ const account_object& controller::get_account( account_name name )const
return my->db.get<account_object, by_name>(name);
} FC_CAPTURE_AND_RETHROW( (name) ) }

vector<transaction_metadata_ptr> controller::get_unapplied_transactions() const {
vector<transaction_metadata_ptr> result;
if ( my->read_mode == db_read_mode::SPECULATIVE ) {
result.reserve(my->unapplied_transactions.size());
for ( const auto& entry: my->unapplied_transactions ) {
result.emplace_back(entry.second);
}
} else {
EOS_ASSERT( my->unapplied_transactions.empty(), transaction_exception, "not empty unapplied_transactions in non-speculative mode" ); //should never happen
}
return result;
}

void controller::drop_unapplied_transaction(const transaction_metadata_ptr& trx) {
my->unapplied_transactions.erase(trx->signed_id);
}

void controller::drop_all_unapplied_transactions() {
my->unapplied_transactions.clear();
}

vector<transaction_id_type> controller::get_scheduled_transactions() const {
const auto& idx = db().get_index<generated_transaction_multi_index,by_delay>();

vector<transaction_id_type> result;

static const size_t max_reserve = 64;
result.reserve(std::min(idx.size(), max_reserve));

auto itr = idx.begin();
while( itr != idx.end() && itr->delay_until <= pending_block_time() ) {
result.emplace_back(itr->trx_id);
++itr;
unapplied_transactions_type& controller::get_unapplied_transactions() {
if ( my->read_mode != db_read_mode::SPECULATIVE ) {
EOS_ASSERT( my->unapplied_transactions.empty(), transaction_exception,
"not empty unapplied_transactions in non-speculative mode" ); //should never happen
}
return result;
return my->unapplied_transactions;
}

bool controller::sender_avoids_whitelist_blacklist_enforcement( account_name sender )const {
Expand Down
18 changes: 14 additions & 4 deletions libraries/chain/include/eosio/chain/asset.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,13 @@ struct asset
};

struct extended_asset {
extended_asset(){}
extended_asset( asset a, name n ):quantity(a),contract(n){}
asset quantity;
name contract;
extended_asset(){}
extended_asset( asset a, name n ):quantity(a),contract(n){}
asset quantity;
name contract;

static extended_asset from_string(const string& from);
string to_string()const;
};

bool operator < (const asset& a, const asset& b);
Expand All @@ -114,5 +117,12 @@ inline void from_variant(const fc::variant& var, eosio::chain::asset& vo) {
}
}

namespace fc {
inline void to_variant(const eosio::chain::extended_asset& var, fc::variant& vo) { vo = var.to_string(); }
inline void from_variant(const fc::variant& var, eosio::chain::extended_asset& vo) {
vo = eosio::chain::extended_asset::from_string(var.get_string());
}
}

FC_REFLECT(eosio::chain::asset, (amount)(sym))
FC_REFLECT(eosio::chain::extended_asset, (quantity)(contract) )
18 changes: 3 additions & 15 deletions libraries/chain/include/eosio/chain/controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ namespace eosio { namespace chain {
class account_object;
using resource_limits::resource_limits_manager;
using apply_handler = std::function<void(apply_context&)>;
using unapplied_transactions_type = map<transaction_id_type, transaction_metadata_ptr>;

class fork_database;

Expand Down Expand Up @@ -111,22 +112,9 @@ namespace eosio { namespace chain {
* The caller is responsible for calling drop_unapplied_transaction on a failing transaction that
* they never intend to retry
*
* @return vector of transactions which have been unapplied
* @return map of transactions which have been unapplied
*/
vector<transaction_metadata_ptr> get_unapplied_transactions() const;
void drop_unapplied_transaction(const transaction_metadata_ptr& trx);
void drop_all_unapplied_transactions();

/**
* These transaction IDs represent transactions available in the head chain state as scheduled
* or otherwise generated transactions.
*
* calling push_scheduled_transaction with these IDs will remove the associated transaction from
* the chain state IFF it succeeds or objectively fails
*
* @return
*/
vector<transaction_id_type> get_scheduled_transactions() const;
unapplied_transactions_type& get_unapplied_transactions();

/**
*
Expand Down
11 changes: 7 additions & 4 deletions libraries/chain/include/eosio/chain/wasm_eosio_injection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ namespace eosio { namespace chain { namespace wasm_injections {

};

struct call_depth_check {
struct call_depth_check_and_insert_checktime {
static constexpr bool kills = true;
static constexpr bool post = false;
static int32_t global_idx;
Expand All @@ -290,6 +290,7 @@ namespace eosio { namespace chain { namespace wasm_injections {
injector_utils::add_import<ResultType::none>(*(arg.module), "call_depth_assert", assert_idx);

wasm_ops::op_types<>::call_t call_assert;
wasm_ops::op_types<>::call_t call_checktime;
wasm_ops::op_types<>::get_global_t get_global_inst;
wasm_ops::op_types<>::set_global_t set_global_inst;

Expand All @@ -301,6 +302,7 @@ namespace eosio { namespace chain { namespace wasm_injections {
wasm_ops::op_types<>::else__t else_inst;

call_assert.field = assert_idx;
call_checktime.field = checktime_injection::chktm_idx;
get_global_inst.field = global_idx;
set_global_inst.field = global_idx;
const_inst.field = -1;
Expand Down Expand Up @@ -334,6 +336,7 @@ namespace eosio { namespace chain { namespace wasm_injections {
INSERT_INJECTED(const_inst);
INSERT_INJECTED(add_inst);
INSERT_INJECTED(set_global_inst);
INSERT_INJECTED(call_checktime);

#undef INSERT_INJECTED
}
Expand Down Expand Up @@ -679,8 +682,8 @@ namespace eosio { namespace chain { namespace wasm_injections {
};

struct pre_op_injectors : wasm_ops::op_types<pass_injector> {
using call_t = wasm_ops::call <call_depth_check>;
using call_indirect_t = wasm_ops::call_indirect <call_depth_check>;
using call_t = wasm_ops::call <call_depth_check_and_insert_checktime>;
using call_indirect_t = wasm_ops::call_indirect <call_depth_check_and_insert_checktime>;

// float binops
using f32_add_t = wasm_ops::f32_add <f32_binop_injector<wasm_ops::f32_add_code>>;
Expand Down Expand Up @@ -785,7 +788,7 @@ namespace eosio { namespace chain { namespace wasm_injections {
// initialize static fields of injectors
injector_utils::init( mod );
checktime_injection::init();
call_depth_check::init();
call_depth_check_and_insert_checktime::init();
}

void inject() {
Expand Down
2 changes: 1 addition & 1 deletion libraries/chain/wasm_eosio_injection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void max_memory_injection_visitor::inject( Module& m ) {
}
void max_memory_injection_visitor::initializer() {}

int32_t call_depth_check::global_idx = -1;
int32_t call_depth_check_and_insert_checktime::global_idx = -1;
uint32_t instruction_counter::icnt = 0;
uint32_t instruction_counter::tcnt = 0;
uint32_t instruction_counter::bcnt = 0;
Expand Down
11 changes: 11 additions & 0 deletions libraries/testing/include/eosio/testing/tester.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,17 @@ namespace eosio { namespace testing {
void produce_min_num_of_blocks_to_spend_time_wo_inactive_prod(const fc::microseconds target_elapsed_time = fc::microseconds());
signed_block_ptr push_block(signed_block_ptr b);

/**
* These transaction IDs represent transactions available in the head chain state as scheduled
* or otherwise generated transactions.
*
* calling push_scheduled_transaction with these IDs will remove the associated transaction from
* the chain state IFF it succeeds or objectively fails
*
* @return
*/
vector<transaction_id_type> get_scheduled_transactions() const;

transaction_trace_ptr push_transaction( packed_transaction& trx, fc::time_point deadline = fc::time_point::maximum(), uint32_t billed_cpu_time_us = DEFAULT_BILLED_CPU_TIME_US );
transaction_trace_ptr push_transaction( signed_transaction& trx, fc::time_point deadline = fc::time_point::maximum(), uint32_t billed_cpu_time_us = DEFAULT_BILLED_CPU_TIME_US );
action_result push_action(action&& cert_act, uint64_t authorizer); // TODO/QUESTION: Is this needed?
Expand Down
21 changes: 17 additions & 4 deletions libraries/testing/tester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <eosio/testing/tester.hpp>
#include <eosio/chain/wast_to_wasm.hpp>
#include <eosio/chain/eosio_contract.hpp>
#include <eosio/chain/generated_transaction_object.hpp>

#include <eosio.bios/eosio.bios.wast.hpp>
#include <eosio.bios/eosio.bios.abi.hpp>
Expand Down Expand Up @@ -163,16 +164,16 @@ namespace eosio { namespace testing {
}

if( !skip_pending_trxs ) {
auto unapplied_trxs = control->get_unapplied_transactions();
for (const auto& trx : unapplied_trxs ) {
auto trace = control->push_transaction(trx, fc::time_point::maximum());
unapplied_transactions_type unapplied_trxs = control->get_unapplied_transactions(); // make copy of map
for (const auto& entry : unapplied_trxs ) {
auto trace = control->push_transaction(entry.second, fc::time_point::maximum());
if(trace->except) {
trace->except->dynamic_rethrow_exception();
}
}

vector<transaction_id_type> scheduled_trxs;
while( (scheduled_trxs = control->get_scheduled_transactions() ).size() > 0 ) {
while( (scheduled_trxs = get_scheduled_transactions() ).size() > 0 ) {
for (const auto& trx : scheduled_trxs ) {
auto trace = control->push_scheduled_transaction(trx, fc::time_point::maximum());
if(trace->except) {
Expand Down Expand Up @@ -237,6 +238,18 @@ namespace eosio { namespace testing {
}
}

vector<transaction_id_type> base_tester::get_scheduled_transactions() const {
const auto& idx = control->db().get_index<generated_transaction_multi_index,by_delay>();

vector<transaction_id_type> result;

auto itr = idx.begin();
while( itr != idx.end() && itr->delay_until <= control->pending_block_time() ) {
result.emplace_back(itr->trx_id);
++itr;
}
return result;
}

void base_tester::produce_blocks_until_end_of_round() {
uint64_t blocks_per_round;
Expand Down
Loading

0 comments on commit 568f52f

Please sign in to comment.