Skip to content
This repository has been archived by the owner on Mar 23, 2021. It is now read-only.

Ethereum HTLCs log wrong messages #30

Closed
bonomat opened this issue Jan 15, 2020 · 0 comments · Fixed by #37
Closed

Ethereum HTLCs log wrong messages #30

bonomat opened this issue Jan 15, 2020 · 0 comments · Fixed by #37
Assignees

Comments

@bonomat
Copy link
Member

bonomat commented Jan 15, 2020

Problem

It seems like both HTLCs for Ethereum (Ether and Erc20) do not print the keccak256 of the proposed messages:

Code claims:

redeem:
log1(0, 32, 0xB8CAC300E37F03AD332E581DEA21B2F0B84EAAADC184A295FEF71E81F44A7413) // log keccak256(Redeemed(<secret>))
selfdestruct(0x3000000000000000000000000000000000000003)
refund:
log1(0, 0, 0x5D26862916391BF49478B2F5103B0720A842B45EF145A268F2CD1FB2AED55178) // log keccak256(Refunded())
selfdestruct(0x4000000000000000000000000000000000000004)

However, I was not able to reproduce the same hash for neither of the 2:

Tested with web3js and http://emn178.github.io/online-tools/keccak_256.html

> var Web3 = require('web3');
> console.log(web3.utils.soliditySha3({ type: 'string', value: "Refunded"}))
0x51e3aa8099bfbb7b9fee513355876c379349ac1dca81cd9eb4e0653e784ff985
undefined
> console.log(web3.utils.soliditySha3({ type: 'string', value: "Refunded()"}))
0x8616bbbbad963e4e65b1366f1d75dfb63f9e9704bbbf91fb01bec70849906cf7

Proposal

  • Regenerate it properly 😬. To simplify it, remove () which are meant to be included, i.e. keccak256("Refunded")
  • Provide web3js snippet in code for reproducibility
@bonomat bonomat added the bug label Jan 15, 2020
@bonomat bonomat self-assigned this Jan 20, 2020
bors bot added a commit that referenced this issue Jan 20, 2020
37: Ethereum HTLCs revert and return error message r=mergify[bot] a=bonomat

Resolves #8 
Resolves #30

We decided to go for `revert` with a reason (return data). 

* the data returned by `revert` can be shown in etherscan
* a transaction failed due to `revert` will be shown as `failed` in metamask 
* we live with the fact that a contract calling this HTLC can't recover from a failure within this contract
* return a string message. A client should be able to transform the returned bytes into text now :)

Note: I also updated solc to 0.5.16. 
Version 0.6.x has breaking changes and a simple upgrade did not work.

 --> Follow-up ticket: 
comit-network/RFCs#135

Co-authored-by: Philipp Hoenisch <philipp@hoenisch.at>
@bors bors bot closed this as completed in #37 Jan 21, 2020
@bors bors bot closed this as completed in 3bf0133 Jan 21, 2020
@bonomat bonomat added this to the Sprint 26 🏉🎇 milestone Jan 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant