2020 TypeVar ,
2121 Union ,
2222)
23- from uuid import UUID
2423
2524import rlp
2625
@@ -886,9 +885,9 @@ def __call__(self, computation: 'ComputationAPI') -> None:
886885 def as_opcode (cls : Type [T ],
887886 logic_fn : Callable [['ComputationAPI' ], None ],
888887 mnemonic : str ,
889- gas_cost : int ) -> Type [ T ] :
888+ gas_cost : int ) -> T :
890889 """
891- Class factory method for turning vanilla functions into Opcode classes .
890+ Class factory method for turning vanilla functions into Opcodes .
892891 """
893892 ...
894893
@@ -1769,6 +1768,16 @@ def state_root(self) -> Hash32:
17691768 """
17701769 ...
17711770
1771+ @state_root .setter
1772+ def state_root (self , value : Hash32 ) -> None :
1773+ """
1774+ Force-set the state root hash.
1775+ """
1776+ # See: https://github.com/python/mypy/issues/4165
1777+ # Since we can't also decorate this with abstract method we want to be
1778+ # sure that the setter doesn't actually get used as a noop.
1779+ raise NotImplementedError
1780+
17721781 @abstractmethod
17731782 def has_root (self , state_root : bytes ) -> bool :
17741783 """
@@ -1935,6 +1944,22 @@ def commit(self, checkpoint: JournalDBCheckpoint) -> None:
19351944 """
19361945 ...
19371946
1947+ @abstractmethod
1948+ def lock_changes (self ) -> None :
1949+ """
1950+ Locks in changes across all accounts' storage databases.
1951+
1952+ This is typically used at the end of a transaction, to make sure that
1953+ a revert doesn't roll back through the previous transaction, and to
1954+ be able to look up the "original" value of any account storage, where
1955+ "original" is the beginning of a transaction (instead of the beginning
1956+ of a block).
1957+
1958+ See :meth:`eth.abc.AccountStorageDatabaseAPI.lock_changes` for
1959+ what is called on each account's storage database.
1960+ """
1961+ ...
1962+
19381963 @abstractmethod
19391964 def make_state_root (self ) -> Hash32 :
19401965 """
@@ -2275,7 +2300,7 @@ def account_is_empty(self, address: Address) -> bool:
22752300 # Access self._chaindb
22762301 #
22772302 @abstractmethod
2278- def snapshot (self ) -> Tuple [Hash32 , UUID ]:
2303+ def snapshot (self ) -> Tuple [Hash32 , JournalDBCheckpoint ]:
22792304 """
22802305 Perform a full snapshot of the current state.
22812306
@@ -2285,14 +2310,14 @@ def snapshot(self) -> Tuple[Hash32, UUID]:
22852310 ...
22862311
22872312 @abstractmethod
2288- def revert (self , snapshot : Tuple [Hash32 , UUID ]) -> None :
2313+ def revert (self , snapshot : Tuple [Hash32 , JournalDBCheckpoint ]) -> None :
22892314 """
22902315 Revert the VM to the state at the snapshot
22912316 """
22922317 ...
22932318
22942319 @abstractmethod
2295- def commit (self , snapshot : Tuple [Hash32 , UUID ]) -> None :
2320+ def commit (self , snapshot : Tuple [Hash32 , JournalDBCheckpoint ]) -> None :
22962321 """
22972322 Commit the journal to the point where the snapshot was taken. This
22982323 merges in any changes that were recorded since the snapshot.
@@ -2481,6 +2506,7 @@ class VirtualMachineAPI(ConfigurableAPI):
24812506 def __init__ (self ,
24822507 header : BlockHeaderAPI ,
24832508 chaindb : ChainDatabaseAPI ,
2509+ chain_context : ChainContextAPI ,
24842510 consensus_context : ConsensusContextAPI ) -> None :
24852511 """
24862512 Initialize the virtual machine.
0 commit comments