From b57a15f17ed753814a515f93c5976452cc541785 Mon Sep 17 00:00:00 2001 From: Benjamin Bollen Date: Wed, 10 Apr 2024 11:56:50 +0100 Subject: [PATCH 1/6] (deploy): deploy v0.3.3-alpha to Chiado only --- CHANGELOG.md | 2 +- ...hiado-0.3.3-alpha-2f46ada-240410-114550.log | 18 ++++++++++++++++++ ...facts-0.3.3-alpha-2f46ada-240410-114550.txt | 9 +++++++++ .../constructorArgs_BaseGroupMintPolicy.txt | 1 + .../constructorArgs_ERC20Lift.txt | 1 + .../constructorArgs_Hub.txt | 1 + ...onstructorArgs_MastercopyDemurrageERC20.txt | 1 + ...tructorArgs_MastercopyInflationaryERC20.txt | 1 + ...constructorArgs_MastercopyStandardVault.txt | 1 + .../constructorArgs_Migration.txt | 1 + .../constructorArgs_NameRegistry.txt | 1 + .../constructorArgs_StandardTreasury.txt | 1 + 12 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 script/deployments/chiado-0.3.3-alpha-2f46ada-240410-114550/chiado-0.3.3-alpha-2f46ada-240410-114550.log create mode 100644 script/deployments/chiado-0.3.3-alpha-2f46ada-240410-114550/chiado-artefacts-0.3.3-alpha-2f46ada-240410-114550.txt create mode 100644 script/deployments/chiado-0.3.3-alpha-2f46ada-240410-114550/constructorArgs_BaseGroupMintPolicy.txt create mode 100644 script/deployments/chiado-0.3.3-alpha-2f46ada-240410-114550/constructorArgs_ERC20Lift.txt create mode 100644 script/deployments/chiado-0.3.3-alpha-2f46ada-240410-114550/constructorArgs_Hub.txt create mode 100644 script/deployments/chiado-0.3.3-alpha-2f46ada-240410-114550/constructorArgs_MastercopyDemurrageERC20.txt create mode 100644 script/deployments/chiado-0.3.3-alpha-2f46ada-240410-114550/constructorArgs_MastercopyInflationaryERC20.txt create mode 100644 script/deployments/chiado-0.3.3-alpha-2f46ada-240410-114550/constructorArgs_MastercopyStandardVault.txt create mode 100644 script/deployments/chiado-0.3.3-alpha-2f46ada-240410-114550/constructorArgs_Migration.txt create mode 100644 script/deployments/chiado-0.3.3-alpha-2f46ada-240410-114550/constructorArgs_NameRegistry.txt create mode 100644 script/deployments/chiado-0.3.3-alpha-2f46ada-240410-114550/constructorArgs_StandardTreasury.txt diff --git a/CHANGELOG.md b/CHANGELOG.md index eaba8d5..01e9958 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## latest +## v0.3.3 - [PR132] bug fix in groupMint(); initial test coverage for group mint - [PR130] remove the code from the first draft proposal (December 2023) diff --git a/script/deployments/chiado-0.3.3-alpha-2f46ada-240410-114550/chiado-0.3.3-alpha-2f46ada-240410-114550.log b/script/deployments/chiado-0.3.3-alpha-2f46ada-240410-114550/chiado-0.3.3-alpha-2f46ada-240410-114550.log new file mode 100644 index 0000000..d846d86 --- /dev/null +++ b/script/deployments/chiado-0.3.3-alpha-2f46ada-240410-114550/chiado-0.3.3-alpha-2f46ada-240410-114550.log @@ -0,0 +1,18 @@ +Chiado deployment +================= +Deployment Date: 2024-04-10 11:45:50 +Version: 0.3.3-alpha +Git Commit: 2f46ada912ee53dfb5e44709b1821f879a61276e +Deployer Address: 0x7619F26728Ced663E50E578EB6ff42430931564c, Intitial nonce: 99 +Compiler Version: v0.8.23+commit.f704f362 + +Deployed Contracts: +Hub: 0xDA02CDB5279B3a1eF27Be3d91aE924495E6A5569 +Migration: 0xd4CB24d1A9bA4e24feDb22a34f502f70c4E929FF +NameRegistry: 0xc6CABB6C7B8C2fF1871A90d7dDeDE8D8a7e9Dc85 +ERC20Lift: 0x44E51009CAf77917e2E06aE731863Cf59C3337dc +StandardTreasury: 0x49c358aFe75F5302A04Becf6F8273B4d55d46a2D +BaseGroupMintPolicy: 0xfC180f31Be6f6a0663EDb450B64E2E2695ed8f02 +MastercopyDemurrageERC20: 0x4a117EE75FC792B613D96ee6BAd576881F6e2B91 +MastercopyInflationaryERC20: 0xEAe752Caaca396A2E494a8B4F6e6d42dD134539b +MastercopyStandardVault: 0x1762C81FadB183495bCFC439CdF3e5d4f8Ff421f diff --git a/script/deployments/chiado-0.3.3-alpha-2f46ada-240410-114550/chiado-artefacts-0.3.3-alpha-2f46ada-240410-114550.txt b/script/deployments/chiado-0.3.3-alpha-2f46ada-240410-114550/chiado-artefacts-0.3.3-alpha-2f46ada-240410-114550.txt new file mode 100644 index 0000000..da04a5f --- /dev/null +++ b/script/deployments/chiado-0.3.3-alpha-2f46ada-240410-114550/chiado-artefacts-0.3.3-alpha-2f46ada-240410-114550.txt @@ -0,0 +1,9 @@ +{"contractName":"Hub","deployedAddress":"0xDA02CDB5279B3a1eF27Be3d91aE924495E6A5569","sourcePath":"src/hub/Hub.sol:Hub","constructor-args":"0xdbF22D4e8962Db3b2F1d9Ff55be728A887e47710 0xc6CABB6C7B8C2fF1871A90d7dDeDE8D8a7e9Dc85 0xd4CB24d1A9bA4e24feDb22a34f502f70c4E929FF 0x44E51009CAf77917e2E06aE731863Cf59C3337dc 0x49c358aFe75F5302A04Becf6F8273B4d55d46a2D 1675209600 31540000 https://fallback.aboutcircles.com/v1/circles/{id}.json","argumentsFile":"constructorArgs_Hub.txt"} +{"contractName":"Migration","deployedAddress":"0xd4CB24d1A9bA4e24feDb22a34f502f70c4E929FF","sourcePath":"src/migration/Migration.sol:Migration","constructor-args":"0xdbF22D4e8962Db3b2F1d9Ff55be728A887e47710 0xDA02CDB5279B3a1eF27Be3d91aE924495E6A5569 1675209600","argumentsFile":"constructorArgs_Migration.txt"} +{"contractName":"NameRegistry","deployedAddress":"0xc6CABB6C7B8C2fF1871A90d7dDeDE8D8a7e9Dc85","sourcePath":"src/names/NameRegistry.sol:NameRegistry","constructor-args":"0xDA02CDB5279B3a1eF27Be3d91aE924495E6A5569","argumentsFile":"constructorArgs_NameRegistry.txt"} +{"contractName":"ERC20Lift","deployedAddress":"0x44E51009CAf77917e2E06aE731863Cf59C3337dc","sourcePath":"src/lift/ERC20Lift.sol:ERC20Lift","constructor-args":"0xDA02CDB5279B3a1eF27Be3d91aE924495E6A5569 0xc6CABB6C7B8C2fF1871A90d7dDeDE8D8a7e9Dc85 0x4a117EE75FC792B613D96ee6BAd576881F6e2B91 0xEAe752Caaca396A2E494a8B4F6e6d42dD134539b","argumentsFile":"constructorArgs_ERC20Lift.txt"} +{"contractName":"StandardTreasury","deployedAddress":"0x49c358aFe75F5302A04Becf6F8273B4d55d46a2D","sourcePath":"src/treasury/StandardTreasury.sol:StandardTreasury","constructor-args":"0xDA02CDB5279B3a1eF27Be3d91aE924495E6A5569 0x1762C81FadB183495bCFC439CdF3e5d4f8Ff421f","argumentsFile":"constructorArgs_StandardTreasury.txt"} +{"contractName":"BaseGroupMintPolicy","deployedAddress":"0xfC180f31Be6f6a0663EDb450B64E2E2695ed8f02","sourcePath":"src/groups/BaseMintPolicy.sol:MintPolicy","constructor-args":"","argumentsFile":"constructorArgs_BaseGroupMintPolicy.txt"} +{"contractName":"MastercopyDemurrageERC20","deployedAddress":"0x4a117EE75FC792B613D96ee6BAd576881F6e2B91","sourcePath":"src/lift/DemurrageCircles.sol:DemurrageCircles","constructor-args":"","argumentsFile":"constructorArgs_MastercopyDemurrageERC20.txt"} +{"contractName":"MastercopyInflationaryERC20","deployedAddress":"0xEAe752Caaca396A2E494a8B4F6e6d42dD134539b","sourcePath":"src/lift/InflationaryCircles.sol:InflationaryCircles","constructor-args":"","argumentsFile":"constructorArgs_MastercopyInflationaryERC20.txt"} +{"contractName":"MastercopyStandardVault","deployedAddress":"0x1762C81FadB183495bCFC439CdF3e5d4f8Ff421f","sourcePath":"src/treasury/StandardVault.sol:StandardVault","constructor-args":"","argumentsFile":"constructorArgs_MastercopyStandardVault.txt"} diff --git a/script/deployments/chiado-0.3.3-alpha-2f46ada-240410-114550/constructorArgs_BaseGroupMintPolicy.txt b/script/deployments/chiado-0.3.3-alpha-2f46ada-240410-114550/constructorArgs_BaseGroupMintPolicy.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/script/deployments/chiado-0.3.3-alpha-2f46ada-240410-114550/constructorArgs_BaseGroupMintPolicy.txt @@ -0,0 +1 @@ + diff --git a/script/deployments/chiado-0.3.3-alpha-2f46ada-240410-114550/constructorArgs_ERC20Lift.txt b/script/deployments/chiado-0.3.3-alpha-2f46ada-240410-114550/constructorArgs_ERC20Lift.txt new file mode 100644 index 0000000..543ebf0 --- /dev/null +++ b/script/deployments/chiado-0.3.3-alpha-2f46ada-240410-114550/constructorArgs_ERC20Lift.txt @@ -0,0 +1 @@ +0xDA02CDB5279B3a1eF27Be3d91aE924495E6A5569 0xc6CABB6C7B8C2fF1871A90d7dDeDE8D8a7e9Dc85 0x4a117EE75FC792B613D96ee6BAd576881F6e2B91 0xEAe752Caaca396A2E494a8B4F6e6d42dD134539b diff --git a/script/deployments/chiado-0.3.3-alpha-2f46ada-240410-114550/constructorArgs_Hub.txt b/script/deployments/chiado-0.3.3-alpha-2f46ada-240410-114550/constructorArgs_Hub.txt new file mode 100644 index 0000000..a163d4e --- /dev/null +++ b/script/deployments/chiado-0.3.3-alpha-2f46ada-240410-114550/constructorArgs_Hub.txt @@ -0,0 +1 @@ +0xdbF22D4e8962Db3b2F1d9Ff55be728A887e47710 0xc6CABB6C7B8C2fF1871A90d7dDeDE8D8a7e9Dc85 0xd4CB24d1A9bA4e24feDb22a34f502f70c4E929FF 0x44E51009CAf77917e2E06aE731863Cf59C3337dc 0x49c358aFe75F5302A04Becf6F8273B4d55d46a2D 1675209600 31540000 https://fallback.aboutcircles.com/v1/circles/{id}.json diff --git a/script/deployments/chiado-0.3.3-alpha-2f46ada-240410-114550/constructorArgs_MastercopyDemurrageERC20.txt b/script/deployments/chiado-0.3.3-alpha-2f46ada-240410-114550/constructorArgs_MastercopyDemurrageERC20.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/script/deployments/chiado-0.3.3-alpha-2f46ada-240410-114550/constructorArgs_MastercopyDemurrageERC20.txt @@ -0,0 +1 @@ + diff --git a/script/deployments/chiado-0.3.3-alpha-2f46ada-240410-114550/constructorArgs_MastercopyInflationaryERC20.txt b/script/deployments/chiado-0.3.3-alpha-2f46ada-240410-114550/constructorArgs_MastercopyInflationaryERC20.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/script/deployments/chiado-0.3.3-alpha-2f46ada-240410-114550/constructorArgs_MastercopyInflationaryERC20.txt @@ -0,0 +1 @@ + diff --git a/script/deployments/chiado-0.3.3-alpha-2f46ada-240410-114550/constructorArgs_MastercopyStandardVault.txt b/script/deployments/chiado-0.3.3-alpha-2f46ada-240410-114550/constructorArgs_MastercopyStandardVault.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/script/deployments/chiado-0.3.3-alpha-2f46ada-240410-114550/constructorArgs_MastercopyStandardVault.txt @@ -0,0 +1 @@ + diff --git a/script/deployments/chiado-0.3.3-alpha-2f46ada-240410-114550/constructorArgs_Migration.txt b/script/deployments/chiado-0.3.3-alpha-2f46ada-240410-114550/constructorArgs_Migration.txt new file mode 100644 index 0000000..075a440 --- /dev/null +++ b/script/deployments/chiado-0.3.3-alpha-2f46ada-240410-114550/constructorArgs_Migration.txt @@ -0,0 +1 @@ +0xdbF22D4e8962Db3b2F1d9Ff55be728A887e47710 0xDA02CDB5279B3a1eF27Be3d91aE924495E6A5569 1675209600 diff --git a/script/deployments/chiado-0.3.3-alpha-2f46ada-240410-114550/constructorArgs_NameRegistry.txt b/script/deployments/chiado-0.3.3-alpha-2f46ada-240410-114550/constructorArgs_NameRegistry.txt new file mode 100644 index 0000000..1e84a72 --- /dev/null +++ b/script/deployments/chiado-0.3.3-alpha-2f46ada-240410-114550/constructorArgs_NameRegistry.txt @@ -0,0 +1 @@ +0xDA02CDB5279B3a1eF27Be3d91aE924495E6A5569 diff --git a/script/deployments/chiado-0.3.3-alpha-2f46ada-240410-114550/constructorArgs_StandardTreasury.txt b/script/deployments/chiado-0.3.3-alpha-2f46ada-240410-114550/constructorArgs_StandardTreasury.txt new file mode 100644 index 0000000..ab63355 --- /dev/null +++ b/script/deployments/chiado-0.3.3-alpha-2f46ada-240410-114550/constructorArgs_StandardTreasury.txt @@ -0,0 +1 @@ +0xDA02CDB5279B3a1eF27Be3d91aE924495E6A5569 0x1762C81FadB183495bCFC439CdF3e5d4f8Ff421f From 19e130862780da257d9ef239fc77ef2c92504fb8 Mon Sep 17 00:00:00 2001 From: Benjamin Bollen Date: Fri, 12 Apr 2024 18:43:03 +0100 Subject: [PATCH 2/6] (hub): start on consented flow --- script/deployments/package.json | 2 +- src/hub/Hub.sol | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/script/deployments/package.json b/script/deployments/package.json index 0cb09cf..94329c6 100644 --- a/script/deployments/package.json +++ b/script/deployments/package.json @@ -1,6 +1,6 @@ { "name": "deploy-circles", - "version": "0.3.2-alpha", + "version": "0.3.4-alpha", "type": "module", "dependencies": { "dotenv": "^16.4.5", diff --git a/src/hub/Hub.sol b/src/hub/Hub.sol index db2c16b..f639921 100644 --- a/src/hub/Hub.sol +++ b/src/hub/Hub.sol @@ -117,6 +117,12 @@ contract Hub is Circles, MetadataDefinitions, IHubErrors, ICirclesErrors { */ mapping(address => address) public treasuries; + /** + * @notice By default the advanced usage flags should remain zero. + * Only for advanced purposes people can consider enabling two flags. + */ + mapping(address => bytes32) public advancedUsageFlags; + /** * @notice The iterable mapping of directional trust relations between avatars and * their expiry times. From 5c90f3dead9c6316b190b3e3ff77c305ef07e74f Mon Sep 17 00:00:00 2001 From: Benjamin Bollen Date: Mon, 15 Apr 2024 18:43:56 +0100 Subject: [PATCH 3/6] (hub): update flow to default consented flow --- src/errors/Errors.sol | 2 +- src/hub/Hub.sol | 27 +++++++++++++++++++++------ 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/errors/Errors.sol b/src/errors/Errors.sol index d2c7502..0ad57c0 100644 --- a/src/errors/Errors.sol +++ b/src/errors/Errors.sol @@ -22,7 +22,7 @@ interface IHubErrors { error CirclesHubOperatorNotApprovedForSource(address operator, address source, uint16 streamId, uint8 code); - error CirclesHubCirclesAreNotTrustedByReceiver(address receiver, uint256 circlesId, uint8 code); + error CirclesHubFlowEdgeIsNotPermitted(address receiver, uint256 circlesId, uint8 code); error CirclesHubOnClosedPathOnlyPersonalCirclesCanReturnToAvatar(address failedReceiver, uint256 circlesId); diff --git a/src/hub/Hub.sol b/src/hub/Hub.sol index f639921..84b9306 100644 --- a/src/hub/Hub.sol +++ b/src/hub/Hub.sol @@ -63,6 +63,8 @@ contract Hub is Circles, MetadataDefinitions, IHubErrors, ICirclesErrors { */ address private constant SENTINEL = address(0x1); + bytes32 private constant ADVANCED_FLAG_OPTOUT_CONSENTEDFLOW = bytes32(uint256(1)); + // State variables /** @@ -118,8 +120,8 @@ contract Hub is Circles, MetadataDefinitions, IHubErrors, ICirclesErrors { mapping(address => address) public treasuries; /** - * @notice By default the advanced usage flags should remain zero. - * Only for advanced purposes people can consider enabling two flags. + * @notice By default the advanced usage flags should remain set to zero. + * Only for advanced purposes people can consider enabling flags. */ mapping(address => bytes32) public advancedUsageFlags; @@ -593,6 +595,18 @@ contract Hub is Circles, MetadataDefinitions, IHubErrors, ICirclesErrors { return uint256(trustMarkers[_truster][_trustee].expiry) >= block.timestamp; } + function isPermittedFlow(address _to, address _circlesAvatar) public view returns (bool) { + // if receiver does not trust the Circles being sent, then the flow is not consented regardless + if (uint256(trustMarkers[_to][_circlesAvatar].expiry) < block.timestamp) return false; + // if the advanced usage flag is set to opt-out of consented flow, + // then the uni-directional trust is sufficient + if (advancedUsageFlags[_circlesAvatar] & ADVANCED_FLAG_OPTOUT_CONSENTEDFLOW != bytes32(0)) { + return true; + } + // however, by default the consented flow requires bi-directional trust from center to receiver + return uint256(trustMarkers[_circlesAvatar][_to].expiry) >= block.timestamp; + } + /** * uri returns the IPFS URI for the ERC1155 token. * If the @@ -645,7 +659,7 @@ contract Hub is Circles, MetadataDefinitions, IHubErrors, ICirclesErrors { // from an address, so we can cast here without checks. if (!isTrusted(_group, address(uint160(_collateral[i])))) { // Group does not trust collateral. - revert CirclesHubCirclesAreNotTrustedByReceiver(_group, _collateral[i], 0); + revert CirclesHubFlowEdgeIsNotPermitted(_group, _collateral[i], 0); } if (_amounts[i] == 0) { @@ -729,9 +743,10 @@ contract Hub is Circles, MetadataDefinitions, IHubErrors, ICirclesErrors { int256 flow = int256(uint256(_flow[i].amount)); // check the receiver trusts the Circles being sent - if (!isTrusted(to, circlesId)) { - // Receiver does not trust Circles being sent - revert CirclesHubCirclesAreNotTrustedByReceiver(to, toTokenId(circlesId), 1); + // and that the center trusts the receiver (unless center opt-ed out) + if (!isPermittedFlow(to, circlesId)) { + // Flow edge is not permitted. + revert CirclesHubFlowEdgeIsNotPermitted(to, toTokenId(circlesId), 1); } if (_closedPath && (to != circlesId || isGroup(circlesId))) { // Closed paths can only return personal Circles to source. From 9ad90599f6b6811e7d5924447b488f2ea0f5fc3f Mon Sep 17 00:00:00 2001 From: Benjamin Bollen Date: Mon, 15 Apr 2024 19:18:15 +0100 Subject: [PATCH 4/6] (test/hub): update path transfer test for consented flow --- test/hub/PathTransferHub.t.sol | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/test/hub/PathTransferHub.t.sol b/test/hub/PathTransferHub.t.sol index 757adbd..a445f54 100644 --- a/test/hub/PathTransferHub.t.sol +++ b/test/hub/PathTransferHub.t.sol @@ -26,7 +26,7 @@ contract HubPathTransferTest is Test, TimeCirclesSetup, HumanRegistration, Appro // and 365 days as bootstrap time mockHub = new MockPathTransferHub(INFLATION_DAY_ZERO, 365 days); - // register 4 humans + // register 8 humans for (uint256 i = 0; i < N; i++) { vm.prank(addresses[i]); mockHub.registerHumanUnrestricted(); @@ -53,11 +53,24 @@ contract HubPathTransferTest is Test, TimeCirclesSetup, HumanRegistration, Appro assertEq(mockHub.isTrusted(addresses[i], addresses[i - 1]), true); assertEq(mockHub.isTrusted(addresses[i - 1], addresses[i]), false); } + + // for consented flow, the origin of the Circles needs to trust the receiver too + // Alice trusts Bob, Bob trusts Charlie, Charlie trusts David + for (uint256 i = 0; i < 3; i++) { + vm.prank(addresses[i]); + mockHub.trust(addresses[i + 1], expiry); + assertEq(mockHub.isTrusted(addresses[i], addresses[i + 1]), true); + assertEq(mockHub.isTrusted(addresses[i + 1], addresses[i]), true); + } } // Tests - function testOperateFlowMatrix() public { + function testOperateFlowMatrixConsentedFlow() public { + // Alice <-> Bob <-> Charlie <-> David + // first four avatars have a linear bi-directional trust + uint256 M = 4; + // Flow matrix for transferring Circles from Alice to David // with indication of which Circles are being sent // A B C D @@ -65,14 +78,14 @@ contract HubPathTransferTest is Test, TimeCirclesSetup, HumanRegistration, Appro // B-C . -5B 5B . // C-D . . -5C 5C - address[] memory flowVertices = new address[](N); - Hub.FlowEdge[] memory flow = new Hub.FlowEdge[](N - 1); + address[] memory flowVertices = new address[](M); + Hub.FlowEdge[] memory flow = new Hub.FlowEdge[](M - 1); // allocate three coordinates per flow edge - uint16[] memory coordinates = new uint16[]((N - 1) * 3); + uint16[] memory coordinates = new uint16[]((M - 1) * 3); // the flow vertices need to be provided in ascending order\ - for (uint256 i = 0; i < N; i++) { + for (uint256 i = 0; i < M; i++) { flowVertices[i] = sortedAddresses[i]; } @@ -81,7 +94,7 @@ contract HubPathTransferTest is Test, TimeCirclesSetup, HumanRegistration, Appro uint256 index = 0; // for each row in the flow matrix specify the coordinates and amount - for (uint256 i = 0; i < N - 1; i++) { + for (uint256 i = 0; i < M - 1; i++) { // flow is the amount of Circles to send, here constant for each edge flow[i].amount = uint240(5 * CRC); flow[i].streamSinkId = uint16(0); From 0a82320d02f5139244b31bf1562e5f1a5644cdac Mon Sep 17 00:00:00 2001 From: Benjamin Bollen Date: Mon, 15 Apr 2024 19:33:53 +0100 Subject: [PATCH 5/6] (hub, tes/hub): apply consented flow to groupMint and associated tests --- src/hub/Hub.sol | 2 +- test/groups/compositeMintGroups.sol | 16 ++++++++++++++-- test/groups/mintGroupCircles.t.sol | 6 +++++- test/hub/PathTransferHub.t.sol | 4 ++-- test/lift/ERC20Lift.t.sol | 6 ------ 5 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/hub/Hub.sol b/src/hub/Hub.sol index 84b9306..ab10d22 100644 --- a/src/hub/Hub.sol +++ b/src/hub/Hub.sol @@ -657,7 +657,7 @@ contract Hub is Circles, MetadataDefinitions, IHubErrors, ICirclesErrors { // _groupMint is only called from the public groupMint function, // or from operateFlowMatrix, and both ensure the collateral ids are derived // from an address, so we can cast here without checks. - if (!isTrusted(_group, address(uint160(_collateral[i])))) { + if (!isPermittedFlow(_group, address(uint160(_collateral[i])))) { // Group does not trust collateral. revert CirclesHubFlowEdgeIsNotPermitted(_group, _collateral[i], 0); } diff --git a/test/groups/compositeMintGroups.sol b/test/groups/compositeMintGroups.sol index 76ce7ff..dc03282 100644 --- a/test/groups/compositeMintGroups.sol +++ b/test/groups/compositeMintGroups.sol @@ -39,6 +39,9 @@ contract CompositeMintGroupsTest is Test, GroupSetup, IHubErrors { for (uint256 i = 0; i < 5; i++) { vm.prank(group0); hub.trust(addresses[i], INDEFINITE_FUTURE); + // and each human trusts the group + vm.prank(addresses[i]); + hub.trust(group0, INDEFINITE_FUTURE); collateral[0] = addresses[i]; amounts[0] = 1 * CRC; @@ -50,6 +53,9 @@ contract CompositeMintGroupsTest is Test, GroupSetup, IHubErrors { for (uint256 i = 0; i < 35; i++) { vm.prank(group1); hub.trust(addresses[i], INDEFINITE_FUTURE); + // and each human trusts the group + vm.prank(addresses[i]); + hub.trust(group1, INDEFINITE_FUTURE); collateral[0] = addresses[i]; amounts[0] = 1 * CRC; @@ -61,6 +67,9 @@ contract CompositeMintGroupsTest is Test, GroupSetup, IHubErrors { for (uint256 i = 0; i < 15; i++) { vm.prank(group2); hub.trust(addresses[i], INDEFINITE_FUTURE); + // and each human trusts the group + vm.prank(addresses[i]); + hub.trust(group2, INDEFINITE_FUTURE); collateral[0] = addresses[i]; amounts[0] = 1 * CRC; @@ -74,8 +83,11 @@ contract CompositeMintGroupsTest is Test, GroupSetup, IHubErrors { function testCompositeGroupMint() public { // everyone already has some group Circles // now let G1 trust G0 - vm.prank(addresses[36]); - hub.trust(addresses[35], INDEFINITE_FUTURE); + vm.prank(group1); + hub.trust(group0, INDEFINITE_FUTURE); + // reversly let G0 trust G1 for consented flow + vm.prank(group0); + hub.trust(group1, INDEFINITE_FUTURE); // now Alice mints with G0 as collateral for G1 address[] memory collateral = new address[](1); diff --git a/test/groups/mintGroupCircles.t.sol b/test/groups/mintGroupCircles.t.sol index 8b7eff0..1c22c53 100644 --- a/test/groups/mintGroupCircles.t.sol +++ b/test/groups/mintGroupCircles.t.sol @@ -28,8 +28,12 @@ contract MintGroupCirclesTest is Test, GroupSetup, IHubErrors { // G1 trusts first 5 humans for (uint256 i = 0; i < 5; i++) { - vm.prank(addresses[35]); + vm.prank(group); hub.trust(addresses[i], INDEFINITE_FUTURE); + + // and each human trusts the group + vm.prank(addresses[i]); + hub.trust(group, INDEFINITE_FUTURE); } } diff --git a/test/hub/PathTransferHub.t.sol b/test/hub/PathTransferHub.t.sol index a445f54..490887c 100644 --- a/test/hub/PathTransferHub.t.sol +++ b/test/hub/PathTransferHub.t.sol @@ -56,7 +56,7 @@ contract HubPathTransferTest is Test, TimeCirclesSetup, HumanRegistration, Appro // for consented flow, the origin of the Circles needs to trust the receiver too // Alice trusts Bob, Bob trusts Charlie, Charlie trusts David - for (uint256 i = 0; i < 3; i++) { + for (uint256 i = 0; i < N - 1; i++) { vm.prank(addresses[i]); mockHub.trust(addresses[i + 1], expiry); assertEq(mockHub.isTrusted(addresses[i], addresses[i + 1]), true); @@ -69,7 +69,7 @@ contract HubPathTransferTest is Test, TimeCirclesSetup, HumanRegistration, Appro function testOperateFlowMatrixConsentedFlow() public { // Alice <-> Bob <-> Charlie <-> David // first four avatars have a linear bi-directional trust - uint256 M = 4; + uint256 M = N; // Flow matrix for transferring Circles from Alice to David // with indication of which Circles are being sent diff --git a/test/lift/ERC20Lift.t.sol b/test/lift/ERC20Lift.t.sol index f712054..8826610 100644 --- a/test/lift/ERC20Lift.t.sol +++ b/test/lift/ERC20Lift.t.sol @@ -53,7 +53,6 @@ contract ERC20LiftTest is Test, TimeCirclesSetup, HumanRegistration { hub.personalMintWithoutV1Check(); uint256 aliceBalance = hub.balanceOf(addresses[0], uint256(uint160(addresses[0]))); - console.log("Alice balance: ", aliceBalance); // test the master contracts in Lift // ERC20Lift lift = mockDeployment.erc20Lift(); @@ -91,11 +90,6 @@ contract ERC20LiftTest is Test, TimeCirclesSetup, HumanRegistration { // somewhat cheekily test here that the demurrage works in ERC20 too // todo: split this out into proper unit tests, rather than stories - (uint192 balance, uint64 lastUpdatedDay) = aliceERC20.discountedBalances(addresses[0]); - console.log("ERC1155 balance: ", hub.balanceOf(addresses[0], uint256(uint160(addresses[0])))); - console.log("balance: ", balance); - console.log("lastUpdatedDay: ", lastUpdatedDay); - // skip time skipTime(2 days); // assert Alice has 15 CRC in her ERC20 From b89a474558f4ee121e7c0ac9d87b554416d5c385 Mon Sep 17 00:00:00 2001 From: Benjamin Bollen Date: Mon, 15 Apr 2024 19:38:54 +0100 Subject: [PATCH 6/6] (hub): add setter for advanced usage flags --- src/hub/Hub.sol | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/hub/Hub.sol b/src/hub/Hub.sol index ab10d22..ecb20b9 100644 --- a/src/hub/Hub.sol +++ b/src/hub/Hub.sol @@ -509,9 +509,7 @@ contract Hub is Circles, MetadataDefinitions, IHubErrors, ICirclesErrors { _burn(msg.sender, _id, _amount); } - // Public functions - - function wrap(address _avatar, uint256 _amount, CirclesType _type) public returns (address) { + function wrap(address _avatar, uint256 _amount, CirclesType _type) external returns (address) { if (!isHuman(_avatar) && !isGroup(_avatar)) { // Avatar must be human or group. revert CirclesAvatarMustBeRegistered(_avatar, 2); @@ -558,6 +556,14 @@ contract Hub is Circles, MetadataDefinitions, IHubErrors, ICirclesErrors { _matchNettedFlows(streamsNettedFlow, matrixNettedFlow); } + function setAdvancedUsageFlag(bytes32 _flag) external { + if (avatars[msg.sender] == address(0)) { + // Only registered avatars can set advanced usage flags. + revert CirclesAvatarMustBeRegistered(msg.sender, 3); + } + advancedUsageFlags[msg.sender] = _flag; + } + // Public functions /**