Skip to content

Commit

Permalink
fix system time in underlying leap image
Browse files Browse the repository at this point in the history
docker dev environment

eliminate unneeded tests

clean-up
  • Loading branch information
porkchop committed Dec 20, 2022
1 parent 792e3d2 commit 3969311
Show file tree
Hide file tree
Showing 17 changed files with 308 additions and 652 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/ubuntu-1804.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Ubuntu 18.04
on:
push:
branches:
- master
- develop
- "release/*"
pull_request:
types: [assigned, opened, synchronize, reopened, labeled]
jobs:
ubuntu-1804-test:
name: Tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Tests
run: |
make dev-docker-all
77 changes: 0 additions & 77 deletions .github/workflows/ubuntu-2004.yml

This file was deleted.

34 changes: 16 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,39 +1,37 @@
CMAKE_CPU_SETUP := $(shell expr $(shell getconf _NPROCESSORS_ONLN) + 2)
DEV_VERSION=latest
DEV_DOCKER_IMAGE=waxteam/dev:$(DEV_VERSION)
DEV_DOCKER_CONTAINER=contracts-development
DEV_DOCKER_COMMON=-v `pwd`:/opt/contracts \
--name $(DEV_DOCKER_CONTAINER) -w /opt/contracts $(DEV_DOCKER_IMAGE)

DOCKER_CONTAINER=contracts-development

DOCKER_COMMON=-v `pwd`:/opt/contracts \
--name $(DOCKER_CONTAINER) -w /opt/contracts waxteam/dev:wax-1.6.1-1.0.0
get-latest:
docker pull $(DEV_DOCKER_IMAGE)

build:
mkdir -p build
cd build && cmake ..
cd build && cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=ON -Dleap_DIR="${LEAP_BUILD_PATH}/lib/cmake/leap" -Dcdt_DIR="${CDT_BUILD_PATH}/lib/cmake/cdt" -DBOOST_ROOT="${HOME}/boost1.79" ..

.PHONY: compile
compile: build
cd build && make -j$(CMAKE_CPU_SETUP)
cd build && make -j $(nproc)

.PHONY: clean
clean:
rm -rf build
-rm -rf build

.PHONY: test
test: compile
./build/tests/unit_test --log_level=all

.PHONY:dev-docker-stop
dev-docker-stop:
-docker rm -f $(DOCKER_CONTAINER)
-docker rm -f $(DEV_DOCKER_CONTAINER)

.PHONY:dev-docker-start
dev-docker-start: dev-docker-stop
docker run -it $(DOCKER_COMMON) bash
dev-docker-start: dev-docker-stop get-latest
docker run -it $(DEV_DOCKER_COMMON) bash

# Useful for wax-docker project
# Useful for travis CI
.PHONY:dev-docker-all
dev-docker-all: dev-docker-stop
docker run --user $(shell id -u):$(shell id -g) $(DOCKER_COMMON) bash -c "\
rm -rf build && \
cmake . -B./build -GNinja && \
cmake --build ./build && \
build/tests/unit_test --show_progress"
dev-docker-all: dev-docker-stop get-latest
docker run $(DEV_DOCKER_COMMON) bash -c "make clean test"
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ cd build/tests
ctest -j $(nproc)
```

Alternatively, use the prebuilt contracts development docker image to get up and running with contracts develompment quickly:
1. Start the interactive shell: `make dev-docker-start`
1. Run all the tests: `make test`
1. Run a single test: `make compile && ./build/tests/unit_test --log_level=all --run_test=eosio_system_tests/producer_pay_as_gbm`

## License

[MIT](LICENSE)
5 changes: 0 additions & 5 deletions _travis.yml

This file was deleted.

35 changes: 0 additions & 35 deletions contracts/eosio.system/include/eosio.system/eosio.system.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,16 +195,6 @@ namespace eosiosystem {
EOSLIB_SERIALIZE( eosio_global_state3, (last_vpay_state_update)(total_vpay_share_change_rate) )
};

// Defines new global state parameters to store inflation rate and distribution
struct [[eosio::table("global4"), eosio::contract("eosio.system")]] eosio_global_state4 {
eosio_global_state4() { }
double continuous_rate;
int64_t inflation_pay_factor;
int64_t votepay_factor;

EOSLIB_SERIALIZE( eosio_global_state4, (continuous_rate)(inflation_pay_factor)(votepay_factor) )
};

inline eosio::block_signing_authority convert_to_block_signing_authority( const eosio::public_key& producer_key ) {
return eosio::block_signing_authority_v0{ .threshold = 1, .keys = {{producer_key, 1}} };
}
Expand Down Expand Up @@ -500,8 +490,6 @@ namespace eosiosystem {

typedef eosio::singleton< "global3"_n, eosio_global_state3 > global_state3_singleton;

typedef eosio::singleton< "global4"_n, eosio_global_state4 > global_state4_singleton;

struct [[eosio::table, eosio::contract("eosio.system")]] user_resources {
name owner;
asset net_weight;
Expand Down Expand Up @@ -600,11 +588,9 @@ namespace eosiosystem {
global_state_singleton _global;
global_state2_singleton _global2;
global_state3_singleton _global3;
global_state4_singleton _global4;
eosio_global_state _gstate;
eosio_global_state2 _gstate2;
eosio_global_state3 _gstate3;
eosio_global_state4 _gstate4;
rammarket _rammarket;
proposer_table _proposers;
proposal_table _proposals;
Expand Down Expand Up @@ -1137,25 +1123,6 @@ namespace eosiosystem {
[[eosio::action]]
void voteproposal(const name& voter_name, const std::vector<name>& proposals);

/**
* Change the annual inflation rate of the core token supply and specify how
* the new issued tokens will be distributed based on the following structure.
*
* @param annual_rate - Annual inflation rate of the core token supply.
* (eg. For 5% Annual inflation => annual_rate=500
* For 1.5% Annual inflation => annual_rate=150
* @param inflation_pay_factor - Inverse of the fraction of the inflation used to reward block producers.
* The remaining inflation will be sent to the `eosio.saving` account.
* (eg. For 20% of inflation going to block producer rewards => inflation_pay_factor = 50000
* For 100% of inflation going to block producer rewards => inflation_pay_factor = 10000).
* @param votepay_factor - Inverse of the fraction of the block producer rewards to be distributed proportional to blocks produced.
* The remaining rewards will be distributed proportional to votes received.
* (eg. For 25% of block producer rewards going towards block pay => votepay_factor = 40000
* For 75% of block producer rewards going towards block pay => votepay_factor = 13333).
*/
[[eosio::action]]
void setinflation( int64_t annual_rate, int64_t inflation_pay_factor, int64_t votepay_factor );

/**
* limitauthchg opts into or out of restrictions on updateauth, deleteauth, linkauth, and unlinkauth.
*
Expand Down Expand Up @@ -1226,7 +1193,6 @@ namespace eosiosystem {
using setwpsstate_action = eosio::action_wrapper<"setwpsstate"_n, &system_contract::setwpsstate>;
using rejectfund_action = eosio::action_wrapper<"rejectfund"_n, &system_contract::rejectfund>;
using voteproposal_action = eosio::action_wrapper<"voteproposal"_n, &system_contract::voteproposal>;
using setinflation_action = eosio::action_wrapper<"setinflation"_n, &system_contract::setinflation>;

private:
// WAX specifics
Expand All @@ -1247,7 +1213,6 @@ namespace eosiosystem {

//defined in eosio.system.cpp
static eosio_global_state get_default_parameters();
static eosio_global_state4 get_default_inflation_parameters();
symbol core_symbol()const;
void update_ram_supply();

Expand Down
3 changes: 1 addition & 2 deletions contracts/eosio.system/src/delegate_bandwidth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,8 @@ namespace eosiosystem {

void validate_b1_vesting( int64_t stake ) {
const int64_t base_time = 1527811200; /// Friday, June 1, 2018 12:00:00 AM UTC
const int64_t current_time = 1638921540; /// Tuesday, December 7, 2021 11:59:00 PM UTC
const int64_t max_claimable = 100'000'000'0000ll;
const int64_t claimable = int64_t(max_claimable * double(current_time - base_time) / (10*seconds_per_year) );
const int64_t claimable = int64_t(max_claimable * double(current_time_point().sec_since_epoch() - base_time) / (10*seconds_per_year) );

check( max_claimable - claimable <= stake, "b1 can only claim their tokens over 10 years" );
}
Expand Down
30 changes: 0 additions & 30 deletions contracts/eosio.system/src/eosio.system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ namespace eosiosystem {
using eosio::current_time_point;
using eosio::token;

double get_continuous_rate(int64_t annual_rate) {
return std::log1p(double(annual_rate)/double(100*inflation_precision));
}

system_contract::system_contract( name s, name code, datastream<const char*> ds )
:native(s,code,ds),
_voters(get_self(), get_self().value),
Expand All @@ -24,7 +20,6 @@ namespace eosiosystem {
_global(get_self(), get_self().value),
_global2(get_self(), get_self().value),
_global3(get_self(), get_self().value),
_global4(get_self(), get_self().value),
_rammarket(get_self(), get_self().value),
_proposers(get_self(), get_self().value),
_proposals(get_self(), get_self().value),
Expand All @@ -36,7 +31,6 @@ namespace eosiosystem {
_gstate = _global.exists() ? _global.get() : get_default_parameters();
_gstate2 = _global2.exists() ? _global2.get() : eosio_global_state2{};
_gstate3 = _global3.exists() ? _global3.get() : eosio_global_state3{};
_gstate4 = _global4.exists() ? _global4.get() : get_default_inflation_parameters();
}

eosio_global_state system_contract::get_default_parameters() {
Expand All @@ -45,14 +39,6 @@ namespace eosiosystem {
return dp;
}

eosio_global_state4 system_contract::get_default_inflation_parameters() {
eosio_global_state4 gs4;
gs4.continuous_rate = get_continuous_rate(default_annual_rate);
gs4.inflation_pay_factor = default_inflation_pay_factor;
gs4.votepay_factor = default_votepay_factor;
return gs4;
}

symbol system_contract::core_symbol()const {
const static auto sym = get_core_symbol( _rammarket );
return sym;
Expand All @@ -63,7 +49,6 @@ namespace eosiosystem {
_global.set( _gstate, get_self() );
_global2.set( _gstate2, get_self() );
_global3.set( _gstate3, get_self() );
_global4.set( _gstate4, get_self() );
}

void system_contract::setram( uint64_t max_ram_size ) {
Expand Down Expand Up @@ -410,21 +395,6 @@ namespace eosiosystem {
_gstate2.revision = revision;
}

void system_contract::setinflation( int64_t annual_rate, int64_t inflation_pay_factor, int64_t votepay_factor ) {
require_auth(get_self());
check(annual_rate >= 0, "annual_rate can't be negative");
if ( inflation_pay_factor < pay_factor_precision ) {
check( false, "inflation_pay_factor must not be less than " + std::to_string(pay_factor_precision) );
}
if ( votepay_factor < pay_factor_precision ) {
check( false, "votepay_factor must not be less than " + std::to_string(pay_factor_precision) );
}
_gstate4.continuous_rate = get_continuous_rate(annual_rate);
_gstate4.inflation_pay_factor = inflation_pay_factor;
_gstate4.votepay_factor = votepay_factor;
_global4.set( _gstate4, get_self() );
}

/**
* Called after a new account is created. This code enforces resource-limits rules
* for new accounts as well as new account naming conventions.
Expand Down
27 changes: 27 additions & 0 deletions docker/Dockerfile.cdt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
ARG leap_version=latest

################################################################################
FROM waxteam/leap:${leap_version}
ARG deps_dir=.

RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get -y install \
build-essential \
clang \
cmake \
git \
libxml2-dev \
opam ocaml-interp \
python3 \
python3-pip \
time && \
rm -rf /var/lib/apt/lists/* && \
python3 -m pip install pygments

WORKDIR /tmp/cdt
COPY ${deps_dir}/cdt .
ENV leap_DIR=/tmp/leap/build/lib/cmake/leap
RUN mkdir build && \
cd build && \
cmake -DBOOST_ROOT=$HOME/boost1.79 .. && \
make -j $(nproc)
12 changes: 12 additions & 0 deletions docker/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
ARG cdt_version=latest

################################################################################
FROM waxteam/cdt:${cdt_version}

RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y \
make && \
rm -rf /var/lib/apt/lists/*

ENV CDT_BUILD_PATH=/tmp/cdt/build
ENV LEAP_BUILD_PATH=/tmp/cdt/leap
Loading

0 comments on commit 3969311

Please sign in to comment.