This repository has been archived by the owner on Aug 2, 2022. It is now read-only.
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.
Change Description
This PR updates the chain code to reflect the new expected chainbase requirements reflected in EOSIO/chainbase#44 (it also updated the chainbase submodule to reflect the code code changes from that PR).
The best way to satisfy those requirements (and other ones we care about like deterministic behavior) in the EOSIO code is to satisfy the following restrictions when dealing with chainbase objects:
A field of a chainbase object is considered to be in the restricted field set if it is involved in the derivation of the key used for one of the indices in the chainbase multi-index unless its only involvement is through being included in composite_keys that end with the id field. The id field is always included in the restricted field set.
So if the multi-index includes an index like the following
both
sender
andsender_id
fields are part of the restricted field set.On the other hand, an index like the following
would not by itself require the
expiration
field to be part of the restricted field set.In order to satisfy this new requirement, it was necessary to change the
by_permission_name
of thepermission_link_index
to switch from a composite key of the tuple(account, required_permission, code, message_type)
to a composite key of the tuple(account, required_permission, id)
. This change is acceptable because only the first two fields of the composite key were used for lookups; the remaining fields were only there to add uniqueness to the index which is better handled by the addition of the id field. However, this change topermission_link_index
definition means that a nodeos incorporating these changes will not be compatible with the shared_memory.bin state file generated by v1.8.0-rc1 nodeos.Satisfying the new requirement also requires doing something about the handling of the
trx_id
field ofgenerated_transaction_object
because of theby_trx_id
index ofgenerated_transaction_multi_index
. Instead of modifying the index definition, the easier solution to satisfying the new requirement was to avoid mutating the restrictedtrx_id
field in a chainbase modifier lambda. This means in order to satisfy the requirements of the replace existing deferred transaction mechanism available to contracts, it was necessary to replace the modification ofgenerated_transaction_object
with a removal followed by a creation.This PR also adds a new unit test,
api_tests/more_deferred_transaction_tests
, which tests out a few of the various ways that replacing a deferred transaction could have been used to trigger the various chainbase failures due to uniqueness violations. This includes the modify and create pattern (case 3 discussed in EOSIO/chainbase#32) which is resolved due to swap of undo processing order in EOSIO/chainbase#44, and the swap unique keys via modifies pattern (case 4 discussed in EOSIO/chainbase#32) which is avoided by following the restrictions above. Thedeferred_test
test contract has been updated to include two new actions to fulfill the testing needs of the new unit test.Older versions of nodeos prior to v1.8.0-rc1 are protected from the schemes demonstrated in the new unit test causing nodeos failure partly because of the subjective mitigation introduced in v1.0.6 that disabled deferred transaction replacement for reasons unrelated to this issue, but also because even prior to the introduction of that subjective mitigation, there was a bug since v1.0.0 that led to the
trx_id
field remaining stale during deferred transaction replacement which neutralized the critical component of carrying out the scheme demonstrated in the new unit test. Even v1.8.0-rc1 is not vulnerable to this issue until theREPLACE_DEFERRED
protocol feature, which among other things fixes the staletrx_id
bug and disables the subjective mitigation preventing deferred transaction replacement, is activated. Coincidentally, even withREPLACE_DEFERRED
activated, it no longer becomes possible to exploit the uniqueness constraint issue if theNO_DUPLICATE_DEFERRED_ID
is also activated.This PR also removed the unused producer_object.hpp file.
Special thanks to @raymondnuaa for first reporting this issue in chainbase through the PR EOSIO/chainbase#32 and describing various scenarios of relevance in the PR description.
Consensus Changes
API Changes
Documentation Additions