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

Implement Trusted Producer Light Validation #5631

Merged
merged 6 commits into from
Sep 17, 2018

Conversation

brianjohnson5972
Copy link
Contributor

#5268
Added configuration options to set trusted producers in chain_plugin.
In controller_impl::push_block added setting (and resetting on exit) a flag that provides the same behavior as light validation.
Made changes to validating_tester to allow calling the main chain and then calling the validating_node separately.

…ight when a block is produced by a trusted producer. GH EOSIO#5268
…anually produce blocks on the main chain and then manually pass the block to the validating_node. GH EOSIO#5268
…ted by a chain when the block was produced by a trusted producer. GH EOSIO#5268

auto reset_prod_light_validation = fc::make_scoped_exit([this]() {
conf.trusted_producer_light_validation = false;
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to see this reset to current value so it could be nested in the future.

      auto reset_prod_light_validation = fc::make_scoped_exit([old_value=conf.trusted_producer_light_validation, this]() {
         conf.trusted_producer_light_validation = old_value;
      });

try {
EOS_ASSERT( b, block_validate_exception, "trying to push empty block" );
EOS_ASSERT( s != controller::block_status::incomplete, block_validate_exception, "invalid block status for a completed block" );
emit( self.pre_accepted_block, b );
bool trust = !conf.force_all_checks && (s == controller::block_status::irreversible || s == controller::block_status::validated);
auto new_header_state = fork_db.add( b, trust );
if (conf.trusted_producers.count(b->producer)) {
conf.trusted_producer_light_validation = true;
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of setting a flag, I wonder if we could just add this check in light_validation_allowed then the extra flag and reset would not be needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that would be much more complicated (handling identifying if we are speculating or applying a block) and this gets called multiple times in a transaction pass, versus being called once for the block.

@@ -74,6 +74,8 @@ namespace eosio { namespace chain {
validation_mode block_validation_mode = validation_mode::FULL;

flat_set<account_name> resource_greylist;
flat_set<account_name> trusted_producers;
bool trusted_producer_light_validation = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont really like this "implementation detail" exposed in the config structure (The bool, the flat_set is appropriate here). There doesn't seem to be a reason why an external system would ever need to know about this. I think I would prefer that be part of the controller_impl class instead alongside in_trx_requiring_checks

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also trusted_producers should be added to the reflection of this structure:

FC_REFLECT( eosio::chain::controller::config,

@wanderingbort wanderingbort merged commit 49d3596 into EOSIO:develop Sep 17, 2018
@brianjohnson5972 brianjohnson5972 deleted the 5268-trusted-producer branch September 17, 2018 15:43
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants