-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Reintroduce way to read data from the chain #1748
Comments
Don't you think anything we come up with to get around this problem is going to be hacky unless the client exposes an endpoint that ignores these new TX validation rules? |
First of all, it is not the right pattern to dry-run transactions to get the internal state of the contract. It is not a production solution and only fits for testing purposes. This issue is related to more general issue regarding all validity rules that fail the execution or validation of the transaction. But we don't have plans to work on it before mainnet since it may bring vulnerabilities. Regarding the rule that each transaction should have at least one spendable input: The primary use case for a dry run is to validate the execution of the transaction before actually sending it to the blockchain. Since blockchain always charges users, there should always be an input that will pay a fee. If you have use cases when you don't know who the sender is or which input to use, it is okay to use a placeholder("fake") coin to pay for the transaction. It is the reason why the So, from the API perspective, you should be able to provide a method that doesn't require the Wallet since you can create any coin with any fields in the place where you want to do a dry run to get the state. |
As discussed, we can re-add the We must document everything well to disambiguate the purpose of each method since this will leave us with four methods:
Later on, we can try reducing these to /*
Call - accepts optional flags
*/
call({ ..., dryRun: boolean, skipUtxoValidation: boolean })
// - Requires Wallet
// - Never use fake UTXOs
// valid calls
call({ ... }) // = default
call({ ..., dryRun: true }) // current simulate
call({ ..., dryRun: true, skipUtxoValidation: true }) // current dryRun
// invalid calls
call({ ..., skipUtxoValidation: true }) // throws error (requires dryRun=true)
call({ ..., dryRun: false, skipUtxoValidation: true }) // throws error (requires dryRun=true) /*
Get - requires no special flags
*/
get({ ... })
// - Do not require but can receive a Wallet
// - Always use fake UTXOs (accounts for lack of balance) |
Previously we had both
get
andcall
methods when interacting with program types. Under the hood the only difference was thatget
would not fund the transaction. This made it appropriate for reading data from the chain without side effects.In the
[email protected]
upgrade, a new transaction validation rule was added, requiring inputs to have at least one spendable input or message. This madeget
redundant as all transactions required funding to be considered valid, even if nothing was being spent. Therefore if a wallet without coins was attempting a transaction, even just to read data, it would throw aNoSpendableInput
error. A current workaround is to callfundWithFakeUtxos
on the request however this is rather hacky.We should reintroduce a recommended approach for reading data from the chain.
The text was updated successfully, but these errors were encountered: