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

feat: checkpointing/integrate bls-sig tx into the message flow #120

Merged
merged 6 commits into from
Sep 10, 2022

Conversation

gitferry
Copy link
Contributor

@gitferry gitferry commented Sep 7, 2022

This PR aims to enable the automatic generation of bls-sig transactions and aggregation. This is the last piece of the BLS signer. In particular, this PR:

  1. adds the account address into the private validator, which is necessary to check whether the node itself belongs to the validator set of the current epoch.
  2. adds additional flags to start a Babylon node in order to enable the checkpointing module to send bls-sig transactions. Specifically, when calling babylond start we need to additionally set --keyring-backend, --chain-id, and --from. The parameters need to be consistent with the ones used when calling babylond testnet. For example,
babylond start --home ./.testnet/node0/babylond \
       --keyring-backend       test \
       --chain-id              chain-test \
       --from                  node0

Now, following the instructions in readme to start a node, we should see the response of sending the bls-sig transaction at the end of each epoch. For example,

4:01PM INF committed state app_hash=66ADBF2088E91E27BC35A0D0CCC6C21B070CCC8A2581A6572EE9412ABEC913BE height=2 module=state num_txs=0
code: 0
codespace: ""
data: ""
events: []
gas_used: "0"
gas_wanted: "0"
height: "0"
info: ""
logs: []
raw_log: '[]'
timestamp: ""
tx: null
txhash: 95530F9E6CAA71868ED95D7882C67E5A919FB277A59622E448C5544A67D5D1F6

I also add @KonradStaniec as a reviewer because these additional flags are necessary for the integration tests. And thanks to @vitsalis for the help.

Copy link
Contributor

@aakoshh aakoshh left a comment

Choose a reason for hiding this comment

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

You guys are awesome to finally have figured it all out!

Just minor comments, no blocker 🎉

babylond start --home ./.testnet/node0/babylond \
--keyring-backend test \
--chain-id chain-test \
--from node0
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't find --from to be an intuitive name. I see it says "Name or address of private key with which to sign". Maybe call it --signing-key-id or --from-name (because it's passed to WithFromName)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I'm also surprised that Cosmos uses --from other than --from-name. See here. There's another flag called --name but it's rarely used. Maybe it's better to stick with --from just to be consistent with Cosmos?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure okay, if this is expected 👍

clientCtx := client.Context{}.
WithChainID(appOpts.Get(flags.FlagChainID).(string)).
WithFromName(appOpts.Get(flags.FlagFrom).(string))
privSigner, err := app.InitClientContext(clientCtx, backend)
privSigner, err := app.InitPrivSigner(clientCtx, "", "")
Copy link
Contributor

Choose a reason for hiding this comment

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

The comma would benefit from being put in a variable name, I have no idea what it might be doing.

@@ -39,6 +40,10 @@ func (k Keeper) SendBlsSig(ctx sdk.Context, epochNum uint64, lch types.LastCommi

// insert the message into the transaction
fs := pflag.NewFlagSet("", pflag.ContinueOnError)
// TODO: hardcoded for now, will set fees as a parameter for the checkpointing module
fs.String(flags.FlagFees, "", "Fees to pay along with transaction; eg: 10uatom")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
fs.String(flags.FlagFees, "", "Fees to pay along with transaction; eg: 10uatom")
fs.String(flags.FlagFees, "", "Fees to pay along with transaction; eg: 10ubbn")

// TODO: use BackendTest of keyring for now because the current integration test does not pass FlagKeryingBackend
privSigner, err := app.InitClientContext(clientCtx, keyring.BackendTest)
backend := cast.ToString(appOpts.Get(flags.FlagKeyringBackend))
chainID := cast.ToString(appOpts.Get(flags.FlagChainID))
Copy link
Collaborator

Choose a reason for hiding this comment

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

so imo the problem place is here. Nodes in testnet are started without this flag and read config options from config files.

Imo this thing should not be read from flags as it is already in genesis file (which is already generated by other commands). You should somehow get access to server config and then you could use GenesisDocFromFile functionf from "github.com/tendermint/tendermint/types" package, to retrieve the chaind id from it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, @KonradStaniec for looking into it. Yes, you are right. It is possible to get these parameters from some config files generated beforehand. After some quick search, I found that backend can be retrieved from nodex/babylond/config/client.toml, chainID can be retrieved from nodex/babylond/config/genesis.json, and fromName can be retrieved from nodex/babylond/config/config.toml. Let me try to access them from the code.

@gitferry gitferry force-pushed the checkpointing/bls-sig-integration branch from cbc5670 to 96522d3 Compare September 10, 2022 15:47
@gitferry
Copy link
Contributor Author

Thanks @KonradStaniec for your advice. I hardcoded these parameters to pass the integration test. I'm merging the PR, for now, to not block the other tasks. Will make another PR to access the parameters from the config file.

@gitferry gitferry merged commit 4520464 into main Sep 10, 2022
@gitferry gitferry deleted the checkpointing/bls-sig-integration branch September 10, 2022 15:58
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