Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove defer transaction configuration options and block incoming delayed transactions #1643

Merged
merged 35 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
c69b589
Remove defer transaction options --max-scheduled-transaction-time-per…
linh2931 Sep 15, 2023
d233ed6
Merge branch 'main' into remove_defer_trx_config
linh2931 Sep 15, 2023
2578ead
remove _blacklisted_transactions, remove_expired_blacklisted_trxs, an…
linh2931 Sep 16, 2023
013b20f
retire expired deferred transactions
linh2931 Sep 18, 2023
c495ab1
use >= for expiration check and logging improvement
linh2931 Sep 18, 2023
8067ad2
Merge branch 'main' into remove_defer_trx_config
linh2931 Sep 18, 2023
eeea80d
add back missing num_processed++;
linh2931 Sep 18, 2023
191d07f
Merge branch 'remove_defer_trx_config' of https://github.com/Antelope…
linh2931 Sep 18, 2023
076e18a
changedeferred_trxs_deadline to 10ms
linh2931 Sep 19, 2023
840c05b
block delayed transactions
linh2931 Sep 19, 2023
fe45fc4
add and update tests for blocking delayed transactions
linh2931 Sep 21, 2023
4603c86
remove delay member from transaction_context class
linh2931 Sep 21, 2023
d995791
remove final trx.delay_sec left behind in transaction_context.cpp
linh2931 Sep 21, 2023
5b1f7f2
Merge branch 'main' into remove_defer_trx_config
linh2931 Sep 21, 2023
8ad615a
Merge branch 'main' into remove_defer_trx_config
linh2931 Sep 21, 2023
54c9384
Merge branch 'main' into remove_defer_trx_config
linh2931 Sep 23, 2023
0310c57
adapt protocol_feature_tests/no_duplicate_deferred_id_test for delay_…
linh2931 Sep 23, 2023
218f933
move delete_auth from delay_tests.cpp to auth_tests.cpp
linh2931 Sep 25, 2023
55c51c8
simplify delayed_action_blocked and minor refactor
linh2931 Sep 25, 2023
0b47abe
restore link_delay_direct_test and link_delay_direct_parent_permissio…
linh2931 Sep 25, 2023
41a5c3b
move generated_transaction_multi_index size checks to delayed_trx_blo…
linh2931 Sep 25, 2023
508397d
restore and adpat link_delay_direct_walk_parent_permissions_test
linh2931 Sep 25, 2023
de5e3c7
restore and adapt link_delay_permission_change_test
linh2931 Sep 25, 2023
b2418c9
restore and adapt link_delay_permission_change_with_delay_heirarchy_test
linh2931 Sep 25, 2023
41ceb75
restore and adapt link_delay_link_change_test
linh2931 Sep 25, 2023
7c78c44
restore and adapt link_delay_unlink_test
linh2931 Sep 25, 2023
43a5082
restore and adapt link_delay_link_change_heirarchy_test
linh2931 Sep 25, 2023
a4d2c5d
rewrite canceldelay_test
linh2931 Sep 26, 2023
604b0e1
rewrite canceldelay_test2
linh2931 Sep 27, 2023
c7032c5
restore max_transaction_delay_create
linh2931 Sep 27, 2023
0ef0175
update max_transaction_delay_execute
linh2931 Sep 27, 2023
c07caf2
minor refactoring
linh2931 Sep 27, 2023
2d7811d
incorporate review comments for producer_plugin.cpp
linh2931 Sep 27, 2023
907d54d
move modify_gto_for_canceldelay_test out of controller to delay_test
linh2931 Sep 27, 2023
35321c9
add missing permission delay back to link_delay_direct_parent_permiss…
linh2931 Sep 28, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions docs/01_nodeos/03_plugins/producer_plugin/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,6 @@ Config Options for eosio::producer_plugin:
consider block full; when within
threshold of max-block-net-usage block
can be produced immediately
--max-scheduled-transaction-time-per-block-ms arg (=100)
Maximum wall-clock time, in
milliseconds, spent retiring scheduled
transactions (and incoming transactions
according to incoming-defer-ratio) in
any block before returning to normal
transaction processing.
--subjective-cpu-leeway-us arg (=31000)
Time in microseconds allowed for a
transaction that starts with
Expand All @@ -114,9 +107,6 @@ Config Options for eosio::producer_plugin:
--subjective-account-decay-time-minutes arg (=1440)
Sets the time to return full subjective
cpu for accounts
--incoming-defer-ratio arg (=1) ratio between incoming transactions and
deferred transactions when both are
queued for execution
--incoming-transaction-queue-size-mb arg (=1024)
Maximum size (in MiB) of the incoming
transaction queue. Exceeding this value
Expand All @@ -142,21 +132,6 @@ Config Options for eosio::producer_plugin:

* [`chain_plugin`](../chain_plugin/index.md)

## The priority of transaction

You can give one of the transaction types priority over another when the producer plugin has a queue of transactions pending.

The option below sets the ratio between the incoming transaction and the deferred transaction:

```console
--incoming-defer-ratio arg (=1)
```

By default value of `1`, the `producer` plugin processes one incoming transaction per deferred transaction. When `arg` sets to `10`, the `producer` plugin processes 10 incoming transactions per deferred transaction.

If the `arg` is set to a sufficiently large number, the plugin always processes the incoming transaction first until the queue of the incoming transactions is empty. Respectively, if the `arg` is 0, the `producer` plugin processes the deferred transactions queue first.


### Load Dependency Examples

```console
Expand Down
8 changes: 2 additions & 6 deletions libraries/chain/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1583,14 +1583,12 @@ struct controller_impl {
trx->packed_trx()->get_prunable_size() );
}

trx_context.delay = fc::seconds(trn.delay_sec);

if( check_auth ) {
authorization.check_authorization(
trn.actions,
trx->recovered_keys(),
{},
trx_context.delay,
fc::seconds(trn.delay_sec),
[&trx_context](){ trx_context.checktime(); },
false,
trx->is_dry_run()
Expand All @@ -1603,9 +1601,7 @@ struct controller_impl {

trx->billed_cpu_time_us = trx_context.billed_cpu_time_us;
if (!trx->implicit() && !trx->is_read_only()) {
transaction_receipt::status_enum s = (trx_context.delay == fc::seconds(0))
? transaction_receipt::executed
: transaction_receipt::delayed;
transaction_receipt::status_enum s = transaction_receipt::executed;
trace->receipt = push_receipt(*trx->packed_trx(), s, trx_context.billed_cpu_time_us, trace->net_usage);
std::get<building_block>(pending->_block_stage)._pending_trx_metas.emplace_back(trx);
} else {
Expand Down
2 changes: 0 additions & 2 deletions libraries/chain/include/eosio/chain/transaction_context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ namespace eosio { namespace chain {

void execute_action( uint32_t action_ordinal, uint32_t recurse_depth );

void schedule_transaction();
void record_transaction( const transaction_id_type& id, fc::time_point_sec expire );

void validate_cpu_usage_to_bill( int64_t billed_us, int64_t account_cpu_limit, bool check_minimum, int64_t subjective_billed_us )const;
Expand Down Expand Up @@ -143,7 +142,6 @@ namespace eosio { namespace chain {
/// the maximum number of virtual CPU instructions of the transaction that can be safely billed to the billable accounts
uint64_t initial_max_billable_cpu = 0;

fc::microseconds delay;
bool is_input = false;
bool apply_context_free = true;
bool enforce_whiteblacklist = true;
Expand Down
59 changes: 3 additions & 56 deletions libraries/chain/transaction_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,7 @@ namespace eosio { namespace chain {
uint64_t packed_trx_prunable_size )
{
const transaction& trx = packed_trx.get_transaction();
if ( is_transient() ) {
EOS_ASSERT( trx.delay_sec.value == 0, transaction_exception, "dry-run or read-only transaction cannot be delayed" );
}
EOS_ASSERT( trx.delay_sec.value == 0, transaction_exception, "transaction cannot be delayed" );
if( trx.transaction_extensions.size() > 0 ) {
disallow_transaction_extensions( "no transaction extensions supported yet for input transactions" );
}
Expand All @@ -268,14 +266,6 @@ namespace eosio { namespace chain {
uint64_t initial_net_usage = static_cast<uint64_t>(cfg.base_per_transaction_net_usage)
+ packed_trx_unprunable_size + discounted_size_for_pruned_data;


if( trx.delay_sec.value > 0 ) {
// If delayed, also charge ahead of time for the additional net usage needed to retire the delayed transaction
// whether that be by successfully executing, soft failure, hard failure, or expiration.
initial_net_usage += static_cast<uint64_t>(cfg.base_per_transaction_net_usage)
+ static_cast<uint64_t>(config::transaction_id_net_usage);
}

published = control.pending_block_time();
is_input = true;
if (!control.skip_trx_checks()) {
Expand Down Expand Up @@ -319,21 +309,15 @@ namespace eosio { namespace chain {
}
}

if( delay == fc::microseconds() ) {
for( const auto& act : trx.actions ) {
schedule_action( act, act.account, false, 0, 0 );
}
for( const auto& act : trx.actions ) {
schedule_action( act, act.account, false, 0, 0 );
}

auto& action_traces = trace->action_traces;
uint32_t num_original_actions_to_execute = action_traces.size();
for( uint32_t i = 1; i <= num_original_actions_to_execute; ++i ) {
execute_action( i, 0 );
}

if( delay != fc::microseconds() ) {
arhag marked this conversation as resolved.
Show resolved Hide resolved
schedule_transaction();
}
}

void transaction_context::finalize() {
Expand Down Expand Up @@ -731,43 +715,6 @@ namespace eosio { namespace chain {
acontext.exec();
}


void transaction_context::schedule_transaction() {
// Charge ahead of time for the additional net usage needed to retire the delayed transaction
// whether that be by successfully executing, soft failure, hard failure, or expiration.
const transaction& trx = packed_trx.get_transaction();
if( trx.delay_sec.value == 0 ) { // Do not double bill. Only charge if we have not already charged for the delay.
const auto& cfg = control.get_global_properties().configuration;
add_net_usage( static_cast<uint64_t>(cfg.base_per_transaction_net_usage)
+ static_cast<uint64_t>(config::transaction_id_net_usage) ); // Will exit early if net usage cannot be payed.
}

auto first_auth = trx.first_authorizer();

uint32_t trx_size = 0;
const auto& cgto = control.mutable_db().create<generated_transaction_object>( [&]( auto& gto ) {
gto.trx_id = id;
gto.payer = first_auth;
gto.sender = account_name(); /// delayed transactions have no sender
gto.sender_id = transaction_id_to_sender_id( gto.trx_id );
gto.published = control.pending_block_time();
gto.delay_until = gto.published + delay;
gto.expiration = gto.delay_until + fc::seconds(control.get_global_properties().configuration.deferred_trx_expiration_window);
trx_size = gto.set( trx );

if (auto dm_logger = control.get_deep_mind_logger(is_transient())) {
std::string event_id = RAM_EVENT_ID("${id}", ("id", gto.id));

dm_logger->on_create_deferred(deep_mind_handler::operation_qualifier::push, gto, packed_trx);
dm_logger->on_ram_trace(std::move(event_id), "deferred_trx", "push", "deferred_trx_pushed");
}
});

int64_t ram_delta = (config::billable_size_v<generated_transaction_object> + trx_size);
add_ram_usage( cgto.payer, ram_delta );
trace->account_ram_delta = account_delta( cgto.payer, ram_delta );
}

void transaction_context::record_transaction( const transaction_id_type& id, fc::time_point_sec expire ) {
try {
control.mutable_db().create<transaction_object>([&](transaction_object& transaction) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ class producer_plugin : public appbase::plugin<producer_plugin> {
std::optional<int32_t> max_transaction_time;
std::optional<int32_t> max_irreversible_block_age;
std::optional<int32_t> cpu_effort_us;
std::optional<int32_t> max_scheduled_transaction_time_per_block_ms;
std::optional<int32_t> subjective_cpu_leeway_us;
std::optional<double> incoming_defer_ratio;
std::optional<uint32_t> greylist_limit;
};

Expand Down Expand Up @@ -162,7 +160,6 @@ class producer_plugin : public appbase::plugin<producer_plugin> {

struct produced_block_metrics : public speculative_block_metrics {
std::size_t unapplied_transactions_total = 0;
std::size_t blacklisted_transactions_total = 0;
std::size_t subjective_bill_account_size_total = 0;
std::size_t scheduled_trxs_total = 0;
std::size_t trxs_produced_total = 0;
Expand Down Expand Up @@ -199,7 +196,7 @@ class producer_plugin : public appbase::plugin<producer_plugin> {

} //eosio

FC_REFLECT(eosio::producer_plugin::runtime_options, (max_transaction_time)(max_irreversible_block_age)(cpu_effort_us)(max_scheduled_transaction_time_per_block_ms)(subjective_cpu_leeway_us)(incoming_defer_ratio)(greylist_limit));
FC_REFLECT(eosio::producer_plugin::runtime_options, (max_transaction_time)(max_irreversible_block_age)(cpu_effort_us)(subjective_cpu_leeway_us)(greylist_limit));
FC_REFLECT(eosio::producer_plugin::greylist_params, (accounts));
FC_REFLECT(eosio::producer_plugin::whitelist_blacklist, (actor_whitelist)(actor_blacklist)(contract_whitelist)(contract_blacklist)(action_blacklist)(key_blacklist) )
FC_REFLECT(eosio::producer_plugin::integrity_hash_information, (head_block_id)(integrity_hash))
Expand Down
Loading