thor
thor copied to clipboard
Adding transaction_call endpoint
Description
This PR adds a new endpoint that allows to simulate and estimate based on transactions instead of clauses. The added value is to bring api communication to the transaction level. This allows for gotchas like, chaintag, expiration, nonce, etc to be more visible and allows executing transactions in a given block revision
Summary of the endpoint:
URL : POST /transactions/call?revision=best
Payload : transaction.Transaction (existing type)
Response: transaction.CallReceipt (transaction.Receipt minus Block info)
type CallReceipt struct {
GasUsed uint64 `json:"gasUsed"`
GasPayer thor.Address `json:"gasPayer"`
Paid *math.HexOrDecimal256 `json:"paid"`
Reward *math.HexOrDecimal256 `json:"reward"`
Reverted bool `json:"reverted"`
TxID thor.Bytes32 `json:"txID"`
TxOrigin thor.Address `json:"txOrigin"`
Outputs []*Output `json:"outputs"`
VmError string `json:"vmError"`
}
Goal: Execute a transaction at the head of a specified block. Retrieve the total gas cost at the transaction level. (Note: Can be expanded to execute in a block at a given tx position.)
Fixes # (issue)
Type of change
- [x] New feature (non-breaking change which adds functionality)
How Has This Been Tested?
- [x] Tests
Checklist:
- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my code
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my feature works
- [x] New and existing unit tests pass locally with my changes
- [x] New and existing E2E tests pass locally with my changes
- [x] Any dependent changes have been merged and published in downstream modules
- [x] I have not added any vulnerable dependencies to my code