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

refactor: Is Eligible Changes #20

Merged
merged 6 commits into from
Sep 4, 2024
Merged

Conversation

gluax
Copy link
Contributor

@gluax gluax commented Aug 26, 2024

Motivation

To have the is eligible check more aligned with the spec/requirements as they change.

Explanation of Changes

Renamed the old IsExecutorEligible to IsExecutorCommitteeEligible, and this one only checks if the stake is enough.
The new IsExecutorEligible still checks that but also takes a message in the form of base64(public_key:dr_id:proof).
To assist with that, there is a QueryFactory for that now.

Testing

I added a new JSON test.
As well as checking the decoding test.

Related PRs and Issues

N/A

@gluax gluax self-assigned this Aug 26, 2024
Copy link
Member

@FranklinWaller FranklinWaller left a comment

Choose a reason for hiding this comment

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

I want to test a bit before approving :)

Comment on lines 87 to 94
#[cfg(test)]
pub(crate) fn create_query(self, proof: Vec<u8>) -> Query {
let data = format!("{}:{}:{}", self.public_key, self.dr_id, proof.to_hex());

Query {
data: Self::encode_data(&data),
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Imo it would be better to not mix test helpers and actual code.

Copy link
Member

Choose a reason for hiding this comment

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

@gluax It may be nice to sort of expose this let data = format!("{}:{}:{}", self.public_key, self.dr_id, proof.to_hex()); in a function. The overlay node right now has no way to just get the raw data (+ base64 encoded) because it only gets the QueryMsg which i cannot easily extract the data property

Copy link
Contributor Author

@gluax gluax Aug 28, 2024

Choose a reason for hiding this comment

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

Oh! Maybe I should make the create_message return the Query type instead? You'd have to call .into on it, but it would let you access the parts method as well as the field itself, which has the encoded string.

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 went for changing create_message to return a tuple of the message and the base64.

IsExecutorEligible { proof: String, dr_id: String },
IsExecutorCommitteeEligible { public_key: String },
#[cfg_attr(feature = "cosmwasm", returns(bool))]
IsExecutorEligible(is_executor_eligible::Query),
Copy link
Member

Choose a reason for hiding this comment

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

To follow the rest of queries, why not like this?

IsExecutorEligible{ data: is_executor_eligible::Query},

Copy link
Contributor Author

@gluax gluax Sep 3, 2024

Choose a reason for hiding this comment

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

It could be done that way, but our standard practice for messages is that if something is complicated to move to its type, we've been using tuples for it.

If we did this, it would change the json as well from:

"is_executor_eligible": {
  "data": "data_str",
}

to

"is_executor_eligible": {
  "data": {
    "data": "data_str",
  }
}

Copy link
Member

@FranklinWaller FranklinWaller left a comment

Choose a reason for hiding this comment

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

Functionality wise this works

@gluax
Copy link
Contributor Author

gluax commented Sep 3, 2024

We have decided to rename IsExecutorCommitteeEligible to IsStakerExecutor, as well. More clarity!

@FranklinWaller FranklinWaller merged commit 2bec955 into main Sep 4, 2024
2 checks passed
@FranklinWaller FranklinWaller deleted the refactor/is-eligible-query branch September 4, 2024 08:32
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.

3 participants