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

IF: Modify set_finalizer host function struct type #1588

Merged
merged 8 commits into from
Sep 1, 2023

Conversation

heifner
Copy link
Member

@heifner heifner commented Aug 31, 2023

  • Rename finalizer_set version to generation.
  • Changed finalizer_set bls_public_key to Jacobian little-endian encoding.
  • Remove generation from set_finalizers host function parameter struct type.
  • Add hs_finalizer_set_extension for block header extension.
  • Move implementation of finalizer_authority and finalizer_set to source file to avoid including bls12-381 headers into libtester.

@heifner heifner added the OCI Work exclusive to OCI team label Sep 1, 2023
@heifner heifner requested review from greg7mdp and linh2931 September 1, 2023 11:54
libraries/chain/webassembly/privileged.cpp Outdated Show resolved Hide resolved
uint64_t f_weight_sum = 0;

for (const auto& f: finalizers) {
f_weight_sum += f.fweight;
unique_finalizer_keys.insert(f.public_key);
unique_finalizers.insert(f.description);
EOS_ASSERT( f.description.size() <= config::max_finalizer_description, wasm_execution_error, "Finalizer description greater than 256" );
Copy link
Member

Choose a reason for hiding this comment

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

You can move this assert to the beginning of this loop body (before f_weight_sum += f.fweight;)

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

libraries/chain/controller.cpp Show resolved Hide resolved
libraries/chain/finalizer_set.cpp Outdated Show resolved Hide resolved
libraries/chain/include/eosio/chain/config.hpp Outdated Show resolved Hide resolved
libraries/chain/include/eosio/chain/finalizer_set.hpp Outdated Show resolved Hide resolved
libraries/chain/include/eosio/chain/finalizer_set.hpp Outdated Show resolved Hide resolved
@@ -152,28 +153,30 @@ namespace eosio { namespace chain { namespace webassembly {
}

void interface::set_finalizers(span<const char> packed_finalizer_set) {
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't we use std::span instead of just span? Same with vector below.

Copy link
Member Author

Choose a reason for hiding this comment

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

This not std::span but using span = eosio::vm::span<T, Extent>;

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, missed that, thanks. Still vector should be std::vector, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, changed to std::vector

}

EOS_ASSERT( finalizers.size() == unique_finalizers.size(), wasm_execution_error, "Duplicate finalizer description in finalizer set" );
EOS_ASSERT( finalizers.size() == unique_finalizer_keys.size(), wasm_execution_error, "Duplicate finalizer bls key in finalizer set" );
EOS_ASSERT( finset.fthreshold > f_weight_sum / 2, wasm_execution_error, "Finalizer set threshold cannot be met by finalizer weights" );
Copy link
Contributor

Choose a reason for hiding this comment

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

why / 2?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't know @arhag or @fcecin ?

Copy link

Choose a reason for hiding this comment

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

That is my attempt to implement this spec: #1511 (comment) ; I hope it is correct?

Copy link
Contributor

Choose a reason for hiding this comment

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

Well, the spec mentions 15, which is 2/3+1 of 21. I wonder if we should not check that threshold > (f_weight_sum / 3) * 2?

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree, seems like it should be threshold >= (f_weight_sum * 2 / 3) + 1 or threshold > (f_weight_sum * 2 / 3) .

Copy link
Member Author

Choose a reason for hiding this comment

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

Conversation summary: The host function will enforce f_weight_sum / 2. It will be up to system contract to enforce a higher threshold if desired.

So if the chain would prefer to be more secure against finality violations at the cost of increased risk of losing liveness, it can increase the threshold above 1/2. Perhaps even all the way to 100% if it wanted.

libraries/chain/webassembly/privileged.cpp Outdated Show resolved Hide resolved
libraries/chain/webassembly/privileged.cpp Outdated Show resolved Hide resolved
@heifner heifner merged commit 8fad42e into hotstuff_integration Sep 1, 2023
@heifner heifner deleted the GH-1523-finalizer-set-transition branch September 1, 2023 19:35
@ericpassmore
Copy link
Contributor

Note:start
group: IF
category: CONSENSUS
summary: Modify set_finalizer host function structure.
Note:end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCI Work exclusive to OCI team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants