@@ -670,97 +670,9 @@ inline evmc_status_code mstore8(StackTop stack, ExecutionState& state) noexcept
670
670
return EVMC_SUCCESS;
671
671
}
672
672
673
- inline evmc_status_code sload (StackTop stack, ExecutionState& state) noexcept
674
- {
675
- auto & x = stack.top ();
676
- const auto key = intx::be::store<evmc::bytes32>(x);
677
-
678
- if (state.rev >= EVMC_BERLIN &&
679
- state.host .access_storage (state.msg ->recipient , key) == EVMC_ACCESS_COLD)
680
- {
681
- // The warm storage access cost is already applied (from the cost table).
682
- // Here we need to apply additional cold storage access cost.
683
- constexpr auto additional_cold_sload_cost =
684
- instr::cold_sload_cost - instr::warm_storage_read_cost;
685
- if ((state.gas_left -= additional_cold_sload_cost) < 0 )
686
- return EVMC_OUT_OF_GAS;
687
- }
688
-
689
- x = intx::be::load<uint256>(state.host .get_storage (state.msg ->recipient , key));
690
-
691
- return EVMC_SUCCESS;
692
- }
693
-
694
- inline evmc_status_code sstore (StackTop stack, ExecutionState& state) noexcept
695
- {
696
- if (state.in_static_mode ())
697
- return EVMC_STATIC_MODE_VIOLATION;
698
-
699
- if (state.rev >= EVMC_ISTANBUL && state.gas_left <= 2300 )
700
- return EVMC_OUT_OF_GAS;
673
+ evmc_status_code sload (StackTop stack, ExecutionState& state) noexcept ;
701
674
702
- const auto key = intx::be::store<evmc::bytes32>(stack.pop ());
703
- const auto value = intx::be::store<evmc::bytes32>(stack.pop ());
704
-
705
- int cost = 0 ;
706
- if (state.rev >= EVMC_BERLIN &&
707
- state.host .access_storage (state.msg ->recipient , key) == EVMC_ACCESS_COLD)
708
- cost = instr::cold_sload_cost;
709
-
710
- const auto status = state.host .set_storage (state.msg ->recipient , key, value);
711
-
712
- if (state.rev <= EVMC_BYZANTIUM || state.rev == EVMC_PETERSBURG) // legacy
713
- {
714
- switch (status)
715
- {
716
- case EVMC_STORAGE_ASSIGNED:
717
- case EVMC_STORAGE_MODIFIED_DELETED:
718
- case EVMC_STORAGE_ADDED_DELETED:
719
- case EVMC_STORAGE_MODIFIED_RESTORED:
720
- case EVMC_STORAGE_MODIFIED:
721
- case EVMC_STORAGE_DELETED:
722
- cost = 5000 ;
723
- break ;
724
- case EVMC_STORAGE_ADDED:
725
- case EVMC_STORAGE_DELETED_ADDED:
726
- case EVMC_STORAGE_DELETED_RESTORED:
727
- cost = 20000 ;
728
- break ;
729
- }
730
- }
731
- else // net gas cost metering
732
- {
733
- switch (status)
734
- {
735
- case EVMC_STORAGE_ASSIGNED:
736
- case EVMC_STORAGE_DELETED_ADDED:
737
- case EVMC_STORAGE_DELETED_RESTORED:
738
- case EVMC_STORAGE_MODIFIED_DELETED:
739
- case EVMC_STORAGE_ADDED_DELETED:
740
- case EVMC_STORAGE_MODIFIED_RESTORED:
741
- if (state.rev >= EVMC_BERLIN)
742
- cost += instr::warm_storage_read_cost;
743
- else if (state.rev == EVMC_ISTANBUL)
744
- cost = 800 ;
745
- else
746
- cost = 200 ; // Constantinople
747
- break ;
748
- case EVMC_STORAGE_MODIFIED:
749
- case EVMC_STORAGE_DELETED:
750
- if (state.rev >= EVMC_BERLIN)
751
- cost += 5000 - instr::cold_sload_cost;
752
- else
753
- cost = 5000 ;
754
- break ;
755
- case EVMC_STORAGE_ADDED:
756
- cost += 20000 ;
757
- break ;
758
- }
759
- }
760
- if ((state.gas_left -= cost) < 0 )
761
- return EVMC_OUT_OF_GAS;
762
- return EVMC_SUCCESS;
763
- }
675
+ evmc_status_code sstore (StackTop stack, ExecutionState& state) noexcept ;
764
676
765
677
// / Internal jump implementation for JUMP/JUMPI instructions.
766
678
inline code_iterator jump_impl (ExecutionState& state, const uint256& dst) noexcept
0 commit comments