* Allow the sendTransaction preflight commitment level to be configured
(cherry picked from commit b660704faa
)
# Conflicts:
# cli/src/cli.rs
# core/src/rpc.rs
* rebase
Co-authored-by: Michael Vines <mvines@gmail.com>
This commit is contained in:
@ -1290,6 +1290,7 @@ fn send_and_confirm_transactions_with_spinner<T: Signers>(
|
|||||||
&transaction,
|
&transaction,
|
||||||
RpcSendTransactionConfig {
|
RpcSendTransactionConfig {
|
||||||
skip_preflight: true,
|
skip_preflight: true,
|
||||||
|
..RpcSendTransactionConfig::default()
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.ok();
|
.ok();
|
||||||
@ -1442,6 +1443,7 @@ fn process_deploy(
|
|||||||
&finalize_tx,
|
&finalize_tx,
|
||||||
RpcSendTransactionConfig {
|
RpcSendTransactionConfig {
|
||||||
skip_preflight: true,
|
skip_preflight: true,
|
||||||
|
..RpcSendTransactionConfig::default()
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
|
@ -12,12 +12,14 @@ pub struct RpcSignatureStatusConfig {
|
|||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct RpcSendTransactionConfig {
|
pub struct RpcSendTransactionConfig {
|
||||||
pub skip_preflight: bool,
|
pub skip_preflight: bool,
|
||||||
|
pub preflight_commitment: Option<CommitmentConfig>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct RpcSimulateTransactionConfig {
|
pub struct RpcSimulateTransactionConfig {
|
||||||
pub sig_verify: bool,
|
pub sig_verify: bool,
|
||||||
|
pub commitment: Option<CommitmentConfig>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
|
@ -2101,7 +2101,9 @@ impl RpcSol for RpcSolImpl {
|
|||||||
.into());
|
.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
if let (Err(err), _log_output) = run_transaction_simulation(&bank, transaction.clone())
|
let preflight_bank = &*meta.bank(config.preflight_commitment)?;
|
||||||
|
if let (Err(err), _log_output) =
|
||||||
|
run_transaction_simulation(&preflight_bank, transaction.clone())
|
||||||
{
|
{
|
||||||
// Note: it's possible that the transaction simulation failed but the actual
|
// Note: it's possible that the transaction simulation failed but the actual
|
||||||
// transaction would succeed, such as when a transaction depends on an earlier
|
// transaction would succeed, such as when a transaction depends on an earlier
|
||||||
@ -2134,7 +2136,7 @@ impl RpcSol for RpcSolImpl {
|
|||||||
Ok(())
|
Ok(())
|
||||||
};
|
};
|
||||||
|
|
||||||
let bank = &*meta.bank(None)?;
|
let bank = &*meta.bank(config.commitment)?;
|
||||||
let logs = if result.is_ok() {
|
let logs = if result.is_ok() {
|
||||||
let sim_result = run_transaction_simulation(&bank, transaction);
|
let sim_result = run_transaction_simulation(&bank, transaction);
|
||||||
result = sim_result.0;
|
result = sim_result.0;
|
||||||
|
@ -1353,6 +1353,7 @@ Before submitting, the following preflight checks are performed:
|
|||||||
- `<string>` - fully-signed Transaction, as base-58 encoded string
|
- `<string>` - fully-signed Transaction, as base-58 encoded string
|
||||||
- `<object>` - (optional) Configuration object containing the following field:
|
- `<object>` - (optional) Configuration object containing the following field:
|
||||||
- `skipPreflight: <bool>` - if true, skip the preflight transaction checks (default: false)
|
- `skipPreflight: <bool>` - if true, skip the preflight transaction checks (default: false)
|
||||||
|
- `preflightCommitment: <object>` - (optional) [Commitment](jsonrpc-api.md#configuring-state-commitment) level to use for preflight (default: max).
|
||||||
|
|
||||||
#### Results:
|
#### Results:
|
||||||
|
|
||||||
@ -1377,6 +1378,7 @@ Simulate sending a transaction
|
|||||||
- `<string>` - Transaction, as base-58 encoded string. The transaction must have a valid blockhash, but is not required to be signed.
|
- `<string>` - Transaction, as base-58 encoded string. The transaction must have a valid blockhash, but is not required to be signed.
|
||||||
- `<object>` - (optional) Configuration object containing the following field:
|
- `<object>` - (optional) Configuration object containing the following field:
|
||||||
- `sigVerify: <bool>` - if true the transaction signatures will be verified (default: false)
|
- `sigVerify: <bool>` - if true the transaction signatures will be verified (default: false)
|
||||||
|
- `commitment: <object>` - (optional) [Commitment](jsonrpc-api.md#configuring-state-commitment) level to simulate the transaction at (default: max).
|
||||||
|
|
||||||
#### Results:
|
#### Results:
|
||||||
|
|
||||||
|
@ -493,6 +493,7 @@ mod test {
|
|||||||
),
|
),
|
||||||
RpcSendTransactionConfig {
|
RpcSendTransactionConfig {
|
||||||
skip_preflight: true,
|
skip_preflight: true,
|
||||||
|
..RpcSendTransactionConfig::default()
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
@ -548,6 +549,7 @@ mod test {
|
|||||||
),
|
),
|
||||||
RpcSendTransactionConfig {
|
RpcSendTransactionConfig {
|
||||||
skip_preflight: true,
|
skip_preflight: true,
|
||||||
|
..RpcSendTransactionConfig::default()
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
@ -593,6 +595,7 @@ mod test {
|
|||||||
),
|
),
|
||||||
RpcSendTransactionConfig {
|
RpcSendTransactionConfig {
|
||||||
skip_preflight: true,
|
skip_preflight: true,
|
||||||
|
..RpcSendTransactionConfig::default()
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
@ -631,6 +634,7 @@ mod test {
|
|||||||
),
|
),
|
||||||
RpcSendTransactionConfig {
|
RpcSendTransactionConfig {
|
||||||
skip_preflight: true,
|
skip_preflight: true,
|
||||||
|
..RpcSendTransactionConfig::default()
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -35,6 +35,7 @@ impl Client for RpcClient {
|
|||||||
&transaction,
|
&transaction,
|
||||||
RpcSendTransactionConfig {
|
RpcSendTransactionConfig {
|
||||||
skip_preflight: true,
|
skip_preflight: true,
|
||||||
|
..RpcSendTransactionConfig::default()
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.map_err(|e| TransportError::Custom(e.to_string()))
|
.map_err(|e| TransportError::Custom(e.to_string()))
|
||||||
|
Reference in New Issue
Block a user