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

demo: Validate that the main interface owns the other contracts. #103

Merged
merged 1 commit into from
Oct 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions demo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ docker push 0xdeca10bcontainerreg.azurecr.io/public/samples/blockchain-ai/0xdeca
docker push 0xdeca10bcontainerreg.azurecr.io/public/samples/blockchain-ai/0xdeca10b-demo:latest
```

(Microsoft Devs) To update the production website, see the instructions at the top of [service.Dockerfile](./service.Dockerfile).

## Troubleshooting Setup
If you have problems running the setup steps related to node-gyp, then you might need to set Python 2.7 to be your default. Recommendation: Set up a Python 2.7 Conda environment and activate it.

Expand Down
2 changes: 1 addition & 1 deletion demo/client/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>Sharing Updatable Models (SUM) Demo</title>
<title>Sharing Updatable Models (SUM)</title>
</head>
<body>
<noscript>
Expand Down
17 changes: 13 additions & 4 deletions demo/client/src/contracts/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Contract } from 'web3-eth-contract'
import Classifier from './compiled/Classifier64.json'
import CollaborativeTrainer64 from './compiled/CollaborativeTrainer64.json'
import DataHandler from './compiled/DataHandler64.json'
import IncentiveMechanism from './compiled/IncentiveMechanism.json'
import IncentiveMechanism from './compiled/IncentiveMechanism64.json'

/**
* An already deployed instance of a CollaborativeTrainer contract.
Expand Down Expand Up @@ -63,15 +63,15 @@ export class ContractLoader {
}

/**
*
* Loads and validates the contracts.
* @param address The address of the main entry point contract.
* @returns An interface to help you use the contracts.
*/
async load(address: string): Promise<CollaborativeTrainer> {
if (!address || address.length === 0) {
return Promise.reject("A blank address was given")
}

// It is a valid address, so check the other interfaces.
const mainEntryPoint = this.getContractInstance({
abi: CollaborativeTrainer64.abi,
address,
Expand All @@ -95,11 +95,20 @@ export class ContractLoader {
address: incentiveMechanismAddress
})
})
]).then(([
]).then(async ([
classifier,
dataHandler,
incentiveMechanism,
]) => {
const [classifierOwner, dataHandlerOwner, incentiveMechanismOwner] = await Promise.all([
classifier.methods.owner().call(),
dataHandler.methods.owner().call(),
incentiveMechanism.methods.owner().call(),
])
if (classifierOwner !== address || dataHandlerOwner !== address || incentiveMechanismOwner !== address) {
throw new Error(`The classifer, data handler, and incentive mechanism must be owned by the main interface.\n Main interface address: ${address}\n Classifier owner: ${classifierOwner}\n Data handler owner: ${dataHandlerOwner}\n IM owner: ${incentiveMechanismOwner}.`)
}

return new CollaborativeTrainer(mainEntryPoint,
classifier, dataHandler, incentiveMechanism)
})
Expand Down
2 changes: 1 addition & 1 deletion demo/service.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# The deployment is set up to happen automatically in Azure.

# When NODE_ENV='production'
# Set BACK_END_URL to the address for the back end.
# Set BACK_END_URL in your environment to the address for the back end service.

FROM appsvc/node:10-lts

Expand Down