Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix predictoor-pm#10: Build prototype 3 #1402

Closed
wants to merge 137 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
137 commits
Select commit Hold shift + click to select a range
c393258
PR for predictoor-pm#10
trentmc Apr 14, 2023
bb21775
add test_datatoken3.py. In this commit, it's a copy-and-paste of prot…
trentmc Apr 16, 2023
09d5a9b
tweak
trentmc Apr 16, 2023
9b64bda
first cut in test of OCEAN staking with DT
trentmc Apr 16, 2023
7a43c89
wip towards tests passing
trentmc Apr 16, 2023
97545c8
wip
trentmc Apr 16, 2023
9bab769
remove unneeded funcs
trentmc Apr 16, 2023
20828d6
towards my predictoor dev flow
trentmc Apr 16, 2023
3df6728
tweak
trentmc Apr 17, 2023
a4750d4
big change: use brownie to deploy Ocean contracts locally
trentmc Apr 17, 2023
1a73c54
Put contract deployment to ganache into a separate file. This allows …
trentmc Apr 17, 2023
1cb8279
Cleanup: deployer actually uses deployer key
trentmc Apr 17, 2023
7172fe6
bug fixes: (a) in deploy, explicit txs to add DT templates 2 & 3 to D…
trentmc Apr 17, 2023
bf260e2
bug fixes: (a) in deploy, explicit txs to add DT templates 2 & 3 to D…
trentmc Apr 17, 2023
2a80ce6
bug fix
trentmc Apr 17, 2023
dbb2709
Bug fix / now ready for template 3
trentmc Apr 17, 2023
011fbb1
(a) move creation of predictoor etc accounts until a bit later, to sp…
trentmc Apr 17, 2023
2ce0618
add run_create_exchange.py to easily demo an issue
trentmc Apr 17, 2023
732cf33
tweak deploy.py formatting
trentmc Apr 17, 2023
5411b0f
special (HACK) unit test for exchange
trentmc Apr 17, 2023
538e0dd
improve run_create_Exchange
trentmc Apr 17, 2023
2d13d4c
Add ERC721Factory to FactoryRouter
alexcos20 Apr 18, 2023
11e51a8
Update predictoor.md
trentmc Apr 19, 2023
8f471c8
Update predictoor.md
trentmc Apr 19, 2023
e2e9d70
Set template 3 id to 3
trizin Apr 21, 2023
ced0b8d
Add Datatoken3 to get_typed
trizin Apr 21, 2023
e521117
Formatting black
trizin Apr 21, 2023
0742800
Fixes
trizin Apr 21, 2023
8745fe7
Remove print
trizin Apr 21, 2023
bf2e96a
Moving on, fixes in test
trizin Apr 21, 2023
daaffb2
Update datatoken3 class
trizin Apr 21, 2023
bc59558
Mint OCEAN to predictoors
trizin Apr 21, 2023
76d72cb
Finalize prototype template
trizin Apr 21, 2023
27f45f0
Fin tests
trizin Apr 21, 2023
230a57f
Remove duplicate
trizin Apr 21, 2023
d5adf6e
tweak. proper install instructions for ganache
trentmc Apr 24, 2023
3ba27c4
link to ganache info
trentmc Apr 24, 2023
f4497c8
Remove thick docs at top of test. Put relevant info into GDoc
trentmc Apr 24, 2023
708378e
remove HACK for getting exchange working
trentmc Apr 24, 2023
e106320
Add presicion
trizin Apr 24, 2023
48b98ed
Merge branch 'predictoor-pm-issue-3' of github.com:oceanprotocol/ocea…
trizin Apr 24, 2023
4f8ec75
Tune README further
trentmc Apr 24, 2023
781ab3c
Merge branch 'predictoor-pm-issue-3' of github.com:oceanprotocol/ocea…
trentmc Apr 24, 2023
32ee28c
bug fix in README
trentmc Apr 24, 2023
1179f61
Remove HACK. Details: it was inserted while debugging exchange stuff.…
trentmc Apr 24, 2023
c5271fc
Update accuracy logic
trizin Apr 24, 2023
6386d00
Merge branch 'predictoor-pm-issue-3' of github.com:oceanprotocol/ocea…
trizin Apr 24, 2023
9bd5227
Fixes
trizin Apr 24, 2023
28323ba
Tweak README: run 1 test not whole module
trentmc Apr 24, 2023
816e3ca
Update get payout func
trizin Apr 24, 2023
b1393e3
Update tests
trizin Apr 24, 2023
4757aa3
Merge branch 'predictoor-pm-issue-3' of github.com:oceanprotocol/ocea…
trizin Apr 24, 2023
d00282e
Stake weighted accuracy and stake slash
trizin Apr 24, 2023
05eab84
tweak
trentmc Apr 24, 2023
15577e7
Fix these bugs: (a) OCEAN.mint() to predictoors & trader wasn't neede…
trentmc Apr 24, 2023
54fa885
make black happy
trentmc Apr 24, 2023
efc9dde
Rename aggpredval to agg_predvals
trizin Apr 24, 2023
427ae36
Rename prediction to predval
trizin Apr 24, 2023
66370ac
Normalization will be done at different steps
trizin Apr 24, 2023
3a97527
Rename counters
trizin Apr 24, 2023
78b45b8
predvaal renaming
trizin Apr 24, 2023
4704281
Fix tests
trizin Apr 24, 2023
108c229
Add comment
trizin Apr 24, 2023
c0f0cd3
num_stake => tot_stake
trizin Apr 24, 2023
6610122
Fix math
trizin Apr 24, 2023
939b5f3
Check earnings and post contract balance
trizin Apr 24, 2023
23ad221
tiny tweak
trentmc Apr 25, 2023
add409e
Fix ocean.py#1418: Bug: in predictoor prototype 3: Contract name does…
trentmc Apr 25, 2023
166437f
Refactor: move SETUP USER ACCOUNTS to earlier. Remove unneeded comments
trentmc Apr 25, 2023
f7efadf
Refactor: improve variable labels
trentmc Apr 25, 2023
5a9b16a
Small refactor: improve some variable names
trentmc Apr 25, 2023
3b89c6e
small tweak
trentmc Apr 25, 2023
329225e
remove breakpoint from previous commit
trentmc Apr 25, 2023
34fe79f
Fix ocean.py#1420: Predictoor prototype 3: mixed sol-py version of co…
trentmc Apr 25, 2023
ae064da
make black happy
trentmc Apr 25, 2023
ea7fe25
tweak
trentmc Apr 25, 2023
2155120
speed up testing via more private keys
trentmc Apr 25, 2023
c245572
small refactor, in how accts are created
trentmc Apr 25, 2023
ce7b350
small refactor, in how accts are created, 2
trentmc Apr 25, 2023
a2ad13b
Bug fix: was checking balance of wrong acct
trentmc Apr 25, 2023
f5e3699
Transfer more OCEAN, therefore we don't have to do it as often
trentmc Apr 25, 2023
5d7b44f
Refactor: rename some vars for clarity; more
trentmc Apr 25, 2023
7dd88ec
make black happy
trentmc Apr 25, 2023
cd9625e
Add pycrypto dependency
trizin Apr 25, 2023
37c69a1
Fix #1420 (part 2/2): Predictoor prototype 3: mixed sol-py version of…
trentmc Apr 25, 2023
8043f9f
Calc agg_predval properly, using both numerator and denominator
trentmc Apr 25, 2023
1e7a069
(a) bug fix: account for when DT treasurer has OCEAN before test star…
trentmc Apr 25, 2023
0bc3740
make black happy
trentmc Apr 25, 2023
8b75290
Bug fix: agg_predval is now scaled correctly
trentmc Apr 25, 2023
8a9805b
Small refactor: move method
trentmc Apr 25, 2023
beb6bc7
Add ElGamal and ElGamalEncryptedObject classes
trizin Apr 25, 2023
7fbeebd
Merge branch 'predictoor-pm-issue-3' of github.com:oceanprotocol/ocea…
trizin Apr 25, 2023
7a4ef9c
refactor: better naming of error-related variables. New method PredCl…
trentmc Apr 25, 2023
276fc8d
tiny tweak
trentmc Apr 25, 2023
5cfdcdf
make black happy
trentmc Apr 25, 2023
8ef4d0c
Make black happier
trizin Apr 25, 2023
882edf0
Merge branch 'main' into predictoor-pm-issue-3
trentmc Apr 25, 2023
f1ecc5e
Move ElGamal class into its own module
trentmc Apr 25, 2023
31826f5
Refactor: move setup steps into new function _setup()
trentmc Apr 26, 2023
ea87f2a
Small refactor: simplify code around DNFT & DT creation
trentmc Apr 26, 2023
43e0624
tiny tweak: remove assert that needs too much detail
trentmc Apr 26, 2023
3f83e4e
Refactor: make DT template3 attributes more malleable in py iterations
trentmc Apr 26, 2023
16ce88d
Refactor: the DT now owns the exchange. More to come...
trentmc Apr 26, 2023
16285f1
Big change: towards goal of $ from selling DT on exchange getting dis…
trentmc Apr 26, 2023
9c54109
Bug fixes, tweaks
trentmc Apr 26, 2023
6c884a3
tweaks
trentmc Apr 26, 2023
6175ea4
tweak
trentmc May 2, 2023
fce2555
Bug fix: datatoken3.py needs to check allowance not balance, when sta…
trentmc May 2, 2023
43c285a
WIP better logging
trentmc May 2, 2023
4e935ca
Improve logging
trentmc May 2, 2023
a636dcd
Running end-to-end without fail now. More testing needed though
trentmc May 2, 2023
0f28f03
make getId virtual
trizin May 3, 2023
8a3950c
First pass of the contract
trizin May 3, 2023
5fd7433
Add new todo
trizin May 3, 2023
2f5eba2
Add get_prediction function
trizin May 3, 2023
a4dbf00
Fix bug
trizin May 3, 2023
bd28076
Remove swe and do black formatting
trizin May 3, 2023
43319ae
add ERC20TemplatePredictoor
alexcos20 May 3, 2023
05c39bb
Formatting
trizin May 4, 2023
c67a106
Comments
trizin May 4, 2023
7fac40a
Update add_revenue function
trizin May 4, 2023
29a0ebf
Use block number for subscriptions
trizin May 4, 2023
3de66c1
Remove unused permit
trizin May 4, 2023
5679fcf
Remove unused permit
trizin May 4, 2023
c3f56e8
Organize admin functions and ability to pause
trizin May 4, 2023
886e824
refund stake to predictoor and cancel round
trizin May 4, 2023
98125c0
Make payout function nonReentrant
trizin May 4, 2023
448526c
Fix typo
trizin May 4, 2023
420e17b
Fix typos
trizin May 4, 2023
b3b426a
add truval_submit_atimeout
trizin May 4, 2023
d072898
Remove unused var
trizin May 4, 2023
f9f44a9
fix typo
alexcos20 May 4, 2023
88eeeb9
Merge branch 'predictoor-pm-issue-3' of https://github.com/oceanproto…
alexcos20 May 4, 2023
21c4877
Add admin function to update seconds
trizin May 4, 2023
956f7a9
Add modifier blocknumOnSlot
trizin May 4, 2023
cd27875
Add function "update_seconds"
trizin May 4, 2023
1ac9a5c
Merge branch 'predictoor-pm-issue-3' of github.com:oceanprotocol/ocea…
trizin May 4, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ artifacts/address.json
/venv/
ocean_lib.egg-info/
/build/
/contracts/
/interfaces/
/reports/
/tests/generated-readmes/test*
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ Copyright 2023 Ocean Protocol Foundation
SPDX-License-Identifier: Apache-2.0
-->

**[Predictoor README](READMEs/predictoor.md).** (Remove this when done prototype)

----

<h1 align="center">
<img src="https://github.com/oceanprotocol/art/blob/main/splashes/ocean_py.png?raw=true" width="300"/>
</h1>
Expand All @@ -12,6 +16,8 @@ SPDX-License-Identifier: Apache-2.0
[![Maintainability](https://api.codeclimate.com/v1/badges/a0be65f412a35440c63e/maintainability)](https://codeclimate.com/github/oceanprotocol/ocean.py/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/a0be65f412a35440c63e/test_coverage)](https://codeclimate.com/github/oceanprotocol/ocean.py/test_coverage)



With ocean.py, you can:

- **Publish** data services: downloadable files or compute-to-data. Create an ERC721 **data NFT** for each service, and ERC20 **datatoken** for access (1.0 datatokens to access).
Expand Down
112 changes: 112 additions & 0 deletions READMEs/predictoor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# Quickstart: Predictoor

This README currently describes how to **develop** Predictoor prototype.

When Predictoor is more mature, this README will change to _using_ Predictoor.

## 1. Pre-Requisites

Ensure pre-requisites:

- Linux/MacOS
- Python 3.8.5+
- solc 0.8.0+ [[Instructions](https://docs.soliditylang.org/en/v0.8.9/installing-solidity.html)]
- ganache. [To install](https://github.com/trufflesuite/ganache#readme): `npm install ganache --global`

## 2. Start ganache, fund accounts

Open a new console and:

```console
#set private keys
export FACTORY_DEPLOYER_PRIVATE_KEY=0xc594c6e5def4bab63ac29eed19a134c130388f74f019bc74b8f4389df2837a58
export TEST_PRIVATE_KEY1=0x8467415bb2ba7c91084d932276214b11a3dd9bdb2930fefa194b666dd8020b99
export TEST_PRIVATE_KEY2=0x1d751ded5a32226054cd2e71261039b65afb9ee1c746d055dd699b1150a5befc
export TEST_PRIVATE_KEY3=0xed45162e5e39ecdd5270afdef42eba06a67dd455b6e580cbeefc1c7de31ee4e2
export TEST_PRIVATE_KEY4=0x9dae18de1b391af0dad691e0566104aedbaf71855ec056feb7567065270a7fd3
export TEST_PRIVATE_KEY5=0xbe8b3fe8699d05bee83f2522ca24f71900356519936c4dd45a8ca8aa1c0f7f35
export TEST_PRIVATE_KEY6=0x3ff9bd14c137a8d1eec9980046c0fefde79c5ac2b023b20bed34363246b94b09

#each account gets 1000 ETH
export AMT_ETH=1000000000000000000000

#start ganache
ganache \
--account "$FACTORY_DEPLOYER_PRIVATE_KEY,$AMT_ETH" \
--account "$TEST_PRIVATE_KEY1,$AMT_ETH" \
--account "$TEST_PRIVATE_KEY2,$AMT_ETH" \
--account "$TEST_PRIVATE_KEY3,$AMT_ETH" \
--account "$TEST_PRIVATE_KEY4,$AMT_ETH" \
--account "$TEST_PRIVATE_KEY5,$AMT_ETH" \
--account "$TEST_PRIVATE_KEY6,$AMT_ETH"
```

## 3. Install

Open a new console, call it "work console".

In work console:

```console
# Clone the repo and enter into it
git clone https://github.com/oceanprotocol/ocean.py
cd ocean.py
git checkout predictoor-pm-issue-3

# Install OS dependencies
sudo apt-get install -y python3-dev gcc python-pytest

#create a virtual environment
python -m venv venv

#activate env
source venv/bin/activate

#install dependencies
pip install -r requirements_dev.txt

#install openzeppelin library, to import from .sol (ignore FileExistsErrors)
brownie pm install OpenZeppelin/openzeppelin-contracts@4.2.0
brownie pm install GNSPS/solidity-bytes-utils@0.8.0
```

## 4. Set envvars in work console

While we already set these envvars in the ganache console, let's also get them in our work console. In work console:

```console
#set private keys
export FACTORY_DEPLOYER_PRIVATE_KEY=0xc594c6e5def4bab63ac29eed19a134c130388f74f019bc74b8f4389df2837a58
export TEST_PRIVATE_KEY1=0x8467415bb2ba7c91084d932276214b11a3dd9bdb2930fefa194b666dd8020b99
export TEST_PRIVATE_KEY2=0x1d751ded5a32226054cd2e71261039b65afb9ee1c746d055dd699b1150a5befc
export TEST_PRIVATE_KEY3=0xed45162e5e39ecdd5270afdef42eba06a67dd455b6e580cbeefc1c7de31ee4e2
export TEST_PRIVATE_KEY4=0x9dae18de1b391af0dad691e0566104aedbaf71855ec056feb7567065270a7fd3
export TEST_PRIVATE_KEY5=0xbe8b3fe8699d05bee83f2522ca24f71900356519936c4dd45a8ca8aa1c0f7f35
export TEST_PRIVATE_KEY6=0x3ff9bd14c137a8d1eec9980046c0fefde79c5ac2b023b20bed34363246b94b09
```

## 5. Compile & deploy contracts

We need to compile once at the beginning, and recompile whenever we change ERC20Template3.sol.

In work console:
```console
#remove old build artifacts
rm -rf build

#compile contracts
brownie compile

#deploy contracts to ganache
./deploy.py
```

## 6. Test

In work console:
```console
#run main prototype 3 test. The "-s" gives verbose printing.
pytest ocean_lib/models/predictoor/test/test_datatoken3.py::test_main -s
```

For envvars that aren't set, `pytest` uses values in `pytest.ini`.
7 changes: 7 additions & 0 deletions brownie-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
compiler:
solc:
version: 0.8.12
remappings:
- "@openzeppelin=OpenZeppelin/openzeppelin-contracts@4.2.0"
- "@solidity-bytes-utils=GNSPS/solidity-bytes-utils@0.8.0"

Loading