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

init validator tx - verify ownership of used keys #2163

Merged
merged 7 commits into from
Nov 21, 2023

Conversation

tzemanovic
Copy link
Member

@tzemanovic tzemanovic commented Nov 12, 2023

Describe your changes

closes #106

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

0.26.0

Checklist before merging to draft

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

@tzemanovic tzemanovic force-pushed the tomas/init-validator-own-keys branch from 0f5b7ac to a9771c2 Compare November 12, 2023 16:38
@tzemanovic tzemanovic marked this pull request as ready for review November 12, 2023 16:44
@tzemanovic
Copy link
Member Author

The bench for init-validator is affected, it’s most likely missing the newly required signatures

@brentstone brentstone mentioned this pull request Nov 13, 2023
tx: &Tx,
pks: Vec<common::PublicKey>,
) -> EnvResult<bool> {
let max_signatures_per_transaction =
Copy link
Collaborator

Choose a reason for hiding this comment

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

What if the max_signatures_per_transaction is lower than the number of validator keys at initialization?

Copy link
Member Author

Choose a reason for hiding this comment

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

As we don't have support for validator multisig, it would only be an issue if the source of the tx is a mutisig with threshold > max_signatures_per_transaction - 5. We use 15 as the default which should be sufficient for either case

Copy link
Member Author

Choose a reason for hiding this comment

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

ah, I was wrong on this - we do have multisig validator support, but with the default this would still allow up to 10 multisig participants which should be sufficient

Ok(SigningTxData {
owner: None,
public_keys,
threshold: 0,
Copy link
Collaborator

Choose a reason for hiding this comment

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

what does a threshold of 0 mean here?

Copy link
Member Author

Choose a reason for hiding this comment

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

it's unused for signing - this field is only used for offline proposal votes

brentstone added a commit that referenced this pull request Nov 15, 2023
* tomas/init-validator-own-keys:
  changelog: add #2163
  client: store validator protocol key in the regular wallet
  wasm/tx_init_validator: check ownership of used keys with sigs
  ledger: add a tx host fn for sig verification
  client: sign tx_init_validator with all keys used
brentstone added a commit that referenced this pull request Nov 16, 2023
* tomas/init-validator-own-keys:
  fix `init_validator` bench
  changelog: add #2163
  client: store validator protocol key in the regular wallet
  wasm/tx_init_validator: check ownership of used keys with sigs
  ledger: add a tx host fn for sig verification
  client: sign tx_init_validator with all keys used
brentstone
brentstone previously approved these changes Nov 17, 2023
Copy link
Collaborator

@brentstone brentstone left a comment

Choose a reason for hiding this comment

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

LGTM

brentstone added a commit that referenced this pull request Nov 17, 2023
* tomas/init-validator-own-keys:
  fix `init_validator` bench
  changelog: add #2163
  client: store validator protocol key in the regular wallet
  wasm/tx_init_validator: check ownership of used keys with sigs
  ledger: add a tx host fn for sig verification
  client: sign tx_init_validator with all keys used
max_signatures,
// This uses VpGasMeter, so we're charging the gas here manually
// instead
&mut None,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Minor thing here, we can change the verify_signatures method of Tx to accept an &mut dyn GasMetering trait object just like we do in fetch_or_compile so that we can still charge gas for every single signature without the need to do it manually, if you prefer. Alternatively, since this function is only called by the init_validator tx, and we always require 4 valid signatures, we could also just skip charging gas in here since its cost is already included in the benchmark of the tx itself

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've refactored it in 88578bf but without the dynamic dispatch using a lambda instead. It also moves the gas metering logic back into the relevant places in vm/host_env.rs instead of being done in proto/types.rs

Fraccaman pushed a commit that referenced this pull request Nov 20, 2023
* origin/tomas/init-validator-own-keys:
  refactor sig verification gas handling
  fix `init_validator` bench
  changelog: add #2163
  client: store validator protocol key in the regular wallet
  wasm/tx_init_validator: check ownership of used keys with sigs
  ledger: add a tx host fn for sig verification
  client: sign tx_init_validator with all keys used

# Conflicts:
#	apps/src/lib/client/tx.rs
Fraccaman pushed a commit that referenced this pull request Nov 20, 2023
* origin/tomas/init-validator-own-keys:
  refactor sig verification gas handling
  fix `init_validator` bench
  changelog: add #2163
  client: store validator protocol key in the regular wallet
  wasm/tx_init_validator: check ownership of used keys with sigs
  ledger: add a tx host fn for sig verification
  client: sign tx_init_validator with all keys used

# Conflicts:
#	apps/src/lib/client/tx.rs
Fraccaman pushed a commit that referenced this pull request Nov 20, 2023
* origin/tomas/init-validator-own-keys:
  refactor sig verification gas handling
  fix `init_validator` bench
  changelog: add #2163
  client: store validator protocol key in the regular wallet
  wasm/tx_init_validator: check ownership of used keys with sigs
  ledger: add a tx host fn for sig verification
  client: sign tx_init_validator with all keys used

# Conflicts:
#	apps/src/lib/client/tx.rs
Fraccaman pushed a commit that referenced this pull request Nov 20, 2023
* origin/tomas/init-validator-own-keys:
  refactor sig verification gas handling
  fix `init_validator` bench
  changelog: add #2163
  client: store validator protocol key in the regular wallet
  wasm/tx_init_validator: check ownership of used keys with sigs
  ledger: add a tx host fn for sig verification
  client: sign tx_init_validator with all keys used

# Conflicts:
#	apps/src/lib/client/tx.rs
@tzemanovic tzemanovic merged commit 4600b17 into main Nov 21, 2023
12 of 14 checks passed
@tzemanovic tzemanovic deleted the tomas/init-validator-own-keys branch November 21, 2023 07:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PoS - verify validator keys ownership with signatures
3 participants