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

Light SDK #2220

Merged
merged 18 commits into from
Dec 29, 2023
Merged

Light SDK #2220

merged 18 commits into from
Dec 29, 2023

Conversation

adrianbrink
Copy link
Member

@adrianbrink adrianbrink commented Nov 28, 2023

Describe your changes

Implements a first version of a simpler, more user-friendly SDK.

Indicate on which release or other PRs this topic is based on

Commit 74d412e of base (v0.28.1)

Checklist before merging to draft

  • I have added a changelog
  • Git history is in acceptable state

pub const TX_REVEAL_PK_HASH: [u8; 32] = [0x8d, 0x4e, 0x20, 0x08, 0x30, 0xa9, 0xf6, 0x03, 0xd6, 0x47, 0x79, 0x9f, 0xaf, 0xdb, 0xf1, 0x94, 0x6e, 0x07, 0xa0, 0x38, 0xa6, 0x7c, 0xfa, 0x09, 0xd4, 0xee, 0xb3, 0x1c, 0x80, 0xc7, 0x74, 0xce];

/// Takes any kind of inner tx and gives me back my sign bytes
pub fn get_inner_sign_bytes(mut tx: Tx) -> Hash {
Copy link
Member Author

Choose a reason for hiding this comment

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

These should be immutable functions on a specific RevealPk struct. Ie. this signature should be repeated for every type of transaction.

Also this function should be immutable.


pub mod pos;

pub(in crate::tx_builders) fn build_tx(
Copy link
Member Author

Choose a reason for hiding this comment

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

no generics - everything should be passed in as strings

Copy link
Contributor

Choose a reason for hiding this comment

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

This function is not exposed to the SDK user

}

pub(in crate::tx_builders) fn attach_raw_signatures(
mut tx: Tx,
Copy link
Member Author

Choose a reason for hiding this comment

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

no mutability - we should consume the tx object and return a new one

Copy link
Contributor

Choose a reason for hiding this comment

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

That's what I'm doing here but I need the object to be mutable in the scope of the function

/// Generate the signature(s) for the given transaction and signers
pub fn generate_signatures(
mut self,
secret_keys: &[common::SecretKey],
Copy link
Member Author

Choose a reason for hiding this comment

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

the library doesn't take secret keys.

it should expose sign_bytes() and then the caller figures out how to sign it

}

/// Generate the signature(s) for the given transaction and signers
pub fn generate_signatures(
Copy link
Member Author

Choose a reason for hiding this comment

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

likewise - this kind of function shouldn't exist in the public api

/// Lookup the full response accompanying the specified transaction event
pub fn query_tx_response(
tendermint_addr: &str,
tx_query: TxEventQuery<'_>,
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 is essentially a hash, right? Can this type be instantiated by the caller?

Copy link
Member

Choose a reason for hiding this comment

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

yeah, I changed this to take a &str. It means you can only query applied txs and not accepted, but I think that is totally fine.

}

/// Query a validator's unbonds for a given epoch
pub fn query_and_print_unbonds(
Copy link
Member Author

Choose a reason for hiding this comment

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

let's not have print options in the api. if a caller wants to print something, they can do it in their own code.

@@ -0,0 +1,679 @@
use std::str::FromStr;
Copy link
Member Author

Choose a reason for hiding this comment

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

Overall I like the api.

It's probably better to split the individual submodules into their own files.

@@ -0,0 +1,3 @@
pub mod blocking {}
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 should be just 1 function - submit_tx().

@grarco grarco marked this pull request as ready for review December 20, 2023 16:03
batconjurer
batconjurer previously approved these changes Dec 21, 2023
@grarco grarco mentioned this pull request Dec 22, 2023
Fraccaman pushed a commit that referenced this pull request Dec 27, 2023
* origin/adrian/light-sdk:
  Adds a method to serialize transactions
  Makes internal struct of `RevealPk` private
  Fixes datetime
  Splits light sdk queries into multiple files
  Renames light sdk crate and adds description
  Adds missing feature for tendermint-rpc in light sdk
  Changelog #2220
  Imports `HttpClient` from `tendermint_rpc`
  Updates types and imports after rebase
  Updates docstrings and fixes clippy
  Some small type simplifications in the reading api
  [feat]: Added rpc functions to light sdk
  Renames `get_msg_to_sign` to `get_sign_bytes`
  [feat]: Small fixes and making stuff public
  First draft of all transactions in light sdk
  Refactors pos txs in separate file. Improved shared functions
  Created light SDK builders.
  First attempt at overview of light-sdk
Fraccaman pushed a commit that referenced this pull request Dec 27, 2023
* origin/adrian/light-sdk:
  Adds a method to serialize transactions
  Makes internal struct of `RevealPk` private
  Fixes datetime
  Splits light sdk queries into multiple files
  Renames light sdk crate and adds description
  Adds missing feature for tendermint-rpc in light sdk
  Changelog #2220
  Imports `HttpClient` from `tendermint_rpc`
  Updates types and imports after rebase
  Updates docstrings and fixes clippy
  Some small type simplifications in the reading api
  [feat]: Added rpc functions to light sdk
  Renames `get_msg_to_sign` to `get_sign_bytes`
  [feat]: Small fixes and making stuff public
  First draft of all transactions in light sdk
  Refactors pos txs in separate file. Improved shared functions
  Created light SDK builders.
  First attempt at overview of light-sdk
brentstone added a commit that referenced this pull request Dec 29, 2023
* origin/adrian/light-sdk:
  Adds a method to serialize transactions
  Makes internal struct of `RevealPk` private
  Fixes datetime
  Splits light sdk queries into multiple files
  Renames light sdk crate and adds description
  Adds missing feature for tendermint-rpc in light sdk
  Changelog #2220
  Imports `HttpClient` from `tendermint_rpc`
  Updates types and imports after rebase
  Updates docstrings and fixes clippy
  Some small type simplifications in the reading api
  [feat]: Added rpc functions to light sdk
  Renames `get_msg_to_sign` to `get_sign_bytes`
  [feat]: Small fixes and making stuff public
  First draft of all transactions in light sdk
  Refactors pos txs in separate file. Improved shared functions
  Created light SDK builders.
  First attempt at overview of light-sdk
@brentstone brentstone merged commit c9a1f48 into main Dec 29, 2023
15 checks passed
@brentstone brentstone deleted the adrian/light-sdk branch December 29, 2023 19:37
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.

5 participants