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

RTA Flow: Implement Auth Sample Validation on Graftnode (GNRTA-283) #290

Open
wants to merge 4 commits into
base: feature/disqual-lookup
Choose a base branch
from

Conversation

cybay
Copy link

@cybay cybay commented May 21, 2019

No description provided.

@cybay cybay changed the base branch from master to feature/disqual-lookup May 21, 2019 14:42
@cybay cybay changed the base branch from master to feature/disqual-lookup May 21, 2019 14:42
Copy link
Contributor

@mbg033 mbg033 left a comment

Choose a reason for hiding this comment

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

  1. Please fix PR title - Gntra 283 means nothing for someone who doesn't have an access to internal issue tracker, this is open source project
  2. Any tests?

@cybay cybay changed the title Gnrta 283 RTA Flow: Implement Auth Sample Validation on Graftnode (GNRTA-283) May 23, 2019
@mbg033
Copy link
Contributor

mbg033 commented May 27, 2019

why target branch is feature/disqual-lookup ?

Copy link
Contributor

@mbg033 mbg033 left a comment

Choose a reason for hiding this comment

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

General notes:
it make sense to introduce a library (say librta) and move implementation of belongs_to_auth_sample and check_rta_signatures there. Not sure there should be any other "check_" functions as public interface


//---------------------------------------------------------------------------------

uint32_t get_rta_hdr_supernode_public_key_offset(const rta_header& rta_hdr)
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. name is wrong - all signatures belongs to supernodes - some of these supernodes are auth sample
  2. at least 6 signatures required as auth sample

Copy link
Author

@cybay cybay May 28, 2019

Choose a reason for hiding this comment

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

You can see that it's not about signatures.
Signatures live in another container - "std::vector<rta_signature> rta_signs".

Here we get offset to 8 supernode pub-keys inside of rta_header.keys.
Does it make sense now?

Copy link
Contributor

Choose a reason for hiding this comment

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

sorry, I meant keys of course. all the keys (except POS_KEY_INDEX) belongs to supernodes (pos proxy and wallet proxy are supernodes as well)

Copy link
Author

Choose a reason for hiding this comment

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

Then ok. You're rather right. Will fix it. But all this about p1. Not p.2. P.2 - is not related to the matter.

Copy link
Author

Choose a reason for hiding this comment

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

Fixed

if(!check_rta_keys_count(rta_hdr, txid))
return false;

const auto sn_pkeys_off = get_rta_hdr_supernode_public_key_offset(rta_hdr);
Copy link
Contributor

Choose a reason for hiding this comment

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

s/sn_pkeys_off/auth_sample_keys_offset/ ?

Copy link
Author

Choose a reason for hiding this comment

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

Will do.

Copy link
Author

Choose a reason for hiding this comment

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

Fixed

@@ -1137,14 +1241,15 @@ namespace cryptonote
return stake ? stake->amount >= config::graft::TIER1_STAKE_AMOUNT : false;
};

bool tx_memory_pool::belongs_to_auth_sample(const rta_header& rta_hdr) const
bool tx_memory_pool::belongs_to_auth_sample(const rta_header& rta_hdr, const uint32_t sn_pkeys_off) const
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 change it so it accepts two sets of public keys - one set from tx and another set is auth sample. This way it doesn't need to be a tx_memory_pool member and can be covered with unit test

Copy link
Author

Choose a reason for hiding this comment

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

Will do, thanks.

Copy link
Author

Choose a reason for hiding this comment

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

Fixed

@@ -0,0 +1,161 @@
// Copyright (c) 2017, The Graft Project
Copy link
Contributor

Choose a reason for hiding this comment

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

copyright year should be 2019

Copy link
Author

Choose a reason for hiding this comment

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

Thank you! Will fix it.

Copy link
Author

Choose a reason for hiding this comment

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

Fixed

#include <string>

#include <cstdint>
using u32 = std::uint32_t;
Copy link
Contributor

Choose a reason for hiding this comment

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

any reasons for introducing such type aliases?

Copy link
Author

@cybay cybay May 28, 2019

Choose a reason for hiding this comment

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

The only reason for most of aliases - convenience.
What's wrong in this case?

Copy link
Contributor

Choose a reason for hiding this comment

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

can't see any "convenience" by introducing alias for standard type here

Copy link
Author

Choose a reason for hiding this comment

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

len(std::uint32_t) = 13
len(u32) = 3
10 char - is WIN
EVERY time you are writing this. But what is more important - every time when you READ this.
Without any loss.
Weak point?

@cybay cybay changed the base branch from feature/disqual-lookup to develop May 28, 2019 10:03
@cybay cybay changed the base branch from develop to feature/disqual-lookup May 28, 2019 10:03
@cybay
Copy link
Author

cybay commented May 28, 2019

why target branch is feature/disqual-lookup ?

It was started from 'feature/disqual-lookup'.
We can easily retarget it to 'develop'. At any moment.
But in this case we will have 22 changed files instead of 8 that was really affected in this PR.

@cybay
Copy link
Author

cybay commented May 28, 2019

General notes:
it make sense to introduce a library (say librta) and move implementation of belongs_to_auth_sample and check_rta_signatures there. Not sure there should be any other "check_" functions as public interface

No any special objections.
We never discussed such approach before. If we want to do it - we need clearly understand why. And when/how we will use it.

@mbg033
Copy link
Contributor

mbg033 commented May 28, 2019

why target branch is feature/disqual-lookup ?

It was started from 'feature/disqual-lookup'.
We can easily retarget it to 'develop'. At any moment.
But in this case we will have 22 changed files instead of 8 that was really affected in this PR.

it needs to point to develop at least. if it depends on feature/disqual-lookup it can be merged only after feature/disqual-lookup merged

Agree with it.
But let's do that switch/retargeting just before to merge and let it be in this way (as it now is) during this discussion.

@mbg033
Copy link
Contributor

mbg033 commented May 28, 2019

General notes:
it make sense to introduce a library (say librta) and move implementation of belongs_to_auth_sample and check_rta_signatures there. Not sure there should be any other "check_" functions as public interface

No any special objections.
We never discussed such approach before. If we want to do it - we need clearly understand why. And when/how we will use it.

Reasons:

  • we might want to use need this functionality in some another places;
  • bool belongs_to_auth_sample(const rta_header& rta_hdr, uint32_t sn_pkeys_off) const is not covered with test
  • these functions are not related to tx_pool:
 bool check_rta_sign_count(const std::vector<rta_signature>& rta_signs, const crypto::hash& txid);
  bool check_rta_keys_count(const rta_header& rta_hdr, const crypto::hash& txid);
  bool check_rta_sign_key_indexes(const std::vector<rta_signature>& rta_signs, const crypto::hash& txid, uint32_t sn_pkeys_off);
  bool check_rta_signatures(const std::vector<rta_signature>& rta_signs, const rta_header& rta_hdr, const crypto::hash& txid, uint32_t sn_pkeys_off);
  uint32_t get_rta_hdr_supernode_public_key_offset(const rta_header& rta_hdr);

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.

2 participants