From 0d79bb6c56f4835ef9242cbad18a51ef86e77011 Mon Sep 17 00:00:00 2001 From: Noel Maersk Date: Tue, 10 Dec 2019 21:15:19 +0200 Subject: [PATCH] ABC: AccountDatabaseAPI's state_root made writable. AccountDB (from eth/db/account.py) has a setter for the `state_root` property, and `BaseState` (from eth/vm/state.py) forcibly sets the state root in its revert() function. This helps silence `mypy` error: eth/vm/state.py:170: error: Property "state_root" defined in "AccountDatabaseAPI" is read-only --- eth/abc.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/eth/abc.py b/eth/abc.py index 8232ffdf68..01ed86d5c9 100644 --- a/eth/abc.py +++ b/eth/abc.py @@ -1623,6 +1623,16 @@ def state_root(self) -> Hash32: """ ... + @state_root.setter + def state_root(self, value: Hash32) -> None: + """ + Force-set the state root hash. + """ + # See: https://github.com/python/mypy/issues/4165 + # Since we can't also decorate this with abstract method we want to be + # sure that the setter doesn't actually get used as a noop. + raise NotImplementedError + @abstractmethod def has_root(self, state_root: bytes) -> bool: """