Skip to content

Commit

Permalink
Merge pull request EOSIO#174 from enumivo/staging
Browse files Browse the repository at this point in the history
Staging
  • Loading branch information
Enumivo authored Jun 1, 2018
2 parents 012be50 + 2176b02 commit 4772ee5
Show file tree
Hide file tree
Showing 40 changed files with 262 additions and 401 deletions.
2 changes: 1 addition & 1 deletion Docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM enumivo/builder as builder
ARG branch=master
ARG symbol=SYS
ARG symbol=ENU

RUN git clone -b $branch https://github.com/enumivo/enumivo.git --recursive \
&& cd enumivo && echo "$branch:$(git rev-parse HEAD)" > /etc/enumivo-version \
Expand Down
2 changes: 1 addition & 1 deletion Docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ The above will build off the most recent commit to the master branch by default.
docker build -t enumivo/enumivo:dawn-v4.0.0 --build-arg branch=dawn-v4.0.0 .
```

By default, the symbol in enumivo.system is set to SYS. You can override this using the symbol argument while building the docker image.
By default, the symbol in enumivo.system is set to ENU. You can override this using the symbol argument while building the docker image.

```bash
docker build -t enumivo/enumivo --build-arg symbol=<symbol> .
Expand Down
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/enumivo.bios/enumivo.bios.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace enumivo {
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/enumivo.system/delegate_bandwidth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ namespace enumivosystem {
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 enumivosystem {
}

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/enumivo.system/enumivo.system-buyrambytes-rc.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

This action will attempt to reserve about {{bytes}} bytes of RAM on behalf of {{receiver}}.

{{buyer}} authorizes this conrtact to transfer sufficient SYS tokens to buy the RAM based upon the current price as determined by the market maker algorithm.
{{buyer}} authorizes this conrtact to transfer sufficient ENU tokens to buy the RAM based upon the current price as determined by the market maker algorithm.

{{buyer}} accepts that a 0.5% fee will be charged on the SYS spent and that the actual RAM received may be slightly less than requested due to the approximations necessary to enable this service.
{{buyer}} accepts that a 0.5% fee will be charged on the ENU spent and that the actual RAM received may be slightly less than requested due to the approximations necessary to enable this service.
{{buyer}} accepts that a 0.5% fee will be charged if and when they sell the RAM received.
{{buyer}} accepts that rounding errors resulting from limits of computational precision may result in less RAM being allocated.
{{buyer}} acknowledges that the supply of RAM may be increased at any time up to the limits of off-the-shelf computer equipment and that this may result in RAM selling for less than purchase price.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The Members grant the right of contract and of private property to each other, t
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 V - No Fiduciary
No Member nor SYS token holder shall have fiduciary responsibility to support the value of the SYS token. The Members do not authorize anyone to hold assets, borrow, nor contract on behalf of SYS token holders collectively. This blockchain has no owners, managers or fiduciaries; therefore, no Member shall have beneficial interest in more than 10% of the SYS token supply.
No Member nor ENU token holder shall have fiduciary responsibility 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 VI - Restitution
Each Member agrees that penalties for breach of contract may include, but are not limited to, fines, loss of account, and other restitution.
Expand Down
4 changes: 2 additions & 2 deletions contracts/enumivo.system/enumivo.system.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ namespace enumivosystem {
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 enumivo::multi_index< N(namebids), name_bid,
Expand Down
2 changes: 1 addition & 1 deletion contracts/enumivo.system/voting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ namespace enumivosystem {
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 enumivo {

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);
enumivo_assert(enumivo::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();
enumivo_assert( false, "system_api should not be allowed" );
} else if ( cfa.payload == 210 ) {
send_inline( "hello", 6 );
send_inline( (char*)"hello", 6 );
enumivo_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 <enumivolib/enumivo.hpp>
#include <enumivolib/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];
enumivo::datastream<char *> ds(buf, sizeof(buf));
ds << v;
double v2;
ds.seekp(0);
ds >> v2;
enumivo_assert(std::abs(v - v2) < 1e-20, errmsg);
}
};

template <>
struct testtype<float> {
static void run(const float &v, const char *errmsg = "") {
char buf[128];
enumivo::datastream<char *> ds(buf, sizeof(buf));
ds << v;
float v2;
ds.seekp(0);
ds >> v2;
enumivo_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 {
ENULIB_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 enumivo;
Expand All @@ -68,7 +68,7 @@ void test_permission::test_permission_last_used(uint64_t receiver, uint64_t code
enumivo_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 enumivo;
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 enumivo;
auto r = cancel_deferred( 0xffffffffffffffff ); //use the same id (0) as in send_deferred_transaction
enumivo_assert( r, "transaction was not found" );
enumivo_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() {
enumivo_assert(false == is_feature_active(N(newfeature)), "we should not have new features unless hardfork");
enumivo_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);
enumivo_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 = enumivo::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), (enumivo::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() {
enumivo_assert(reinterpret_cast<int32_t>(sbrk(-1)) == -1, "Should have errored for trying to remove memory");
enumivo_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 <enumivolib/enumivo.hpp>
#include <enumivolib/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 enumivo::contract {
public:
const uint32_t FIVE_MINUTES = 5*60;
Expand Down Expand Up @@ -73,4 +78,6 @@ class test_ram_limit : public enumivo::contract {
typedef enumivo::multi_index< N(test.table), test> test_table;
};

#pragma clang diagnostic pop

ENUMIVO_ABI( test_ram_limit, (setentry)(rmentry)(printentry) )
16 changes: 13 additions & 3 deletions enumivo_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="ENU"
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
Loading

0 comments on commit 4772ee5

Please sign in to comment.