Skip to content

Commit

Permalink
Acceptance manifestos (#121)
Browse files Browse the repository at this point in the history
* add acceptance manifestos

* rename to winner, add basic tests! :)

* more manifesto tests

* add max speech length

* Update AuctionHouse.sol

* fix bug...

* new gas reports
  • Loading branch information
rocketman-21 committed Feb 14, 2024
1 parent abc7062 commit c463b00
Show file tree
Hide file tree
Showing 8 changed files with 1,285 additions and 858 deletions.
5 changes: 5 additions & 0 deletions .changeset/sweet-waves-do.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@cobuild/revolution": patch
---

Manifestos
198 changes: 55 additions & 143 deletions gas-reports/protocol-rewards.ansi

Large diffs are not rendered by default.

1,550 changes: 857 additions & 693 deletions gas-reports/revolution.ansi

Large diffs are not rendered by default.

49 changes: 42 additions & 7 deletions gas-reports/splits.ansi
Original file line number Diff line number Diff line change
@@ -1,10 +1,45 @@
Compiling 41 files with 0.8.22
Solc 0.8.22 finished in 6.46s
Compiler run successful!
Compiling 62 files with 0.8.22
Solc 0.8.22 finished in 18.55s
Compiler run successful with warnings:
Warning (2018): Function state mutability can be restricted to view
--> test/Splits.t.sol:58:5:
 |
58 | function setupBasicSplit()
 | ^ (Relevant source part starts here and spans across multiple lines).


Running 10 tests for test/ValidateSplits.t.sol:ValidateSplitsTest
[PASS] test__NO_Revert_TooFewSplitAccounts() (gas: 121569)
[PASS] test__Revert_AccountsAndAllocationsMismatch() (gas: 17792)
[PASS] test__Revert_AllocationMustBePositive() (gas: 21788)
[PASS] test__Revert_LargePointsSplit() (gas: 20282)
[PASS] test__Revert_LargeTreasurySplit() (gas: 18437)
[PASS] test__Revert_NoTreasurySplit() (gas: 17391)
[PASS] test__Revert_PointsAccountsAndAllocationsMismatch() (gas: 18600)
[PASS] test__Revert_PointsAccountsMustBeOrdered() (gas: 21512)
[PASS] test__Revert_SmallPointsSplit() (gas: 20197)
[PASS] test__Revert_TooFewPointsAccounts() (gas: 17410)
Test result: ok. 10 passed; 0 failed; 0 skipped; finished in 1.24ms
| node_modules/@cobuild/utility-contracts/src/proxy/ERC1967Proxy.sol:ERC1967Proxy contract | | | | | |
|------------------------------------------------------------------------------------------|-----------------|--------|--------|--------|---------|
| Deployment Cost | Deployment Size | | | | |
| 52860 | 825 | | | | |
| Function Name | min | avg | median | max | # calls |
| PERCENTAGE_SCALE | 611 | 611 | 611 | 611 | 10 |
| createSplit | 6866 | 19225 | 9034 | 114681 | 10 |
| initialize | 414799 | 414799 | 414799 | 414799 | 10 |


| src/SplitMain.sol:SplitMain contract | | | | | |
|--------------------------------------|-----------------|--------|--------|--------|---------|
| Deployment Cost | Deployment Size | | | | |
| 4773417 | 24187 | | | | |
| Function Name | min | avg | median | max | # calls |
| PERCENTAGE_SCALE | 313 | 313 | 313 | 313 | 10 |
| createSplit | 1986 | 14332 | 4142 | 109805 | 10 |
| initialize | 414498 | 414498 | 414498 | 414498 | 10 |


Running 1 test for test/Splits.t.sol:SplitsTest
[PASS] test__Blank() (gas: 200)
Test result: ok. 1 passed; 0 failed; 0 skipped; finished in 498.67µs


Ran 1 test suites: 1 tests passed, 0 failed, 0 skipped (1 total tests)
Ran 1 test suites: 10 tests passed, 0 failed, 0 skipped (10 total tests)
31 changes: 16 additions & 15 deletions packages/revolution/.storage-layout
Original file line number Diff line number Diff line change
Expand Up @@ -114,21 +114,22 @@
➡ AuctionHouse
=======================

| Name | Type | Slot | Offset | Bytes | Contract |
|---------------------------|-----------------------------------|------|--------|-------|-----------------------------------|
| revolutionToken | contract IRevolutionToken | 0 | 0 | 20 | src/AuctionHouse.sol:AuctionHouse |
| revolutionPointsEmitter | contract IRevolutionPointsEmitter | 1 | 0 | 20 | src/AuctionHouse.sol:AuctionHouse |
| WETH | address | 2 | 0 | 20 | src/AuctionHouse.sol:AuctionHouse |
| timeBuffer | uint256 | 3 | 0 | 32 | src/AuctionHouse.sol:AuctionHouse |
| reservePrice | uint256 | 4 | 0 | 32 | src/AuctionHouse.sol:AuctionHouse |
| minBidIncrementPercentage | uint8 | 5 | 0 | 1 | src/AuctionHouse.sol:AuctionHouse |
| creatorRateBps | uint256 | 6 | 0 | 32 | src/AuctionHouse.sol:AuctionHouse |
| minCreatorRateBps | uint256 | 7 | 0 | 32 | src/AuctionHouse.sol:AuctionHouse |
| entropyRateBps | uint256 | 8 | 0 | 32 | src/AuctionHouse.sol:AuctionHouse |
| duration | uint256 | 9 | 0 | 32 | src/AuctionHouse.sol:AuctionHouse |
| auction | struct IAuctionHouse.Auction | 10 | 0 | 192 | src/AuctionHouse.sol:AuctionHouse |
| grantsAddress | address | 16 | 0 | 20 | src/AuctionHouse.sol:AuctionHouse |
| grantsRateBps | uint256 | 17 | 0 | 32 | src/AuctionHouse.sol:AuctionHouse |
| Name | Type | Slot | Offset | Bytes | Contract |
|---------------------------|--------------------------------------------------------------|------|--------|-------|-----------------------------------|
| revolutionToken | contract IRevolutionToken | 0 | 0 | 20 | src/AuctionHouse.sol:AuctionHouse |
| revolutionPointsEmitter | contract IRevolutionPointsEmitter | 1 | 0 | 20 | src/AuctionHouse.sol:AuctionHouse |
| WETH | address | 2 | 0 | 20 | src/AuctionHouse.sol:AuctionHouse |
| timeBuffer | uint256 | 3 | 0 | 32 | src/AuctionHouse.sol:AuctionHouse |
| reservePrice | uint256 | 4 | 0 | 32 | src/AuctionHouse.sol:AuctionHouse |
| minBidIncrementPercentage | uint8 | 5 | 0 | 1 | src/AuctionHouse.sol:AuctionHouse |
| creatorRateBps | uint256 | 6 | 0 | 32 | src/AuctionHouse.sol:AuctionHouse |
| minCreatorRateBps | uint256 | 7 | 0 | 32 | src/AuctionHouse.sol:AuctionHouse |
| entropyRateBps | uint256 | 8 | 0 | 32 | src/AuctionHouse.sol:AuctionHouse |
| duration | uint256 | 9 | 0 | 32 | src/AuctionHouse.sol:AuctionHouse |
| auction | struct IAuctionHouse.Auction | 10 | 0 | 192 | src/AuctionHouse.sol:AuctionHouse |
| grantsAddress | address | 16 | 0 | 20 | src/AuctionHouse.sol:AuctionHouse |
| grantsRateBps | uint256 | 17 | 0 | 32 | src/AuctionHouse.sol:AuctionHouse |
| manifestos | mapping(uint256 => struct IAuctionHouse.AcceptanceManifesto) | 18 | 0 | 32 | src/AuctionHouse.sol:AuctionHouse |

=======================
➡ MaxHeap
Expand Down
24 changes: 24 additions & 0 deletions packages/revolution/src/AuctionHouse.sol
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ contract AuctionHouse is
// Split of purchase proceeds sent to the grants system as ether in basis points
uint256 public grantsRateBps;

// The new revolution member's acceptance speech
mapping(uint256 => AcceptanceManifesto) public manifestos;

/// ///
/// IMMUTABLES ///
/// ///
Expand Down Expand Up @@ -418,6 +421,9 @@ contract AuctionHouse is
} else {
//If someone has bid and won, transfer the token to the winning bidder
revolutionToken.transferFrom(address(this), _auction.bidder, _auction.tokenId);

// Set the blank acceptance speech for the new member
manifestos[_auction.tokenId] = AcceptanceManifesto({ member: _auction.bidder, speech: "" });
}

if (_auction.amount > 0) {
Expand Down Expand Up @@ -523,6 +529,24 @@ contract AuctionHouse is
}
}

/**
* @notice Allows a member to update their manifesto.
* @param tokenId The ID of the token for which the manifesto is to be updated.
* @param newSpeech The new manifesto speech.
*/
function updateManifesto(uint256 tokenId, string calldata newSpeech) external {
AcceptanceManifesto memory manifesto = manifestos[tokenId];

// Ensure the new manifesto speech is not too long ("we choose to go to the moon" - JFK)
if (bytes(newSpeech).length > 12_096) revert MANIFESTO_TOO_LONG();

if (msg.sender != manifesto.member) revert NOT_INITIAL_TOKEN_OWNER();

manifestos[tokenId].speech = newSpeech;

emit ManifestoUpdated(tokenId, msg.sender, newSpeech);
}

/// ///
/// GRANTS PROGRAM ///
/// ///
Expand Down
15 changes: 15 additions & 0 deletions packages/revolution/src/interfaces/IAuctionHouse.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ interface IAuctionHouseEvents {

event AuctionExtended(uint256 indexed tokenId, uint256 endTime);

event ManifestoUpdated(uint256 indexed tokenId, address member, string speech);

event AuctionSettled(
uint256 indexed tokenId,
address winner,
Expand Down Expand Up @@ -105,6 +107,12 @@ interface IAuctionHouse is IAuctionHouseEvents, IGrantsRevenueStream {
/// @dev Reverts if an existing auction is in progress.
error AUCTION_ALREADY_IN_PROGRESS();

/// @dev Reverts if `updateManifesto` msg.sender is not the initial winner of the tokenId
error NOT_INITIAL_TOKEN_OWNER();

/// @dev Reverts if the manifesto speech specified in `updateManifesto` is too long.
error MANIFESTO_TOO_LONG();

struct Auction {
// ERC721 token ID
uint256 tokenId;
Expand Down Expand Up @@ -136,6 +144,13 @@ interface IAuctionHouse is IAuctionHouseEvents, IGrantsRevenueStream {
uint256 eth;
}

// A new community member has joined the revolution.
// What do you have to say for yourself?
struct AcceptanceManifesto {
address member;
string speech;
}

function settleAuction() external;

function settleCurrentAndCreateNewAuction() external;
Expand Down
Loading

0 comments on commit c463b00

Please sign in to comment.