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

Adding transaction_call endpoint #832

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft

Conversation

otherview
Copy link
Member

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

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

  • Tests

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • New and existing E2E tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have not added any vulnerable dependencies to my code

@codecov-commenter
Copy link

codecov-commenter commented Aug 28, 2024

Codecov Report

Attention: Patch coverage is 38.19742% with 144 lines in your changes missing coverage. Please review.

Project coverage is 61.83%. Comparing base (f1aa5ae) to head (8ff45c0).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
runtime/runtime.go 0.00% 78 Missing ⚠️
api/transactions/types.go 62.16% 25 Missing and 3 partials ⚠️
runtime/resolved_tx.go 0.00% 23 Missing ⚠️
api/transactions/transactions.go 75.43% 8 Missing and 6 partials ⚠️
api/api.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #832      +/-   ##
==========================================
- Coverage   62.14%   61.83%   -0.32%     
==========================================
  Files         204      204              
  Lines       18859    19084     +225     
==========================================
+ Hits        11720    11800      +80     
- Misses       6040     6176     +136     
- Partials     1099     1108       +9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

This pull request has been marked as stale due to inactivity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale PR/ Issue has been marked as stale label Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale PR/ Issue has been marked as stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants