Skip to content

Commit

Permalink
revert custom storage slot
Browse files Browse the repository at this point in the history
  • Loading branch information
alistair-singh committed Jan 9, 2025
1 parent 266a350 commit 4ec8b97
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 30 deletions.
18 changes: 14 additions & 4 deletions contracts/src/Gateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import {SafeNativeTransfer} from "./utils/SafeTransfer.sol";
import {Call} from "./utils/Call.sol";
import {Math} from "./utils/Math.sol";
import {ScaleCodec} from "./utils/ScaleCodec.sol";
import {ReentrantGuard} from "./utils/ReentrantGuard.sol";

import {
AgentExecuteParams,
Expand Down Expand Up @@ -109,11 +108,22 @@ contract Gateway is IGateway, IInitializable, IUpgradable {
_;
}

// Makes sure that a method is non reentrant.
modifier nonreentrant() {
ReentrantGuard.checkAndSet();
assembly {
// Check if flag is set and if true revert because it means the function is currently executing.
if tload(0) { revert(0, 0) }

// Set the flag to mark the the function is currently executing.
tstore(0, 1)
}

// Execute the function here.
_;
ReentrantGuard.clear();

assembly {
// Clear the flag as the function has completed execution.
tstore(0, 0)
}
}

constructor(
Expand Down
26 changes: 0 additions & 26 deletions contracts/src/utils/ReentrantGuard.sol

This file was deleted.

0 comments on commit 4ec8b97

Please sign in to comment.