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

Commit c097d54

Browse files
Merge pull request #505 from EOSIO/feature/cherry-pick-inline-msig
OOB Patch to v1.8.3 based on #504
2 parents 7109f00 + 37efeea commit c097d54

12 files changed

Lines changed: 389 additions & 94 deletions

File tree

CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@ endif()
1616
include(ExternalProject)
1717

1818
find_package(eosio.cdt)
19+
message(STATUS "Using eosio.cdt in ${EOSIO_CDT_ROOT}")
1920

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

2223
set(EOSIO_CDT_VERSION_MIN "1.6")
2324
set(EOSIO_CDT_VERSION_SOFT_MAX "1.6")
24-
#set(EOSIO_CDT_VERSION_HARD_MAX "")
25+
set(EOSIO_CDT_VERSION_HARD_MAX "1.6")
2526

2627
### Check the version of eosio.cdt
2728
set(VERSION_MATCH_ERROR_MSG "")
@@ -82,7 +83,7 @@ if(BUILD_TESTS)
8283
ExternalProject_Add(
8384
contracts_unit_tests
8485
LIST_SEPARATOR | # Use the alternate list separator
85-
CMAKE_ARGS -DCMAKE_BUILD_TYPE=${TEST_BUILD_TYPE} -DCMAKE_PREFIX_PATH=${TEST_PREFIX_PATH} -DCMAKE_FRAMEWORK_PATH=${TEST_FRAMEWORK_PATH} -DCMAKE_MODULE_PATH=${TEST_MODULE_PATH} -DEOSIO_ROOT=${EOSIO_ROOT} -DLLVM_DIR=${LLVM_DIR} -DBOOST_ROOT=${BOOST_ROOT}
86+
CMAKE_ARGS -Deosio.cdt_DIR=${eosio.cdt_DIR} -DCMAKE_BUILD_TYPE=${TEST_BUILD_TYPE} -DCMAKE_PREFIX_PATH=${TEST_PREFIX_PATH} -DCMAKE_FRAMEWORK_PATH=${TEST_FRAMEWORK_PATH} -DCMAKE_MODULE_PATH=${TEST_MODULE_PATH} -DEOSIO_ROOT=${EOSIO_ROOT} -DLLVM_DIR=${LLVM_DIR} -DBOOST_ROOT=${BOOST_ROOT}
8687
SOURCE_DIR ${CMAKE_SOURCE_DIR}/tests
8788
BINARY_DIR ${CMAKE_BINARY_DIR}/tests
8889
BUILD_ALWAYS 1

build.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ function usage() {
1212
exit 1
1313
}
1414

15+
EOSIO_MAX_VERSION_MAJOR=1
16+
EOSIO_MAX_VERSION_MINOR=8
1517
BUILD_TESTS=false
1618

1719
if [ $# -ne 0 ]; then
@@ -55,6 +57,9 @@ fi
5557
if [[ ${BUILD_TESTS} == true ]]; then
5658
# Prompt user for location of eosio.
5759
eosio-directory-prompt
60+
61+
default-boost-directories;
62+
echo "Using Boost installation at: ${BOOST_INSTALL_DIR}"
5863
fi
5964

6065
# Prompt user for location of eosio.cdt.
@@ -71,6 +76,7 @@ if [[ ${BUILD_TESTS} == true ]]; then
7176
# Include EOSIO_INSTALL_DIR in CMAKE_FRAMEWORK_PATH
7277
echo "Using EOSIO installation at: $EOSIO_INSTALL_DIR"
7378
export CMAKE_FRAMEWORK_PATH="${EOSIO_INSTALL_DIR}:${CMAKE_FRAMEWORK_PATH}"
79+
export CMAKE_PREFIX_PATH="${BOOST_INSTALL_DIR}"
7480
fi
7581

7682
printf "\t=========== Building eosio.contracts ===========\n\n"

contracts/eosio.msig/src/eosio.msig.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,14 @@ void multisig::exec( name proposer, name proposal_name, name executer ) {
146146
proposals proptable( get_self(), proposer.value );
147147
auto& prop = proptable.get( proposal_name.value, "proposal not found" );
148148
transaction_header trx_header;
149+
std::vector<action> context_free_actions;
150+
std::vector<action> actions;
149151
datastream<const char*> ds( prop.packed_transaction.data(), prop.packed_transaction.size() );
150152
ds >> trx_header;
151153
check( trx_header.expiration >= eosio::time_point_sec(current_time_point()), "transaction expired" );
154+
ds >> context_free_actions;
155+
check( context_free_actions.empty(), "not allowed to `exec` a transaction with context-free actions" );
156+
ds >> actions;
152157

153158
approvals apptable( get_self(), proposer.value );
154159
auto apps_it = apptable.find( proposal_name.value );
@@ -184,8 +189,9 @@ void multisig::exec( name proposer, name proposal_name, name executer ) {
184189

185190
check( res > 0, "transaction authorization failed" );
186191

187-
send_deferred( (uint128_t(proposer.value) << 64) | proposal_name.value, executer,
188-
prop.packed_transaction.data(), prop.packed_transaction.size() );
192+
for (const auto& act : actions) {
193+
act.send();
194+
}
189195

190196
proptable.erase(prop);
191197
}

scripts/helper.sh

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,37 @@ function check-version-numbers() {
2222
exit 0
2323
}
2424

25+
# Ensures passed in boost version values are supported.
26+
function check-boost-version-numbers() {
27+
CHECK_VERSION_MAJOR=$1
28+
CHECK_VERSION_MINOR=$2
29+
30+
if [[ ${BOOST_MIN_VERSION_MAJOR} && ${BOOST_MIN_VERSION_MAJOR} != "" ]]; then
31+
if [[ $CHECK_VERSION_MAJOR -lt $BOOST_MIN_VERSION_MAJOR ]]; then
32+
exit 1
33+
fi
34+
fi
35+
if [[ ${BOOST_MAX_VERSION_MAJOR} && ${BOOST_MAX_VERSION_MAJOR} != "" ]]; then
36+
if [[ $CHECK_VERSION_MAJOR -gt $BOOST_MAX_VERSION_MAJOR ]]; then
37+
exit 1
38+
fi
39+
fi
40+
if [[ $CHECK_VERSION_MAJOR -eq $BOOST_MIN_VERSION_MAJOR ]]; then
41+
if [[ ${BOOST_MIN_VERSION_MINOR} && ${BOOST_MIN_VERSION_MINOR} != "" ]]; then
42+
if [[ $CHECK_VERSION_MINOR -lt $BOOST_MIN_VERSION_MINOR ]]; then
43+
exit 1
44+
fi
45+
fi
46+
fi
47+
if [[ $CHECK_VERSION_MAJOR -eq $BOOST_MAX_VERSION_MAJOR ]]; then
48+
if [[ ${BOOST_MAX_VERSION_MINOR} && ${BOOST_MAX_VERSION_MINOR} != "" ]]; then
49+
if [[ $CHECK_VERSION_MINOR -gt $BOOST_MAX_VERSION_MINOR ]]; then
50+
exit 1
51+
fi
52+
fi
53+
fi
54+
exit 0
55+
}
2556

2657
# Handles choosing which EOSIO directory to select when the default location is used.
2758
function default-eosio-directories() {
@@ -46,7 +77,6 @@ function default-eosio-directories() {
4677
done
4778
}
4879

49-
5080
# Prompts or sets default behavior for choosing EOSIO directory.
5181
function eosio-directory-prompt() {
5282
if [[ -z $EOSIO_DIR_PROMPT ]]; then
@@ -83,6 +113,29 @@ function eosio-directory-prompt() {
83113
export EOSIO_INSTALL_DIR="${EOSIO_DIR_PROMPT:-${HOME}/eosio/${EOSIO_VERSION}}"
84114
}
85115

116+
# Handles choosing which Boost directory to select.
117+
function default-boost-directories() {
118+
REGEX='boost_[0-9]+([_][0-9]+)?+([_][0-9]+)?$'
119+
ALL_BOOST_SUBDIRS=()
120+
if [[ -d ${HOME}/eosio ]]; then
121+
ALL_BOOST_SUBDIRS=($(ls ${EOSIO_INSTALL_DIR}/src | sort -V))
122+
fi
123+
for ITEM in "${ALL_BOOST_SUBDIRS[@]}"; do
124+
if [[ "$ITEM" =~ $REGEX ]]; then
125+
DIR_MAJOR=$(echo $ITEM | cut -f2 -d '_')
126+
DIR_MINOR=$(echo $ITEM | cut -f3 -d '_')
127+
if $(check-boost-version-numbers $DIR_MAJOR $DIR_MINOR); then
128+
PROMPT_BOOST_DIRS+=($ITEM)
129+
fi
130+
fi
131+
done
132+
for ITEM in "${PROMPT_BOOST_DIRS[@]}"; do
133+
if [[ "$ITEM" =~ $REGEX ]]; then
134+
BOOST_VERSION=$ITEM
135+
fi
136+
done
137+
export BOOST_INSTALL_DIR=${EOSIO_INSTALL_DIR}/src/${BOOST_VERSION}
138+
}
86139

87140
# Prompts or default behavior for choosing EOSIO.CDT directory.
88141
function cdt-directory-prompt() {

tests/CMakeLists.txt

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

3+
add_subdirectory(test_contracts)
4+
35
set(EOSIO_VERSION_MIN "1.8")
46
set(EOSIO_VERSION_SOFT_MAX "1.8")
5-
#set(EOSIO_VERSION_HARD_MAX "")
7+
set(EOSIO_VERSION_HARD_MAX "1.8")
68

79
find_package(eosio)
810

tests/contracts.hpp.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ struct contracts {
2222
static std::vector<char> system_abi_old() { return read_abi("${CMAKE_SOURCE_DIR}/test_contracts/eosio.system.old/eosio.system.abi"); }
2323
static std::vector<uint8_t> msig_wasm_old() { return read_wasm("${CMAKE_SOURCE_DIR}/test_contracts/eosio.msig.old/eosio.msig.wasm"); }
2424
static std::vector<char> msig_abi_old() { return read_abi("${CMAKE_SOURCE_DIR}/test_contracts/eosio.msig.old/eosio.msig.abi"); }
25+
static std::vector<uint8_t> sendinline_wasm() {return read_wasm("${CMAKE_BINARY_DIR}/test_contracts/sendinline/sendinline.wasm"); }
26+
static std::vector<char> sendinline_abi() {return read_abi("${CMAKE_BINARY_DIR}/test_contracts/sendinline/sendinline.abi"); }
2527
};
2628
};
2729
}} //ns eosio::testing

0 commit comments

Comments
 (0)