MIT IEEE URTC 2023. GSET 2023. Repository for "SeBRUS: Mitigating Data Poisoning in Crowdsourced Datasets with Blockchain". Using Ethereum smart contracts to stop AI security attacks on crowdsourced datasets.
Ethereum smart contracts require a configuration known as an ABI. While we have an existing endpoint for /api/dataset that has information about the deployed smart contract, the amount of data required in an ABI is increasingly large in scale and is difficult to manage at an endpoint with other functionality. For these reasons, we will provide a separate endpoint that purely acts to serve ABI JSON files to the client to allow it to connect to the blockchain. This will also allow changes to be made to the smart contract without significant changes needed to be made to the client.
Proposed Solution
This depends on #10 and is required for #18. This endpoint will simply handle saving JSON files for the ABI.
Action Items
[x] implement the ABI table using Flask-SQLAlchemy. This table will have two columns. One is the ABI id column (this can be implemented the exact same way as other tables with db.Integer, primary key, and not nullable) and a file name column (db.String(80), not nullable). You should also add a new column to the Dataset table which is ABI id (db.Integer) which acts as a foreign key to the ABI table containing the ABI the id of the ABI corresponding to a particular dataset.
[x] GET will have similar error and status messages to other endpoints. This will query the database based on the id and return a status and abi containing the JSON for the ABI.
[x] POST will have similar error and status messages to other endpoints. This will expect a name field, a database id, and an abi field. These will be used to store in the database while the contents of the ABI field will be saved to a file based on the file name + .json. It will also query the Database table to make sure that there is not a duplicate ABI for a particular dataset.
[x] PUT will have similar error and status messages to other endpoints. This will expect a name field, a database id, and an abi contain the JSON for the new ABI along with the abi id. All of these fields are required and will be used to check if this actually corresponds to an existing Dataset and ABI.
[x] DELETE will have similar error and status messages to the other endpoints. This will expect an abi id and delete the corresponding ABI in the database as well as the file on the local file system.
Use Case
Ethereum smart contracts require a configuration known as an ABI. While we have an existing endpoint for
/api/dataset
that has information about the deployed smart contract, the amount of data required in an ABI is increasingly large in scale and is difficult to manage at an endpoint with other functionality. For these reasons, we will provide a separate endpoint that purely acts to serve ABI JSON files to the client to allow it to connect to the blockchain. This will also allow changes to be made to the smart contract without significant changes needed to be made to the client.Proposed Solution
This depends on #10 and is required for #18. This endpoint will simply handle saving JSON files for the ABI.
Action Items
ABI
table usingFlask-SQLAlchemy
. This table will have two columns. One is the ABI id column (this can be implemented the exact same way as other tables withdb.Integer
, primary key, and not nullable) and a file name column (db.String(80)
, not nullable). You should also add a new column to theDataset
table which is ABI id (db.Integer
) which acts as a foreign key to theABI
table containing the ABI the id of the ABI corresponding to a particular dataset.abi
containing the JSON for the ABI.name
field, a database id, and anabi
field. These will be used to store in the database while the contents of the ABI field will be saved to a file based on the file name +.json
. It will also query theDatabase
table to make sure that there is not a duplicate ABI for a particular dataset.name
field, a database id, and anabi
contain the JSON for the new ABI along with theabi
id. All of these fields are required and will be used to check if this actually corresponds to an existingDataset
andABI
.abi
id and delete the corresponding ABI in the database as well as the file on the local file system.Resources
https://www.geeksforgeeks.org/reading-and-writing-json-to-a-file-in-python
This is a :rocket: Feature Request