mojtaba-eshghie / HighGuard

The runtime monitoring tool for smart contracts business logic.
https://dl.acm.org/doi/abs/10.1145/3691620.3695356
MIT License
6 stars 2 forks source link

Create smart contract oracle for exchange rate lookup #121

Closed hansstammler closed 5 months ago

hansstammler commented 5 months ago

Create a smart contract oracle for cross-chain exchange rate lookup, should have some exploitable flaw

Alter currently existing router contracts to consult this oracle.

hansstammler commented 5 months ago

Hi @mojtaba-eshghie

I have added a bridge using an oracle contract. When pulling recent commits from main I can no longer run the test sequence where monitors are used, in the old or new implementation. I assume this is due to a file having moved, but I am unsure how to fix this, would appreciate advice.

branch

hans@DESKTOP-RNS9M5A:/mnt/e/GitHub/HighGuard$ node CI/setup-cross-chain.js
...
2024-06-12 21:52:10 [info]: LINE 104 monitor
2024-06-12 21:52:10 [debug]:  Trying to execute eth_deposit
2024-06-12 21:52:10 [debug]:  LINE 52
2024-06-12 21:52:10 [debug]: current requestbody.DataXML: undefined
2024-06-12 21:52:10 [debug]:  LINE 67
2024-06-12 21:52:10 [debug]: nextEventAddress: https://repository.dcrgraphs.net/api/graphs/1823056/sims/2014582/events/eth_deposit
2024-06-12 21:52:10 [info]:   Response data: ""
2024-06-12 21:52:10 [info]:   Response status: 204
2024-06-12 21:52:10 [info]:   Response headers: {"server":"Microsoft-IIS/10.0","www-authenticate":"Basic","x-powered-by":"ASP.NET","date":"Wed, 12 Jun 2024 19:52:10 GMT","connection":"close"}
2024-06-12 21:52:10 [debug]: This time, violates is: false
2024-06-12 21:52:10 [debug]: The executed dcr activities are: [{"name":"eth_deposit","time":"2024-06-12T19:52:10.185Z","violation":false}]
/mnt/e/GitHub/HighGuard/node_modules/solc/soljson.js:133
    process["on"]("unhandledRejection", function (reason) { throw reason; });
                                                            ^

Error: ENOENT: no such file or directory, open 'results/EthRouter.md'
    at Object.openSync (node:fs:590:3)
    at Object.writeFileSync (node:fs:2202:35)
    at Monitor.writeMarkdownFile (/mnt/e/GitHub/HighGuard/monitor/monitor.js:178:8)
    at Monitor.handleContractEvent (/mnt/e/GitHub/HighGuard/monitor/monitor.js:124:12)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: 'results/EthRouter.md'
}
mojtaba-eshghie commented 5 months ago

Hi @hansstammler,

It should be because of lack of a results folder in the project root. This will be fixed in the next merge.