Ref. https://github.com/neo-project/neo/issues/3300, port https://github.com/neo-project/neo/pull/3301 if needed.
Ref. neo-project/neo#3300, port neo-project/neo#3301 if needed.