Skip to content

Commit

Permalink
Merge pull request #720 from oasisprotocol/ptrus/feature/consensus-tx…
Browse files Browse the repository at this point in the history
…-gaslimit

api: expose gas limit for consensus transactions
  • Loading branch information
ptrus authored Jul 2, 2024
2 parents 8f899e6 + a57a167 commit 5225417
Show file tree
Hide file tree
Showing 14 changed files with 224 additions and 7 deletions.
1 change: 1 addition & 0 deletions .changelog/720.1.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
api: expose gas limit for consensus transactions
1 change: 1 addition & 0 deletions .changelog/720.2.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
consensus/transactions: track related accounts for failed transactions
8 changes: 7 additions & 1 deletion analyzer/consensus/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,13 @@ func (m *processor) queueTransactionInserts(batch *storage.QueryBatch, data *con
// Enqueue DB statements to store events that were generated as the result of a TX execution.
func (m *processor) queueTxEventInserts(batch *storage.QueryBatch, data *consensusBlockData) error {
for i, txr := range data.TransactionsWithResults {
var txAccounts []staking.Address
txAccounts := []staking.Address{
// Always insert sender as a related address, some transactions (e.g. failed ones) might not have
// any events associated.
// TODO: this could also track the receiver (when applicable), but currently we don't do
// much transaction parsing, where we could extract it for each transaction type.
staking.NewAddress(txr.Transaction.Signature.PublicKey),
}
for _, event := range txr.Result.Events {
eventData := m.extractEventData(event)
txAccounts = append(txAccounts, eventData.relatedAddresses...)
Expand Down
6 changes: 5 additions & 1 deletion api/spec/v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1490,7 +1490,7 @@ components:
Transaction:
type: object
required: [block, index, timestamp, hash, sender, nonce, fee, method, body, success]
required: [block, index, timestamp, hash, sender, nonce, fee, gas_limit, method, body, success]
properties:
block:
type: integer
Expand Down Expand Up @@ -1528,6 +1528,10 @@ components:
The fee that this transaction's sender committed
to pay to execute it.
example: 1000
gas_limit:
allOf: [$ref: '#/components/schemas/TextBigInt']
description: |
The maximum gas that a transaction can use.
method:
allOf: [$ref: '#/components/schemas/ConsensusTxMethod']
description: The method that was called.
Expand Down
2 changes: 2 additions & 0 deletions storage/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ func (c *StorageClient) Transactions(ctx context.Context, p apiTypes.GetConsensu
&t.Sender,
&t.Nonce,
&t.Fee,
&t.GasLimit,
&t.Method,
&t.Body,
&code,
Expand Down Expand Up @@ -459,6 +460,7 @@ func (c *StorageClient) Transaction(ctx context.Context, txHash string) (*Transa
&t.Sender,
&t.Nonce,
&t.Fee,
&t.GasLimit,
&t.Method,
&t.Body,
&code,
Expand Down
3 changes: 2 additions & 1 deletion storage/client/queries/queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const (
chain.transactions.sender as sender,
chain.transactions.nonce as nonce,
chain.transactions.fee_amount as fee_amount,
chain.transactions.max_gas as gas_limit,
chain.transactions.method as method,
chain.transactions.body as body,
chain.transactions.code as code,
Expand All @@ -72,7 +73,7 @@ const (
OFFSET $8::bigint`

Transaction = `
SELECT block, tx_index, tx_hash, sender, nonce, fee_amount, method, body, code, module, message, chain.blocks.time
SELECT block, tx_index, tx_hash, sender, nonce, fee_amount, max_gas, method, body, code, module, message, chain.blocks.time
FROM chain.transactions
JOIN chain.blocks ON chain.transactions.block = chain.blocks.height
WHERE tx_hash = $1::text`
Expand Down
1 change: 1 addition & 0 deletions tests/e2e_regression/damask/expected/tx.body
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"module": "staking"
},
"fee": "0",
"gas_limit": "1263",
"hash": "f7a03e0912d355901ee794e5fec79a6b4c91363fc27d953596ee6de5c1492798",
"index": 0,
"method": "staking.Transfer",
Expand Down
100 changes: 100 additions & 0 deletions tests/e2e_regression/damask/expected/txs.body

Large diffs are not rendered by default.

Binary file modified tests/e2e_regression/damask/rpc-cache/emerald/db.pmt
Binary file not shown.
Git LFS file not shown
1 change: 1 addition & 0 deletions tests/e2e_regression/eden/expected/tx.body
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"to": "oasis1qqv9tknl8afkxkzszwl80g3wz80f2w8u0g502ewc"
},
"fee": "0",
"gas_limit": "1259",
"hash": "142d43e5194b738ab2223f8d0b42326fab06edd714a8cefc59a078b89b5de057",
"index": 0,
"method": "staking.Transfer",
Expand Down
100 changes: 100 additions & 0 deletions tests/e2e_regression/eden/expected/txs.body

Large diffs are not rendered by default.

Git LFS file not shown
Git LFS file not shown

0 comments on commit 5225417

Please sign in to comment.