Skip to content

Commit 7e09e71

Browse files
committed
Some update from reviewing process.
1 parent ae25c5e commit 7e09e71

File tree

1 file changed

+20
-21
lines changed

1 file changed

+20
-21
lines changed

linera-execution/src/evm/revm.rs

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ enum RuntimePrecompile {
316316

317317
fn get_precompile_output(output: Vec<u8>, gas_limit: u64) -> InterpreterResult {
318318
// The gas usage is set to `gas_limit` and no spending is being done on it.
319-
// This means that for REVM, it looks like the precompile call costs nothing.
319+
// This means that for Revm, it looks like the precompile call costs nothing.
320320
// This is because the costs of the EVM precompile calls is accounted for
321321
// separately in Linera.
322322
let output = Bytes::from(output);
@@ -492,15 +492,14 @@ fn get_evm_destination<Runtime: ContractRuntime>(
492492
account: Account,
493493
) -> Result<Option<Address>, ExecutionError> {
494494
let mut runtime = context.db().0.runtime.lock().unwrap();
495-
let chain_id = runtime.chain_id()?;
496-
if chain_id == account.chain_id {
495+
if runtime.chain_id()? != account.chain_id {
497496
return Ok(None);
498497
}
499498
Ok(account.owner.to_evm_address())
500499
}
501500

502501
/// If we are using the `None` case of `fn call` and `fn create` then the transfer
503-
/// of ethers is done by REVM. On the other hand, if we are managing the call/create
502+
/// of ethers is done by Revm. On the other hand, if we are managing the call/create
504503
/// by hand, then we need to do the transfers ourselves.
505504
fn revm_transfer<Runtime: ContractRuntime>(
506505
context: &mut Ctx<'_, Runtime>,
@@ -846,7 +845,7 @@ impl<Runtime: ContractRuntime> CallInterceptorContract<Runtime> {
846845
Ok(ApplicationId::from(&application_description))
847846
}
848847

849-
/// Publishes the `input`.
848+
/// Publishes the `inputs`.
850849
fn publish_create_inputs(
851850
context: &mut Ctx<'_, Runtime>,
852851
inputs: &mut CreateInputs,
@@ -862,7 +861,7 @@ impl<Runtime: ContractRuntime> CallInterceptorContract<Runtime> {
862861
/// function can have some error case which are not supported
863862
/// in `fn create`, we call a `fn create_or_fail` that can
864863
/// return errors.
865-
/// When the database runtime is created, the REVM contract
864+
/// When the database runtime is created, the Evm contract
866865
/// may or may not have been created. Therefore, at startup
867866
/// we have `is_revm_instantiated = false`. That boolean
868867
/// can be updated after `set_is_initialized`.
@@ -909,7 +908,7 @@ impl<Runtime: ContractRuntime> CallInterceptorContract<Runtime> {
909908
/// constructor argument.
910909
/// * What needs to be determined is the deployed bytecode.
911910
/// This is stored in the AccountInfo entry. It is
912-
/// the result of the execution by the REVM interpreter
911+
/// the result of the execution by the Revm interpreter
913912
/// and there is no way to do it without doing the execution.
914913
///
915914
/// The strategy for creating the contract is thus:
@@ -926,22 +925,22 @@ impl<Runtime: ContractRuntime> CallInterceptorContract<Runtime> {
926925
/// This is simply not part of create/create2 in the EVM.
927926
/// * That call to `create_application` leads to a creation of
928927
/// a new contract and so a call to `fn create_or_fail` in
929-
/// another instance of REVM.
928+
/// another instance of Revm.
930929
/// * When returning the `CreateOutcome`, we need to have the
931930
/// deployed bytecode. This is implemented through a special
932931
/// call to `GET_DEPLOYED_BYTECODE_SELECTOR`. This is done
933932
/// with an `execute_operation`.
934-
/// * Data is put together as a `Some(...)` which tells REVM
933+
/// * Data is put together as a `Some(...)` which tells Revm
935934
/// that it does not need to execute the bytecode since the
936935
/// output is given to it.
937936
///
938937
/// The fact that the creation of a contract can be done in a
939-
/// parallel way to transfering native tokens to the contract
938+
/// parallel way to transferring native tokens to the contract
940939
/// being created requires us to handle this as well.
941940
/// * We cannot do a transfer from the calling contract with
942-
/// the deposit_funds because we would not have the right
941+
/// `deposit_funds` because we would not have the right
943942
/// to make the transfer.
944-
/// * Therefore, we have to do the transfer before the
943+
/// * Therefore, we have to do the transfer before
945944
/// `create_application`. This forces us to know the
946945
/// `application_id` before it is created. This is done
947946
/// by building the `ApplicationDescription` and its hash.
@@ -960,7 +959,7 @@ impl<Runtime: ContractRuntime> CallInterceptorContract<Runtime> {
960959
if inputs.value != U256::ZERO {
961960
// decrease the balance of the contract address by the expected amount.
962961
// We put the tokens in FAUCET_ADDRESS because we cannot transfer to
963-
// a contract that do not yet exist.
962+
// a contract that does not yet exist.
964963
// It is a common construction. We can see that in ERC20 contract code
965964
// for example for burning and minting.
966965
revm_transfer(
@@ -1022,17 +1021,17 @@ impl<Runtime: ContractRuntime> CallInterceptorContract<Runtime> {
10221021
/// --- Call to the PRECOMPILE smart contract.
10231022
/// --- Call to other EVM smart contract
10241023
///
1025-
/// The first case is handled by the using the REVM. This is
1024+
/// The first case is handled by the using Revm. This is
10261025
/// when we call this contract.
10271026
///
1028-
/// Calling the precompile is also handled by using REVM
1027+
/// Calling the precompile is also handled by using Revm
10291028
/// which would then use specific code for that purpose.
10301029
///
1031-
/// Calling other EVM contracts is handled here and we have
1032-
/// to produce the `Some(_)` as output. Note that in the EVM
1033-
/// transfering ethers is the same as calling a function.
1030+
/// Calling other Evm contracts is handled here and we have
1031+
/// to produce `Some(_)` as output. Note that in the Evm
1032+
/// transferring ethers is the same as calling a function.
10341033
///
1035-
/// In Linera, transfering lineras and calling a function are
1034+
/// In Linera, transferring native tokens and calling a function are
10361035
/// different operations. However, the block is accepted
10371036
/// completely or not at all. Therefore, we can ensure the
10381037
/// atomicity of the operations.
@@ -1082,7 +1081,7 @@ impl<Runtime: ContractRuntime> CallInterceptorContract<Runtime> {
10821081
//
10831082
// So, the correct way is instead to test the existence of the application
10841083
// given the application_id. So, we would need following function in BaseRuntime:
1085-
// fn is_existing_application(&mut self, application_id: ApplicationId)
1084+
// fn has_trivial_storage(&mut self, application: ApplicationId)
10861085
// -> Result<bool, ExecutionError>;
10871086
let authenticated = true;
10881087
let result = {
@@ -1151,7 +1150,7 @@ impl<Runtime: ServiceRuntime> CallInterceptorService<Runtime> {
11511150
/// function can have some error case which are not supported
11521151
/// in `fn create`, we call a `fn create_or_fail` that can
11531152
/// return errors.
1154-
/// When the database runtime is created, the REVM contract
1153+
/// When the database runtime is created, the Evm contract
11551154
/// may or may not have been created. Therefore, at startup
11561155
/// we have `is_revm_instantiated = false`. That boolean
11571156
/// can be updated after `set_is_initialized`.

0 commit comments

Comments
 (0)