Skip to content

Commit afd5401

Browse files
committed
finalized basic benchmarking
1 parent cf48b15 commit afd5401

File tree

4 files changed

+14
-15
lines changed

4 files changed

+14
-15
lines changed

README.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ Tested consumption of Drainer `drain(address payable victim, uint256 cycles)` fu
3535

3636
Benchmark is given for RateLimiting functionality assuming that drain function can have different `cycles` argument
3737

38-
| First Header | 1 tx/block rate | 10 tx/block rate | 100 tx/block rate |
39-
| ------------------------------------ | --------------- | ---------------- | ----------------- |
40-
| No Layer modifier | 82,897 | 131,704 | 619,774 |
41-
| Layer modifier installed (no layers) | 85,344 | 138,174 | 666,474 |
42-
| 1 Layer call added (Interface only) | **97,980** | **188,034** | **1,088,574** |
43-
| 1 Layer call added (Rate limiter x1) | 97,980 | 239,337 | 1,206,027 |
44-
| 2 Layer call added (Rate limiter x2) | 153,499 | 293,647 | 1,695,127 |
38+
| First Header | gas used (cycles=1) | delta from fixture |
39+
| --------------------------------------- | ------------------- | ------------------ |
40+
| No Layer modifier (fixture consumption) | 31,231 | 0 |
41+
| Layer modifier installed (no layers) | 33,869 | + 2 638 |
42+
| 1 Layer call added (Interface only) | **50,310** | **+ 19 079** |
43+
| 1 Layer call added (Rate limiter x1) | 75,476 | + 44 244 |
44+
| 2 Layer call added (Rate limiter x2) | 117,024 | + 85 793 |
4545

4646
_\*Bold numbers show cost to call layer contract protection wrapper that has no internal processing overhead._

hardhat.config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export default {
2828
token: "MATIC",
2929
gasPriceApi:
3030
"https://api.polygonscan.com/api?module=proxy&action=eth_gasPrice",
31-
enabled: true,
31+
enabled: false,
3232
coinmarketcap: process.env.COINMARKETCAP_KEY,
3333
},
3434
namedAccounts: {

src/LayeredProxy.sol

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ contract LayeredProxy is TransparentUpgradeableProxy, AccessLayers {
2626

2727
fallback() external payable override layers(msg.sig, msg.sender, msg.data, msg.value) {
2828
drainedMethod();
29-
_delegate(_implementation());
3029
}
3130

3231
receive() external payable {

test/mock.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ describe("test drainage", async function () {
3434
env = await setupTest();
3535
});
3636
it("succeeds below 10 transactions", async () => {
37-
await expect(env.attacker.drain(env.victim.address, 100)).to.emit(
37+
await expect(env.attacker.drain(env.victim.address, 1)).to.emit(
3838
env.victim,
3939
"BalanceReduced",
4040
);
4141
});
42-
// it("fails beyond 10 transactions", async () => {
43-
// await expect(env.attacker.drain(env.victim.address, 11)).to.be.revertedWith(
44-
// "Out of quota this block",
45-
// );
46-
// });
42+
it("fails beyond 10 transactions", async () => {
43+
await expect(env.attacker.drain(env.victim.address, 11)).to.be.revertedWith(
44+
"Out of quota this block",
45+
);
46+
});
4747
});

0 commit comments

Comments
 (0)