This repository has been archived by the owner on Aug 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
fixes to contract whitelist/blacklist #3921
Merged
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
a055d1b
add test demonstrating onblock blacklist issue #3814
arhag c9e70f6
early (and more meaningful) validation of receipts matching #3814
arhag 0caacc6
onblock should never fail due to subjective reasons #3814
arhag 8a00c6e
add test demonstrating deferred transaction blacklist issue #3814
arhag 06f4cd1
add whitelist/blacklist exceptions to failure_is_subjective #3814
arhag a5dfb67
Merge branch 'master' into 3814-onblock-whitelist-blacklist
arhag 61459b6
@wanderingbort's requested changes from PR #3921 review
arhag d7e5977
Merge branch 'master' into 3814-onblock-whitelist-blacklist
arhag File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,6 +75,7 @@ namespace eosio { namespace chain { | |
fc::microseconds delay; | ||
bool is_input = false; | ||
bool apply_context_free = true; | ||
bool cannot_subjectively_fail = false; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The double negative name is probably more confusing than an alternative like |
||
|
||
fc::time_point deadline = fc::time_point::maximum(); | ||
fc::microseconds leeway = fc::microseconds(3000); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
|
||
if (( $# < 3 )); then | ||
echo "$0 SOURCE_DIR BUILD_DIR ARGS..." | ||
exit 0 | ||
fi | ||
|
||
function get_absolute_dir_path() { | ||
pushd $1 > /dev/null | ||
echo $PWD | ||
popd > /dev/null | ||
} | ||
|
||
SOURCE_DIR=$(get_absolute_dir_path $1) | ||
|
||
BUILD_DIR=$2 | ||
|
||
shift; shift | ||
|
||
#echo "Source directory: ${SOURCE_DIR}" | ||
|
||
eval "${BUILD_DIR}/programs/eosio-abigen/eosio-abigen -extra-arg=--std=c++14 -extra-arg=--target=wasm32 -extra-arg=\"-I${SOURCE_DIR}/contracts/libc++/upstream/include\" -extra-arg=\"-I${SOURCE_DIR}/contracts/musl/upstream/include\" -extra-arg=\"-I${SOURCE_DIR}/externals/magic_get/include\" -extra-arg=\"-I${SOURCE_DIR}/contracts\" $@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# will be implictly used for any compilation unit if not overrided by SYSTEM_INCLUDE_FOLDERS parameter | ||
# these directories go as -isystem <dir> to avoid warnings from code of third-party libraries | ||
set(DEFAULT_SYSTEM_INCLUDE_FOLDERS ${CMAKE_SOURCE_DIR}/contracts/libc++/upstream/include ${CMAKE_SOURCE_DIR}/contracts/musl/upstream/include ${Boost_INCLUDE_DIR}) | ||
|
||
set(STANDARD_INCLUDE_FOLDERS ${CMAKE_SOURCE_DIR}/contracts ${CMAKE_SOURCE_DIR}/unittests/contracts ${CMAKE_SOURCE_DIR}/externals/magic_get/include) | ||
|
||
add_subdirectory(deferred_test) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
file(GLOB ABI_FILES "*.abi") | ||
configure_file("${ABI_FILES}" "${CMAKE_CURRENT_BINARY_DIR}" COPYONLY) | ||
|
||
add_wast_executable(TARGET deferred_test | ||
INCLUDE_FOLDERS "${STANDARD_INCLUDE_FOLDERS}" ${Boost_INCLUDE_DIR} | ||
LIBRARIES libc++ libc eosiolib | ||
DESTINATION_FOLDER ${CMAKE_CURRENT_BINARY_DIR} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{ | ||
"version": "eosio::abi/1.0", | ||
"types": [], | ||
"structs": [{ | ||
"name": "defercall", | ||
"base": "", | ||
"fields": [{ | ||
"name": "payer", | ||
"type": "name" | ||
},{ | ||
"name": "sender_id", | ||
"type": "uint64" | ||
},{ | ||
"name": "contract", | ||
"type": "name" | ||
},{ | ||
"name": "payload", | ||
"type": "uint64" | ||
} | ||
] | ||
},{ | ||
"name": "deferfunc", | ||
"base": "", | ||
"fields": [{ | ||
"name": "payload", | ||
"type": "uint64" | ||
} | ||
] | ||
} | ||
], | ||
"actions": [{ | ||
"name": "defercall", | ||
"type": "defercall", | ||
"ricardian_contract": "" | ||
},{ | ||
"name": "deferfunc", | ||
"type": "deferfunc", | ||
"ricardian_contract": "" | ||
} | ||
], | ||
"tables": [], | ||
"ricardian_clauses": [], | ||
"error_messages": [], | ||
"abi_extensions": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/** | ||
* @file | ||
* @copyright defined in eos/LICENSE.txt | ||
*/ | ||
|
||
#include <eosiolib/eosio.hpp> | ||
#include <eosiolib/transaction.hpp> | ||
#include <eosiolib/dispatcher.hpp> | ||
|
||
using namespace eosio; | ||
|
||
class deferred_test : public eosio::contract { | ||
public: | ||
using contract::contract; | ||
|
||
struct deferfunc_args { | ||
uint64_t payload; | ||
}; | ||
|
||
//@abi action | ||
void defercall( account_name payer, uint64_t sender_id, account_name contract, uint64_t payload ) { | ||
print( "defercall called on ", name{_self}, "\n" ); | ||
require_auth( payer ); | ||
|
||
print( "deferred send of deferfunc action to ", name{contract}, " by ", name{payer}, " with sender id ", sender_id ); | ||
transaction trx; | ||
deferfunc_args a = {.payload = payload}; | ||
trx.actions.emplace_back(permission_level{_self, N(active)}, contract, N(deferfunc), a); | ||
trx.send( (static_cast<uint128_t>(payer) << 64) | sender_id, payer); | ||
} | ||
|
||
//@abi action | ||
void deferfunc( uint64_t payload ) { | ||
print("deferfunc called on ", name{_self}, "\n"); | ||
} | ||
|
||
private: | ||
}; | ||
|
||
void apply_onerror(uint64_t receiver, const onerror& error ) { | ||
print("onerror called on ", name{receiver}, "\n"); | ||
} | ||
|
||
extern "C" { | ||
/// The apply method implements the dispatch of events to this contract | ||
void apply( uint64_t receiver, uint64_t code, uint64_t action ) { | ||
if( code == N(eosio) && action == N(onerror) ) { | ||
apply_onerror( receiver, onerror::from_current_action() ); | ||
} else if( code == receiver ) { | ||
deferred_test thiscontract(receiver); | ||
if( action == N(defercall) ) { | ||
execute_action( &thiscontract, &deferred_test::defercall ); | ||
} else if( action == N(deferfunc) ) { | ||
execute_action( &thiscontract, &deferred_test::deferfunc ); | ||
} | ||
} | ||
} | ||
} | ||
|
||
//EOSIO_ABI( deferred_test, (defercall)(deferfunc) ) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be made into an EOS_ASSERT with a proper type