mirror of
https://github.com/logos-blockchain/lssa.git
synced 2026-01-04 06:13:10 +00:00
move nonce to public execution input
This commit is contained in:
parent
6a38c2eaa2
commit
e9b11af986
@ -5,6 +5,7 @@ use crate::merkle_tree_public::TreeHashType;
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct PublicNativeTokenSend {
|
||||
pub from: TreeHashType,
|
||||
pub nonce: u64,
|
||||
pub to: TreeHashType,
|
||||
pub balance_to_move: u64,
|
||||
}
|
||||
|
||||
@ -62,8 +62,6 @@ pub struct TransactionBody {
|
||||
///
|
||||
/// First value represents vector of changes, second is new length of a state
|
||||
pub state_changes: (serde_json::Value, usize),
|
||||
|
||||
pub nonce: u64,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
@ -328,7 +326,6 @@ mod tests {
|
||||
secret_r: [8; 32],
|
||||
sc_addr: "someAddress".to_string(),
|
||||
state_changes: (serde_json::Value::Null, 10),
|
||||
nonce: 1,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -511,7 +511,6 @@ mod tests {
|
||||
secret_r: [0; 32],
|
||||
sc_addr: "sc_addr".to_string(),
|
||||
state_changes: (serde_json::Value::Null, 0),
|
||||
nonce: 1,
|
||||
};
|
||||
Transaction::new(body, SignaturePrivateKey::random(&mut rng))
|
||||
}
|
||||
|
||||
@ -274,7 +274,6 @@ impl NodeCore {
|
||||
secret_r,
|
||||
sc_addr,
|
||||
state_changes,
|
||||
nonce: 1,
|
||||
};
|
||||
let key_to_sign_transaction = account.key_holder.get_pub_account_signing_key();
|
||||
|
||||
@ -371,7 +370,6 @@ impl NodeCore {
|
||||
secret_r,
|
||||
sc_addr,
|
||||
state_changes,
|
||||
nonce: 1,
|
||||
};
|
||||
let key_to_sign_transaction = account.key_holder.get_pub_account_signing_key();
|
||||
|
||||
@ -486,7 +484,6 @@ impl NodeCore {
|
||||
secret_r,
|
||||
sc_addr,
|
||||
state_changes,
|
||||
nonce: 1,
|
||||
};
|
||||
|
||||
let key_to_sign_transaction = account.key_holder.get_pub_account_signing_key();
|
||||
@ -632,7 +629,6 @@ impl NodeCore {
|
||||
secret_r,
|
||||
sc_addr,
|
||||
state_changes,
|
||||
nonce: 1,
|
||||
};
|
||||
|
||||
let key_to_sign_transaction = account.key_holder.get_pub_account_signing_key();
|
||||
@ -761,7 +757,6 @@ impl NodeCore {
|
||||
secret_r,
|
||||
sc_addr,
|
||||
state_changes,
|
||||
nonce: 1,
|
||||
};
|
||||
|
||||
let key_to_sign_transaction = account.key_holder.get_pub_account_signing_key();
|
||||
@ -851,7 +846,6 @@ impl NodeCore {
|
||||
secret_r,
|
||||
sc_addr,
|
||||
state_changes,
|
||||
nonce: 1,
|
||||
};
|
||||
|
||||
let key_to_sign_transaction = account.key_holder.get_pub_account_signing_key();
|
||||
@ -962,6 +956,7 @@ impl NodeCore {
|
||||
pub async fn send_public_native_token_transfer(
|
||||
&self,
|
||||
from: AccountAddress,
|
||||
nonce: u64,
|
||||
to: AccountAddress,
|
||||
balance_to_move: u64,
|
||||
) -> Result<SendTxResponse, ExecutionFailureKind> {
|
||||
@ -989,6 +984,7 @@ impl NodeCore {
|
||||
sc_core::transaction_payloads_tools::create_public_transaction_payload(
|
||||
serde_json::to_vec(&PublicNativeTokenSend {
|
||||
from,
|
||||
nonce,
|
||||
to,
|
||||
balance_to_move,
|
||||
})
|
||||
@ -998,7 +994,6 @@ impl NodeCore {
|
||||
secret_r,
|
||||
sc_addr,
|
||||
state_changes,
|
||||
1,
|
||||
);
|
||||
tx.log();
|
||||
|
||||
@ -1555,7 +1550,6 @@ impl NodeCore {
|
||||
secret_r,
|
||||
sc_addr,
|
||||
state_changes,
|
||||
nonce: 1,
|
||||
};
|
||||
let key_to_sign_transaction = account.key_holder.get_pub_account_signing_key();
|
||||
|
||||
|
||||
@ -15,7 +15,6 @@ pub fn create_public_transaction_payload(
|
||||
secret_r: [u8; 32],
|
||||
sc_addr: String,
|
||||
state_changes: (serde_json::Value, usize),
|
||||
nonce: u64,
|
||||
) -> TransactionBody {
|
||||
TransactionBody {
|
||||
tx_kind: TxKind::Public,
|
||||
@ -32,7 +31,6 @@ pub fn create_public_transaction_payload(
|
||||
secret_r,
|
||||
sc_addr,
|
||||
state_changes,
|
||||
nonce,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -221,22 +221,24 @@ impl SequencerCore {
|
||||
ref utxo_commitments_created_hashes,
|
||||
ref nullifier_created_hashes,
|
||||
execution_input,
|
||||
nonce,
|
||||
..
|
||||
} = mempool_tx.auth_tx.transaction().body();
|
||||
|
||||
let tx_hash = *mempool_tx.auth_tx.hash();
|
||||
|
||||
// Nonce check
|
||||
let signer_addres = address::from_public_key(&mempool_tx.auth_tx.transaction().public_key);
|
||||
if self.store.acc_store.get_account_nonce(&signer_addres) != *nonce {
|
||||
return Err(TransactionMalformationErrorKind::NonceMismatch { tx: tx_hash });
|
||||
}
|
||||
|
||||
//Balance move
|
||||
if let Ok(native_transfer_action) =
|
||||
serde_json::from_slice::<PublicNativeTokenSend>(execution_input)
|
||||
{
|
||||
// Nonce check
|
||||
let signer_addres =
|
||||
address::from_public_key(&mempool_tx.auth_tx.transaction().public_key);
|
||||
if self.store.acc_store.get_account_nonce(&signer_addres)
|
||||
!= native_transfer_action.nonce
|
||||
{
|
||||
return Err(TransactionMalformationErrorKind::NonceMismatch { tx: tx_hash });
|
||||
}
|
||||
|
||||
let from_balance = self
|
||||
.store
|
||||
.acc_store
|
||||
@ -406,7 +408,6 @@ mod tests {
|
||||
secret_r: [0; 32],
|
||||
sc_addr: "sc_addr".to_string(),
|
||||
state_changes: (serde_json::Value::Null, 0),
|
||||
nonce: 0,
|
||||
};
|
||||
Transaction::new(body, SignaturePrivateKey::random(&mut rng))
|
||||
}
|
||||
@ -422,6 +423,7 @@ mod tests {
|
||||
|
||||
let native_token_transfer = PublicNativeTokenSend {
|
||||
from,
|
||||
nonce,
|
||||
to,
|
||||
balance_to_move,
|
||||
};
|
||||
@ -441,7 +443,6 @@ mod tests {
|
||||
secret_r: [0; 32],
|
||||
sc_addr: "sc_addr".to_string(),
|
||||
state_changes: (serde_json::Value::Null, 0),
|
||||
nonce,
|
||||
};
|
||||
Transaction::new(body, signing_key)
|
||||
}
|
||||
|
||||
@ -95,7 +95,6 @@ mod tests {
|
||||
secret_r: Default::default(),
|
||||
sc_addr: Default::default(),
|
||||
state_changes: Default::default(),
|
||||
nonce: 1,
|
||||
};
|
||||
let tx = Transaction::new(body, SignaturePrivateKey::from_slice(&[1; 32]).unwrap());
|
||||
(
|
||||
|
||||
@ -288,7 +288,6 @@ mod tests {
|
||||
secret_r: Default::default(),
|
||||
sc_addr: Default::default(),
|
||||
state_changes: Default::default(),
|
||||
nonce: 0,
|
||||
};
|
||||
let tx = Transaction::new(tx_body, SignaturePrivateKey::from_slice(&[1; 32]).unwrap());
|
||||
|
||||
@ -500,7 +499,7 @@ mod tests {
|
||||
let request = serde_json::json!({
|
||||
"jsonrpc": "2.0",
|
||||
"method": "get_transaction_by_hash",
|
||||
"params": { "hash": "b70b861373b99a509b27a0c61d6340762c9a0c0026520921d92218712efc3bca"},
|
||||
"params": { "hash": "a5210ef33912a448cfe6eda43878c144df81f7bdf51d19b5ddf97be11806a6ed"},
|
||||
"id": 1
|
||||
});
|
||||
|
||||
@ -524,10 +523,9 @@ mod tests {
|
||||
"tx_kind": "Shielded",
|
||||
"utxo_commitments_created_hashes": [],
|
||||
"utxo_commitments_spent_hashes": [],
|
||||
"nonce": 0,
|
||||
},
|
||||
"public_key": "3056301006072A8648CE3D020106052B8104000A034200041B84C5567B126440995D3ED5AABA0565D71E1834604819FF9C17F5E9D5DD078F70BEAF8F588B541507FED6A642C5AB42DFDF8120A7F639DE5122D47A69A8E8D1",
|
||||
"signature": "50AEACE783026D0B6CE221474A928A05A99E2942246DF1C79162C08175F80744746E4A00D6C7F70BDBCF6D7B3668334396B9378FB0F58DC2E8A9B13F3BF001C4"
|
||||
"signature": "A4E0D6A25BE829B006124F0DFD766427967AA3BEA96C29219E79BB2CC871891F384748C27E28718A4450AA78709FBF1A57DB33BCD575A2C819D2A439C2D878E6"
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user