dia-oracle-anchor's People
dia-oracle-anchor's Issues
[medium severity] Split into "view" and "modify" traits.
From the perspective of another contract that will be using the oracle data, it will have to add it (the oracle contract) as its dependency - ink_as_dependency
feature in Cargo.toml
- in its current state, the whole contract will be "pulled in" as dependency, including the "setters", all events etc.
You can consider splitting the interface into two traits - "getters" and "setters" - which would enable users to depend on just part of the interface.
[high severity] Owner/update of the price
Looking at the code, it's clear that only an "owner" or an "updater" can change the state of the Oracle. Access is based on the comparison of caller's public key (account ID).
This means that the design has a single point of failure which can lead to number of problems:
- if that key is lost or binary/process/machine that updates the prices goes offline - the Oracle stops updating.
- if single key is compromised the Oracle can get updated with wrong prices, cause liquidations or other problems
Do you plan on using a multisignature account here?
Example usage
Please add an example usage of the Oracle contract - i.e. another contract that reads the feeds.
[low severity] Indexing price field
Why did you decide to index price
field in the event here https://github.com/diadata-org/dia-oracle-anchor/blob/main/contracts/lib.rs#L36 ?
Hardcoded precision
In line https://github.com/diadata-org/dia-oracle-anchor/blob/main/contracts/lib.rs#L108
you return precision from a function. The number is never used, can you explain what is it for? If it's required to stay, please extract to a const
and add appropriate comments.
No CI
There is no continuous integration set up for this repo and it should be. You can't even tell if code is compiling or tests are passing after new changes are made to the contracts.
[high severity] Upgradeability of the contract
If we want to evolve the contract in the future, without changing its address, contract needs to be upgradable.
There are various patterns available:
- proxy
- diamond pattern
set_code_hash
The first two require custom code (provided by library like OpenBrush) while the last one is built-in into ink! itself.
We, as Aleph Zero team, are of opinion that we should stick with set_code_hash
as it seems like the safest of the approaches (OB hasn't been audited yet and has a track record of various patterns not working as advertised - especially the upgradeability ones).
For reference, you can check this file https://github.com/Cardinal-Cryptography/aleph-node/blob/main/contracts/simple_dex/lib.rs
Note usage of Lazy<_>
in the pattern as below:
struct MyContractData {
a: u64,
b: Mapping<String, u64>,
}
#[ink(storage)]
#[derive(Storage)]
struct MyContract {
data: Lazy<MyContractData, ManualKey<_>>,
}
This decouples contract's data from its logic and allows for upgrading the latter w/o need to migrate the data.
[high severity]: Usage of `Vec`.
In https://github.com/diadata-org/dia-oracle-anchor/blob/main/contracts/lib.rs#L13 you're using Vec<(u64, u128)>
as a value in the Mapping
-- ink vectors don't work the same way they do in Solidity - they're (de)serialized as one big blog and stored as such. They should never be used for collections that can grow uncontrollably. Here, the vector represents price change over time and data is appended to the end of it. In the extreme case, you will grow vector so big that it won't fit into VM's sandboxed memory anymore and the contract will be bricked (until someone clears its storage via upgrade of some sort).
I'm not suggesting any specific alternative to this on purpose - leaving that decision to you. If you need help, reach out.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.