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

V0.3.7 patch01 personal mint reentrancy #47

Closed
Closed
Show file tree
Hide file tree
Changes from all 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
7 changes: 4 additions & 3 deletions src/circles/Circles.sol
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,12 @@ contract Circles is ERC1155, ICirclesErrors {
// No issuance to claim, simply return without reverting
return;
}
// mint personal Circles to the human
_mintAndUpdateTotalSupply(_human, toTokenId(_human), issuance, "");
// update the last mint time
// update the last mint time, before minting as mint time determines the check (guard for reeentrancy attack)
mintTimes[_human].lastMintTime = uint96(block.timestamp);

// mint personal Circles to the human; ERC1155 mint will perform acceptance call
_mintAndUpdateTotalSupply(_human, toTokenId(_human), issuance, "");

emit PersonalMint(_human, issuance, startPeriod, endPeriod);
}

Expand Down
4 changes: 2 additions & 2 deletions src/hub/Hub.sol
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ contract Hub is Circles, TypeDefinitions, IHubErrors {
* @dev Reentrancy guard for nonReentrant functions.
* see https://soliditylang.org/blog/2024/01/26/transient-storage/
*/
modifier nonReentrant(uint8 _code) {
modifier nonReentrant() {
assembly {
if tload(0) { revert(0, 0) }
tstore(0, 1)
Expand Down Expand Up @@ -543,7 +543,7 @@ contract Hub is Circles, TypeDefinitions, IHubErrors {
FlowEdge[] calldata _flow,
Stream[] calldata _streams,
bytes calldata _packedCoordinates
) external nonReentrant(0) {
) external nonReentrant {
// first unpack the coordinates to array of uint16
uint16[] memory coordinates = _unpackCoordinates(_packedCoordinates, _flow.length);

Expand Down
Loading