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

how to verify transaction faster? #80

Open
aihuawu opened this issue Jun 24, 2021 · 2 comments
Open

how to verify transaction faster? #80

aihuawu opened this issue Jun 24, 2021 · 2 comments

Comments

@aihuawu
Copy link

aihuawu commented Jun 24, 2021

I am a newcomer to smartweave.

According to the tutorial,
https://cedriking.medium.com/lets-buidl-smartweave-contracts-6353d22c4561

Since the SW contract itself is updated on the client, to get the latest state of a contract, the client needs to go through each interaction to find its latest valid state.

If I create a PST token, it may have millions of actions, I have to verify it whenever I do a transfer.
Is there any better way to do it?

Thanks.

George Wu

@AndreVallestero
Copy link

I'm aware of 3 different ways to tackle this problem:

  • Submit your transactions in batches using some type of bundler middleware. This will reduce the amount of transactions that need to be processed when computing the state
  • Regularly create snapshots of your state and only compute the changes since the snapshot block
  • Regularly redeploy a new contract using the last computed state as the new initial state

@ppedziwiatr
Copy link
Contributor

Redeploying contract is good solution, the only issue here is the constantly changing txId, that must be updated in all the client apps.
To tackle this issue, we've created a "contracts-registry" contract, that allows to get the most current contract txid by its "logical" name: https://github.com/redstone-finance/redstone-smartweave-contracts/tree/main/src/contracts-registry
https://viewblock.io/arweave/address/XQkGzXG6YknJyy-YbakEZvQKAWkW2_aPRhc3ShC8lyA?tab=state
The example API for getting current txId from the contract source code is here https://github.com/redstone-finance/redstone-smartweave-contracts/blob/main/src/common/ContractInteractions.ts#L48

It also allows to deploy contract's upgrades.

Re. caching - please consider switching to https://github.com/redstone-finance/redstone-smartcontracts - it allows to easily plugin different type of caches.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants