Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 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: 1 addition & 1 deletion environments/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { getEnvironment } from "@iexec/dataprotector-environments";
const {
smsUrl,
iexecGatewayUrl,
resultProxyUrl,
resultProxyUrl, // TODO remove
ipfsGatewayUrl,
ipfsNodeUrl,
workerpoolProdAddress,
Expand Down
2 changes: 1 addition & 1 deletion environments/common/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const KNOWN_KEYS = [
// iexec protocol config
"smsUrl",
"iexecGatewayUrl",
"resultProxyUrl",
"resultProxyUrl", // TODO remove
"ipfsGatewayUrl",
"ipfsNodeUrl",
"workerpoolProdAddress",
Expand Down
2 changes: 1 addition & 1 deletion environments/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export declare type KnownEnv = "prod" | "staging";
export declare type EnvKey =
| "smsUrl"
| "iexecGatewayUrl"
| "resultProxyUrl"
| "resultProxyUrl" // TODO remove
| "ipfsGatewayUrl"
| "ipfsNodeUrl"
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2007,11 +2007,6 @@
"internalType": "string",
"name": "iexecResultStorageProvider_",
"type": "string"
},
{
"internalType": "string",
"name": "iexecResultStorageProxy_",
"type": "string"
}
],
"name": "updateEnv",
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk/tests/test-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const TEST_CHAIN = {
smsDebugURL: DRONE ? 'http://sms-debug:13300' : 'http://127.0.0.1:13301',
resultProxyURL: DRONE
? 'http://result-proxy:13200'
: 'http://127.0.0.1:13200',
: 'http://127.0.0.1:13200', // TODO remove
iexecGatewayURL: DRONE ? 'http://market-api:3000' : 'http://127.0.0.1:3000',
provider: new JsonRpcProvider(
DRONE ? 'http://bellecour-fork:8545' : 'http://localhost:8545'
Expand All @@ -34,7 +34,7 @@ export const getTestRpcProvider = () => new JsonRpcProvider(TEST_CHAIN.rpcURL);
export const getTestIExecOption = () => ({
smsURL: TEST_CHAIN.smsURL,
smsDebugURL: TEST_CHAIN.smsDebugURL,
resultProxyURL: TEST_CHAIN.resultProxyURL,
resultProxyURL: TEST_CHAIN.resultProxyURL, // TODO remove
iexecGatewayURL: TEST_CHAIN.iexecGatewayURL,
});

Expand Down
1 change: 1 addition & 0 deletions packages/sharing-smart-contract/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file.

### Changed

- [BREAKING] Remove result proxy url from contract config and deal params.
- Fix Sharing contract constructor arguments order (#433)
- Update blockscout url

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2007,11 +2007,6 @@
"internalType": "string",
"name": "iexecResultStorageProvider_",
"type": "string"
},
{
"internalType": "string",
"name": "iexecResultStorageProxy_",
"type": "string"
}
],
"name": "updateEnv",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ contract DataProtectorSharing is
__AccessControl_init();
_grantRole(DEFAULT_ADMIN_ROLE, msg.sender);

updateEnv("ipfs", "https://result.v8-bellecour.iex.ec");
updateEnv("ipfs");
}

/***************************************************************************
Expand Down Expand Up @@ -261,11 +261,9 @@ contract DataProtectorSharing is
* Admin *
**************************************************************************/
function updateEnv(
string memory iexecResultStorageProvider_,
string memory iexecResultStorageProxy_
string memory iexecResultStorageProvider_
) public onlyRole(DEFAULT_ADMIN_ROLE) {
_iexecResultStorageProvider = iexecResultStorageProvider_;
_iexecResultStorageProxy = iexecResultStorageProxy_;
}

/***************************************************************************
Expand Down
5 changes: 3 additions & 2 deletions packages/sharing-smart-contract/contracts/ManageOrders.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ abstract contract ManageOrders {
0x0000000000000000000000000000000000000000000000000000000000000003; // [tee,scone]
uint256 internal constant TRUST = 0; // No replication
string internal _iexecResultStorageProvider;
// This value is not used anymore but it is kept
// as a placeholder to not break storage of the proxy
// deployed on Bellecour.
string internal _iexecResultStorageProxy;
uint256 private _salt;

Expand Down Expand Up @@ -166,8 +169,6 @@ abstract contract ManageOrders {
'{"iexec_result_encryption":true', // solhint-disable-line quotes
',"iexec_result_storage_provider":"', // solhint-disable-line quotes
_iexecResultStorageProvider,
'","iexec_result_storage_proxy":"', // solhint-disable-line quotes
_iexecResultStorageProxy,
'"}' // solhint-disable-line quotes
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// SPDX-License-Identifier: Apache-2.0

/******************************************************************************
* Copyright 2024-2025 IEXEC BLOCKCHAIN TECH *
* *
* Licensed under the Apache License, Version 2.0 (the "License"); *
* you may not use this file except in compliance with the License. *
* You may obtain a copy of the License at *
* *
* http://www.apache.org/licenses/LICENSE-2.0 *
* *
* Unless required by applicable law or agreed to in writing, software *
* distributed under the License is distributed on an "AS IS" BASIS, *
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
* See the License for the specific language governing permissions and *
* limitations under the License. *
******************************************************************************/

pragma solidity ^0.8.24;

import {ERC721BurnableUpgradeable, ERC721Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721BurnableUpgradeable.sol";
import {AccessControlUpgradeable} from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import {MulticallUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/MulticallUpgradeable.sol";
import {ERC721Holder} from "@openzeppelin/contracts/token/ERC721/utils/ERC721Holder.sol";
import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";
import {DataProtectorSharing} from "../DataProtectorSharing.sol";
import {AddOnlyAppWhitelistRegistry, IAddOnlyAppWhitelist} from "../registry/AddOnlyAppWhitelistRegistry.sol";
import {IRegistry} from "../interfaces/IRegistry.sol";
import {ManageOrders} from "../ManageOrders.sol";

/**
* @notice This contract is for upgradeability testing purposes only.
*/

contract DataProtectorSharingV2Mock is DataProtectorSharing {
string public newStorage;

/// @custom:oz-upgrades-unsafe-allow constructor
constructor()
DataProtectorSharing(
address(0),
IRegistry(address(0)),
AddOnlyAppWhitelistRegistry(address(0))
)
{}

function initializeV2(string calldata foo) public reinitializer(2) {
newStorage = foo;
}
}
1 change: 1 addition & 0 deletions packages/sharing-smart-contract/hardhat.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ require('@nomicfoundation/hardhat-foundry');
require('@nomicfoundation/hardhat-toolbox');
require('@openzeppelin/hardhat-upgrades');
require('hardhat-contract-sizer');
require('@openzeppelin/hardhat-upgrades');
require('dotenv').config();

const { WALLET_PRIVATE_KEY } = process.env;
Expand Down
11 changes: 7 additions & 4 deletions packages/sharing-smart-contract/scripts/updateEnv.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@ const { ethers } = pkg;
async function main() {
const { ENV } = env;
console.log(`using ENV: ${ENV}`);
const { dataprotectorSharingContractAddress, resultProxyUrl } = getEnvironment(ENV);
const { dataprotectorSharingContractAddress } = getEnvironment(ENV);

const newEnv = ['ipfs', resultProxyUrl];
const newResultStorageProvider = 'ipfs';

console.log(`UpdateEnv Contract at ${dataprotectorSharingContractAddress} with [${newEnv}]`);
console.log(
`UpdateEnv contract at ${dataprotectorSharingContractAddress} ` +
`[newResultStorageProvider=${newResultStorageProvider}]`,
);
const [admin] = await ethers.getSigners();
console.log(`using wallet ${admin.address}`);

Expand All @@ -20,7 +23,7 @@ async function main() {
dataprotectorSharingContractAddress,
);

const updateEnvTx = await dataProtectorSharingContract.updateEnv(...newEnv);
const updateEnvTx = await dataProtectorSharingContract.updateEnv(newResultStorageProvider);
console.log(`tx: ${updateEnvTx.hash}`);

await updateEnvTx.wait();
Expand Down
51 changes: 51 additions & 0 deletions packages/sharing-smart-contract/test/e2e/upgrade.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { loadFixture } from '@nomicfoundation/hardhat-toolbox/network-helpers.js';
import { expect } from 'chai';
import hardhat from 'hardhat';
import { beforeEach } from 'mocha';
import { createCollection, deploySCFixture } from './utils/loadFixture.test.js';
const { ethers, upgrades } = hardhat;

// TODO convert to ts.
// TODO use typechain for factories.

let dataProtectorSharingContract;
let contractAddress;
let owner, addr1;

describe('DataProtectorSharing', function () {
beforeEach('Deploy fixture', async function () {
({ dataProtectorSharingContract, owner, addr1 } = await loadFixture(deploySCFixture));
contractAddress = await dataProtectorSharingContract.getAddress();
await dataProtectorSharingContract.createCollection(owner).then((tx) => tx.wait());
});

describe('Upgrade', function () {
it('Should upgrade', async function () {
// Update the state of the original proxy.
const { collectionTokenId } = await createCollection();
// Upgrade the proxy.
const newImplementationFactory = await ethers.getContractFactory(
'DataProtectorSharingV2Mock',
owner,
);
await upgrades
.upgradeProxy(contractAddress, newImplementationFactory)
.then((contract) => contract.waitForDeployment());
const dataProtectorSharingContractV2 = await ethers.getContractAt(
'DataProtectorSharingV2Mock',
contractAddress,
);
await dataProtectorSharingContractV2.initializeV2('bar');
// Check V1 storage.
expect(await dataProtectorSharingContractV2.ownerOf(collectionTokenId)).to.equal(
addr1.address,
);
// Check V2 storage.
expect(await dataProtectorSharingContractV2.newStorage()).to.equal('bar');
// Check address.
expect(await dataProtectorSharingContractV2.getAddress()).to.equal(contractAddress);
});

it('TODO - Should not upgrade when storage is broken', async function () {});
});
});
5 changes: 0 additions & 5 deletions packages/subgraph/abis/DataProtectorSharingABI.json
Original file line number Diff line number Diff line change
Expand Up @@ -2007,11 +2007,6 @@
"internalType": "string",
"name": "iexecResultStorageProvider_",
"type": "string"
},
{
"internalType": "string",
"name": "iexecResultStorageProxy_",
"type": "string"
}
],
"name": "updateEnv",
Expand Down
Loading