Skip to content

Commit 6598f77

Browse files
committed
refactor: fixed time machine + beacon chain addresses
1 parent cf9391b commit 6598f77

File tree

4 files changed

+17
-16
lines changed

4 files changed

+17
-16
lines changed

src/test/integration/IntegrationDeployer.t.sol

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ abstract contract IntegrationDeployer is ExistingDeploymentParser {
6767
mapping(address => bool) public tokensNotTested;
6868

6969
// Mock Contracts to deploy
70-
TimeMachine public timeMachine;
71-
BeaconChainMock public beaconChain;
70+
TimeMachine public constant timeMachine = TimeMachine(address(0x000000000000000074696D65206D616368696e65)); // bytes("time machine")
71+
BeaconChainMock public constant beaconChain = BeaconChainMock(address(0x0000000000000000626561636f6e636861696e6D6f636b)); // bytes("beacon chain")
7272

7373
// Admin Addresses
7474
address constant pauser = address(555);
@@ -211,8 +211,10 @@ abstract contract IntegrationDeployer is ExistingDeploymentParser {
211211
BEACON_GENESIS_TIME = GENESIS_TIME_LOCAL;
212212
cheats.warp(BEACON_GENESIS_TIME);
213213
cheats.roll(10_000);
214-
timeMachine = new TimeMachine();
215-
beaconChain = new BeaconChainMock(eigenPodManager, BEACON_GENESIS_TIME);
214+
215+
vm.etch(address(timeMachine), type(TimeMachine).runtimeCode);
216+
vm.etch(address(beaconChain), type(BeaconChainMock).runtimeCode);
217+
beaconChain.initialize(eigenPodManager, BEACON_GENESIS_TIME);
216218
}
217219

218220
/// Parse existing contracts from mainnet
@@ -251,8 +253,9 @@ abstract contract IntegrationDeployer is ExistingDeploymentParser {
251253

252254
// Create time machine and mock beacon chain
253255
BEACON_GENESIS_TIME = GENESIS_TIME_MAINNET;
254-
timeMachine = new TimeMachine();
255-
beaconChain = new BeaconChainMock(eigenPodManager, BEACON_GENESIS_TIME);
256+
vm.etch(address(timeMachine), type(TimeMachine).runtimeCode);
257+
vm.etch(address(beaconChain), type(BeaconChainMock).runtimeCode);
258+
beaconChain.initialize(eigenPodManager, BEACON_GENESIS_TIME);
256259

257260
// Since we haven't done the slashing upgrade on mainnet yet, upgrade mainnet contracts
258261
// prior to test. `isUpgraded` is true by default, but is set to false in `UpgradeTest.t.sol`

src/test/integration/mocks/BeaconChainMock.t.sol

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,11 @@ contract BeaconChainMock is Logger {
7575
// see https://eth2book.info/capella/part3/containers/blocks/#beaconblock
7676
uint constant BEACON_BLOCK_FIELDS = 5;
7777

78-
uint immutable BLOCKROOT_PROOF_LEN = 32 * BeaconChainProofs.BEACON_BLOCK_HEADER_TREE_HEIGHT;
79-
uint immutable VAL_FIELDS_PROOF_LEN = 32 * ((BeaconChainProofs.VALIDATOR_TREE_HEIGHT + 1) + BeaconChainProofs.BEACON_STATE_TREE_HEIGHT);
80-
uint immutable BALANCE_CONTAINER_PROOF_LEN =
78+
uint constant BLOCKROOT_PROOF_LEN = 32 * BeaconChainProofs.BEACON_BLOCK_HEADER_TREE_HEIGHT;
79+
uint constant VAL_FIELDS_PROOF_LEN = 32 * ((BeaconChainProofs.VALIDATOR_TREE_HEIGHT + 1) + BeaconChainProofs.BEACON_STATE_TREE_HEIGHT);
80+
uint constant BALANCE_CONTAINER_PROOF_LEN =
8181
32 * (BeaconChainProofs.BEACON_BLOCK_HEADER_TREE_HEIGHT + BeaconChainProofs.BEACON_STATE_TREE_HEIGHT);
82-
uint immutable BALANCE_PROOF_LEN = 32 * (BeaconChainProofs.BALANCE_TREE_HEIGHT + 1);
82+
uint constant BALANCE_PROOF_LEN = 32 * (BeaconChainProofs.BALANCE_TREE_HEIGHT + 1);
8383

8484
uint64 genesisTime;
8585
uint64 public nextTimestamp;
@@ -128,7 +128,7 @@ contract BeaconChainMock is Logger {
128128

129129
bytes32[] zeroNodes;
130130

131-
constructor(EigenPodManager _eigenPodManager, uint64 _genesisTime) {
131+
function initialize(EigenPodManager _eigenPodManager, uint64 _genesisTime) public {
132132
genesisTime = _genesisTime;
133133
eigenPodManager = _eigenPodManager;
134134

src/test/integration/users/AVS.t.sol

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import "src/contracts/strategies/StrategyFactory.sol";
99

1010
import "src/test/mocks/ERC20Mock.sol";
1111
import "src/test/integration/users/User.t.sol";
12-
import "src/test/integration/TimeMachine.t.sol";
1312
import "src/test/utils/Logger.t.sol";
1413

1514
import "src/test/utils/ArrayLib.sol";
@@ -20,21 +19,20 @@ interface IAVSDeployer {
2019
function allocationManager() external view returns (AllocationManager);
2120
function strategyFactory() external view returns (StrategyFactory);
2221
function permissionController() external view returns (PermissionController);
23-
function timeMachine() external view returns (TimeMachine);
2422
}
2523

2624
contract AVS is Logger, IAllocationManagerTypes, IAVSRegistrar {
2725
using print for *;
2826
using ArrayLib for *;
2927

3028
IStrategy constant beaconChainETHStrategy = IStrategy(0xbeaC0eeEeeeeEEeEeEEEEeeEEeEeeeEeeEEBEaC0);
29+
TimeMachine constant timeMachine = TimeMachine(address(0x000000000000000074696D65206D616368696e65));
3130

3231
// TODO: fix later for same reason as User.t.sol
3332
AllocationManager immutable allocationManager;
3433
PermissionController immutable permissionController;
3534
DelegationManager immutable delegationManager;
3635
StrategyFactory immutable strategyFactory;
37-
TimeMachine immutable timeMachine;
3836
string _NAME;
3937

4038
uint32 totalOperatorSets;
@@ -45,7 +43,6 @@ contract AVS is Logger, IAllocationManagerTypes, IAVSRegistrar {
4543
permissionController = deployer.permissionController();
4644
delegationManager = deployer.delegationManager();
4745
strategyFactory = deployer.strategyFactory();
48-
timeMachine = deployer.timeMachine();
4946
_NAME = name;
5047
cheats.label(address(this), NAME_COLORED());
5148
}

src/test/unit/EigenPodUnit.t.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ contract EigenPodUnitTests is EigenLayerUnitTestSetup, EigenPodPausingConstants,
5353
ethPOSDepositMock = new ETHPOSDepositMock();
5454
cheats.warp(GENESIS_TIME_LOCAL);
5555
timeMachine = new TimeMachine();
56-
beaconChain = new BeaconChainMock(EigenPodManager(address(eigenPodManagerMock)), GENESIS_TIME_LOCAL);
56+
beaconChain = new BeaconChainMock();
57+
beaconChain.initialize(EigenPodManager(address(eigenPodManagerMock)), GENESIS_TIME_LOCAL);
5758

5859
// Deploy EigenPod
5960
podImplementation = new EigenPod(ethPOSDepositMock, IEigenPodManager(address(eigenPodManagerMock)), GENESIS_TIME_LOCAL, "v9.9.9");

0 commit comments

Comments
 (0)