I've been reading about the problem of front-running, especially in the Bancor case (https://hackernoon.com/front-running-bancor-in-150-lines-of-python-with-ethereum-api-d5e2bfd0d798). One proposed solution is using CREATE2 opcode (from EIP-86) - http://hackingdistributed.com/2017/08/28/submarine-sends/ But I am not sure I understand the whole concept, so it would be nice if someone could elaborate on this.

CREATE2 will compute the address of the newly created smart contract C as H(addrCreator, salt, codeC), where addrCreator is the address of the contract’s creator, salt is a 256-bit salt value chosen by the creator, and codeC is the EVM byte code of C’s initcode

So this basically means that you can "reserve" an address without revealing the contract there or what? And you can even send ether to it? CREATE2 then basically "turns" this seemingly random address into a smart contract?

The "submarine receiver" uses CREATE2 to instantiate a forwarder contract for himself but because the code is part of the hash he can just create the exact forwarding contract "submarine sender" had in mind (so both have to be synchronized in that sense)?

But that whole stuff doesn't happen atomically, does it? In the sense that when the nonce/salt is revealed the same block could also contain a "normal" send that would front-run the "submarine send"? Or that doesn't matter anymore because the timestamp of the original transaction that sent ether is used?

  • Or is the nonce (first) shared "out of band" (not on the blockchain)? – fiction Oct 14 '17 at 12:10
  • Ah that is also mentioned "The astute reader might notice that an important step is still missing in the above scheme: Contract does not check that the transaction that sent $val to A actually happened during the commit phase". Sorry. Still a different viewpoint on this would be helpful for me. zk-SNARKs would also solve this, right? – fiction Oct 14 '17 at 12:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.