-
Notifications
You must be signed in to change notification settings - Fork 72
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
IF: Modify set_finalizer host function struct type #1588
Conversation
…it to description.
…ion of bls12-381 headers in header files.
…ption. Remove generation from finalizer_set used by CDT/ABI.
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" ); |
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.
You can move this assert to the beginning of this loop body (before f_weight_sum += f.fweight;
)
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.
Done
@@ -152,28 +153,30 @@ namespace eosio { namespace chain { namespace webassembly { | |||
} | |||
|
|||
void interface::set_finalizers(span<const char> packed_finalizer_set) { |
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.
shouldn't we use std::span
instead of just span
? Same with vector
below.
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.
This not std::span
but using span = eosio::vm::span<T, Extent>;
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.
Oh, missed that, thanks. Still vector
should be std::vector, right?
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.
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" ); |
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.
why / 2
?
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.
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.
That is my attempt to implement this spec: #1511 (comment) ; I hope it is correct?
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.
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
?
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.
I agree, seems like it should be threshold >= (f_weight_sum * 2 / 3) + 1
or threshold > (f_weight_sum * 2 / 3)
.
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.
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.
Note:start |
finalizer_set
version
togeneration
.finalizer_set
bls_public_key
to Jacobian little-endian encoding.generation
fromset_finalizers
host function parameter struct type.hs_finalizer_set_extension
for block header extension.finalizer_authority
andfinalizer_set
to source file to avoid includingbls12-381
headers intolibtester
.