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: Add setfinalizer action to eosio.bios #33

Merged
merged 16 commits into from
Dec 14, 2023
Merged

Conversation

linh2931
Copy link
Member

Add setfinalizer action to bios contract to set a new finalizer policy. For each public key, a proof of possession of private key are validated.

Extensive tests are included.

Resolves #26

Change Description

Deployment Changes

  • Deployment Changes

API Changes

  • API Changes

Documentation Additions

  • Documentation Additions

@linh2931 linh2931 requested review from heifner and arhag December 11, 2023 16:32
contracts/eosio.bios/src/eosio.bios.cpp Outdated Show resolved Hide resolved
tests/eosio.bios_inst_fin_tests.cpp Outdated Show resolved Hide resolved
@arhag arhag linked an issue Dec 11, 2023 that may be closed by this pull request
@@ -62,7 +62,7 @@ jobs:
echo cdt-prerelease=${{inputs.override-cdt-prerelease}} >> $GITHUB_OUTPUT
fi
- name: Download cdt
uses: AntelopeIO/asset-artifact-download-action@v2
uses: AntelopeIO/asset-artifact-download-action@v3
Copy link
Member

Choose a reason for hiding this comment

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

should also change the download below to v3,

- name: Download leap-dev
uses: AntelopeIO/asset-artifact-download-action@v2

Also, v3 does not require the token in our usage, so you can remove lines

token: ${{github.token}}

token: ${{github.token}}

@linh2931 linh2931 requested review from heifner and arhag December 13, 2023 16:38
tests/eosio.bios_inst_fin_tests.cpp Outdated Show resolved Hide resolved
@linh2931 linh2931 requested a review from heifner December 13, 2023 18:30
@linh2931 linh2931 requested a review from heifner December 13, 2023 22:48
struct g1_hash {
// bls_g1 is defined as std::array<char, 96>
std::size_t operator()(const eosio::bls_g1& g1) const {
std::hash<std::string> hash_func;
Copy link
Member

Choose a reason for hiding this comment

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

I think you could use std::hash<const char*> instead as each memory location will be unique and should be quicker than hashing all 96 bytes.

There is no specialization for C strings. std::hash<const char*> produces a hash of the value of the pointer (the memory address), it does not examine the contents of any character array.


struct g1_equal {
bool operator()(const eosio::bls_g1& lhs, const eosio::bls_g1& rhs) const {
return std::memcmp(lhs.data(), rhs.data(), 96 * sizeof(char)) == 0;
Copy link
Member

Choose a reason for hiding this comment

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

Use lhs.size() would be better here. Even better to add a static_assert(lhs.size() == sizeof(bls_g1))

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks. Changed to use lhs.size(). But the static_assert is not possible as lhs.size() is not a constant integral value. The compiler complains
error: static_assert expression is not an integral constant expression

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 moved g1_hash and g1_equal inside the function body for better encapsulation.

… use std::hash<const char*> for hashing, use size() instead of 96 * sizeof(char)
@linh2931 linh2931 requested a review from heifner December 14, 2023 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add bios contract action to support Instant Finality
4 participants