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

[Access] Experiment with validating a transaction payer can pay for tx before submission #5823

Open
Tracked by #5683
peterargue opened this issue May 1, 2024 · 0 comments
Assignees
Labels

Comments

@peterargue
Copy link
Contributor

Problem Definition

See #5683 for details.

Sometimes dapps and scripted clients will send transactions using a payer account that does not have enough FLOW balance to pay for the transaction fee. In these cases, the tx will not succeed and nodes on the network spend resources handling the tx.

Now that Access nodes have data about account balances, they can be configured to screen for these tx and return a useful error to the client about why their tx is rejected.

There are limitations to how well this would protect the network from an actual malicious actor, but there is still some value protecting from the more common unintentional spam.

Proposed Solution

Add a check to the transaction validation done during SendTransaction, that ensures the payer has sufficient balance to pay for the transaction.

Access nodes currently validate a transaction here:

err := b.transactionValidator.Validate(tx)

which calls this method:

func (v *TransactionValidator) Validate(tx *flow.TransactionBody) (err error) {

Add a new check that calls GetAccount on a execution.ScriptExecutor resource for the transaction's payer. If the available balance is below some constant, the validation fails.

Note:

  • the execution.ScriptExecutor should be configured in "local only" mode. We do not want scripts to failover to an execution nodes
  • If the lookup fails, we should fail open and allow the transaction
  • we can cache the balance lookups where balances are over some threshold. this will be important since payers are often wallets, so the majority of submitted tx will have payers with relatively larger balances.

We do not need this to test, but if this goes into GA use, we will want to create a new method in FVM that an Access node could use to query an account's balance without querying for all fields (keys, contracts, sequence number, etc).

Definition of Done

  • Access nodes can enable a feature to validate the transaction payers have sufficient balance to submit the tx
  • There are unit and integration tests covering the new behavior
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants