Skip to content

Commit

Permalink
Merge branch 'master' into 3701-name-suffix-cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
arhag committed Jun 1, 2018
2 parents eb9e273 + cf6b059 commit 44d4386
Show file tree
Hide file tree
Showing 36 changed files with 253 additions and 392 deletions.
2 changes: 1 addition & 1 deletion contracts/asserter/asserter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ static int global_variable = 45;

extern "C" {
/// The apply method implements the dispatch of events to this contract
void apply( uint64_t receiver, uint64_t code, uint64_t action ) {
void apply( uint64_t /* receiver */, uint64_t code, uint64_t action ) {
require_auth(code);
if( code == N(asserter) ) {
if( action == N(procassert) ) {
Expand Down
2 changes: 1 addition & 1 deletion contracts/eosio.bios/eosio.bios.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace eosio {
set_privileged( account, ispriv );
}

void setalimits( account_name account, uint64_t ram_bytes, uint64_t net_weight, uint64_t cpu_weight ) {
void setalimits( account_name account, int64_t ram_bytes, int64_t net_weight, int64_t cpu_weight ) {
require_auth( _self );
set_resource_limits( account, ram_bytes, net_weight, cpu_weight );
}
Expand Down
3 changes: 1 addition & 2 deletions contracts/eosio.system/delegate_bandwidth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ namespace eosiosystem {
tokens_out = es.convert( asset(bytes,S(0,RAM)), CORE_SYMBOL);
});

_gstate.total_ram_bytes_reserved -= bytes;
_gstate.total_ram_bytes_reserved -= static_cast<decltype(_gstate.total_ram_bytes_reserved)>(bytes); // bytes > 0 is asserted above
_gstate.total_ram_stake -= tokens_out.amount;

//// this shouldn't happen, but just in case it does we should prevent it
Expand All @@ -190,7 +190,6 @@ namespace eosiosystem {
}

void validate_b1_vesting( int64_t stake ) {
const int64_t seconds_per_year = 60*60*24*365;
const int64_t base_time = 1527811200; /// 2018-06-01
const int64_t max_claimable = 100'000'000'0000ll;
const int64_t claimable = int64_t(max_claimable * double(now()-base_time) / (10*seconds_per_year) );
Expand Down
4 changes: 2 additions & 2 deletions contracts/eosio.system/eosio.system.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ namespace eosiosystem {
int64_t high_bid = 0; ///< negative high_bid == closed auction waiting to be claimed
uint64_t last_bid_time = 0;

auto primary_key()const { return newname; }
uint64_t by_high_bid()const { return -high_bid; }
auto primary_key()const { return newname; }
uint64_t by_high_bid()const { return static_cast<uint64_t>(-high_bid); }
};

typedef eosio::multi_index< N(namebids), name_bid,
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 @@ -100,7 +100,7 @@ namespace eosiosystem {
bytes packed_schedule = pack(producers);

if( set_proposed_producers( packed_schedule.data(), packed_schedule.size() ) >= 0 ) {
_gstate.last_producer_schedule_size = top_producers.size();
_gstate.last_producer_schedule_size = static_cast<decltype(_gstate.last_producer_schedule_size)>( top_producers.size() );
}
}

Expand Down
2 changes: 1 addition & 1 deletion contracts/exchange/exchange.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ namespace eosio {

void exchange::createx( account_name creator,
asset initial_supply,
uint32_t fee,
uint32_t /* fee */,
extended_asset base_deposit,
extended_asset quote_deposit
) {
Expand Down
8 changes: 5 additions & 3 deletions contracts/exchange/test_exchange.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ exchange_state borrow( const exchange_state& current, account_name user,
/// remove amount_to_borrow from exchange
/// lock collateral for user
/// simulate complete margin calls
return exchange_state();
}

exchange_state cover( const exchange_state& current, account_name user,
Expand All @@ -357,22 +358,23 @@ exchange_state cover( const exchange_state& current, account_name user,
// - if borrowed from user, reduce borrowed from user
/// calculate new call price and update least collateralized position
/// simulate complete margin calls

return exchange_state();
}

exchange_state lend( const exchange_state& current, account_name lender,
asset asset_to_lend ) {
/// add to pool of funds available for lending and buy SHARES in
/// interest pool at current rate.

return exchange_state();
}

exchange_state unlend( const exchange_state& current, account_name lender,
asset asset_to_lend ) {
/// sell shares in interest pool at current rate
/// this is permitable so long as total borrowed from users remains less than
/// total available to lend. Otherwise, margin is called on the least
/// collateralized position.
/// collateralized position.
return exchange_state();
}


Expand Down
2 changes: 1 addition & 1 deletion contracts/multi_index_test/multi_index_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ struct limit_order {
namespace multi_index_test {
extern "C" {
/// The apply method implements the dispatch of events to this contract
void apply( uint64_t receiver, uint64_t code, uint64_t action ) {
void apply( uint64_t /* receiver */, uint64_t code, uint64_t action ) {
require_auth(code);
eosio_assert(eosio::dispatch<multi_index_test, multi_index_test::trigger>(code, action),
"Could not dispatch");
Expand Down
2 changes: 1 addition & 1 deletion contracts/proxy/proxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace proxy {
};

template<typename T>
void apply_transfer(uint64_t receiver, account_name code, const T& transfer) {
void apply_transfer(uint64_t receiver, account_name /* code */, const T& transfer) {
config code_config;
const auto self = receiver;
auto get_res = configs::get(code_config, self);
Expand Down
2 changes: 1 addition & 1 deletion contracts/test_api/test_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ void test_action::test_cf_action() {
publication_time();
eosio_assert( false, "system_api should not be allowed" );
} else if ( cfa.payload == 210 ) {
send_inline( "hello", 6 );
send_inline( (char*)"hello", 6 );
eosio_assert( false, "transaction_api should not be allowed" );
} else if ( cfa.payload == 211 ) {
send_deferred( N(testapi), N(testapi), "hello", 6 );
Expand Down
35 changes: 31 additions & 4 deletions contracts/test_api/test_datastream.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

#include <eosiolib/eosio.hpp>
#include <eosiolib/datastream.hpp>
#include <cmath>

#include "test_api.hpp"

Expand All @@ -17,6 +18,32 @@ struct testtype {
}
};

template <>
struct testtype<double> {
static void run(const double &v, const char *errmsg = "") {
char buf[128];
eosio::datastream<char *> ds(buf, sizeof(buf));
ds << v;
double v2;
ds.seekp(0);
ds >> v2;
eosio_assert(std::abs(v - v2) < 1e-20, errmsg);
}
};

template <>
struct testtype<float> {
static void run(const float &v, const char *errmsg = "") {
char buf[128];
eosio::datastream<char *> ds(buf, sizeof(buf));
ds << v;
float v2;
ds.seekp(0);
ds >> v2;
eosio_assert(std::abs(v - v2) < float(1e-10), errmsg);
}
};

void test_datastream::test_basic()
{

Expand All @@ -28,7 +55,7 @@ void test_datastream::test_basic()
testtype<unsigned short>::run(12345, "uint16");
testtype<int>::run(-1234567890, "int32");
testtype<unsigned int>::run(3234567890u, "uint32");
testtype<long long>::run(0x8000000000000000ull, "int64");
testtype<long long>::run((long long)0x8000000000000000ll, "int64");
testtype<unsigned long long>::run(0x7fffffffffffffffull, "uint64");
testtype<float>::run(1.234f, "float");
testtype<double>::run(0.333333333333333333, "double");
Expand All @@ -39,21 +66,21 @@ void test_datastream::test_basic()
struct Pair {
int a;
double d;
bool operator==(const Pair &p) const { return a == p.a && d == p.d;}
bool operator==(const Pair &p) const { return a == p.a && std::abs(d - p.d) < 1e-20;}
};
testtype<Pair>::run({1, 1.23456}, "struct");

struct StaticArray {
int a[2];
bool operator==(const StaticArray &o) const { return a[0] == o.a[0] && a[1] == o.a[1]; }
};
testtype<StaticArray>::run({10,20}, "staticArray");
testtype<StaticArray>::run({{10,20}}, "StaticArray");

testtype<std::string>::run("hello", "string");

testtype<std::vector<int> >::run({10,20,30}, "vector");
testtype<std::vector<int> >::run({}, "empty vector");
testtype<std::array<int, 3> >::run({10,20,30}, "std::array<T,N>");
testtype<std::array<int, 3> >::run({{10,20,30}}, "std::array<T,N>");
testtype<std::map<int, std::string> >::run({{1,"apple"}, {2,"cat"}, {3,"panda"}}, "map");
testtype<std::tuple<int, std::string, double> >::run({1, "abc", 3.3333}, "tuple");
}
Expand Down
4 changes: 2 additions & 2 deletions contracts/test_api/test_permission.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ struct test_permission_last_used_msg {
EOSLIB_SERIALIZE( test_permission_last_used_msg, (account)(permission)(last_used_time) )
};

void test_permission::test_permission_last_used(uint64_t receiver, uint64_t code, uint64_t action) {
void test_permission::test_permission_last_used(uint64_t /* receiver */, uint64_t code, uint64_t action) {
(void)code;
(void)action;
using namespace eosio;
Expand All @@ -68,7 +68,7 @@ void test_permission::test_permission_last_used(uint64_t receiver, uint64_t code
eosio_assert( get_permission_last_used(params.account, params.permission) == params.last_used_time, "unexpected last used permission time" );
}

void test_permission::test_account_creation_time(uint64_t receiver, uint64_t code, uint64_t action) {
void test_permission::test_account_creation_time(uint64_t /* receiver */, uint64_t code, uint64_t action) {
(void)code;
(void)action;
using namespace eosio;
Expand Down
6 changes: 3 additions & 3 deletions contracts/test_api/test_transaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ void test_transaction::send_deferred_tx_with_dtt_action() {
void test_transaction::cancel_deferred_transaction_success() {
using namespace eosio;
auto r = cancel_deferred( 0xffffffffffffffff ); //use the same id (0) as in send_deferred_transaction
eosio_assert( r, "transaction was not found" );
eosio_assert( (bool)r, "transaction was not found" );
}

void test_transaction::cancel_deferred_transaction_not_found() {
Expand Down Expand Up @@ -310,9 +310,9 @@ void test_transaction::context_free_api() {

extern "C" { int is_feature_active(int64_t); }
void test_transaction::new_feature() {
eosio_assert(false == is_feature_active(N(newfeature)), "we should not have new features unless hardfork");
eosio_assert(false == is_feature_active((int64_t)N(newfeature)), "we should not have new features unless hardfork");
}

void test_transaction::active_new_feature() {
activate_feature(N(newfeature));
activate_feature((int64_t)N(newfeature));
}
11 changes: 8 additions & 3 deletions contracts/test_api_db/test_db.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ void test_db::primary_i64_general(uint64_t receiver, uint64_t code, uint64_t act

buffer_len = 20;
len = db_get_i64(itr, value, 0);
len = db_get_i64(itr, value, len);
len = db_get_i64(itr, value, (uint32_t)len);
value[len] = '\0';
std::string sfull(value);
eosio_assert(sfull == "bob's info", "primary_i64_general - db_get_i64 - full");
Expand Down Expand Up @@ -448,7 +448,7 @@ void test_db::test_invalid_access(uint64_t receiver, uint64_t code, uint64_t act
uint64_t pk = scope;

int32_t itr = -1;
uint64_t value;
uint64_t value = 0;
switch( ia.index ) {
case 1:
itr = db_idx64_find_primary(ia.code, scope, table, &value, pk);
Expand Down Expand Up @@ -536,7 +536,10 @@ void test_db::idx_double_nan_lookup_fail(uint64_t receiver, uint64_t, uint64_t)
}
}

void test_db::misaligned_secondary_key256_tests(uint64_t receiver, uint64_t, uint64_t) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wcast-align"

void test_db::misaligned_secondary_key256_tests(uint64_t /* receiver */, uint64_t, uint64_t) {
auto key = eosio::key256::make_from_word_sequence<uint64_t>(0ULL, 0ULL, 0ULL, 42ULL);
char* ptr = (char*)(&key);
ptr += 1;
Expand All @@ -545,3 +548,5 @@ void test_db::misaligned_secondary_key256_tests(uint64_t receiver, uint64_t, uin
// test that find_primary doesn't crash on unaligned data
db_idx256_find_primary( N(testapi), N(testtable), N(testapi), (eosio::key256*)(ptr), 2, 0);
}

#pragma clang diagnostic pop
2 changes: 1 addition & 1 deletion contracts/test_api_mem/test_extended_memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void test_extended_memory::test_page_memory_exceeded() {
}

void test_extended_memory::test_page_memory_negative_bytes() {
eosio_assert(reinterpret_cast<int32_t>(sbrk(-1)) == -1, "Should have errored for trying to remove memory");
eosio_assert(reinterpret_cast<int32_t>(sbrk((uint32_t)-1)) == -1, "Should have errored for trying to remove memory");
}

void test_extended_memory::test_initial_buffer() {
Expand Down
7 changes: 7 additions & 0 deletions contracts/test_ram_limit/test_ram_limit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
#include <eosiolib/eosio.hpp>
#include <eosiolib/contract.hpp>

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wsign-conversion"
#pragma clang diagnostic ignored "-Wshorten-64-to-32"
#pragma clang diagnostic ignored "-Wsign-compare"

class test_ram_limit : public eosio::contract {
public:
const uint32_t FIVE_MINUTES = 5*60;
Expand Down Expand Up @@ -73,4 +78,6 @@ class test_ram_limit : public eosio::contract {
typedef eosio::multi_index< N(test.table), test> test_table;
};

#pragma clang diagnostic pop

EOSIO_ABI( test_ram_limit, (setentry)(rmentry)(printentry) )
16 changes: 13 additions & 3 deletions eosio_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

function usage()
{
printf "\\tUsage: %s [Build Option -o <Debug|Release|RelWithDebInfo|MinSizeRel>] [CodeCoverage -c ] [Doxygen -d]\\n\\n" "$0" 1>&2
printf "\\tUsage: %s \\n\\t[Build Option -o <Debug|Release|RelWithDebInfo|MinSizeRel>] \\n\\t[CodeCoverage -c ] \\n\\t[Doxygen -d] \\n\\t[CoreSymbolName -s <1-7 characters>]\\n\\n" "$0" 1>&2
exit 1
}

Expand All @@ -52,6 +52,7 @@
DISK_MIN=20
DOXYGEN=false
ENABLE_COVERAGE_TESTING=false
CORE_SYMBOL_NAME="SYS"
TEMP_DIR="/tmp"
TIME_BEGIN=$( date -u +%s )
VERSION=1.2
Expand All @@ -61,7 +62,7 @@
txtrst=$(tput sgr0)

if [ $# -ne 0 ]; then
while getopts ":cdo:" opt; do
while getopts ":cdos:" opt; do
case "${opt}" in
o )
options=( "Debug" "Release" "RelWithDebInfo" "MinSizeRel" )
Expand All @@ -79,6 +80,15 @@
d )
DOXYGEN=true
;;
s)
if [ "${#OPTARG}" -gt 6 ] || [ -z "${#OPTARG}" ]; then
printf "\\n\\tInvalid argument: %s\\n" "${OPTARG}" 1>&2
usage
exit 1
else
CORE_SYMBOL_NAME="${OPTARG}"
fi
;;
\? )
printf "\\n\\tInvalid Option: %s\\n" "-${OPTARG}" 1>&2
usage
Expand Down Expand Up @@ -226,7 +236,7 @@
fi

if ! "${CMAKE}" -DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}" -DCMAKE_CXX_COMPILER="${CXX_COMPILER}" \
-DCMAKE_C_COMPILER="${C_COMPILER}" -DWASM_ROOT="${WASM_ROOT}" \
-DCMAKE_C_COMPILER="${C_COMPILER}" -DWASM_ROOT="${WASM_ROOT}" -DCORE_SYMBOL_NAME="${CORE_SYMBOL_NAME}" \
-DOPENSSL_ROOT_DIR="${OPENSSL_ROOT_DIR}" -DBUILD_MONGO_DB_PLUGIN=true \
-DENABLE_COVERAGE_TESTING="${ENABLE_COVERAGE_TESTING}" -DBUILD_DOXYGEN="${DOXYGEN}" ..
then
Expand Down
2 changes: 1 addition & 1 deletion libraries/appbase
Submodule appbase updated 1 files
+4 −1 application.cpp
2 changes: 1 addition & 1 deletion libraries/chain/block_header_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ namespace eosio { namespace chain {

auto itr = producer_to_last_produced.find(h.producer);
if( itr != producer_to_last_produced.end() ) {
FC_ASSERT( itr->second < result.block_num - h.confirmed, "producer double-confirming known range" );
FC_ASSERT( itr->second < result.block_num - h.confirmed, "producer ${prod} double-confirming known range", ("prod", h.producer) );
}

// FC_ASSERT( result.header.block_mroot == h.block_mroot, "mismatch block merkle root" );
Expand Down
2 changes: 1 addition & 1 deletion libraries/chain/eosio_contract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ void apply_eosio_setcode(apply_context& context) {

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
// TODO: update setcode message to include the hash, then validate it in validate
a.last_code_update = context.control.pending_block_time();
a.code_version = code_id;
a.code.resize( code_size );
Expand Down
2 changes: 1 addition & 1 deletion libraries/chain/include/eosio/chain/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const static uint32_t default_context_free_discount_net_usage_den = 100;
const static uint32_t transaction_id_net_usage = 32; // 32 bytes for the size of a transaction id

const static uint32_t default_max_block_cpu_usage = 200'000; /// max block cpu usage in microseconds
const static uint32_t default_target_block_cpu_usage_pct = percent_1; /// target 1000 TPS
const static uint32_t default_target_block_cpu_usage_pct = 10 * percent_1;
const static uint32_t default_max_transaction_cpu_usage = 3*default_max_block_cpu_usage/4; /// max trx cpu usage in microseconds
const static uint32_t default_min_transaction_cpu_usage = 100; /// min trx cpu usage in microseconds (10000 TPS equiv)

Expand Down
7 changes: 6 additions & 1 deletion libraries/chain/wasm_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1281,7 +1281,12 @@ class memory_api : public context_aware_api {
}

int memcmp( array_ptr<const char> dest, array_ptr<const char> src, size_t length) {
return ::memcmp(dest, src, length);
int ret = ::memcmp(dest, src, length);
if(ret < 0)
return -1;
if(ret > 0)
return 1;
return 0;
}

char* memset( array_ptr<char> dest, int value, size_t length ) {
Expand Down
Loading

0 comments on commit 44d4386

Please sign in to comment.