Skip to content

Commit a16ba26

Browse files
authored
Merge pull request #1103 from oasisprotocol/ptrus/feature/runtimetxs-results
runtime: Runtime transactions raw results
2 parents 3fb8bf8 + d7d440e commit a16ba26

32 files changed

+1766
-3
lines changed

.changelog/1103.feature.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
api/runtime: Expose runtime transaction raw results

analyzer/queries/queries.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -660,8 +660,8 @@ var (
660660
SET total_received = EXCLUDED.total_received`
661661

662662
RuntimeTransactionInsert = `
663-
INSERT INTO chain.runtime_transactions (runtime, round, tx_index, tx_hash, tx_eth_hash, fee, fee_symbol, fee_proxy_module, fee_proxy_id, gas_limit, gas_used, size, timestamp, oasis_encrypted_format, oasis_encrypted_public_key, oasis_encrypted_data_nonce, oasis_encrypted_data_data, oasis_encrypted_result_nonce, oasis_encrypted_result_data, method, body, "to", amount, amount_symbol, evm_encrypted_format, evm_encrypted_public_key, evm_encrypted_data_nonce, evm_encrypted_data_data, evm_encrypted_result_nonce, evm_encrypted_result_data, success, error_module, error_code, error_message_raw, error_message, likely_native_transfer)
664-
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, $31, $32, $33, $34, $35, $36)`
663+
INSERT INTO chain.runtime_transactions (runtime, round, tx_index, tx_hash, tx_eth_hash, fee, fee_symbol, fee_proxy_module, fee_proxy_id, gas_limit, gas_used, size, raw_result, timestamp, oasis_encrypted_format, oasis_encrypted_public_key, oasis_encrypted_data_nonce, oasis_encrypted_data_data, oasis_encrypted_result_nonce, oasis_encrypted_result_data, method, body, "to", amount, amount_symbol, evm_encrypted_format, evm_encrypted_public_key, evm_encrypted_data_nonce, evm_encrypted_data_data, evm_encrypted_result_nonce, evm_encrypted_result_data, success, error_module, error_code, error_message_raw, error_message, likely_native_transfer)
664+
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, $31, $32, $33, $34, $35, $36, $37)`
665665

666666
// We use COALESCE here to avoid overwriting existing data with null values.
667667
RuntimeTransactionEvmParsedFieldsUpdate = `

analyzer/runtime/runtime.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,7 @@ func (m *processor) queueTransactionInsert(batch *storage.QueryBatch, round uint
357357
transactionData.GasLimit,
358358
transactionData.GasUsed,
359359
transactionData.Size,
360+
transactionData.RawResult,
360361
timestamp,
361362
oasisEncryptedFormat,
362363
oasisEncryptedPublicKey,

api/spec/v1.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3281,7 +3281,7 @@ components:
32813281
RuntimeTransaction:
32823282
type: object
32833283
# NOTE: Not guaranteed to be present: eth_hash, to, amount.
3284-
required: [round, index, timestamp, hash, signers, sender_0, nonce_0, fee, fee_symbol, charged_fee, gas_limit, gas_used, size, is_likely_native_token_transfer]
3284+
required: [round, index, timestamp, hash, signers, sender_0, nonce_0, fee, fee_symbol, charged_fee, gas_limit, gas_used, size, raw_result, is_likely_native_token_transfer]
32853285
properties:
32863286
round:
32873287
type: integer
@@ -3379,6 +3379,12 @@ components:
33793379
type: integer
33803380
format: int32
33813381
description: The total byte size of the transaction.
3382+
raw_result:
3383+
type: string
3384+
format: byte
3385+
description: |
3386+
The raw result of the transaction execution, as returned by the runtime.
3387+
This is a base64-encoded byte array. The meaning of this field depends on the transaction type.
33823388
oasis_encryption_envelope:
33833389
allOf: [$ref: '#/components/schemas/RuntimeTransactionEncryptionEnvelope']
33843390
description: |

storage/client/client.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1650,6 +1650,7 @@ func runtimeTransactionFromRow(rows pgx.Rows, logger *log.Logger) (*RuntimeTrans
16501650
&t.GasUsed,
16511651
&t.ChargedFee,
16521652
&t.Size,
1653+
&t.RawResult,
16531654
&oasisEncryptionEnvelopeFormat,
16541655
&oasisEncryptionEnvelope.PublicKey,
16551656
&oasisEncryptionEnvelope.DataNonce,

storage/client/queries/queries.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,7 @@ const (
546546
ELSE COALESCE(FLOOR(txs.fee / NULLIF(txs.gas_limit, 0)) * txs.gas_used, 0)
547547
END AS charged_fee,
548548
txs.size,
549+
txs.raw_result,
549550
txs.oasis_encrypted_format,
550551
txs.oasis_encrypted_public_key,
551552
txs.oasis_encrypted_data_nonce,

storage/migrations/01_runtimes.up.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ CREATE TABLE chain.runtime_transactions
101101
abi_parsed_at TIMESTAMP WITH TIME ZONE -- Updated in 34_runtime_abi_parsed_at.up.sql: NOT NULL DEFAULT '0001-01-01'
102102

103103
-- likely_native_transfer BOOLEAN NOT NULL DEFAULT FALSE -- Added in 18_related_runtime_transactions_method_denorm.up.sql.
104+
105+
-- raw_result BYTEA -- Added in 45_runtime_transactions_raw_result.up.sql.
104106
);
105107
CREATE INDEX ix_runtime_transactions_tx_hash ON chain.runtime_transactions USING hash (tx_hash);
106108
CREATE INDEX ix_runtime_transactions_tx_eth_hash ON chain.runtime_transactions USING hash (tx_eth_hash);
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
BEGIN;
2+
3+
ALTER TABLE chain.runtime_transactions ADD COLUMN raw_result BYTEA;
4+
5+
COMMIT;

tests/e2e_regression/eden/expected/emerald_failed_tx.body

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"is_likely_native_token_transfer": false,
2727
"method": "evm.Call",
2828
"nonce_0": 31228,
29+
"raw_result": "oWRmYWlso2Rjb2RlCGZtb2R1bGVjZXZtZ21lc3NhZ2V4unJldmVydGVkOiBDTU41b0FBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQWdBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUN0UVlYbHRaVzUwVTNCc2FYUjBaWEk2SUdGalkyOTFiblFnYVhNZ2JtOTBJR1IxWlNCd1lYbHRaVzUwQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQQ==",
2930
"round": 8059465,
3031
"sender_0": "oasis1qr9ak7ck2fs3pscs635gapk96ncl02yyxggrqgq5",
3132
"sender_0_eth": "0x7274e8a2F8C599a1265651037e0da68C5ECa06bD",

tests/e2e_regression/eden/expected/emerald_tx.body

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"is_likely_native_token_transfer": true,
2121
"method": "evm.Call",
2222
"nonce_0": 3063641,
23+
"raw_result": "oWJva0A=",
2324
"round": 8060338,
2425
"sender_0": "oasis1qzchk9eh0n4p2raym2e6cyvegrjumxl3lqkfhztr",
2526
"sender_0_eth": "0xCB2412a993f406eFf10a74011410a4F35e3549E3",

0 commit comments

Comments
 (0)