Skip to content

Commit

Permalink
removes mergify merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
behzadnouri committed Jun 4, 2022
1 parent 304d480 commit 2feeb4f
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 812 deletions.
26 changes: 1 addition & 25 deletions cli/src/nonce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,17 +333,8 @@ pub fn check_nonce_account(
) -> Result<(), CliError> {
match state_from_account(nonce_account)? {
State::Initialized(ref data) => {
<<<<<<< HEAD
if &data.blockhash != nonce_hash {
Err(Error::InvalidHash.into())
=======
if &data.blockhash() != nonce_hash {
Err(Error::InvalidHash {
provided: *nonce_hash,
expected: data.blockhash(),
}
.into())
>>>>>>> 5ee157f43 (separates durable nonce and blockhash domains)
Err(Error::InvalidHash.into())
} else if nonce_authority != &data.authority {
Err(Error::InvalidAuthority.into())
} else {
Expand Down Expand Up @@ -967,27 +958,12 @@ mod tests {
if let CliError::InvalidNonce(err) =
check_nonce_account(&invalid_hash.unwrap(), &nonce_pubkey, &blockhash).unwrap_err()
{
<<<<<<< HEAD
assert_eq!(err, Error::InvalidHash,);
=======
assert_eq!(
err,
Error::InvalidHash {
provided: blockhash,
expected: *invalid_durable_nonce.as_hash(),
}
);
>>>>>>> 5ee157f43 (separates durable nonce and blockhash domains)
}

let data = Versions::new_current(State::Initialized(nonce::state::Data::new(
<<<<<<< HEAD
solana_sdk::pubkey::new_rand(),
blockhash,
=======
new_nonce_authority,
durable_nonce,
>>>>>>> 5ee157f43 (separates durable nonce and blockhash domains)
0,
)));
let invalid_authority = Account::new_data(1, &data, &system_program::ID);
Expand Down
90 changes: 0 additions & 90 deletions client/src/nonce_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,96 +70,6 @@ pub fn state_from_account<T: ReadableAccount + StateMut<Versions>>(
.map(|v| v.convert_to_current())
}

<<<<<<< HEAD
=======
/// Deserialize the state data of a durable transaction nonce account.
///
/// # Errors
///
/// Returns an error if the account is not owned by the system program or
/// contains no data. Returns an error if the account state is uninitialized or
/// fails to deserialize.
///
/// # Examples
///
/// Create and sign a transaction with a durable nonce:
///
/// ```no_run
/// use solana_client::{
/// rpc_client::RpcClient,
/// nonce_utils,
/// };
/// use solana_sdk::{
/// message::Message,
/// pubkey::Pubkey,
/// signature::{Keypair, Signer},
/// system_instruction,
/// transaction::Transaction,
/// };
/// use std::path::Path;
/// use anyhow::Result;
/// # use anyhow::anyhow;
///
/// fn create_transfer_tx_with_nonce(
/// client: &RpcClient,
/// nonce_account_pubkey: &Pubkey,
/// payer: &Keypair,
/// receiver: &Pubkey,
/// amount: u64,
/// tx_path: &Path,
/// ) -> Result<()> {
///
/// let instr_transfer = system_instruction::transfer(
/// &payer.pubkey(),
/// receiver,
/// amount,
/// );
///
/// // In this example, `payer` is `nonce_account_pubkey`'s authority
/// let instr_advance_nonce_account = system_instruction::advance_nonce_account(
/// nonce_account_pubkey,
/// &payer.pubkey(),
/// );
///
/// // The `advance_nonce_account` instruction must be the first issued in
/// // the transaction.
/// let message = Message::new(
/// &[
/// instr_advance_nonce_account,
/// instr_transfer
/// ],
/// Some(&payer.pubkey()),
/// );
///
/// let mut tx = Transaction::new_unsigned(message);
///
/// // Sign the tx with nonce_account's `blockhash` instead of the
/// // network's latest blockhash.
/// let nonce_account = client.get_account(nonce_account_pubkey)?;
/// let nonce_data = nonce_utils::data_from_account(&nonce_account)?;
/// let blockhash = nonce_data.blockhash();
///
/// tx.try_sign(&[payer], blockhash)?;
///
/// // Save the signed transaction locally for later submission.
/// save_tx_to_file(&tx_path, &tx)?;
///
/// Ok(())
/// }
/// #
/// # fn save_tx_to_file(path: &Path, tx: &Transaction) -> Result<()> {
/// # Ok(())
/// # }
/// #
/// # let client = RpcClient::new(String::new());
/// # let nonce_account_pubkey = Pubkey::new_unique();
/// # let payer = Keypair::new();
/// # let receiver = Pubkey::new_unique();
/// # create_transfer_tx_with_nonce(&client, &nonce_account_pubkey, &payer, &receiver, 1024, Path::new("new_tx"))?;
/// #
/// # Ok::<(), anyhow::Error>(())
/// ```
>>>>>>> 5ee157f43 (separates durable nonce and blockhash domains)
pub fn data_from_account<T: ReadableAccount + StateMut<Versions>>(
account: &T,
) -> Result<Data, Error> {
Expand Down
27 changes: 0 additions & 27 deletions rpc/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4396,14 +4396,8 @@ pub mod tests {
fee_calculator::DEFAULT_BURN_PERCENT,
hash::{hash, Hash},
instruction::InstructionError,
<<<<<<< HEAD
message::Message,
nonce, rpc_port,
=======
message::{v0, v0::MessageAddressTableLookup, MessageHeader, VersionedMessage},
nonce::{self, state::DurableNonce},
rpc_port,
>>>>>>> 5ee157f43 (separates durable nonce and blockhash domains)
signature::{Keypair, Signer},
system_program, system_transaction,
timing::slot_duration_from_slots_per_year,
Expand Down Expand Up @@ -5472,7 +5466,6 @@ pub mod tests {
assert!(contains_slot);

// Set up nonce accounts to test filters
<<<<<<< HEAD
let nonce_keypair0 = Keypair::new();
let instruction = system_instruction::create_nonce_account(
&alice.pubkey(),
Expand All @@ -5495,26 +5488,6 @@ pub mod tests {
let message = Message::new(&instruction, Some(&alice.pubkey()));
let tx = Transaction::new(&[&alice, &nonce_keypair1], message, blockhash);
bank.process_transaction(&tx).unwrap();
=======
let nonce_authorities = (0..2)
.map(|_| {
let pubkey = Pubkey::new_unique();
let authority = Pubkey::new_unique();
let account = AccountSharedData::new_data(
42,
&nonce::state::Versions::new_current(nonce::State::new_initialized(
&authority,
DurableNonce::default(),
1000,
)),
&system_program::id(),
)
.unwrap();
bank.store_account(&pubkey, &account);
authority
})
.collect::<Vec<_>>();
>>>>>>> 5ee157f43 (separates durable nonce and blockhash domains)

// Test memcmp filter; filter on Initialized state
let req = format!(
Expand Down
15 changes: 1 addition & 14 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3764,26 +3764,13 @@ impl Bank {
fn check_transaction_for_nonce(
&self,
tx: &SanitizedTransaction,
<<<<<<< HEAD
) -> Option<(Pubkey, AccountSharedData)> {
if self.cluster_type() == ClusterType::MainnetBeta {
if self.slot() <= 135986379 {
self.check_message_for_nonce(tx.message())
} else {
None
}
} else {
self.check_message_for_nonce(tx.message())
}
=======
enable_durable_nonce: bool,
) -> Option<TransactionAccount> {
) -> Option<(Pubkey, AccountSharedData)> {
(enable_durable_nonce
|| self.slot() <= 135986379
|| self.cluster_type() != ClusterType::MainnetBeta)
.then(|| self.check_message_for_nonce(tx.message()))
.flatten()
>>>>>>> 985177413 (adds feature gate enabling durable nonce)
}

pub fn check_transactions(
Expand Down
Loading

0 comments on commit 2feeb4f

Please sign in to comment.