Skip to content

Commit

Permalink
Remove contract_account_id and method_name from hashchain computation.
Browse files Browse the repository at this point in the history
  • Loading branch information
Casuso committed Jul 18, 2023
1 parent 735b40f commit 2d13411
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 259 deletions.
1 change: 0 additions & 1 deletion engine-standalone-storage/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ rocksdb.workspace = true
postgres.workspace = true
serde = { workspace = true, features = ["std"] }
serde_json = { workspace = true, features = ["std"] }
strum.workspace = true

[features]
default = ["snappy", "lz4", "zstd", "zlib"]
Expand Down
6 changes: 1 addition & 5 deletions engine-standalone-storage/src/sync/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ use crate::engine_state::EngineStateAccess;
use crate::{BlockMetadata, Diff, Storage};
use types::{Message, TransactionKind, TransactionMessage};

use self::types::InnerTransactionKind;

pub fn consume_message<M: ModExpAlgorithm + 'static>(
storage: &mut Storage,
message: Message,
Expand Down Expand Up @@ -495,7 +493,6 @@ fn non_submit_execute<'db, M: ModExpAlgorithm + 'static>(

let mut blockchain_hashchain = BlockchainHashchain::new(
prev.chain_id,
env.current_account_id.as_bytes().to_vec(),
args.block_height + 1,
args.block_hashchain,
);
Expand Down Expand Up @@ -530,15 +527,14 @@ fn update_hashchain<'db>(

let mut blockchain_hashchain = hashchain_state?;

let method_name = InnerTransactionKind::from(transaction).to_string();
let input = get_input(transaction)?;
let (output, log_bloom) = get_output_and_log_bloom(result)?;

if block_height > blockchain_hashchain.get_current_block_height() {
blockchain_hashchain.move_to_block(block_height)?;
}

blockchain_hashchain.add_block_tx(block_height, &method_name, &input, &output, &log_bloom)?;
blockchain_hashchain.add_block_tx(block_height, &input, &output, &log_bloom)?;

Ok(hashchain::storage::set_state(io, &blockchain_hashchain)?)
}
Expand Down
118 changes: 0 additions & 118 deletions engine-standalone-storage/src/sync/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use aurora_engine_types::{
H256, U256,
};
use std::borrow::Cow;
use strum::{Display, EnumString};

/// Type describing the format of messages sent to the storage layer for keeping
/// it in sync with the blockchain.
Expand Down Expand Up @@ -402,123 +401,6 @@ impl TransactionKind {
}
}

#[derive(Display, EnumString)]
pub enum InnerTransactionKind {
#[strum(serialize = "submit")]
Submit,
#[strum(serialize = "submit_with_args")]
SubmitWithArgs,
#[strum(serialize = "call")]
Call,
#[strum(serialize = "pause_precompiles")]
PausePrecompiles,
#[strum(serialize = "resume_precompiles")]
ResumePrecompiles,
#[strum(serialize = "deploy_code")]
Deploy,
#[strum(serialize = "deploy_erc20_token")]
DeployErc20,
#[strum(serialize = "ft_on_transfer")]
FtOnTransfer,
#[strum(serialize = "deposit")]
Deposit,
#[strum(serialize = "ft_transfer_call")]
FtTransferCall,
#[strum(serialize = "finish_deposit")]
FinishDeposit,
#[strum(serialize = "ft_resolve_transfer")]
ResolveTransfer,
#[strum(serialize = "ft_transfer")]
FtTransfer,
#[strum(serialize = "withdraw")]
Withdraw,
#[strum(serialize = "storage_deposit")]
StorageDeposit,
#[strum(serialize = "storage_unregister")]
StorageUnregister,
#[strum(serialize = "storage_withdraw")]
StorageWithdraw,
#[strum(serialize = "set_owner")]
SetOwner,
#[strum(serialize = "set_paused_flags")]
SetPausedFlags,
#[strum(serialize = "set_upgrade_delay_blocks")]
SetUpgradeDelayBlocks,
#[strum(serialize = "register_relayer")]
RegisterRelayer,
#[strum(serialize = "refund_on_error")]
RefundOnError,
#[strum(serialize = "set_eth_connector_contract_data")]
SetConnectorData,
#[strum(serialize = "new_eth_connector")]
NewConnector,
#[strum(serialize = "new")]
NewEngine,
#[strum(serialize = "factory_update")]
FactoryUpdate,
#[strum(serialize = "factory_update_address_version")]
FactoryUpdateAddressVersion,
#[strum(serialize = "factory_set_wnear_address")]
FactorySetWNearAddress,
#[strum(serialize = "fund_xcc_sub_account")]
FundXccSubAccound,
#[strum(serialize = "pause_contract")]
PauseContract,
#[strum(serialize = "resume_contract")]
ResumeContract,
#[strum(serialize = "start_hashchain")]
StartHashchain,
Unknown,
}

/// Used to make sure `InnerTransactionKind` is kept in sync with `TransactionKind`
impl From<TransactionKind> for InnerTransactionKind {
fn from(tx: TransactionKind) -> Self {
Self::from(&tx)
}
}

/// Used to make sure `InnerTransactionKind` is kept in sync with `TransactionKind`
impl From<&TransactionKind> for InnerTransactionKind {
fn from(tx: &TransactionKind) -> Self {
match tx {
TransactionKind::Submit(_) => Self::Submit,
TransactionKind::SubmitWithArgs(_) => Self::SubmitWithArgs,
TransactionKind::Call(_) => Self::Call,
TransactionKind::PausePrecompiles(_) => Self::PausePrecompiles,
TransactionKind::ResumePrecompiles(_) => Self::ResumePrecompiles,
TransactionKind::Deploy(_) => Self::Deploy,
TransactionKind::DeployErc20(_) => Self::DeployErc20,
TransactionKind::FtOnTransfer(_) => Self::FtOnTransfer,
TransactionKind::Deposit(_) => Self::Deposit,
TransactionKind::FtTransferCall(_) => Self::FtTransferCall,
TransactionKind::FinishDeposit(_) => Self::FinishDeposit,
TransactionKind::ResolveTransfer(_, _) => Self::ResolveTransfer,
TransactionKind::FtTransfer(_) => Self::FtTransfer,
TransactionKind::Withdraw(_) => Self::Withdraw,
TransactionKind::StorageDeposit(_) => Self::StorageDeposit,
TransactionKind::StorageUnregister(_) => Self::StorageUnregister,
TransactionKind::StorageWithdraw(_) => Self::StorageWithdraw,
TransactionKind::SetOwner(_) => Self::SetOwner,
TransactionKind::SetPausedFlags(_) => Self::SetPausedFlags,
TransactionKind::RegisterRelayer(_) => Self::RegisterRelayer,
TransactionKind::RefundOnError(_) => Self::RefundOnError,
TransactionKind::SetConnectorData(_) => Self::SetConnectorData,
TransactionKind::NewConnector(_) => Self::NewConnector,
TransactionKind::NewEngine(_) => Self::NewEngine,
TransactionKind::FactoryUpdate(_) => Self::FactoryUpdate,
TransactionKind::FactoryUpdateAddressVersion(_) => Self::FactoryUpdateAddressVersion,
TransactionKind::FactorySetWNearAddress(_) => Self::FactorySetWNearAddress,
TransactionKind::FundXccSubAccound(_) => Self::FundXccSubAccound,
TransactionKind::Unknown => Self::Unknown,
TransactionKind::SetUpgradeDelayBlocks(_) => Self::SetUpgradeDelayBlocks,
TransactionKind::PauseContract => Self::PauseContract,
TransactionKind::ResumeContract => Self::ResumeContract,
TransactionKind::StartHashchain(_) => Self::StartHashchain,
}
}
}

/// This data type represents `TransactionMessage` above in the way consistent with how it is
/// stored on disk (in the DB). This type implements borsh (de)serialization. The purpose of
/// having a private struct for borsh, which is separate from the main `TransactionMessage`
Expand Down
1 change: 0 additions & 1 deletion engine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ bitflags.workspace = true
ethabi.workspace = true
evm.workspace = true
fixed-hash.workspace = true
function_name = "0.3.0"
hex.workspace = true
impl-serde.workspace = true
rlp.workspace = true
Expand Down
Loading

0 comments on commit 2d13411

Please sign in to comment.