I want to build an oracle similar to OmniBridge for xDai or Arbitrary Message Bridge but I am worried about how to make it secure.
It would seem such an oracle should be reliable, as long as there is a way to take the hash of a transaction and prove that it was included in a block, which in turn was mined on the "main blockchain". (That last part is subjective, but as long as we can prove enough block difficulty after the transaction, the smart contract calling the oracle can be satisfied). The components I need to verify all this are:
The Merkle Branch (or some other proof) that the transaction was mined in its Block
Some way to verify how many blocks were "legitimately" mined until we get to the hash of the "latest/top" block (which the oracle would just get from the blockchain nodes).
The person will provide the actual transaction parameters, and the transaction's hash would have to be computed again by the smart contract, to make sure it is the right hash.
Is 1, 2, 3 even possible? That's the question!
The idea is to "cash out" X amount of FOO tokens which were sent to a smart contract on the Ethereum mainnet and locked there. For example if someone sends corresponding X amount of xFOO tokens on the xDai chain, and this transaction is "confirmed" after a few blocks, then the person can call a method on the smart contract, and it will release X tokens to the same wallet EOA address that sent them.
Security analysis: Presumably, under a large enough blockchain like xDai, whether it's PoW or PoS, it should be secure, but if X is large enough, someone might want to fool the oracle network by mining more fake blocks on top and then "proving" that the transaction happened. I guess they can't really fool the oracle, though, because the ERC1677 token contract on xDai would roll back any transaction that didn't have enough balance. They'd have to fork the entire xDai network and mess up a lot in order to fake a transaction that violates the smart contract logic.
geth
node and related javascript scripts to manage it?