Closed greged93 closed 1 month ago
Querying the Initial Balance: When a transaction is received for the first time, the user's balance is checked in the cache. If it is not cached, the sender's balance is queried.
Caching the Balance Balance Validation: If the balance is sufficient and the transaction is valid, the user's balance is removed from the cache. If the transaction is not valid, the balance is kept in the cache to avoid querying the balance again.
The cache is represented by a HashMap. The size of the HashMap is not limited, as users are removed from the cache every time a transaction is validated, so the growth is not excessive.
Closing in favour of #1321
Describe the enhancement request Add a check of the balance of the sender in the
send_raw_transaction
in order to avoid sending the transaction if the user doesn't have enough balance.This can be added in the
validate_transaction
function, which should query the ETH balance of the user and check that the total cost for the transaction can be covered with the current balance.The simple approach would just be to query the balance of the user each time a transaction is received. However, this would mean we will emit a lot of queries to the Juno instance since each retry will also trigger a call.
Need to design a smart solution which avoids a requery of the balance for each retry.