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

Simple ImmutableBeaconProxy implementation #19

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

kyzia551
Copy link
Contributor

No description provided.

@kyzia551 kyzia551 requested review from sakulstra and eboadom May 25, 2023 11:00
@github-actions
Copy link
Contributor

github-actions bot commented May 25, 2023

Foundry report

forge 0.2.0 (1caa0fa 2023-05-30T00:03:46.380409943Z)
Build log
Compiling 51 files with 0.8.14
Solc 0.8.14 finished in 3.89s
Compiler run �[32msuccessful!�[0m
| Contract                    | Size (kB) | Margin (kB) |
|-----------------------------|-----------|-------------|
| Address                     | 0.086     | 24.49       |
| BeaconMock                  | 0.145     | 24.431      |
| ERC1967Proxy                | 0.711     | 23.865      |
| ImmutableBeaconProxy        | 0.331     | 24.245      |
| ImmutableBeaconProxyMock    | 0.424     | 24.152      |
| ImplOwnableWithGuardian     | 0.807     | 23.769      |
| ImplementationMock          | 0.063     | 24.513      |
| MockImpl                    | 0.476     | 24.1        |
| ProxyAdmin                  | 1.69      | 22.886      |
| SafeCast                    | 0.086     | 24.49       |
| SafeERC20                   | 0.086     | 24.49       |
| StorageSlot                 | 0.086     | 24.49       |
| TransparentProxyFactory     | 7.541     | 17.035      |
| TransparentUpgradeableProxy | 2.104     | 22.472      |
| UpgradeableBeacon           | 0.852     | 23.724      |
| console                     | 0.086     | 24.49       |
| console2                    | 0.086     | 24.49       |
| stdError                    | 0.598     | 23.978      |
| stdJson                     | 0.086     | 24.49       |
| stdMath                     | 0.086     | 24.49       |
| stdStorage                  | 0.086     | 24.49       |
| stdStorageSafe              | 0.086     | 24.49       |
Test success 🌈
No files changed, compilation skipped

Running 3 tests for test/OwnableWithGuardian.t.sol:TestOfOwnableWithGuardian
�[32m[PASS]�[0m testConstructorLogic() (gas: 10594)
�[32m[PASS]�[0m testGuardianUpdate(address) (runs: 256, μ: 12259, ~: 12270)
�[32m[PASS]�[0m testGuardianUpdateNoAccess(address) (runs: 256, μ: 11501, ~: 11501)
Test result: �[32mok�[0m. 3 passed; 0 failed; finished in 40.95ms

Running 5 tests for test/EmergencyConsumer.t.sol:EmergencyConsumerTest
�[32m[PASS]�[0m testEmergency(int256,uint256) (runs: 256, μ: 33586, ~: 33586)
�[32m[PASS]�[0m testGetChainlinkEmergencyOracle() (gas: 2414)
�[32m[PASS]�[0m testGetEmergencyCount() (gas: 2339)
�[32m[PASS]�[0m testRevertIfNotInEmergency(int256,uint256) (runs: 256, μ: 30904, ~: 31221)
�[32m[PASS]�[0m testUpdateCLEmergencyOracleInternal(address) (runs: 256, μ: 10841, ~: 10863)
Test result: �[32mok�[0m. 5 passed; 0 failed; finished in 98.70ms

Running 3 tests for test/ImmutableBeaconProxy.t.sol:ImmutableBeaconProxyTest
�[32m[PASS]�[0m testBeaconNotAContract() (gas: 36193)
�[32m[PASS]�[0m testImplementationNotAContract() (gas: 120667)
�[32m[PASS]�[0m testResolvesImplementationCorrectly() (gas: 253716)
Test result: �[32mok�[0m. 3 passed; 0 failed; finished in 644.63µs

Running 4 tests for test/TransparentProxyFactory.t.sol:TestTransparentProxyFactory
�[32m[PASS]�[0m testCreateDeterministic(address,bytes32) (runs: 256, μ: 579900, ~: 579900)
�[32m[PASS]�[0m testCreateDeterministicProxyAdmin(address,bytes32) (runs: 256, μ: 413164, ~: 413164)
�[32m[PASS]�[0m testCreateDeterministicWithDeterministicProxy(bytes32,bytes32) (runs: 256, μ: 586673, ~: 586673)
�[32m[PASS]�[0m testCreateProxyAdmin(address,bytes32) (runs: 256, μ: 406237, ~: 406237)
Test result: �[32mok�[0m. 4 passed; 0 failed; finished in 233.55ms

* because it will not be accessible via delegatecall, and will not work as expected
*/
contract ImmutableBeaconProxy is Proxy {
address internal immutable _beacon;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
address internal immutable _beacon;
address public immutable BEACON;

/**
* @dev Returns the current implementation address of the associated beacon.
*/
function _implementation() internal view virtual override returns (address) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why internal?


pragma solidity ^0.8.0;

import './interfaces/IBeacon.sol';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this import this way?

@kyzia551
Copy link
Contributor Author

kyzia551 commented May 26, 2023 via email

@kyzia551 kyzia551 requested a review from eboadom May 31, 2023 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants