Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Implement fee module beforeTransactionExecution hook #6694

Closed
mitsuaki-u opened this issue Aug 25, 2021 · 0 comments
Closed

Implement fee module beforeTransactionExecution hook #6694

mitsuaki-u opened this issue Aug 25, 2021 · 0 comments

Comments

@mitsuaki-u
Copy link
Contributor

mitsuaki-u commented Aug 25, 2021

Description

Before a trs is executed, the following logic is applied:

minFee = MIN_FEE_PER_BYTE * size(trs) 
         + extraFee(trs.moduleID, trs.commandID)
senderAddress is derived from trs.senderPublicKey
generatorAddress is the address of the generator of the block including trs

if FEE_TOKEN_ID.chainID == 0: # fee token is a native token 
    token.burn(senderAddress,
               FEE_TOKEN_ID,
               minFee)
    token.transfer(senderAddress, 
                   generatorAddress, 
                   FEE_TOKEN_ID, 
                   trs.fee - minFee) 
else:
    token.transfer(senderAddress,
                   generatorAddress,
                   FEE_TOKEN_ID,
                   trs.fee)

If any of those function fails, the trs is invalid.

Acceptance Criteria

  • The beforeTransactionExecution hook should implement the above logic.
  • Unit tests

Additional Information

Related issue: #6691

@mitsuaki-u mitsuaki-u changed the title Implement fee module afterTransactionExecution hook Implement fee module beforeTransactionExecution hook Aug 26, 2021
@sridharmeganathan sridharmeganathan added this to the Sprint 52 milestone Aug 30, 2021
@mitsuaki-u mitsuaki-u self-assigned this Sep 2, 2021
shuse2 added a commit that referenced this issue Sep 3, 2021
Implement fee module `beforeExecuteTransaction` hook - Closes #6694
@shuse2 shuse2 closed this as completed Sep 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants