Skip to content

Commit 1ae9cdc

Browse files
committed
RPC: Ensure innerInstructions/logMessages metadata is null when --enable-cpi-and-log-storage is disabled
1 parent 2b269db commit 1ae9cdc

File tree

3 files changed

+33
-17
lines changed

3 files changed

+33
-17
lines changed

docs/src/developing/clients/jsonrpc-api.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -394,10 +394,10 @@ The result field will be an object with the following fields:
394394
- `fee: <u64>` - fee this transaction was charged, as u64 integer
395395
- `preBalances: <array>` - array of u64 account balances from before the transaction was processed
396396
- `postBalances: <array>` - array of u64 account balances after the transaction was processed
397-
- `innerInstructions: <array|undefined>` - List of [inner instructions](#inner-instructions-structure) or omitted if inner instruction recording was not yet enabled during this transaction
397+
- `innerInstructions: <array|null>` - List of [inner instructions](#inner-instructions-structure) or `null` if inner instruction recording was not enabled during this transaction
398398
- `preTokenBalances: <array|undefined>` - List of [token balances](#token-balances-structure) from before the transaction was processed or omitted if token balance recording was not yet enabled during this transaction
399399
- `postTokenBalances: <array|undefined>` - List of [token balances](#token-balances-structure) from after the transaction was processed or omitted if token balance recording was not yet enabled during this transaction
400-
- `logMessages: <array>` - array of string log messages or omitted if log message recording was not yet enabled during this transaction
400+
- `logMessages: <array|null>` - array of string log messages or `null` if log message recording was not enabled during this transaction
401401
- DEPRECATED: `status: <object>` - Transaction status
402402
- `"Ok": <null>` - Transaction was successful
403403
- `"Err": <ERR>` - Transaction failed with TransactionError
@@ -520,8 +520,8 @@ Result:
520520
"meta": {
521521
"err": null,
522522
"fee": 5000,
523-
"innerInstructions": [],
524-
"logMessages": [],
523+
"innerInstructions": null,
524+
"logMessages": null,
525525
"postBalances": [
526526
499998932500,
527527
26858640,
@@ -2752,10 +2752,10 @@ Returns transaction details for a confirmed transaction
27522752
- `fee: <u64>` - fee this transaction was charged, as u64 integer
27532753
- `preBalances: <array>` - array of u64 account balances from before the transaction was processed
27542754
- `postBalances: <array>` - array of u64 account balances after the transaction was processed
2755-
- `innerInstructions: <array|undefined>` - List of [inner instructions](#inner-instructions-structure) or omitted if inner instruction recording was not yet enabled during this transaction
2755+
- `innerInstructions: <array|null>` - List of [inner instructions](#inner-instructions-structure) or `null` if inner instruction recording was not enabled during this transaction
27562756
- `preTokenBalances: <array|undefined>` - List of [token balances](#token-balances-structure) from before the transaction was processed or omitted if token balance recording was not yet enabled during this transaction
27572757
- `postTokenBalances: <array|undefined>` - List of [token balances](#token-balances-structure) from after the transaction was processed or omitted if token balance recording was not yet enabled during this transaction
2758-
- `logMessages: <array>` - array of string log messages or omitted if log message recording was not yet enabled during this transaction
2758+
- `logMessages: <array|null>` - array of string log messages or `null` if log message recording was not enabled during this transaction
27592759
- DEPRECATED: `status: <object>` - Transaction status
27602760
- `"Ok": <null>` - Transaction was successful
27612761
- `"Err": <ERR>` - Transaction failed with TransactionError
@@ -4144,10 +4144,10 @@ The result field will be an object with the following fields:
41444144
- `fee: <u64>` - fee this transaction was charged, as u64 integer
41454145
- `preBalances: <array>` - array of u64 account balances from before the transaction was processed
41464146
- `postBalances: <array>` - array of u64 account balances after the transaction was processed
4147-
- `innerInstructions: <array|undefined>` - List of [inner instructions](#inner-instructions-structure) or omitted if inner instruction recording was not yet enabled during this transaction
4147+
- `innerInstructions: <array|null>` - List of [inner instructions](#inner-instructions-structure) or `null` if inner instruction recording was not enabled during this transaction
41484148
- `preTokenBalances: <array|undefined>` - List of [token balances](#token-balances-structure) from before the transaction was processed or omitted if token balance recording was not yet enabled during this transaction
41494149
- `postTokenBalances: <array|undefined>` - List of [token balances](#token-balances-structure) from after the transaction was processed or omitted if token balance recording was not yet enabled during this transaction
4150-
- `logMessages: <array>` - array of string log messages or omitted if log message recording was not yet enabled during this transaction
4150+
- `logMessages: <array|null>` - array of string log messages or `null` if log message recording was not enabled during this transaction
41514151
- DEPRECATED: `status: <object>` - Transaction status
41524152
- `"Ok": <null>` - Transaction was successful
41534153
- `"Err": <ERR>` - Transaction failed with TransactionError
@@ -4460,10 +4460,10 @@ Returns transaction details for a confirmed transaction
44604460
- `fee: <u64>` - fee this transaction was charged, as u64 integer
44614461
- `preBalances: <array>` - array of u64 account balances from before the transaction was processed
44624462
- `postBalances: <array>` - array of u64 account balances after the transaction was processed
4463-
- `innerInstructions: <array|undefined>` - List of [inner instructions](#inner-instructions-structure) or omitted if inner instruction recording was not yet enabled during this transaction
4463+
- `innerInstructions: <array|null>` - List of [inner instructions](#inner-instructions-structure) or `null` if inner instruction recording was not enabled during this transaction
44644464
- `preTokenBalances: <array|undefined>` - List of [token balances](#token-balances-structure) from before the transaction was processed or omitted if token balance recording was not yet enabled during this transaction
44654465
- `postTokenBalances: <array|undefined>` - List of [token balances](#token-balances-structure) from after the transaction was processed or omitted if token balance recording was not yet enabled during this transaction
4466-
- `logMessages: <array>` - array of string log messages or omitted if log message recording was not yet enabled during this transaction
4466+
- `logMessages: <array|null>` - array of string log messages or `null` if log message recording was not enabled during this transaction
44674467
- DEPRECATED: `status: <object>` - Transaction status
44684468
- `"Ok": <null>` - Transaction was successful
44694469
- `"Err": <ERR>` - Transaction failed with TransactionError

storage-proto/proto/confirmed_block.proto

+2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ message TransactionStatusMeta {
4141
repeated uint64 pre_balances = 3;
4242
repeated uint64 post_balances = 4;
4343
repeated InnerInstructions inner_instructions = 5;
44+
bool inner_instructions_none = 10;
4445
repeated string log_messages = 6;
46+
bool log_messages_none = 11;
4547
repeated TokenBalance pre_token_balances = 7;
4648
repeated TokenBalance post_token_balances = 8;
4749
repeated Reward rewards = 9;

storage-proto/src/convert.rs

+21-7
Original file line numberDiff line numberDiff line change
@@ -283,11 +283,13 @@ impl From<TransactionStatusMeta> for generated::TransactionStatusMeta {
283283
err: bincode::serialize(&err).expect("transaction error to serialize to bytes"),
284284
}),
285285
};
286+
let inner_instructions_none = inner_instructions.is_none();
286287
let inner_instructions = inner_instructions
287288
.unwrap_or_default()
288289
.into_iter()
289290
.map(|ii| ii.into())
290291
.collect();
292+
let log_messages_none = log_messages.is_none();
291293
let log_messages = log_messages.unwrap_or_default();
292294
let pre_token_balances = pre_token_balances
293295
.unwrap_or_default()
@@ -311,7 +313,9 @@ impl From<TransactionStatusMeta> for generated::TransactionStatusMeta {
311313
pre_balances,
312314
post_balances,
313315
inner_instructions,
316+
inner_instructions_none,
314317
log_messages,
318+
log_messages_none,
315319
pre_token_balances,
316320
post_token_balances,
317321
rewards,
@@ -336,7 +340,9 @@ impl TryFrom<generated::TransactionStatusMeta> for TransactionStatusMeta {
336340
pre_balances,
337341
post_balances,
338342
inner_instructions,
343+
inner_instructions_none,
339344
log_messages,
345+
log_messages_none,
340346
pre_token_balances,
341347
post_token_balances,
342348
rewards,
@@ -345,13 +351,21 @@ impl TryFrom<generated::TransactionStatusMeta> for TransactionStatusMeta {
345351
None => Ok(()),
346352
Some(tx_error) => Err(bincode::deserialize(&tx_error.err)?),
347353
};
348-
let inner_instructions = Some(
349-
inner_instructions
350-
.into_iter()
351-
.map(|inner| inner.into())
352-
.collect(),
353-
);
354-
let log_messages = Some(log_messages);
354+
let inner_instructions = if inner_instructions_none {
355+
None
356+
} else {
357+
Some(
358+
inner_instructions
359+
.into_iter()
360+
.map(|inner| inner.into())
361+
.collect(),
362+
)
363+
};
364+
let log_messages = if log_messages_none {
365+
None
366+
} else {
367+
Some(log_messages)
368+
};
355369
let pre_token_balances = Some(
356370
pre_token_balances
357371
.into_iter()

0 commit comments

Comments
 (0)