Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/EOSIO/eos
Browse files Browse the repository at this point in the history
  • Loading branch information
nsjames committed Jun 16, 2018
2 parents 7caced5 + 013c282 commit 9dc07d4
Show file tree
Hide file tree
Showing 57 changed files with 1,320 additions and 517 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ set( CXX_STANDARD_REQUIRED ON)

set(VERSION_MAJOR 1)
set(VERSION_MINOR 0)
set(VERSION_PATCH 1)
set(VERSION_PATCH 4)

set( CLI_CLIENT_EXECUTABLE_NAME cleos )
set( GUI_CLIENT_EXECUTABLE_NAME eosio )
Expand Down
2 changes: 1 addition & 1 deletion Docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ RUN git clone -b $branch https://github.com/EOS-Mainnet/eos.git --recursive \

FROM ubuntu:18.04

RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install openssl && rm -rf /var/lib/apt/lists/*
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install openssl ca-certificates && rm -rf /var/lib/apt/lists/*
COPY --from=builder /usr/local/lib/* /usr/local/lib/
COPY --from=builder /tmp/build/bin /opt/eosio/bin
COPY --from=builder /tmp/build/contracts /contracts
Expand Down
12 changes: 6 additions & 6 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 v1.0.1 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 v1.0.4 tag, you could do the following:

```bash
docker build -t eosio/eos:v1.0.1 --build-arg branch=v1.0.1 .
docker build -t eosio/eos:v1.0.4 --build-arg branch=v1.0.4 .
```

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 @@ -73,7 +73,7 @@ After `docker-compose up -d`, two services named `nodeosd` and `keosd` will be s
You can run the `cleos` commands via a bash alias.

```bash
alias cleos='docker-compose exec keosd /opt/eosio/bin/cleos -u http://nodeosd:8888 --wallet-url http://localhost:8888'
alias cleos='docker-compose exec keosd /opt/eosio/bin/cleos -u http://nodeosd:8888 --wallet-url http://localhost:8900'
cleos get info
cleos get account inita
```
Expand Down Expand Up @@ -142,7 +142,7 @@ version: "3"
services:
nodeosd:
image: eosio/eos:latest
command: /opt/eosio/bin/nodeosd.sh -e
command: /opt/eosio/bin/nodeosd.sh --data-dir /opt/eosio/bin/data-dir -e
hostname: nodeosd
ports:
- 8888:8888
Expand All @@ -154,7 +154,7 @@ services:

keosd:
image: eosio/eos:latest
command: /opt/eosio/bin/keosd
command: /opt/eosio/bin/keosd --wallet-dir /opt/eosio/bin/data-dir --http-server-address=127.0.0.1:8900
hostname: keosd
links:
- nodeosd
Expand All @@ -181,7 +181,7 @@ Note: if you want to use the mongo db plugin, you have to enable it in your `dat

```
# pull images
docker pull eosio/eos:v1.0.1
docker pull eosio/eos:v1.0.4
# create volume
docker volume create --name=nodeos-data-volume
Expand Down
2 changes: 1 addition & 1 deletion Docker/dev/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ RUN git clone -b $branch https://github.com/EOSIO/eos.git --recursive \
&& mv /eos/Docker/config.ini / && mv /opt/eosio/contracts /contracts && mv /eos/Docker/nodeosd.sh /opt/eosio/bin/nodeosd.sh && mv tutorials /tutorials \
&& rm -rf /eos

RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install openssl vim psmisc python3-pip && rm -rf /var/lib/apt/lists/*
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install openssl ca-certificates vim psmisc python3-pip && rm -rf /var/lib/apt/lists/*
RUN pip3 install numpy
ENV EOSIO_ROOT=/opt/eosio
RUN chmod +x /opt/eosio/bin/nodeosd.sh
Expand Down
4 changes: 2 additions & 2 deletions Docker/docker-compose-eosio1.0.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "3"

services:
nodeosd:
image: eosio/eos:v1.0.1
image: eosio/eos:v1.0.4
command: /opt/eosio/bin/nodeosd.sh --data-dir /opt/eosio/bin/data-dir -e
hostname: nodeosd
ports:
Expand All @@ -14,7 +14,7 @@ services:
- nodeos-data-volume:/opt/eosio/bin/data-dir

keosd:
image: eosio/eos:v1.0.1
image: eosio/eos:v1.0.4
command: /opt/eosio/bin/keosd --wallet-dir /opt/eosio/bin/data-dir --http-server-address=127.0.0.1:8900
hostname: keosd
links:
Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,12 @@ EOSIO currently supports the following operating systems:
2. [EOSIO Blog](https://medium.com/eosio)
3. [EOSIO Documentation Wiki](https://github.com/EOSIO/eos/wiki)
4. [EOSIO API Documentation](https://eosio.github.io/eos/)
5. [EOSIO StackExchange for Q&A](https://eosio.stackexchange.com/)
6. [Community Telegram Group](https://t.me/EOSProject)
7. [Developer Telegram Group](https://t.me/joinchat/EaEnSUPktgfoI-XPfMYtcQ)
8. [White Paper](https://github.com/EOSIO/Documentation/blob/master/TechnicalWhitePaper.md)
9. [Roadmap](https://github.com/EOSIO/Documentation/blob/master/Roadmap.md)
5. [EOSIO Developer Portal](https://developers.eos.io)
6. [EOSIO StackExchange for Q&A](https://eosio.stackexchange.com/)
7. [Community Telegram Group](https://t.me/EOSProject)
8. [Developer Telegram Group](https://t.me/joinchat/EaEnSUPktgfoI-XPfMYtcQ)
9. [White Paper](https://github.com/EOSIO/Documentation/blob/master/TechnicalWhitePaper.md)
10. [Roadmap](https://github.com/EOSIO/Documentation/blob/master/Roadmap.md)

<a name="gettingstarted"></a>
## Getting Started
Expand Down
7 changes: 6 additions & 1 deletion contracts/eosio.system/delegate_bandwidth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,14 @@ namespace eosiosystem {
eosio_assert( quant.amount > 0, "must purchase a positive amount" );

auto fee = quant;
fee.amount /= 200; /// .5% fee
fee.amount = ( fee.amount + 199 ) / 200; /// .5% fee (round up)
// fee.amount cannot be 0 since that is only possible if quant.amount is 0 which is not allowed by the assert above.
// If quant.amount == 1, then fee.amount == 1,
// otherwise if quant.amount > 1, then 0 < fee.amount < quant.amount.
auto quant_after_fee = quant;
quant_after_fee.amount -= fee.amount;
// quant_after_fee.amount should be > 0 if quant.amount > 1.
// If quant.amount == 1, then quant_after_fee.amount == 0 and the next inline transfer will fail causing the buyram action to fail.

INLINE_ACTION_SENDER(eosio::token, transfer)( N(eosio.token), {payer,N(active)},
{ payer, N(eosio.ram), quant_after_fee, std::string("buy ram") } );
Expand Down
5 changes: 1 addition & 4 deletions contracts/eosio.system/eosio.system.abi
Original file line number Diff line number Diff line change
Expand Up @@ -319,10 +319,7 @@
{"name":"staked", "type":"int64"},
{"name":"last_vote_weight", "type":"float64"},
{"name":"proxied_vote_weight", "type":"float64"},
{"name":"is_proxy", "type":"bool"},
{"name":"deferred_trx_id", "type":"uint32"},
{"name":"last_unstake_time", "type":"time_point_sec"},
{"name":"unstaking", "type":"asset"}
{"name":"is_proxy", "type":"bool"}
]
},{
"name": "claimrewards",
Expand Down
8 changes: 4 additions & 4 deletions contracts/eosio.system/eosio.system.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,14 @@ namespace eosiosystem {
bool is_proxy = 0; /// whether the voter is a proxy for others


uint32_t deferred_trx_id = 0; /// the ID of the 3-day delay deferred transaction
time last_unstake_time = 0; /// the time when the deferred_trx_id was sent
eosio::asset unstaking; /// the total unstaking (pending 3 day delay)
uint32_t reserved1 = 0;
time reserved2 = 0;
eosio::asset reserved3;

uint64_t primary_key()const { return owner; }

// explicit serialization macro is not necessary, used here only to improve compilation time
EOSLIB_SERIALIZE( voter_info, (owner)(proxy)(producers)(staked)(last_vote_weight)(proxied_vote_weight)(is_proxy)(deferred_trx_id)(last_unstake_time)(unstaking) )
EOSLIB_SERIALIZE( voter_info, (owner)(proxy)(producers)(staked)(last_vote_weight)(proxied_vote_weight)(is_proxy)(reserved1)(reserved2)(reserved3) )
};

typedef eosio::multi_index< N(voters), voter_info> voters_table;
Expand Down
2 changes: 1 addition & 1 deletion contracts/eosio.system/voting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ namespace eosiosystem {
*/
if( voter->last_vote_weight <= 0.0 ) {
_gstate.total_activated_stake += voter->staked;
if( _gstate.total_activated_stake >= min_activated_stake ) {
if( _gstate.total_activated_stake >= min_activated_stake && _gstate.thresh_activated_stake_time == 0 ) {
_gstate.thresh_activated_stake_time = current_time();
}
}
Expand Down
50 changes: 28 additions & 22 deletions libraries/chain/abi_serializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,11 @@ namespace eosio { namespace chain {
}
}

bool abi_serializer::is_type(const type_name& rtype)const {
bool abi_serializer::_is_type(const type_name& rtype, size_t recursion_depth)const {
if( ++recursion_depth > max_recursion_depth) return false;
auto type = fundamental_type(rtype);
if( built_in_types.find(type) != built_in_types.end() ) return true;
if( typedefs.find(type) != typedefs.end() ) return is_type(typedefs.find(type)->second);
if( typedefs.find(type) != typedefs.end() ) return _is_type(typedefs.find(type)->second, recursion_depth);
if( structs.find(type) != structs.end() ) return true;
return false;
}
Expand Down Expand Up @@ -237,19 +238,21 @@ namespace eosio { namespace chain {
return type;
}

void abi_serializer::binary_to_variant(const type_name& type, fc::datastream<const char *>& stream,
fc::mutable_variant_object& obj)const {
void abi_serializer::_binary_to_variant(const type_name& type, fc::datastream<const char *>& stream,
fc::mutable_variant_object& obj, size_t recursion_depth)const {
FC_ASSERT( ++recursion_depth < max_recursion_depth, "recursive definition, max_recursion_depth" );
const auto& st = get_struct(type);
if( st.base != type_name() ) {
binary_to_variant(resolve_type(st.base), stream, obj);
_binary_to_variant(resolve_type(st.base), stream, obj, recursion_depth);
}
for( const auto& field : st.fields ) {
obj( field.name, binary_to_variant(resolve_type(field.type), stream) );
obj( field.name, _binary_to_variant(resolve_type(field.type), stream, recursion_depth) );
}
}

fc::variant abi_serializer::binary_to_variant(const type_name& type, fc::datastream<const char *>& stream)const
fc::variant abi_serializer::_binary_to_variant(const type_name& type, fc::datastream<const char *>& stream, size_t recursion_depth)const
{
FC_ASSERT( ++recursion_depth < max_recursion_depth, "recursive definition, max_recursion_depth" );
type_name rtype = resolve_type(type);
auto ftype = fundamental_type(rtype);
auto btype = built_in_types.find(ftype );
Expand All @@ -262,27 +265,29 @@ namespace eosio { namespace chain {
vector<fc::variant> vars;
vars.resize(size);
for (auto& var : vars) {
var = binary_to_variant(ftype, stream);
var = _binary_to_variant(ftype, stream, recursion_depth);
}
return fc::variant( std::move(vars) );
} else if ( is_optional(rtype) ) {
char flag;
fc::raw::unpack(stream, flag);
return flag ? binary_to_variant(ftype, stream) : fc::variant();
return flag ? _binary_to_variant(ftype, stream, recursion_depth) : fc::variant();
}

fc::mutable_variant_object mvo;
binary_to_variant(rtype, stream, mvo);
_binary_to_variant(rtype, stream, mvo, recursion_depth);
return fc::variant( std::move(mvo) );
}

fc::variant abi_serializer::binary_to_variant(const type_name& type, const bytes& binary)const{
fc::variant abi_serializer::_binary_to_variant(const type_name& type, const bytes& binary, size_t recursion_depth)const{
FC_ASSERT( ++recursion_depth < max_recursion_depth, "recursive definition, max_recursion_depth" );
fc::datastream<const char*> ds( binary.data(), binary.size() );
return binary_to_variant(type, ds);
return _binary_to_variant(type, ds, recursion_depth);
}

void abi_serializer::variant_to_binary(const type_name& type, const fc::variant& var, fc::datastream<char *>& ds)const
void abi_serializer::_variant_to_binary(const type_name& type, const fc::variant& var, fc::datastream<char *>& ds, size_t recursion_depth)const
{ try {
FC_ASSERT( ++recursion_depth < max_recursion_depth, "recursive definition, max_recursion_depth" );
auto rtype = resolve_type(type);

auto btype = built_in_types.find(fundamental_type(rtype));
Expand All @@ -292,7 +297,7 @@ namespace eosio { namespace chain {
vector<fc::variant> vars = var.get_array();
fc::raw::pack(ds, (fc::unsigned_int)vars.size());
for (const auto& var : vars) {
variant_to_binary(fundamental_type(rtype), var, ds);
_variant_to_binary(fundamental_type(rtype), var, ds, recursion_depth);
}
} else {
const auto& st = get_struct(rtype);
Expand All @@ -301,14 +306,14 @@ namespace eosio { namespace chain {
const auto& vo = var.get_object();

if( st.base != type_name() ) {
variant_to_binary(resolve_type(st.base), var, ds);
_variant_to_binary(resolve_type(st.base), var, ds, recursion_depth);
}
for( const auto& field : st.fields ) {
if( vo.contains( string(field.name).c_str() ) ) {
variant_to_binary(field.type, vo[field.name], ds);
_variant_to_binary(field.type, vo[field.name], ds, recursion_depth);
}
else {
variant_to_binary(field.type, fc::variant(), ds);
_variant_to_binary(field.type, fc::variant(), ds, recursion_depth);
/// TODO: default construct field and write it out
FC_THROW( "Missing '${f}' in variant object", ("f",field.name) );
}
Expand All @@ -318,31 +323,32 @@ namespace eosio { namespace chain {

FC_ASSERT( st.base == type_name(), "support for base class as array not yet implemented" );
/*if( st.base != type_name() ) {
variant_to_binary(resolve_type(st.base), var, ds);
_variant_to_binary(resolve_type(st.base), var, ds, recursive_depth);
}
*/
uint32_t i = 0;
if (va.size() > 0) {
for( const auto& field : st.fields ) {
if( va.size() > i )
variant_to_binary(field.type, va[i], ds);
_variant_to_binary(field.type, va[i], ds, recursion_depth);
else
variant_to_binary(field.type, fc::variant(), ds);
_variant_to_binary(field.type, fc::variant(), ds, recursion_depth);
++i;
}
}
}
}
} FC_CAPTURE_AND_RETHROW( (type)(var) ) }

bytes abi_serializer::variant_to_binary(const type_name& type, const fc::variant& var)const { try {
bytes abi_serializer::_variant_to_binary(const type_name& type, const fc::variant& var, size_t recursion_depth)const { try {
FC_ASSERT( ++recursion_depth < max_recursion_depth, "recursive definition, max_recursion_depth" );
if( !is_type(type) ) {
return var.as<bytes>();
}

bytes temp( 1024*1024 );
fc::datastream<char*> ds(temp.data(), temp.size() );
variant_to_binary(type, var, ds);
_variant_to_binary(type, var, ds, recursion_depth);
temp.resize(ds.tellp());
return temp;
} FC_CAPTURE_AND_RETHROW( (type)(var) ) }
Expand Down
17 changes: 16 additions & 1 deletion libraries/chain/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,8 @@ struct controller_impl {
|| (code == actor_blacklist_exception::code_value)
|| (code == contract_whitelist_exception::code_value)
|| (code == contract_blacklist_exception::code_value)
|| (code == action_blacklist_exception::code_value);
|| (code == action_blacklist_exception::code_value)
|| (code == key_blacklist_exception::code_value);
}

transaction_trace_ptr push_scheduled_transaction( const transaction_id_type& trxid, fc::time_point deadline, uint32_t billed_cpu_time_us ) {
Expand Down Expand Up @@ -1102,6 +1103,16 @@ struct controller_impl {
}
}

void check_key_list( const public_key_type& key )const {
if( conf.key_blacklist.size() > 0 ) {
EOS_ASSERT( conf.key_blacklist.find( key ) == conf.key_blacklist.end(),
key_blacklist_exception,
"public key '${key}' is on the key blacklist",
("key", key)
);
}
}

/*
bool should_check_tapos()const { return true; }
Expand Down Expand Up @@ -1448,6 +1459,10 @@ void controller::check_action_list( account_name code, action_name action )const
my->check_action_list( code, action );
}

void controller::check_key_list( const public_key_type& key )const {
my->check_key_list( key );
}

bool controller::is_producing_block()const {
if( !my->pending ) return false;

Expand Down
8 changes: 7 additions & 1 deletion libraries/chain/eosio_contract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ void validate_authority_precondition( const apply_context& context, const author
);
}
}

if( context.control.is_producing_block() ) {
for( const auto& p : auth.keys ) {
context.control.check_key_list( p.key );
}
}
}

/**
Expand Down Expand Up @@ -130,7 +136,7 @@ void apply_eosio_setcode(apply_context& context) {
FC_ASSERT( act.vmversion == 0 );

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(context.control, act.code);
Expand Down
Loading

0 comments on commit 9dc07d4

Please sign in to comment.