Skip to content

Commit

Permalink
Upgrade to Newest Version of Saddle
Browse files Browse the repository at this point in the history
This patch upgrades to the newest version of saddle and fixes most of our docker items to be more resiliant to any number of changes.
  • Loading branch information
hayesgm committed Jan 22, 2020
1 parent a274a2b commit ce11cda
Show file tree
Hide file tree
Showing 14 changed files with 463 additions and 88 deletions.
12 changes: 12 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.build
.circleci
.dockerbuild
.github
node_modules
sdk/javascript/node_modules
sdk/javascript/.tsbuilt
poster/node_modules
poster/.tsbuilt
tests
yarn-error.log
junit.xml
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.dockerbuild
*node_modules*
*.tsbuilt*
*.DS_Store*
Expand Down
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
FROM ethereum/solc:0.5.12-alpine
FROM node:13.6.0-alpine3.10
WORKDIR /open-oracle
RUN wget https://github.com/ethereum/solidity/releases/download/v0.5.12/solc-static-linux -O /usr/local/bin/solc && chmod +x /usr/local/bin/solc
RUN apk update && apk add --no-cache --virtual .gyp \
python \
make \
Expand All @@ -15,6 +16,7 @@ RUN yarn install

ENV PROVIDER PROVIDER
ADD contracts contracts
ADD saddle.config.js saddle.config.js
RUN npx saddle compile

ENTRYPOINT []
Expand Down
18 changes: 14 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@ services:
deployer:
build: .
command: "sh -c '
npx saddle deploy OpenOraclePriceData;
npx saddle deploy DelFiPrice 0xe78A0F7E598Cc8b0Bb87894B0F60dD2a88d6a8Ab [0x90f8bf6a479f320ead074411a4b0e7944ea8c9c1,0xffcf8fdee72ac11b5c542428b35eef5769c409f0]
apk add jq;
SADDLE_BUILD=/build npx saddle compile;
GAS=6721975 SADDLE_BUILD=/build npx saddle deploy OpenOraclePriceData;
GAS=6721975 SADDLE_BUILD=/build npx saddle deploy DelFiPrice $$(cat /build/development.json | jq -r .OpenOraclePriceData) 0x90f8bf6a479f320ead074411a4b0e7944ea8c9c1,0xffcf8fdee72ac11b5c542428b35eef5769c409f0
'"
environment:
- PROVIDER=http://ganache:8545
depends_on:
- ganache
volumes:
- ./.dockerbuild:/build

reporter-1:
build: sdk/javascript
Expand All @@ -35,13 +39,19 @@ services:

poster:
build: poster
command: npm run start --
command: "sh -c '
apk add jq;
while [ ! -f /build/development.json ]; do echo waiting for /build/development.json; sleep 1; done;
npm run start --
--poster_key 0x4f3edf983ac636a65a842ce7c78d9aa706d3b113bce9c46f30d7d21715b23b1d
--sources http://reporter-1:3000/prices.json,http://reporter-2:3000/prices.json
--view_address 0x5b1869d9a4c187f2eaa108f3062412ecf0526b24
--view_address $$(cat /build/development.json | jq -r .DelFiPrice)
--web3_provider http://ganache:8545
'"
depends_on:
- deployer
- reporter-1
- reporter-2
restart: "always"
volumes:
- ./.dockerbuild:/build
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"author": "Compound Labs, Inc.",
"license": "MIT",
"dependencies": {
"eth-saddle": "^0.0.29",
"eth-saddle": "0.1.6",
"web3": "^1.2.4",
"yargs": "^15.0.2"
},
Expand All @@ -19,7 +19,7 @@
"jest-junit": "^10.0.0"
},
"scripts": {
"test": "npx saddle compile && npx saddle test"
"test": "npx saddle test"
},
"resolutions": {
"scrypt.js": "https://registry.npmjs.org/@compound-finance/ethereumjs-wallet/-/ethereumjs-wallet-0.6.3.tgz"
Expand Down
2 changes: 2 additions & 0 deletions poster/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
.tsbuilt
2 changes: 1 addition & 1 deletion poster/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:current-alpine
FROM node:13.6.0-alpine3.10

RUN apk update && apk add --no-cache --virtual .gyp \
python \
Expand Down
2 changes: 1 addition & 1 deletion saddle.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
module.exports = {
// solc: "solc", // Solc command to run
// solc_args: [], // Extra solc args
// build_dir: ".build", // Directory to place built contracts
build_dir: process.env['SADDLE_BUILD'] || ".build", // Directory to place built contracts
// contracts: "contracts/*.sol", // Glob to match contract files
tests: ['**/tests/*Test.js'], // Glob to match test files
networks: { // Define configuration for each network
Expand Down
2 changes: 2 additions & 0 deletions sdk/javascript/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
.tsbuilt
2 changes: 1 addition & 1 deletion sdk/javascript/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:current-alpine
FROM node:13.6.0-alpine3.10

WORKDIR /open-oracle-reporter
ADD package.json /open-oracle-reporter/package.json
Expand Down
8 changes: 4 additions & 4 deletions tests/DelFiPriceTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ async function setup(N) {
signatures.push(signature);
}
});
return send(delfi.methods.postPrices(messages, signatures, symbols), {gas: 6000000});
return send(delfi, 'postPrices', [messages, signatures, symbols], {gas: 6000000});
}

async function getPrice(symbol) {
return call(delfi.methods.prices(symbol))
return call(delfi, 'prices', [symbol]);
}

return {sources, nonSources, priceData, delfi, now, postPrices, getPrice};
Expand All @@ -59,7 +59,7 @@ describe('DelFiPrice', () => {
const {nonSources, delfi, now, postPrices, getPrice} = await setup(5);

// Reads a price of an asset that doesn't exist yet
expect(await call(delfi.methods.prices('ETH'))).numEquals(0);
expect(await call(delfi, 'prices', ['ETH'])).numEquals(0);

/** Posts nothing **/

Expand Down Expand Up @@ -164,7 +164,7 @@ describe('DelFiPrice', () => {

/** Does revert on invalid message **/

await expect(send(delfi.methods.postPrices(['0xabc'], ['0x123'], []), {gas: 5000000})).rejects.toRevert();
await expect(send(delfi, 'postPrices', [['0xabc'], ['0x123'], []], {gas: 5000000})).rejects.toRevert();
}, 30000);

it.skip('quantifies the amount of gas used for a substantial set of updates', async () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/IntegrationTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('Integration', () => {

const web3 = new Web3('http://localhost:9999');
const accounts = await web3.eth.getAccounts();
const delfi = await contract.getContractAt(web3, 'DelFiPrice', false, '0x5b1869D9A4C187F2EAa108f3062412ecf0526b24');
const delfi = await contract.getContractAt(web3, 'DelFiPrice', '.dockerbuild', false, '0x5b1869D9A4C187F2EAa108f3062412ecf0526b24');

expect(await delfi.methods.prices('BTC').call({from: accounts[0]})).numEquals(0);
expect(await delfi.methods.prices('ETH').call({from: accounts[0]})).numEquals('260000000');
Expand Down
22 changes: 11 additions & 11 deletions tests/OpenOracleDataTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('OpenOracleData', () => {
let {
0: timestamp,
1: value
} = await call(priceData.methods.get(address(0), 'ETH'));
} = await call(priceData, 'get', [address(0), 'ETH']);

expect(timestamp).numEquals(0);
expect(value).numEquals(0);
Expand All @@ -38,19 +38,19 @@ describe('OpenOracleData', () => {

for (let {message, signature, signatory} of signed) {
// writes
const wrote1 = await send(priceData.methods.put(message, signature), {gas: 1000000});
const wrote1 = await send(priceData, 'put', [message, signature], {gas: 1000000});
expect(wrote1.gasUsed).toBeLessThan(86000);

// the source we recover in solidity should match
expect(await call(oracleData.methods.source(message, signature))).toEqual(signatory);
expect(await call(oracleData.methods.source(bytes('bad'), signature))).not.toEqual(signatory);
await expect(call(oracleData.methods.source(message, bytes('0xbad')))).rejects.toRevert();
expect(await call(oracleData, 'source', [message, signature])).toEqual(signatory);
expect(await call(oracleData, 'source', [bytes('bad'), signature])).not.toEqual(signatory);
await expect(call(oracleData, 'source', [message, bytes('0xbad')])).rejects.toRevert();

// reads
({
0: timestamp,
1: value
} = await call(priceData.methods.get(signatory, K)));
} = await call(priceData, 'get', [signatory, K]));
expect(timestamp).numEquals(now);
expect(value).numEquals(V * 1e6);
}
Expand All @@ -60,12 +60,12 @@ describe('OpenOracleData', () => {

for (let {message, signature, signatory} of signed) {
// write fails
await send(priceData.methods.put(message, signature), {gas: 1000000});
await send(priceData, 'put', [message, signature], {gas: 1000000});

({
0: timestamp,
1: value
} = await call(priceData.methods.get(signatory, K)));
} = await call(priceData, 'get', [signatory, K]));
expect(timestamp).numEquals(now);
expect(value).numEquals(V * 1e6);
}
Expand All @@ -79,14 +79,14 @@ describe('OpenOracleData', () => {
let i = 0;
for (let {message, signature, signatory} of signed) {
// writes
const wrote2a = await send(priceData.methods.put(message, signature), {gas: 1000000});
const wrote2a = await send(priceData, 'put', [message, signature], {gas: 1000000});
expect(wrote2a.gasUsed).toBeLessThan(135000);

if (i++ == 1) {
({
0: timestamp,
1: value
} = await call(priceData.methods.get(signatory, 'BTC')));
} = await call(priceData, 'get', [signatory, 'BTC']));
expect(timestamp).numEquals(now);
expect(value).numEquals(9000e6);
}
Expand All @@ -99,7 +99,7 @@ describe('OpenOracleData', () => {
]), privateKey);

for (let {message, signature, signatory} of signed) {
const wrote2b = await send(priceData.methods.put(message, signature), {gas: 1000000});
const wrote2b = await send(priceData, 'put', [message, signature], {gas: 1000000});
expect(wrote2b.gasUsed).toBeLessThan(75000);
}
}, 30000);
Expand Down
Loading

0 comments on commit ce11cda

Please sign in to comment.