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

Add ledger entry diff to simulateTransaction response #120

Merged
merged 5 commits into from
Apr 4, 2024

Conversation

2opremio
Copy link
Contributor

@2opremio 2opremio commented Apr 2, 2024

What

It adds the following field to SimulateTransactionResponse

StateDiff       []LedgerEntryChange            `json:"stateDiff,omitempty"`       // If present, it indicates how the state (ledger entries) will change as a result of the transaction execution.

where:

// LedgerEntryDiff designates a change in a ledger entry. Before and After cannot be be omitted at the same time.
// If Before is omitted, it constitutes a creation, if After is omitted, it constitutes a delation.
type LedgerEntryChange struct {
	Type   LedgerEntryChangeType `json:"type"`
	Key    string                `json:"key"`    // LedgerEntryKey in base64
	Before *string               `json:"before"` // LedgerEntry XDR in base64
	After  *string               `json:"after"`  // LedgerEntry XDR in base64
}

Why

Closes #11

Known limitations

It can considerably increase the size of simulate transaction responses (particularly for contract uploads, which will contain the full wasm).

It adds the following field to `SimulateTransactionResponse`

```
	StateDiff       []LedgerEntryDiff            `json:"stateDiff,omitempty"`       // If present, it indicates how the state (ledger entries) will change as a result of the transaction execution.

```

where:

```
// LedgerEntryDiff designates a change in a ledger entry. Before and After cannot be be omitted at the same time.
// If Before is omitted, it constitutes a creation, if After is omitted, it constitutes a delation.
type LedgerEntryDiff struct {
	Before string `json:"before,omitempty"` // LedgerEntry XDR in base64
	After  string `json:"after,omitempty"`  // LedgerEntry XDR in base64
}
```
Copy link
Member

@leighmcculloch leighmcculloch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One request on the API and one question.

cmd/soroban-rpc/internal/methods/simulate_transaction.go Outdated Show resolved Hide resolved
cmd/soroban-rpc/internal/methods/simulate_transaction.go Outdated Show resolved Hide resolved
@2opremio
Copy link
Contributor Author

2opremio commented Apr 3, 2024

@leighmcculloch PTAL

@2opremio 2opremio force-pushed the compute-ledger-entry-diff branch from 006f1a4 to 29e04e9 Compare April 3, 2024 14:33
Copy link
Member

@leighmcculloch leighmcculloch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏🏻

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

Successfully merging this pull request may close these issues.

soroban-rpc: add effects/changes a transaction makes over an account in the simulation response
3 participants