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

Commit 8b0d3fd

Browse files
authored
Merge pull request #123 from EOSIO/develop
version 1.5.0
2 parents 1b85741 + 6aa2d87 commit 8b0d3fd

File tree

9 files changed

+121
-121
lines changed

9 files changed

+121
-121
lines changed

CMakeLists.txt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
cmake_minimum_required(VERSION 3.5)
2-
project(eosio_contracts VERSION 1.4.0)
2+
project(eosio_contracts VERSION 1.5.0)
33

4-
set(EOSIO_CDT_VERSION_MIN "1.3")
5-
set(EOSIO_CDT_VERSION_SOFT_MAX "1.3")
4+
set(EOSIO_CDT_VERSION_MIN "1.4")
5+
set(EOSIO_CDT_VERSION_SOFT_MAX "1.4")
66
#set(EOSIO_CDT_VERSION_HARD_MAX "")
77

8-
include(CheckVersion.txt)
9-
108
find_package(eosio.cdt)
119

1210
### Check the version of eosio.cdt

CheckVersion.txt

Lines changed: 0 additions & 90 deletions
This file was deleted.

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# eosio.contracts
22

3-
## Version : 1.4.0
3+
## Version : 1.5.0
44

55
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 wrap (formerly known as sudo) contracts.
66

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

1616
Dependencies:
17-
* [eosio v1.3.x](https://github.com/EOSIO/eos/releases/tag/v1.3.2)
18-
* [eosio.cdt v1.3.x](https://github.com/EOSIO/eosio.cdt/releases/tag/v1.3.0)
17+
* [eosio v1.4.x](https://github.com/EOSIO/eos/releases/tag/v1.4.3)
18+
* [eosio.cdt v1.4.x](https://github.com/EOSIO/eosio.cdt/releases/tag/v1.4.0)
1919

2020
To build the contracts and the unit tests:
2121
* First, ensure that your __eosio__ is compiled to the core symbol for the EOSIO blockchain that intend to deploy to.

UnitTestsExternalProject.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@ include(ExternalProject)
22
find_package(Git REQUIRED)
33
include(GNUInstallDirs)
44

5+
string(REPLACE ";" "|" TEST_FRAMEWORK_PATH "${CMAKE_FRAMEWORK_PATH}")
6+
string(REPLACE ";" "|" TEST_MODULE_PATH "${CMAKE_MODULE_PATH}")
7+
58
ExternalProject_Add(
69
contracts_unit_tests
7-
CMAKE_ARGS -DCMAKE_BUILD_TYPE=${TEST_BUILD_TYPE} -DEOSIO_ROOT=${EOSIO_ROOT}
10+
LIST_SEPARATOR | # Use the alternate list separator
11+
CMAKE_ARGS -DCMAKE_BUILD_TYPE=${TEST_BUILD_TYPE} -DCMAKE_FRAMEWORK_PATH=${TEST_FRAMEWORK_PATH} -DCMAKE_MODULE_PATH=${TEST_MODULE_PATH} -DEOSIO_ROOT=${EOSIO_ROOT}
812
SOURCE_DIR ${CMAKE_SOURCE_DIR}/tests
913
BINARY_DIR ${CMAKE_BINARY_DIR}/tests
1014
BUILD_ALWAYS 1

eosio.msig/include/eosio.msig/eosio.msig.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ namespace eosio {
1313
void propose(ignore<name> proposer, ignore<name> proposal_name,
1414
ignore<std::vector<permission_level>> requested, ignore<transaction> trx);
1515
[[eosio::action]]
16-
void approve( name proposer, name proposal_name, permission_level level );
16+
void approve( name proposer, name proposal_name, permission_level level,
17+
const eosio::binary_extension<eosio::checksum256>& proposal_hash );
1718
[[eosio::action]]
1819
void unapprove( name proposer, name proposal_name, permission_level level );
1920
[[eosio::action]]

eosio.msig/src/eosio.msig.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include <eosio.msig/eosio.msig.hpp>
22
#include <eosiolib/action.hpp>
33
#include <eosiolib/permission.hpp>
4+
#include <eosiolib/crypto.hpp>
45

56
namespace eosio {
67

@@ -57,9 +58,17 @@ void multisig::propose( ignore<name> proposer,
5758
});
5859
}
5960

60-
void multisig::approve( name proposer, name proposal_name, permission_level level ) {
61+
void multisig::approve( name proposer, name proposal_name, permission_level level,
62+
const eosio::binary_extension<eosio::checksum256>& proposal_hash )
63+
{
6164
require_auth( level );
6265

66+
if( proposal_hash ) {
67+
proposals proptable( _self, proposer.value );
68+
auto& prop = proptable.get( proposal_name.value, "proposal not found" );
69+
assert_sha256( prop.packed_transaction.data(), prop.packed_transaction.size(), *proposal_hash );
70+
}
71+
6372
approvals apptable( _self, proposer.value );
6473
auto apps_it = apptable.find( proposal_name.value );
6574
if ( apps_it != apptable.end() ) {

eosio.system/src/eosio.system.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -291,16 +291,15 @@ namespace eosiosystem {
291291
auto system_token_supply = eosio::token::get_supply(token_account, core.code() );
292292
eosio_assert( system_token_supply.symbol == core, "specified core symbol does not exist (precision mismatch)" );
293293

294-
if( system_token_supply.amount > 0 ) {
295-
_rammarket.emplace( _self, [&]( auto& m ) {
296-
m.supply.amount = 100000000000000ll;
297-
m.supply.symbol = ramcore_symbol;
298-
m.base.balance.amount = int64_t(_gstate.free_ram());
299-
m.base.balance.symbol = ram_symbol;
300-
m.quote.balance.amount = system_token_supply.amount / 1000;
301-
m.quote.balance.symbol = core;
302-
});
303-
}
294+
eosio_assert( system_token_supply.amount > 0, "system token supply must be greater than 0" );
295+
_rammarket.emplace( _self, [&]( auto& m ) {
296+
m.supply.amount = 100000000000000ll;
297+
m.supply.symbol = ramcore_symbol;
298+
m.base.balance.amount = int64_t(_gstate.free_ram());
299+
m.base.balance.symbol = ram_symbol;
300+
m.quote.balance.amount = system_token_supply.amount / 1000;
301+
m.quote.balance.symbol = core;
302+
});
304303
}
305304
} /// eosio.system
306305

tests/CMakeLists.txt

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
11
cmake_minimum_required( VERSION 3.5 )
22

3-
set(EOSIO_VERSION_MIN "1.3")
4-
set(EOSIO_VERSION_SOFT_MAX "1.3")
3+
set(EOSIO_VERSION_MIN "1.4")
4+
set(EOSIO_VERSION_SOFT_MAX "1.4")
55
#set(EOSIO_VERSION_HARD_MAX "")
66

7-
include(../CheckVersion.txt)
8-
9-
if(EOSIO_ROOT STREQUAL "" OR NOT EOSIO_ROOT)
10-
set(EOSIO_ROOT "/usr/local/eosio")
11-
endif()
12-
13-
list(APPEND CMAKE_MODULE_PATH ${EOSIO_ROOT}/lib/cmake)
14-
include(EosioTester)
7+
find_package(eosio)
158

169
### Check the version of eosio
1710
set(VERSION_MATCH_ERROR_MSG "")

tests/eosio.msig_tests.cpp

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -861,4 +861,90 @@ BOOST_FIXTURE_TEST_CASE( approve_by_two_old, eosio_msig_tester ) try {
861861

862862
} FC_LOG_AND_RETHROW()
863863

864+
BOOST_FIXTURE_TEST_CASE( approve_with_hash, eosio_msig_tester ) try {
865+
auto trx = reqauth("alice", {permission_level{N(alice), config::active_name}}, abi_serializer_max_time );
866+
auto trx_hash = fc::sha256::hash( trx );
867+
auto not_trx_hash = fc::sha256::hash( trx_hash );
868+
869+
push_action( N(alice), N(propose), mvo()
870+
("proposer", "alice")
871+
("proposal_name", "first")
872+
("trx", trx)
873+
("requested", vector<permission_level>{{ N(alice), config::active_name }})
874+
);
875+
876+
//fail to approve with incorrect hash
877+
BOOST_REQUIRE_EXCEPTION( push_action( N(alice), N(approve), mvo()
878+
("proposer", "alice")
879+
("proposal_name", "first")
880+
("level", permission_level{ N(alice), config::active_name })
881+
("proposal_hash", not_trx_hash)
882+
),
883+
eosio::chain::crypto_api_exception,
884+
fc_exception_message_is("hash mismatch")
885+
);
886+
887+
//approve and execute
888+
push_action( N(alice), N(approve), mvo()
889+
("proposer", "alice")
890+
("proposal_name", "first")
891+
("level", permission_level{ N(alice), config::active_name })
892+
("proposal_hash", trx_hash)
893+
);
894+
895+
transaction_trace_ptr trace;
896+
control->applied_transaction.connect([&]( const transaction_trace_ptr& t) { if (t->scheduled) { trace = t; } } );
897+
push_action( N(alice), N(exec), mvo()
898+
("proposer", "alice")
899+
("proposal_name", "first")
900+
("executer", "alice")
901+
);
902+
903+
BOOST_REQUIRE( bool(trace) );
904+
BOOST_REQUIRE_EQUAL( 1, trace->action_traces.size() );
905+
BOOST_REQUIRE_EQUAL( transaction_receipt::executed, trace->receipt->status );
906+
} FC_LOG_AND_RETHROW()
907+
908+
BOOST_FIXTURE_TEST_CASE( switch_proposal_and_fail_approve_with_hash, eosio_msig_tester ) try {
909+
auto trx1 = reqauth("alice", {permission_level{N(alice), config::active_name}}, abi_serializer_max_time );
910+
auto trx1_hash = fc::sha256::hash( trx1 );
911+
912+
push_action( N(alice), N(propose), mvo()
913+
("proposer", "alice")
914+
("proposal_name", "first")
915+
("trx", trx1)
916+
("requested", vector<permission_level>{{ N(alice), config::active_name }})
917+
);
918+
919+
auto trx2 = reqauth("alice",
920+
{ permission_level{N(alice), config::active_name},
921+
permission_level{N(alice), config::owner_name} },
922+
abi_serializer_max_time );
923+
924+
push_action( N(alice), N(cancel), mvo()
925+
("proposer", "alice")
926+
("proposal_name", "first")
927+
("canceler", "alice")
928+
);
929+
930+
push_action( N(alice), N(propose), mvo()
931+
("proposer", "alice")
932+
("proposal_name", "first")
933+
("trx", trx2)
934+
("requested", vector<permission_level>{ { N(alice), config::active_name },
935+
{ N(alice), config::owner_name } })
936+
);
937+
938+
//fail to approve with hash meant for old proposal
939+
BOOST_REQUIRE_EXCEPTION( push_action( N(alice), N(approve), mvo()
940+
("proposer", "alice")
941+
("proposal_name", "first")
942+
("level", permission_level{ N(alice), config::active_name })
943+
("proposal_hash", trx1_hash)
944+
),
945+
eosio::chain::crypto_api_exception,
946+
fc_exception_message_is("hash mismatch")
947+
);
948+
} FC_LOG_AND_RETHROW()
949+
864950
BOOST_AUTO_TEST_SUITE_END()

0 commit comments

Comments
 (0)