mirror of
https://github.com/logos-blockchain/lssa.git
synced 2026-01-08 00:03:09 +00:00
fix: account data public only for sequencer
This commit is contained in:
parent
8e987847ee
commit
54284be74b
@ -13,8 +13,6 @@ pub struct HelloRequest {}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct RegisterAccountRequest {
|
||||
pub nullifier_public_key: Vec<u8>,
|
||||
pub viewing_public_key: Vec<u8>,
|
||||
pub address: [u8; 32],
|
||||
}
|
||||
|
||||
|
||||
@ -7,7 +7,6 @@ use common::rpc_primitives::requests::{
|
||||
use common::transaction::Transaction;
|
||||
use common::{SequencerClientError, SequencerRpcError};
|
||||
use json::{SendTxRequest, SendTxResponse, SequencerRpcRequest, SequencerRpcResponse};
|
||||
use k256::elliptic_curve::group::GroupEncoding;
|
||||
use reqwest::Client;
|
||||
use serde_json::Value;
|
||||
|
||||
@ -94,8 +93,6 @@ impl SequencerClient {
|
||||
account: &Account,
|
||||
) -> Result<RegisterAccountResponse, SequencerClientError> {
|
||||
let acc_req = RegisterAccountRequest {
|
||||
nullifier_public_key: account.key_holder.nullifer_public_key.to_bytes().to_vec(),
|
||||
viewing_public_key: account.key_holder.viewing_public_key.to_bytes().to_vec(),
|
||||
address: account.address,
|
||||
};
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
use std::fmt::Display;
|
||||
|
||||
use accounts::account_core::AccountAddress;
|
||||
use anyhow::Result;
|
||||
use common::{
|
||||
block::{Block, HashableBlockData},
|
||||
@ -10,7 +11,7 @@ use common::{
|
||||
};
|
||||
use config::SequencerConfig;
|
||||
use mempool::MemPool;
|
||||
use sequencer_store::{accounts_store::AccountPublicData, SequecerChainStore};
|
||||
use sequencer_store::SequecerChainStore;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use transaction_mempool::TransactionMempool;
|
||||
|
||||
@ -209,11 +210,8 @@ impl SequencerCore {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn register_account(&mut self, acc_data: AccountPublicData) {
|
||||
self.store
|
||||
.acc_store
|
||||
.accounts
|
||||
.insert(acc_data.address, acc_data);
|
||||
pub fn register_account(&mut self, account_addr: AccountAddress) {
|
||||
self.store.acc_store.register_account(account_addr);
|
||||
}
|
||||
|
||||
///Produces new block from transactions in mempool
|
||||
@ -306,12 +304,14 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
fn common_setup(mut sequencer: &mut SequencerCore) {
|
||||
fn common_setup(sequencer: &mut SequencerCore) {
|
||||
let tx = create_dummy_transaction([12; 32], vec![[9; 32]], vec![[7; 32]], vec![[8; 32]]);
|
||||
let tx_mempool = TransactionMempool { tx };
|
||||
sequencer.mempool.push_item(tx_mempool);
|
||||
|
||||
sequencer.produce_new_block_with_mempool_transactions();
|
||||
sequencer
|
||||
.produce_new_block_with_mempool_transactions()
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@ -3,14 +3,23 @@ use serde::{Deserialize, Serialize};
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct AccountPublicData {
|
||||
pub(crate) struct AccountPublicData {
|
||||
pub balance: u64,
|
||||
pub address: AccountAddress,
|
||||
}
|
||||
|
||||
impl AccountPublicData {
|
||||
pub fn new(address: AccountAddress) -> Self {
|
||||
Self {
|
||||
balance: 0,
|
||||
address,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct SequencerAccountsStore {
|
||||
pub accounts: HashMap<AccountAddress, AccountPublicData>,
|
||||
accounts: HashMap<AccountAddress, AccountPublicData>,
|
||||
}
|
||||
|
||||
impl SequencerAccountsStore {
|
||||
@ -20,9 +29,9 @@ impl SequencerAccountsStore {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn register_account(&mut self, account_pub_data: AccountPublicData) {
|
||||
pub fn register_account(&mut self, account_addr: AccountAddress) {
|
||||
self.accounts
|
||||
.insert(account_pub_data.address, account_pub_data);
|
||||
.insert(account_addr, AccountPublicData::new(account_addr));
|
||||
}
|
||||
|
||||
pub fn unregister_account(&mut self, account_addr: AccountAddress) {
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
use actix_web::Error as HttpError;
|
||||
use sequencer_core::sequencer_store::accounts_store::AccountPublicData;
|
||||
use serde_json::Value;
|
||||
|
||||
use common::rpc_primitives::{
|
||||
@ -61,11 +60,7 @@ impl JsonHandler {
|
||||
{
|
||||
let mut acc_store = self.sequencer_state.lock().await;
|
||||
|
||||
acc_store.register_account(AccountPublicData::from_raw(
|
||||
acc_req.address,
|
||||
acc_req.nullifier_public_key,
|
||||
acc_req.viewing_public_key,
|
||||
));
|
||||
acc_store.register_account(acc_req.address);
|
||||
}
|
||||
|
||||
let helperstruct = RegisterAccountResponse {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user