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 #505 from EOSIO/feature/cherry-pick-inline-msig
Browse files Browse the repository at this point in the history
OOB Patch to v1.8.3 based on #504
  • Loading branch information
jeffreyssmith2nd authored Jul 30, 2020
2 parents 7109f00 + 37efeea commit c097d54
Show file tree
Hide file tree
Showing 12 changed files with 389 additions and 94 deletions.
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ endif()
include(ExternalProject)

find_package(eosio.cdt)
message(STATUS "Using eosio.cdt in ${EOSIO_CDT_ROOT}")

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_HARD_MAX "")
set(EOSIO_CDT_VERSION_HARD_MAX "1.6")

### Check the version of eosio.cdt
set(VERSION_MATCH_ERROR_MSG "")
Expand Down Expand Up @@ -82,7 +83,7 @@ if(BUILD_TESTS)
ExternalProject_Add(
contracts_unit_tests
LIST_SEPARATOR | # Use the alternate list separator
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}
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}
SOURCE_DIR ${CMAKE_SOURCE_DIR}/tests
BINARY_DIR ${CMAKE_BINARY_DIR}/tests
BUILD_ALWAYS 1
Expand Down
6 changes: 6 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ function usage() {
exit 1
}

EOSIO_MAX_VERSION_MAJOR=1
EOSIO_MAX_VERSION_MINOR=8
BUILD_TESTS=false

if [ $# -ne 0 ]; then
Expand Down Expand Up @@ -55,6 +57,9 @@ fi
if [[ ${BUILD_TESTS} == true ]]; then
# Prompt user for location of eosio.
eosio-directory-prompt

default-boost-directories;
echo "Using Boost installation at: ${BOOST_INSTALL_DIR}"
fi

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

printf "\t=========== Building eosio.contracts ===========\n\n"
Expand Down
10 changes: 8 additions & 2 deletions contracts/eosio.msig/src/eosio.msig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,14 @@ void multisig::exec( name proposer, name proposal_name, name executer ) {
proposals proptable( get_self(), proposer.value );
auto& prop = proptable.get( proposal_name.value, "proposal not found" );
transaction_header trx_header;
std::vector<action> context_free_actions;
std::vector<action> actions;
datastream<const char*> ds( prop.packed_transaction.data(), prop.packed_transaction.size() );
ds >> trx_header;
check( trx_header.expiration >= eosio::time_point_sec(current_time_point()), "transaction expired" );
ds >> context_free_actions;
check( context_free_actions.empty(), "not allowed to `exec` a transaction with context-free actions" );
ds >> actions;

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

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

send_deferred( (uint128_t(proposer.value) << 64) | proposal_name.value, executer,
prop.packed_transaction.data(), prop.packed_transaction.size() );
for (const auto& act : actions) {
act.send();
}

proptable.erase(prop);
}
Expand Down
55 changes: 54 additions & 1 deletion scripts/helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,37 @@ function check-version-numbers() {
exit 0
}

# Ensures passed in boost version values are supported.
function check-boost-version-numbers() {
CHECK_VERSION_MAJOR=$1
CHECK_VERSION_MINOR=$2

if [[ ${BOOST_MIN_VERSION_MAJOR} && ${BOOST_MIN_VERSION_MAJOR} != "" ]]; then
if [[ $CHECK_VERSION_MAJOR -lt $BOOST_MIN_VERSION_MAJOR ]]; then
exit 1
fi
fi
if [[ ${BOOST_MAX_VERSION_MAJOR} && ${BOOST_MAX_VERSION_MAJOR} != "" ]]; then
if [[ $CHECK_VERSION_MAJOR -gt $BOOST_MAX_VERSION_MAJOR ]]; then
exit 1
fi
fi
if [[ $CHECK_VERSION_MAJOR -eq $BOOST_MIN_VERSION_MAJOR ]]; then
if [[ ${BOOST_MIN_VERSION_MINOR} && ${BOOST_MIN_VERSION_MINOR} != "" ]]; then
if [[ $CHECK_VERSION_MINOR -lt $BOOST_MIN_VERSION_MINOR ]]; then
exit 1
fi
fi
fi
if [[ $CHECK_VERSION_MAJOR -eq $BOOST_MAX_VERSION_MAJOR ]]; then
if [[ ${BOOST_MAX_VERSION_MINOR} && ${BOOST_MAX_VERSION_MINOR} != "" ]]; then
if [[ $CHECK_VERSION_MINOR -gt $BOOST_MAX_VERSION_MINOR ]]; then
exit 1
fi
fi
fi
exit 0
}

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


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

# Handles choosing which Boost directory to select.
function default-boost-directories() {
REGEX='boost_[0-9]+([_][0-9]+)?+([_][0-9]+)?$'
ALL_BOOST_SUBDIRS=()
if [[ -d ${HOME}/eosio ]]; then
ALL_BOOST_SUBDIRS=($(ls ${EOSIO_INSTALL_DIR}/src | sort -V))
fi
for ITEM in "${ALL_BOOST_SUBDIRS[@]}"; do
if [[ "$ITEM" =~ $REGEX ]]; then
DIR_MAJOR=$(echo $ITEM | cut -f2 -d '_')
DIR_MINOR=$(echo $ITEM | cut -f3 -d '_')
if $(check-boost-version-numbers $DIR_MAJOR $DIR_MINOR); then
PROMPT_BOOST_DIRS+=($ITEM)
fi
fi
done
for ITEM in "${PROMPT_BOOST_DIRS[@]}"; do
if [[ "$ITEM" =~ $REGEX ]]; then
BOOST_VERSION=$ITEM
fi
done
export BOOST_INSTALL_DIR=${EOSIO_INSTALL_DIR}/src/${BOOST_VERSION}
}

# Prompts or default behavior for choosing EOSIO.CDT directory.
function cdt-directory-prompt() {
Expand Down
4 changes: 3 additions & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
cmake_minimum_required( VERSION 3.5 )

add_subdirectory(test_contracts)

set(EOSIO_VERSION_MIN "1.8")
set(EOSIO_VERSION_SOFT_MAX "1.8")
#set(EOSIO_VERSION_HARD_MAX "")
set(EOSIO_VERSION_HARD_MAX "1.8")

find_package(eosio)

Expand Down
2 changes: 2 additions & 0 deletions tests/contracts.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ struct contracts {
static std::vector<char> system_abi_old() { return read_abi("${CMAKE_SOURCE_DIR}/test_contracts/eosio.system.old/eosio.system.abi"); }
static std::vector<uint8_t> msig_wasm_old() { return read_wasm("${CMAKE_SOURCE_DIR}/test_contracts/eosio.msig.old/eosio.msig.wasm"); }
static std::vector<char> msig_abi_old() { return read_abi("${CMAKE_SOURCE_DIR}/test_contracts/eosio.msig.old/eosio.msig.abi"); }
static std::vector<uint8_t> sendinline_wasm() {return read_wasm("${CMAKE_BINARY_DIR}/test_contracts/sendinline/sendinline.wasm"); }
static std::vector<char> sendinline_abi() {return read_abi("${CMAKE_BINARY_DIR}/test_contracts/sendinline/sendinline.abi"); }
};
};
}} //ns eosio::testing
Loading

0 comments on commit c097d54

Please sign in to comment.