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 #68 from EOSIO/develop
Browse files Browse the repository at this point in the history
Merge develop into master
  • Loading branch information
arhag authored Sep 6, 2018
2 parents aa965d0 + 25584b3 commit 6ca72e7
Show file tree
Hide file tree
Showing 30 changed files with 2,704 additions and 137 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@
*.app

build/*
.DS_Store
19 changes: 10 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
cmake_minimum_required(VERSION 3.5)
project(eosio_contracts VERSION 1.2.1)
project(eosio_contracts VERSION 1.3.0)

set(EOSIO_DEPENDENCY "1.1")
set(EOSIO_WASMSDK_DEPENDENCY "1.1")
set(EOSIO_DEPENDENCY "1.2")
set(EOSIO_CDT_DEPENDENCY "1.2")

if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(TEST_BUILD_TYPE "Debug")
Expand All @@ -15,21 +15,22 @@ if(EOSIO_ROOT STREQUAL "" OR NOT EOSIO_ROOT)
set(EOSIO_ROOT "/usr/local/eosio")
endif()

if(EOSIO_WASMSDK_ROOT STREQUAL "" OR NOT EOSIO_WASMSDK_ROOT)
set(EOSIO_WASMSDK_ROOT "/usr/local/eosio.wasmsdk")
if(EOSIO_CDT_ROOT STREQUAL "" OR NOT EOSIO__ROOT)
set(EOSIO_CDT_ROOT "/usr/local/eosio.cdt")
endif()

list(APPEND CMAKE_MODULE_PATH ${EOSIO_WASMSDK_ROOT}/lib/cmake)
list(APPEND CMAKE_MODULE_PATH ${EOSIO_CDT_ROOT}/lib/cmake)
include(EosioWasmToolchain)

### Check the version of wasmsdk
string(FIND "${EOSIO_WASMSDK_VERSION}" "${EOSIO_WASMSDK_DEPENDENCY}" output)
### Check the version of eosio.cdt
string(FIND "${EOSIO_CDT_VERSION}" "${EOSIO_CDT_DEPENDENCY}" output)

if (NOT "${output}" EQUAL 0)
message(FATAL_ERROR "Incorrect EOSIO.WasmSDK version, please use version ${EOSIO_WASMSDK_DEPENDENCY}.x")
message(FATAL_ERROR "Incorrect EOSIO.CDT version, please use version ${EOSIO_CDT_DEPENDENCY}.x")
endif()

include_directories(AFTER ${BOOST_ROOT}/include)
add_subdirectory(eosio.bios)
add_subdirectory(eosio.msig)
add_subdirectory(eosio.sudo)
add_subdirectory(eosio.system)
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.2.1
## Version : 1.3.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 system, token, msig and sudo contracts.

Expand All @@ -14,8 +14,8 @@ The following unprivileged contract(s) are also part of the system.
* [eosio.token](https://github.com/eosio/eosio.contracts/tree/master/eosio.token)

Dependencies:
* [eosio v1.1.2](https://github.com/eosio/eos/tree/v1.1.2)
* [eosio.wasmsdk v1.1.0](https://github.com/eosio/eosio.wasmsdk/tree/v1.1.0)
* [eosio v1.2.x](https://github.com/EOSIO/eos/releases/tag/v1.2.4)
* [eosio.cdt v1.2.x](https://github.com/EOSIO/eosio.cdt/releases/tag/v1.2.0)

To build the contracts and the unit tests:
* First, ensure that your __eosio__ is compiled to the core symbol for the EOSIO blockchain that intend to deploy to.
Expand Down
10 changes: 10 additions & 0 deletions eosio.bios/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
add_executable(eosio.bios.wasm ${CMAKE_CURRENT_SOURCE_DIR}/src/eosio.bios.cpp)
target_include_directories(eosio.bios.wasm
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include)

set_target_properties(eosio.bios.wasm
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")

configure_file("${CMAKE_CURRENT_SOURCE_DIR}/abi/eosio.bios.abi" "${CMAKE_CURRENT_BINARY_DIR}" COPYONLY)
244 changes: 244 additions & 0 deletions eosio.bios/abi/eosio.bios.abi
Original file line number Diff line number Diff line change
@@ -0,0 +1,244 @@
{
"version": "eosio::abi/1.0",
"types": [{
"new_type_name": "account_name",
"type": "name"
},{
"new_type_name": "permission_name",
"type": "name"
},{
"new_type_name": "action_name",
"type": "name"
},{
"new_type_name": "transaction_id_type",
"type": "checksum256"
},{
"new_type_name": "weight_type",
"type": "uint16"
}],
"structs": [{
"name": "permission_level",
"base": "",
"fields": [
{"name":"actor", "type":"account_name"},
{"name":"permission", "type":"permission_name"}
]
},{
"name": "key_weight",
"base": "",
"fields": [
{"name":"key", "type":"public_key"},
{"name":"weight", "type":"weight_type"}
]
},{
"name": "permission_level_weight",
"base": "",
"fields": [
{"name":"permission", "type":"permission_level"},
{"name":"weight", "type":"weight_type"}
]
},{
"name": "wait_weight",
"base": "",
"fields": [
{"name":"wait_sec", "type":"uint32"},
{"name":"weight", "type":"weight_type"}
]
},{
"name": "authority",
"base": "",
"fields": [
{"name":"threshold", "type":"uint32"},
{"name":"keys", "type":"key_weight[]"},
{"name":"accounts", "type":"permission_level_weight[]"},
{"name":"waits", "type":"wait_weight[]"}
]
},{
"name": "newaccount",
"base": "",
"fields": [
{"name":"creator", "type":"account_name"},
{"name":"name", "type":"account_name"},
{"name":"owner", "type":"authority"},
{"name":"active", "type":"authority"}
]
},{
"name": "setcode",
"base": "",
"fields": [
{"name":"account", "type":"account_name"},
{"name":"vmtype", "type":"uint8"},
{"name":"vmversion", "type":"uint8"},
{"name":"code", "type":"bytes"}
]
},{
"name": "setabi",
"base": "",
"fields": [
{"name":"account", "type":"account_name"},
{"name":"abi", "type":"bytes"}
]
},{
"name": "abi_hash",
"base": "",
"fields": [
{"name":"owner", "type":"account_name"},
{"name":"hash", "type":"checksum256"}
]
},{
"name": "updateauth",
"base": "",
"fields": [
{"name":"account", "type":"account_name"},
{"name":"permission", "type":"permission_name"},
{"name":"parent", "type":"permission_name"},
{"name":"auth", "type":"authority"}
]
},{
"name": "deleteauth",
"base": "",
"fields": [
{"name":"account", "type":"account_name"},
{"name":"permission", "type":"permission_name"}
]
},{
"name": "linkauth",
"base": "",
"fields": [
{"name":"account", "type":"account_name"},
{"name":"code", "type":"account_name"},
{"name":"type", "type":"action_name"},
{"name":"requirement", "type":"permission_name"}
]
},{
"name": "unlinkauth",
"base": "",
"fields": [
{"name":"account", "type":"account_name"},
{"name":"code", "type":"account_name"},
{"name":"type", "type":"action_name"}
]
},{
"name": "canceldelay",
"base": "",
"fields": [
{"name":"canceling_auth", "type":"permission_level"},
{"name":"trx_id", "type":"transaction_id_type"}
]
},{
"name": "onerror",
"base": "",
"fields": [
{"name":"sender_id", "type":"uint128"},
{"name":"sent_trx", "type":"bytes"}
]
},{
"name": "set_account_limits",
"base": "",
"fields": [
{"name":"account", "type":"account_name"},
{"name":"ram_bytes", "type":"int64"},
{"name":"net_weight", "type":"int64"},
{"name":"cpu_weight", "type":"int64"}
]
},{
"name": "setpriv",
"base": "",
"fields": [
{"name":"account", "type":"account_name"},
{"name":"is_priv", "type":"int8"}
]
},{
"name": "set_global_limits",
"base": "",
"fields": [
{"name":"cpu_usec_per_period", "type":"int64"}
]
},{
"name": "producer_key",
"base": "",
"fields": [
{"name":"producer_name", "type":"account_name"},
{"name":"block_signing_key", "type":"public_key"}
]
},{
"name": "set_producers",
"base": "",
"fields": [
{"name":"schedule", "type":"producer_key[]"}
]
},{
"name": "require_auth",
"base": "",
"fields": [
{"name":"from", "type":"account_name"}
]
}],
"actions": [{
"name": "newaccount",
"type": "newaccount",
"ricardian_contract": ""
},{
"name": "setcode",
"type": "setcode",
"ricardian_contract": ""
},{
"name": "setabi",
"type": "setabi",
"ricardian_contract": ""
},{
"name": "updateauth",
"type": "updateauth",
"ricardian_contract": ""
},{
"name": "deleteauth",
"type": "deleteauth",
"ricardian_contract": ""
},{
"name": "linkauth",
"type": "linkauth",
"ricardian_contract": ""
},{
"name": "unlinkauth",
"type": "unlinkauth",
"ricardian_contract": ""
},{
"name": "canceldelay",
"type": "canceldelay",
"ricardian_contract": ""
},{
"name": "onerror",
"type": "onerror",
"ricardian_contract": ""
},{
"name": "setalimits",
"type": "set_account_limits",
"ricardian_contract": ""
},{
"name": "setglimits",
"type": "set_global_limits",
"ricardian_contract": ""
},{
"name": "setpriv",
"type": "setpriv",
"ricardian_contract": ""
},{
"name": "setprods",
"type": "set_producers",
"ricardian_contract": ""
},{
"name": "reqauth",
"type": "require_auth",
"ricardian_contract": ""
}
],
"tables": [{
"name": "abihash",
"type": "abi_hash",
"index_type": "i64",
"key_names": ["owner"],
"key_types": ["account_name"]
}],
"ricardian_clauses": [],
"abi_extensions": []
}
70 changes: 70 additions & 0 deletions eosio.bios/include/eosio.bios/eosio.bios.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#pragma once
#include <eosiolib/crypto.h>
#include <eosiolib/eosio.hpp>
#include <eosiolib/privileged.hpp>

namespace eosio {

struct abi_hash {
account_name owner;
checksum256 hash;
auto primary_key()const { return owner; }

EOSLIB_SERIALIZE( abi_hash, (owner)(hash) )
};

typedef eosio::multi_index< N(abihash), abi_hash> abi_hash_table;

class bios : public contract {
public:
bios( action_name self ):contract(self){}

void setpriv( account_name account, uint8_t ispriv ) {
require_auth( _self );
set_privileged( account, ispriv );
}

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 );
}

void setglimits( uint64_t ram, uint64_t net, uint64_t cpu ) {
(void)ram; (void)net; (void)cpu;
require_auth( _self );
}

void setprods( std::vector<eosio::producer_key> schedule ) {
(void)schedule; // schedule argument just forces the deserialization of the action data into vector<producer_key> (necessary check)
require_auth( _self );

constexpr size_t max_stack_buffer_size = 512;
size_t size = action_data_size();
char* buffer = (char*)( max_stack_buffer_size < size ? malloc(size) : alloca(size) );
read_action_data( buffer, size );
set_proposed_producers(buffer, size);
}

void reqauth( action_name from ) {
require_auth( from );
}

void setabi( account_name acnt, const bytes& abi ) {
abi_hash_table table(_self, _self);
auto itr = table.find( acnt );
if( itr == table.end() ) {
table.emplace( acnt, [&]( auto& row ) {
row.owner = acnt;
sha256( const_cast<char*>(abi.data()), abi.size(), &row.hash );
});
} else {
table.modify( itr, 0, [&]( auto& row ) {
sha256( const_cast<char*>(abi.data()), abi.size(), &row.hash );
});
}
}

private:
};

} /// namespace eosio
3 changes: 3 additions & 0 deletions eosio.bios/src/eosio.bios.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include <eosio.bios/eosio.bios.hpp>

EOSIO_ABI( eosio::bios, (setpriv)(setalimits)(setglimits)(setprods)(reqauth)(setabi) )
Loading

0 comments on commit 6ca72e7

Please sign in to comment.