Skip to content

Commit

Permalink
Disable start iterative transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
Semen Medvedev committed Dec 16, 2024
1 parent 43ced94 commit a5f3f27
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 39 deletions.
3 changes: 3 additions & 0 deletions evm_loader/program/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,9 @@ pub enum Error {

#[error("Operator Balance - invalid address")]
OperatorBalanceInvalidAddress,

#[error("Maintenance mode")]
MaintenanceMode,
}

pub type Result<T> = std::result::Result<T, Error>;
Expand Down
79 changes: 40 additions & 39 deletions evm_loader/program/src/instruction/transaction_step.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,47 +16,48 @@ type EvmBackend<'a, 'r> = ExecutorState<'r, ProgramAccountStorage<'a>>;
type Evm<'a, 'r> = Machine<EvmBackend<'a, 'r>, NoopEventListener>;

pub fn do_begin<'a>(
accounts: AccountsDB<'a>,
mut storage: StateAccount<'a>,
gasometer: Gasometer,
_accounts: AccountsDB<'a>,
mut _storage: StateAccount<'a>,
_gasometer: Gasometer,
) -> Result<()> {
debug_print!("do_begin");

let account_storage = ProgramAccountStorage::new(accounts)?;

let origin = storage.trx_origin();

storage.trx().validate(origin, &account_storage)?;

// Increment origin nonce in the first iteration
// This allows us to run multiple iterative transactions from the same sender in parallel
// These transactions are guaranteed to start in a correct sequence
// BUT they finalize in an undefined order
let mut origin_account = account_storage.origin(origin, storage.trx())?;
origin_account.increment_revision(account_storage.rent(), account_storage.db())?;
origin_account.increment_nonce()?;

// Burn `gas_limit` tokens from the origin account
// Later we will mint them to the operator
// Remaining tokens are returned to the origin in the last iteration
let gas_limit_in_tokens = storage.trx().gas_limit_in_tokens()?;
origin_account.burn(gas_limit_in_tokens)?;

// Initialize EVM and serialize it to the Holder
let mut backend = ExecutorState::new(&account_storage);
let evm = Machine::new(storage.trx(), origin, &mut backend, None)?;

serialize_evm_state(&mut storage, &backend, &evm)?;

let (_, touched_accounts) = backend.deconstruct();
finalize(
0,
storage,
account_storage,
None,
gasometer,
touched_accounts,
)
return Err(Error::MaintenanceMode);

// let account_storage = ProgramAccountStorage::new(accounts)?;

// let origin = storage.trx_origin();

// storage.trx().validate(origin, &account_storage)?;

// // Increment origin nonce in the first iteration
// // This allows us to run multiple iterative transactions from the same sender in parallel
// // These transactions are guaranteed to start in a correct sequence
// // BUT they finalize in an undefined order
// let mut origin_account = account_storage.origin(origin, storage.trx())?;
// origin_account.increment_revision(account_storage.rent(), account_storage.db())?;
// origin_account.increment_nonce()?;

// // Burn `gas_limit` tokens from the origin account
// // Later we will mint them to the operator
// // Remaining tokens are returned to the origin in the last iteration
// let gas_limit_in_tokens = storage.trx().gas_limit_in_tokens()?;
// origin_account.burn(gas_limit_in_tokens)?;

// // Initialize EVM and serialize it to the Holder
// let mut backend = ExecutorState::new(&account_storage);
// let evm = Machine::new(storage.trx(), origin, &mut backend, None)?;

// serialize_evm_state(&mut storage, &backend, &evm)?;

// let (_, touched_accounts) = backend.deconstruct();
// finalize(
// 0,
// storage,
// account_storage,
// None,
// gasometer,
// touched_accounts,
// )
}

pub fn do_continue<'a>(
Expand Down

0 comments on commit a5f3f27

Please sign in to comment.