nimbus-eth1/nimbus/vm
Jamie Lokier 11f03a1846
Transaction: EVMC fix, `CREATE2` salt is a 256-bit blob not a number
This changes fixes a bug in `CREATE2` ops when used with EVMC.
Because it changes the salt type, it affects non-EVMC code as well.

The salt was passed through EVMC with the wrong byte order, although this went
unnoticed as the Nimbus host flipped the byte order before using it.

This was found when running Nimbus with third-party EVM,
["evmone"](https://github.com/ethereum/evmone).

There are different ways to remedy this.

If treated as a number, Nimbus EVM would byte-flip the value when calling EVMC,
then Nimbus host would flip the received value.  Finally, it would be flipped a
third time when generating the address in `generateSafeAddress`.  The first two
flips can be eliminated by negotiation (like other numbers), but there would
always be one flip.

As a bit pattern, Nimbus EVM would flip the same way it does when dealing with
hashes on the stack (e.g. with `getBlockHash`).  Nimbus host wouldn't flip at
all - and when using third-party EVMs there would be no flips in Nimbus.

Because this value is not for arithmetic, any bit pattern is valid, and there
shouldn't be any flips when using a third-party EVM, the bit-pattern
interpretation is favoured.  The only flip is done in Nimbus EVM (and might be
eliminated in an optimised version).

As suggested, we'll define a new "opaque 256 bits" type to hold this value.
(Similar to `Hash256`, but the salt isn't necessarily a hash.)

Signed-off-by: Jamie Lokier <jamie@shareable.org>
2021-08-05 10:35:52 +01:00
..
interpreter Transaction: EVMC fix, `CREATE2` salt is a 256-bit blob not a number 2021-08-05 10:35:52 +01:00
blake2b_f.nim implement EIP-152 2019-11-12 15:51:48 +00:00
blscurve.nim bump submodules 2021-01-20 11:50:07 +07:00
code_stream.nim reset explicit import paths for local modules 2021-04-01 12:53:22 +01:00
computation.nim Transaction: EVMC fix, `CREATE2` salt is a 256-bit blob not a number 2021-08-05 10:35:52 +01:00
evmc_api.nim preparation for London hard fork 2021-06-29 07:34:45 +07:00
evmc_helpers.nim Transaction: EVMC fix, `CREATE2` salt is a 256-bit blob not a number 2021-08-05 10:35:52 +01:00
evmc_host.nim Transaction: EVMC fix, `CREATE2` salt is a 256-bit blob not a number 2021-08-05 10:35:52 +01:00
interpreter.nim EVM: Remove `vm_forks` everywhere, use common forks list instead 2021-06-08 15:36:31 +01:00
interpreter_dispatch.nim Tracing: Remove some trace messages that occur a lot during sync 2021-07-27 14:12:55 +01:00
map_to_curve_g1.nim more eip2537 cleanup 2020-12-02 15:15:58 +07:00
memory.nim reset explicit import paths for local modules 2021-04-01 12:53:22 +01:00
message.nim reset explicit import paths for local modules 2021-04-01 12:53:22 +01:00
precompiles.nim Tracing: Remove some trace messages that occur a lot during sync 2021-07-27 14:12:55 +01:00
stack.nim reset explicit import paths for local modules 2021-04-01 12:53:22 +01:00
state.nim fix CI failing 2021-08-05 12:27:14 +07:00
state_transactions.nim EIP-3529: Remove the SELFDESTRUCT refund. 2021-06-29 07:37:17 +07:00
transaction_tracer.nim reset explicit import paths for local modules 2021-04-01 12:53:22 +01:00
types.nim EVM: Remove `vm_forks` everywhere, use common forks list instead 2021-06-08 15:36:31 +01:00