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

v2.3.0 migration script and upgrade test #680

Merged
merged 59 commits into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
3967780
Modify contract change detection
zajck Jun 12, 2023
0185e67
generic tests
zajck Jun 12, 2023
5e8804e
return zero DR clerk
zajck Jun 12, 2023
1034392
always return zero DR clerk
zajck Jun 12, 2023
74165aa
Clerk related tests
zajck Jun 13, 2023
5802557
unpause regions
zajck Jun 26, 2023
254b3ad
minimal resolution period related
zajck Jun 27, 2023
cfdf30c
correctly clear pending updates
zajck Jun 27, 2023
e7884e5
limit twin gas transfer
zajck Jun 27, 2023
cea10b0
commit at expiry
zajck Jun 27, 2023
c85e7b4
twin related tests
zajck Jun 27, 2023
0c89635
token gating
zajck Jun 28, 2023
32407b6
multiple collections
zajck Jun 28, 2023
62edd20
get*Funds, getTokenList*
zajck Jun 28, 2023
3352051
protocol limits are not enforced anymore
zajck Jun 29, 2023
46d0604
get pending update metadataUri
zajck Jul 3, 2023
d157370
Merge branch 'main' into upgrade-2.3.0-tests
anajuliabit Jul 10, 2023
d68efc8
Fix import
anajuliabit Jul 11, 2023
57021c0
package.json
anajuliabit Jul 12, 2023
1d7f7f1
Continue work on upgrade tests
anajuliabit Jul 12, 2023
9a60768
Improve migration
anajuliabit Jul 13, 2023
c8f205f
Remediate hardhat listAccounts bug
anajuliabit Jul 13, 2023
09fadae
minor changes
anajuliabit Jul 14, 2023
53282e1
Merge branch 'main' into upgrade-2.3.0-tests
anajuliabit Jul 14, 2023
7363063
Continue work on upgrade tests
anajuliabit Jul 14, 2023
f4314dd
Add exchange handler to migration upgrade
anajuliabit Jul 18, 2023
ca4106c
Add upgrade BV to migration
anajuliabit Jul 18, 2023
77eb3c4
Continue
anajuliabit Jul 19, 2023
a7b8d5f
Make twin creation opt
anajuliabit Jul 21, 2023
85b63ba
Adding BosonVoucher and PauseHandler tests
anajuliabit Jul 21, 2023
84786ea
Fix new collection tests
anajuliabit Jul 21, 2023
0963b36
Fix rest of failling tests
anajuliabit Jul 23, 2023
b8e8a33
Migrations improvements
anajuliabit Jul 24, 2023
d5ac4a1
Adding subgraph call to fetch seller creators
anajuliabit Jul 24, 2023
17d2e9e
adding dry-run env
anajuliabit Jul 25, 2023
d7d430e
Adding and removing selectors from metaTx handler
anajuliabit Jul 25, 2023
dc27892
Adding and removing selectors from metaTx handler
anajuliabit Jul 25, 2023
0d771da
Make subgraph call respect chain
anajuliabit Jul 25, 2023
1460fe1
Make subgraph call respect chain
anajuliabit Jul 25, 2023
cb42993
removing logs
anajuliabit Jul 25, 2023
aebd13b
fixing bug on migration
anajuliabit Jul 26, 2023
7b8e155
Tidy
anajuliabit Jul 26, 2023
8cd1973
Fix offer collectionIndex script
anajuliabit Jul 26, 2023
d21f22a
Removing logs
anajuliabit Jul 26, 2023
1a1017c
Add create2 test
anajuliabit Jul 28, 2023
8117dbe
Fix configHandler storage validation
anajuliabit Jul 28, 2023
6dad5df
Populate sellerCreators when is upgrade test env
anajuliabit Jul 28, 2023
7785276
Remove upgrade tests from coverage
anajuliabit Jul 28, 2023
7ce0897
Make generic tests compatible with v2.3.0
anajuliabit Aug 2, 2023
8b66743
WIP: review changes
anajuliabit Aug 2, 2023
7b31d24
Continue review changes
anajuliabit Aug 3, 2023
9b649ef
Add generic tests for vouchers
anajuliabit Aug 4, 2023
63eb046
Fix wrong proxy address [skip ci]
zajck Aug 8, 2023
88417da
Fix generic voucher tests
anajuliabit Aug 9, 2023
bae11cd
Merge branch 'upgrade-2.3.0-tests' of github.com:bosonprotocol/boson-…
zajck Aug 30, 2023
96e102f
WIP update tests to rc.2
zajck Aug 30, 2023
98e1c49
Merge branch 'main' into upgrade-2.3.0-tests
zajck Aug 30, 2023
4355423
Adapt tests to v2.3.0-rc.2
zajck Aug 31, 2023
77fef46
Merge branch 'main' into upgrade-2.3.0-tests
zajck Aug 31, 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: 1 addition & 0 deletions contracts/protocol/facets/DisputeResolverHandlerFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,7 @@ contract DisputeResolverHandlerFacet is IBosonAccountEvents, ProtocolBase {
{
(exists, disputeResolver, disputeResolverFees) = fetchDisputeResolver(_disputeResolverId);
if (exists) {
disputeResolver.clerk = address(0);
sellerAllowList = protocolLookups().allowedSellers[_disputeResolverId];
}
}
Expand Down
2 changes: 0 additions & 2 deletions contracts/protocol/facets/ExchangeHandlerFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,6 @@ contract ExchangeHandlerFacet is IBosonExchangeHandler, BuyerBase, DisputeBase {
// Token transfer order is descending
twinM.tokenId += twinM.supplyAvailable;
}

// ERC-721 style transfer
data = abi.encodeWithSignature(
"safeTransferFrom(address,address,uint256,bytes)",
Expand All @@ -890,7 +889,6 @@ contract ExchangeHandlerFacet is IBosonExchangeHandler, BuyerBase, DisputeBase {
""
);
}

// Make call only if there is enough gas and code at address exists.
// If not, skip the call and mark the transfer as failed
twinM.tokenAddress = twinS.tokenAddress;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ contract ProtocolInitializationHandlerFacet is IBosonProtocolInitializationHandl
function initV2_3_0(bytes calldata _initializationData) internal {
// Current version must be 2.2.1
require(protocolStatus().version == bytes32("2.2.1"), WRONG_CURRENT_VERSION);

require(protocolCounters().nextTwinId == 1, TWINS_ALREADY_EXIST);

// Decode initialization data
Expand Down
2 changes: 1 addition & 1 deletion contracts/protocol/facets/SellerHandlerFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ contract SellerHandlerFacet is SellerBase {

(exists, sellerId) = getSellerIdByAuthToken(_associatedAuthToken);
if (exists) {
return fetchSeller(sellerId);
return fetchSellerWithoutClerk(sellerId);
}
}

Expand Down
9 changes: 5 additions & 4 deletions hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,12 @@ task(
task("upgrade-facets", "Upgrade existing facets, add new facets or remove existing facets")
.addParam("newVersion", "The version of the protocol to upgrade to")
.addParam("env", "The deployment environment")
.addParam("functionNamesToSelector", "JSON list of function names to selectors")
.addOptionalParam("facetConfig", "JSON list of facets to upgrade")
.setAction(async ({ env, facetConfig, newVersion }) => {
.setAction(async ({ env, facetConfig, newVersion, functionNamesToSelector }) => {
const { upgradeFacets } = await lazyImport("./scripts/upgrade-facets.js");

await upgradeFacets(env, facetConfig, newVersion);
await upgradeFacets(env, facetConfig, newVersion, functionNamesToSelector);
});

task("upgrade-clients", "Upgrade existing clients")
Expand Down Expand Up @@ -115,9 +116,9 @@ task("migrate", "Migrates the protocol to a new version")

if (dryRun) {
const balanceAfter = await getBalance();
const etherSpent = balanceBefore.sub(balanceAfter);
const etherSpent = balanceBefore - balanceAfter;

const formatUnits = require("ethers").utils.formatUnits;
const formatUnits = require("ethers").formatUnits;
console.log("Ether spent: ", formatUnits(etherSpent, "ether"));
}
});
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"tidy:contracts": "solhint --fix contracts/**/*.sol && prettier --write contracts/**",
"tidy:scripts": "eslint --fix test/** scripts/** '*.js' && prettier --write test/** scripts/** '*.js'",
"size": "npx hardhat size-contracts",
"coverage": "npx hardhat clean && npx hardhat coverage",
"coverage": "npx hardhat clean && npx hardhat coverage --testfiles '{test/access/*.js,test/protocol/*.js,test/protocol/clients/*.js}'",
"deploy-suite:hardhat": "npx hardhat clean && npx hardhat compile && npx hardhat deploy-suite --network hardhat",
"deploy-suite:local": "npx hardhat clean && npx hardhat compile && npx hardhat deploy-suite --network localhost",
"deploy-suite:test": "npx hardhat clean && npx hardhat compile && npx hardhat deploy-suite --network test --env test >> logs/test.deploy.contracts.txt",
Expand All @@ -52,6 +52,7 @@
"upgrade-facets:polygon:mumbai-test": "npx hardhat clean && npx hardhat compile && npx hardhat upgrade-facets --network mumbai --env test >> logs/mumbai-test.upgrade.contracts.txt",
"upgrade-facets:polygon:mumbai-staging": "npx hardhat clean && npx hardhat compile && npx hardhat upgrade-facets --network mumbai --env staging >> logs/mumbai-staging.upgrade.contracts.txt",
"upgrade-facets:polygon:mainnet": "npx hardhat clean && npx hardhat compile && npx hardhat upgrade-facets --network polygon --env prod >> logs/polygon.upgrade.contracts.txt",
"migrate": "npx hardhat clean && npx hardhat compile && npx hardhat migrate >> logs/${npm_config_env}-migrate.contracts.txt",
"upgrade-clients:local": "npx hardhat clean && npx hardhat compile && npx hardhat upgrade-clients --network localhost --env ''",
"upgrade-clients:test": "npx hardhat clean && npx hardhat compile && npx hardhat upgrade-clients --network test --env test >> logs/test.upgrade.contracts.txt",
"upgrade-clients:ethereum:mainnet": "npx hardhat clean && npx hardhat compile && npx hardhat upgrade-clients --network mainnet --env prod >> logs/mainnet.upgrade.contracts.txt",
Expand Down
3 changes: 3 additions & 0 deletions scripts/domain/Offer.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ class Offer {
voided,
collectionIndex,
] = struct;
if (!collectionIndex) {
collectionIndex = 0;
}

return Offer.fromObject({
id: id.toString(),
Expand Down
4 changes: 2 additions & 2 deletions scripts/manage-roles.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const hre = require("hardhat");
const { getContractAt, provider } = hre.ethers;
const network = hre.network.name;
const { RoleAssignments } = require("./config/role-assignments");
const { readContracts } = require("./util/utils");
const { readContracts, listAccounts } = require("./util/utils");
const environments = require("../environments");
const Role = require("./domain/Role");

Expand Down Expand Up @@ -39,7 +39,7 @@ async function main(env) {
console.log(`⛓ Network: ${hre.network.name}\n📅 ${new Date()}`);

// Get the accounts
const accounts = await provider.listAccounts();
const accounts = await listAccounts();
const admin = accounts[0];
console.log("🔱 Admin account: ", admin ? admin : "not found" && process.exit());
console.log(divider);
Expand Down
2 changes: 1 addition & 1 deletion scripts/migrations/dry-run.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ async function setupDryRun(env) {

await hre.changeNetwork("hardhat");

env = "upgrade-test";
env = `${env}-dry-run`;

const { chainId } = await ethers.provider.getNetwork();
if (chainId != "31337") process.exit(1); // make sure network is hardhat
Expand Down
1 change: 1 addition & 0 deletions scripts/migrations/migrate_2.2.1.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ async function migrate(env) {

console.log("Compiling old contracts");
await hre.run("clean");

await hre.run("compile");

const { chainId } = await provider.getNetwork();
Expand Down
Loading