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

Calculate fee based on tx size and on-chain tx fee parameters #1349

Closed
3 tasks
webmaster128 opened this issue Dec 18, 2019 · 0 comments · Fixed by #1366
Closed
3 tasks

Calculate fee based on tx size and on-chain tx fee parameters #1349

webmaster128 opened this issue Dec 18, 2019 · 0 comments · Fixed by #1366
Assignees

Comments

@webmaster128
Copy link
Contributor

webmaster128 commented Dec 18, 2019

We are planning to charge per byte of signed transaction size: iov-one/weave#1091

In order to calculate the fee, we need to know the final transaction size including aignatures before the the transaction is signed.

Do no this, we can do bnsCodec.bytesToPost(withDummySignatures), where withDummySignatures is the unsigned transaction plus the expected number of signatures. A dummy signature can be constructed as

const dummy: FullSignature = {
  nonce: 66 as Nonce,
  pubkey: {
    algo: Algorithm.Ed25519,
    // ed25519 pubkey has 32 bytes https://blog.mozilla.org/warner/2011/11/29/ed25519-keys/
    data: new Uint8Array(32) as PubkeyBytes,
  },
  // ed25519 signature has 64 bytes https://blog.mozilla.org/warner/2011/11/29/ed25519-keys/
  signature: new Uint8Array(64) as SignatureBytes,
};

The fee calculation constants FREE_CONTINGENT and MULTIPLIER can be fixed in the first step but should be queried from the chain later on.

  • Add helper functions for estimating tx size as above
  • Add function for getting tx fee parameters from chain
  • Update BnsConnection.getFeeQuote to use these functions
@webmaster128 webmaster128 created this issue from a note in IOV Core team (Backlog) Dec 18, 2019
@annatorok annatorok moved this from Backlog to Ready for Dev in IOV Core team Jan 7, 2020
@willclarktech willclarktech moved this from Ready for Dev to In progress in IOV Core team Jan 7, 2020
@willclarktech willclarktech self-assigned this Jan 7, 2020
@willclarktech willclarktech changed the title Add helpers to calculate BNS transaction size Calculate fee based on tx size and on-chain tx fee parameters Jan 8, 2020
@willclarktech willclarktech moved this from In progress to Needs review in IOV Core team Jan 9, 2020
IOV Core team automation moved this from Needs review to Done Jan 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
IOV Core team
  
Done
Development

Successfully merging a pull request may close this issue.

2 participants