Skip to content
This repository has been archived by the owner on Aug 30, 2022. It is now read-only.

Commit

Permalink
Merge pull request #428 from EOSIO/merge-release-1.9.0-to-master
Browse files Browse the repository at this point in the history
Version 1.9.0
  • Loading branch information
arhag authored Jan 10, 2020
2 parents 7109f00 + 2b129be commit 636406b
Show file tree
Hide file tree
Showing 21 changed files with 474 additions and 242 deletions.
2 changes: 1 addition & 1 deletion .cicd/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ fi
if [[ "$EXIT_STATUS" != 0 ]]; then
echo "Failing due to non-zero exit status from ctest: $EXIT_STATUS"
exit $EXIT_STATUS
fi
fi
10 changes: 5 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ cmake_minimum_required(VERSION 3.5)
project(eosio_contracts)

set(VERSION_MAJOR 1)
set(VERSION_MINOR 8)
set(VERSION_PATCH 3)
#set(VERSION_SUFFIX develop)
set(VERSION_MINOR 9)
set(VERSION_PATCH 0)
#set(VERSION_SUFFIX rc4)

if (VERSION_SUFFIX)
set(VERSION_FULL "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}-${VERSION_SUFFIX}")
Expand All @@ -19,8 +19,8 @@ find_package(eosio.cdt)

message(STATUS "Building eosio.contracts v${VERSION_FULL}")

set(EOSIO_CDT_VERSION_MIN "1.6")
set(EOSIO_CDT_VERSION_SOFT_MAX "1.6")
set(EOSIO_CDT_VERSION_MIN "1.7")
set(EOSIO_CDT_VERSION_SOFT_MAX "1.7")
#set(EOSIO_CDT_VERSION_HARD_MAX "")

### Check the version of eosio.cdt
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# eosio.contracts

## Version : 1.8.3
## Version : 1.9.0

The design of the EOSIO blockchain calls for a number of smart contracts that are run at a privileged permission level in order to support functions such as block producer registration and voting, token staking for CPU and network bandwidth, RAM purchasing, multi-sig, etc. These smart contracts are referred to as the bios, system, msig, wrap (formerly known as sudo) and token contracts.

Expand All @@ -15,8 +15,8 @@ The following unprivileged contract(s) are also part of the system.
* [eosio.token](./contracts/eosio.token)

Dependencies:
* [eosio.cdt v1.6.x](https://github.com/EOSIO/eosio.cdt/releases/tag/v1.6.3)
* [eosio v1.8.x](https://github.com/EOSIO/eos/releases/tag/v1.8.6) (optional dependency only needed to build unit tests)
* [eosio.cdt v1.7.x](https://github.com/EOSIO/eosio.cdt/releases/tag/v1.7.0-rc1)
* [eosio v2.0.x](https://github.com/EOSIO/eos/releases/tag/v2.0.0-rc2) (optional dependency only needed to build unit tests)

To build the contracts follow the instructions in [`Build and deploy` section](./docs/02_build-and-deploy.md).

Expand Down
41 changes: 7 additions & 34 deletions contracts/eosio.bios/include/eosio.bios/eosio.bios.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,6 @@
#include <eosio/privileged.hpp>
#include <eosio/producer_schedule.hpp>

// This header is needed until `is_feature_activiated` and `preactivate_feature` are added to `eosio.cdt`
#include <eosio/../../capi/eosio/crypto.h>

namespace eosio {
namespace internal_use_do_not_use {
extern "C" {
__attribute__((eosio_wasm_import))
bool is_feature_activated( const ::capi_checksum256* feature_digest );

__attribute__((eosio_wasm_import))
void preactivate_feature( const ::capi_checksum256* feature_digest );
}
}
}

namespace eosio {
bool is_feature_activated( const eosio::checksum256& feature_digest ) {
auto feature_digest_data = feature_digest.extract_as_byte_array();
return internal_use_do_not_use::is_feature_activated(
reinterpret_cast<const ::capi_checksum256*>( feature_digest_data.data() )
);
}

void preactivate_feature( const eosio::checksum256& feature_digest ) {
auto feature_digest_data = feature_digest.extract_as_byte_array();
internal_use_do_not_use::preactivate_feature(
reinterpret_cast<const ::capi_checksum256*>( feature_digest_data.data() )
);
}
}

/**
* EOSIO Contracts
*
Expand All @@ -57,9 +26,13 @@ namespace eosio {
* - eosio.token
*/

namespace eosio {
namespace eosiobios {

using eosio::action_wrapper;
using eosio::check;
using eosio::checksum256;
using eosio::ignore;
using eosio::name;
using eosio::permission_level;
using eosio::public_key;

Expand Down Expand Up @@ -112,7 +85,7 @@ namespace eosio {
(schedule_version)(new_producers))
};

class [[eosio::contract("eosio.bios")]] bios : public contract {
class [[eosio::contract("eosio.bios")]] bios : public eosio::contract {
public:
using contract::contract;
/**
Expand Down Expand Up @@ -285,7 +258,7 @@ namespace eosio {
* @param schedule - New list of active producers to set
*/
[[eosio::action]]
void setprods( std::vector<eosio::producer_key> schedule );
void setprods( const std::vector<eosio::producer_authority>& schedule );

/**
* Set the blockchain parameters
Expand Down
8 changes: 7 additions & 1 deletion contracts/eosio.bios/ricardian/eosio.bios.contracts.md.in
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,13 @@ icon: @ICON_BASE_URL@/@ADMIN_ICON_URI@

{{$action.account}} proposes a block producer schedule of:
{{#each schedule}}
1. {{this.producer_name}} with a block signing key of {{this.block_signing_key}}
1. {{this.producer_name}}
{{/each}}

The block signing authorities of each of the producers in the above schedule are listed below:
{{#each schedule}}
### {{this.producer_name}}
{{to_json this.authority}}
{{/each}}

<h1 class="contract">unlinkauth</h1>
Expand Down
10 changes: 5 additions & 5 deletions contracts/eosio.bios/src/eosio.bios.cpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
#include <eosio.bios/eosio.bios.hpp>

namespace eosio {
namespace eosiobios {

void bios::setabi( name account, const std::vector<char>& abi ) {
abi_hash_table table(get_self(), get_self().value);
auto itr = table.find( account.value );
if( itr == table.end() ) {
table.emplace( account, [&]( auto& row ) {
row.owner = account;
row.hash = sha256(const_cast<char*>(abi.data()), abi.size());
row.hash = eosio::sha256(const_cast<char*>(abi.data()), abi.size());
});
} else {
table.modify( itr, same_payer, [&]( auto& row ) {
row.hash = sha256(const_cast<char*>(abi.data()), abi.size());
table.modify( itr, eosio::same_payer, [&]( auto& row ) {
row.hash = eosio::sha256(const_cast<char*>(abi.data()), abi.size());
});
}
}
Expand All @@ -31,7 +31,7 @@ void bios::setalimits( name account, int64_t ram_bytes, int64_t net_weight, int6
set_resource_limits( account, ram_bytes, net_weight, cpu_weight );
}

void bios::setprods( std::vector<eosio::producer_key> schedule ) {
void bios::setprods( const std::vector<eosio::producer_authority>& schedule ) {
require_auth( get_self() );
set_proposed_producers( schedule );
}
Expand Down
6 changes: 2 additions & 4 deletions contracts/eosio.msig/src/eosio.msig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ void multisig::propose( ignore<name> proposer,
check( proptable.find( _proposal_name.value ) == proptable.end(), "proposal with the same name exists" );

auto packed_requested = pack(_requested);
// TODO: Remove internal_use_do_not_use namespace after minimum eosio.cdt dependency becomes 1.7.x
auto res = internal_use_do_not_use::check_transaction_authorization(
auto res = check_transaction_authorization(
trx_pos, size,
(const char*)0, 0,
packed_requested.data(), packed_requested.size()
Expand Down Expand Up @@ -175,8 +174,7 @@ void multisig::exec( name proposer, name proposal_name, name executer ) {
old_apptable.erase(apps);
}
auto packed_provided_approvals = pack(approvals);
// TODO: Remove internal_use_do_not_use namespace after minimum eosio.cdt dependency becomes 1.7.x
auto res = internal_use_do_not_use::check_transaction_authorization(
auto res = check_transaction_authorization(
prop.packed_transaction.data(), prop.packed_transaction.size(),
(const char*)0, 0,
packed_provided_approvals.data(), packed_provided_approvals.size()
Expand Down
47 changes: 35 additions & 12 deletions contracts/eosio.system/include/eosio.system/eosio.system.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#pragma once

#include <eosio/asset.hpp>
#include <eosio/binary_extension.hpp>
#include <eosio/privileged.hpp>
#include <eosio/producer_schedule.hpp>
#include <eosio/singleton.hpp>
#include <eosio/system.hpp>
#include <eosio/time.hpp>
Expand Down Expand Up @@ -179,22 +181,24 @@ namespace eosiosystem {

// Defines `producer_info` structure to be stored in `producer_info` table, added after version 1.0
struct [[eosio::table, eosio::contract("eosio.system")]] producer_info {
name owner;
double total_votes = 0;
eosio::public_key producer_key; /// a packed public key object
bool is_active = true;
std::string url;
uint32_t unpaid_blocks = 0;
time_point last_claim_time;
uint16_t location = 0;
name owner;
double total_votes = 0;
eosio::public_key producer_key; /// a packed public key object
bool is_active = true;
std::string url;
uint32_t unpaid_blocks = 0;
time_point last_claim_time;
uint16_t location = 0;
eosio::binary_extension<eosio::block_signing_authority> producer_authority; // added in version 1.9.0

uint64_t primary_key()const { return owner.value; }
double by_votes()const { return is_active ? -total_votes : total_votes; }
bool active()const { return is_active; }
void deactivate() { producer_key = public_key(); is_active = false; }
void deactivate() { producer_key = public_key(); producer_authority.reset(); is_active = false; }

// explicit serialization macro is not necessary, used here only to improve compilation time
EOSLIB_SERIALIZE( producer_info, (owner)(total_votes)(producer_key)(is_active)(url)
(unpaid_blocks)(last_claim_time)(location) )
(unpaid_blocks)(last_claim_time)(location)(producer_authority) )
};

// Defines new producer info structure to be stored in new producer info table, added after version 1.3.0
Expand Down Expand Up @@ -936,13 +940,30 @@ namespace eosiosystem {
* @param url - the url of the block producer, normally the url of the block producer presentation website,
* @param location - is the country code as defined in the ISO 3166, https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes
*
* @pre Producer is not already registered
* @pre Producer to register is an account
* @pre Authority of producer to register
*/
[[eosio::action]]
void regproducer( const name& producer, const public_key& producer_key, const std::string& url, uint16_t location );

/**
* Register producer action.
*
* @details Register producer action, indicates that a particular account wishes to become a producer,
* this action will create a `producer_config` and a `producer_info` object for `producer` scope
* in producers tables.
*
* @param producer - account registering to be a producer candidate,
* @param producer_authority - the weighted threshold multisig block signing authority of the block producer used to sign blocks,
* @param url - the url of the block producer, normally the url of the block producer presentation website,
* @param location - is the country code as defined in the ISO 3166, https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes
*
* @pre Producer to register is an account
* @pre Authority of producer to register
*/
[[eosio::action]]
void regproducer2( const name& producer, const eosio::block_signing_authority& producer_authority, const std::string& url, uint16_t location );

/**
* Unregister producer action. Deactivate the block producer with account name `producer`.
*
Expand Down Expand Up @@ -1132,6 +1153,7 @@ namespace eosiosystem {
using sellram_action = eosio::action_wrapper<"sellram"_n, &system_contract::sellram>;
using refund_action = eosio::action_wrapper<"refund"_n, &system_contract::refund>;
using regproducer_action = eosio::action_wrapper<"regproducer"_n, &system_contract::regproducer>;
using regproducer2_action = eosio::action_wrapper<"regproducer2"_n, &system_contract::regproducer2>;
using unregprod_action = eosio::action_wrapper<"unregprod"_n, &system_contract::unregprod>;
using setram_action = eosio::action_wrapper<"setram"_n, &system_contract::setram>;
using setramrate_action = eosio::action_wrapper<"setramrate"_n, &system_contract::setramrate>;
Expand Down Expand Up @@ -1204,7 +1226,8 @@ namespace eosiosystem {
const asset& stake_net_quantity, const asset& stake_cpu_quantity, bool transfer );
void update_voting_power( const name& voter, const asset& total_update );

// defined in voting.hpp
// defined in voting.cpp
void register_producer( const name& producer, const eosio::block_signing_authority& producer_authority, const std::string& url, uint16_t location );
void update_elected_producers( const block_timestamp& timestamp );
void update_votes( const name& voter, const name& proxy, const std::vector<name>& producers, bool voting );
void propagate_weight_change( const voter_info& voter );
Expand Down
18 changes: 0 additions & 18 deletions contracts/eosio.system/include/eosio.system/native.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,6 @@
#include <eosio/privileged.hpp>
#include <eosio/producer_schedule.hpp>

// This header is needed until `is_feature_activiated` and `preactivate_feature` are added to `eosio.cdt`
#include <eosio/../../capi/eosio/crypto.h>

namespace eosio {
namespace internal_use_do_not_use {
extern "C" {
__attribute__((eosio_wasm_import))
bool is_feature_activated( const ::capi_checksum256* feature_digest );

__attribute__((eosio_wasm_import))
void preactivate_feature( const ::capi_checksum256* feature_digest );
}
}

bool is_feature_activated( const eosio::checksum256& feature_digest );
void preactivate_feature( const eosio::checksum256& feature_digest );
}

namespace eosiosystem {

using eosio::checksum256;
Expand Down
10 changes: 5 additions & 5 deletions contracts/eosio.system/ricardian/eosio.system.clauses.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@ User agreement for the chain can go here.

I, {{producer}}, hereby nominate myself for consideration as an elected block producer.

If {{producer}} is selected to produce blocks by the system contract, I will sign blocks with {{producer_key}} and I hereby attest that I will keep this key secret and secure.
If {{producer}} is selected to produce blocks by the system contract, I will sign blocks with my registered block signing keys and I hereby attest that I will keep these keys secret and secure.

If {{producer}} is unable to perform obligations under this contract I will resign my position by resubmitting this contract with the null producer key.
If {{producer}} is unable to perform obligations under this contract I will resign my position using the unregprod action.

I acknowledge that a block is 'objectively valid' if it conforms to the deterministic blockchain rules in force at the time of its creation, and is 'objectively invalid' if it fails to conform to those rules.

{{producer}} hereby agrees to only use {{producer_key}} to sign messages under the following scenarios:
{{producer}} hereby agrees to only use my registered block signing keys to sign messages under the following scenarios:

* proposing an objectively valid block at the time appointed by the block scheduling algorithm;
* pre-confirming a block produced by another producer in the schedule when I find said block objectively valid;
* and, confirming a block for which {{producer}} has received pre-confirmation messages from more than two-thirds of the active block producers.

I hereby accept liability for any and all provable damages that result from my:

* signing two different block proposals with the same timestamp with {{producer_key}};
* signing two different block proposals with the same block number with {{producer_key}};
* signing two different block proposals with the same timestamp;
* signing two different block proposals with the same block number;
* signing any block proposal which builds off of an objectively invalid block;
* signing a pre-confirmation for an objectively invalid block;
* or, signing a confirmation for a block for which I do not possess pre-confirmation messages from more than two-thirds of the active block producers.
Expand Down
24 changes: 24 additions & 0 deletions contracts/eosio.system/ricardian/eosio.system.contracts.md.in
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,30 @@ icon: @ICON_BASE_URL@/@VOTING_ICON_URI@

Register {{producer}} account as a block producer candidate.

URL: {{url}}
Location code: {{location}}
Block signing key: {{producer_key}}

## Block Producer Agreement
{{$clauses.BlockProducerAgreement}}

<h1 class="contract">regproducer2</h1>

---
spec_version: "0.2.0"
title: Register as a Block Producer Candidate
summary: 'Register {{nowrap producer}} account as a block producer candidate'
icon: @ICON_BASE_URL@/@VOTING_ICON_URI@
---

Register {{producer}} account as a block producer candidate.

URL: {{url}}
Location code: {{location}}
Block signing authority:
{{to_json producer_authority}}

## Block Producer Agreement
{{$clauses.BlockProducerAgreement}}

<h1 class="contract">regproxy</h1>
Expand Down
16 changes: 0 additions & 16 deletions contracts/eosio.system/src/native.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,6 @@

#include <eosio/check.hpp>

namespace eosio {
bool is_feature_activated( const eosio::checksum256& feature_digest ) {
auto feature_digest_data = feature_digest.extract_as_byte_array();
return internal_use_do_not_use::is_feature_activated(
reinterpret_cast<const ::capi_checksum256*>( feature_digest_data.data() )
);
}

void preactivate_feature( const eosio::checksum256& feature_digest ) {
auto feature_digest_data = feature_digest.extract_as_byte_array();
internal_use_do_not_use::preactivate_feature(
reinterpret_cast<const ::capi_checksum256*>( feature_digest_data.data() )
);
}
}

namespace eosiosystem {

void native::onerror( ignore<uint128_t>, ignore<std::vector<char>> ) {
Expand Down
Loading

0 comments on commit 636406b

Please sign in to comment.