generated from bgd-labs/bgd-forge-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from bgd-labs/feat/mantle-path-activation
feat: Mantle a.DI activation path
- Loading branch information
Showing
8 changed files
with
173 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
...d_mantle_path_to_adiethereum_before_adi_add_mantle_path_to_adiethereum_after.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
## Raw diff | ||
|
||
```json | ||
{ | ||
"forwarderAdaptersByChain": { | ||
"5000": { | ||
"from": "", | ||
"to": { | ||
"0xb66FA987fa7975Cac3d12B629c9c44e459e50990": "0x4E740ac02b866b429738a9e225e92A15F4452521" | ||
} | ||
} | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
scripts/payloads/adapters/ethereum/Ethereum_Activate_Mantle_Bridge_Adapter_Payload.s.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
import '../../../BaseDeployerScript.sol'; | ||
import '../../../../src/templates/SimpleAddForwarderAdapter.sol'; | ||
|
||
abstract contract Ethereum_Activate_Mantle_Bridge_Adapter_Payload is BaseDeployerScript { | ||
function _getPayloadByteCode() internal virtual returns (bytes memory); | ||
|
||
function PAYLOAD_SALT() internal pure virtual returns (string memory) { | ||
return 'Add Mantle path to a.DI'; | ||
} | ||
|
||
function DESTINATION_CHAIN_ID() internal pure virtual returns (uint256); | ||
|
||
function _deployPayload(AddForwarderAdapterArgs memory args) internal returns (address) { | ||
bytes memory payloadCode = abi.encodePacked(_getPayloadByteCode(), abi.encode(args)); | ||
|
||
return _deployByteCode(payloadCode, PAYLOAD_SALT()); | ||
} | ||
|
||
function _execute(Addresses memory addresses) internal virtual override { | ||
Addresses memory destinationAddresses = _getAddresses(DESTINATION_CHAIN_ID()); | ||
|
||
_deployPayload( | ||
AddForwarderAdapterArgs({ | ||
crossChainController: addresses.crossChainController, | ||
currentChainBridgeAdapter: addresses.mantleAdapter, | ||
destinationChainBridgeAdapter: destinationAddresses.mantleAdapter, | ||
destinationChainId: DESTINATION_CHAIN_ID() | ||
}) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
pragma solidity ^0.8.0; | ||
|
||
import 'forge-std/console.sol'; | ||
import {ADITestBase} from '../../adi/ADITestBase.sol'; | ||
import {Addresses, Ethereum as PayloadEthereumScript} from '../../../scripts/payloads/adapters/ethereum/Network_Deployments.s.sol'; | ||
import {SimpleAddForwarderAdapter, AddForwarderAdapterArgs} from '../../../src/templates/SimpleAddForwarderAdapter.sol'; | ||
|
||
abstract contract BaseAddMantlePathPayloadTest is ADITestBase { | ||
address internal _payload; | ||
address internal _crossChainController; | ||
|
||
string internal NETWORK; | ||
uint256 internal immutable BLOCK_NUMBER; | ||
|
||
constructor(string memory network, uint256 blockNumber) { | ||
NETWORK = network; | ||
BLOCK_NUMBER = blockNumber; | ||
} | ||
|
||
function _getDeployedPayload() internal virtual returns (address); | ||
|
||
function _getPayload() internal virtual returns (address); | ||
|
||
function _getCurrentNetworkAddresses() internal virtual returns (Addresses memory); | ||
|
||
function setUp() public { | ||
vm.createSelectFork(vm.rpcUrl(NETWORK), BLOCK_NUMBER); | ||
|
||
Addresses memory addresses = _getCurrentNetworkAddresses(); | ||
_crossChainController = addresses.crossChainController; | ||
|
||
_payload = _getPayload(); | ||
} | ||
|
||
function test_defaultTest() public { | ||
defaultTest( | ||
string.concat('add_mantle_path_to_adi', NETWORK), | ||
_crossChainController, | ||
address(_payload), | ||
false, | ||
vm | ||
); | ||
} | ||
|
||
function test_samePayloadAddress( | ||
address currentChainAdapter, | ||
address destinationChainAdapter, | ||
address crossChainController, | ||
uint256 destinationChainId | ||
) public { | ||
SimpleAddForwarderAdapter deployedPayload = SimpleAddForwarderAdapter(_getDeployedPayload()); | ||
SimpleAddForwarderAdapter predictedPayload = SimpleAddForwarderAdapter(_getPayload()); | ||
|
||
assertEq(predictedPayload.DESTINATION_CHAIN_ID(), deployedPayload.DESTINATION_CHAIN_ID()); | ||
assertEq(predictedPayload.CROSS_CHAIN_CONTROLLER(), deployedPayload.CROSS_CHAIN_CONTROLLER()); | ||
assertEq( | ||
predictedPayload.CURRENT_CHAIN_BRIDGE_ADAPTER(), | ||
deployedPayload.CURRENT_CHAIN_BRIDGE_ADAPTER() | ||
); | ||
assertEq( | ||
predictedPayload.DESTINATION_CHAIN_BRIDGE_ADAPTER(), | ||
deployedPayload.DESTINATION_CHAIN_BRIDGE_ADAPTER() | ||
); | ||
} | ||
} | ||
|
||
contract EthereumAddMantlePathPayloadTest is | ||
PayloadEthereumScript, | ||
BaseAddMantlePathPayloadTest('ethereum', 21830243) | ||
{ | ||
function _getDeployedPayload() internal pure override returns (address) { | ||
return 0x184CA99Cd89313c00a69b9A8E1649D84FBD8D86D; | ||
} | ||
|
||
function _getCurrentNetworkAddresses() internal view override returns (Addresses memory) { | ||
return _getAddresses(TRANSACTION_NETWORK()); | ||
} | ||
|
||
function _getPayload() internal override returns (address) { | ||
Addresses memory currentAddresses = _getCurrentNetworkAddresses(); | ||
Addresses memory destinationAddresses = _getAddresses(DESTINATION_CHAIN_ID()); | ||
|
||
AddForwarderAdapterArgs memory args = AddForwarderAdapterArgs({ | ||
crossChainController: currentAddresses.crossChainController, | ||
currentChainBridgeAdapter: currentAddresses.mantleAdapter, // ethereum -> mantle bridge adapter | ||
destinationChainBridgeAdapter: destinationAddresses.mantleAdapter, // mantle bridge adapter | ||
destinationChainId: DESTINATION_CHAIN_ID() | ||
}); | ||
return _deployPayload(args); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34b85a9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
♻️ Forge Gas Snapshots
Seems like you are not measuring gas of any operations yet. 🤔
Consider adding some snapshot tests to measure regressions & improvements.
34b85a9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🌈 Test Results
34b85a9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔮 Coverage report
43
Ethereum_Celo_Path_Payload.getForwarderBridgeAdaptersToEnable
43, 81
Ethereum_Sonic_Path_Payload.getForwarderBridgeAdaptersToEnable, Ethereum_Sonic_Path_Payload._updateOptimalBandwidth
17, 18, 19, 21, 25 and 42 more
Ethereum_Add_Shuffle_to_CCC_Payload.getInitializeSignature, Polygon_Add_Shuffle_to_CCC_Payload.getInitializeSignature, Avalanche_Add_Shuffle_to_CCC_Payload.getInitializeSignature, Arbitrum_Add_Shuffle_to_CCC_Payload.getInitializeSignature, Optimism_Add_Shuffle_to_CCC_Payload.getInitializeSignature and 5 more
30, 33, 34, 40, 41
BaseCCCUpdate.constructor, BaseCCCUpdate.execute
12, 22, 28, 32, 37 and 2 more
BaseForwarderAdaptersUpdate.getForwarderBridgeAdaptersToRemove, BaseForwarderAdaptersUpdate.getForwarderBridgeAdaptersToEnable, BaseForwarderAdaptersUpdate.getOptimalBandwidthByChain, BaseForwarderAdaptersUpdate.executeForwardersUpdate
12, 23, 33, 38, 45
BaseReceiverAdaptersUpdate.getReceiverBridgeAdaptersToRemove, BaseReceiverAdaptersUpdate.getReceiverBridgeAdaptersToAllow, BaseReceiverAdaptersUpdate.executeReceiversUpdate
31
SimpleAddForwarderAdapter.getForwarderBridgeAdaptersToEnable
26, 27, 28, 35, 41 and 34 more
SimpleOneToManyAdapterUpdate.constructor, SimpleOneToManyAdapterUpdate.getDestinationAdapters, SimpleOneToManyAdapterUpdate.getChainsToSend, SimpleOneToManyAdapterUpdate.getReceiverBridgeAdaptersToRemove, SimpleOneToManyAdapterUpdate.getForwarderBridgeAdaptersToRemove and 2 more
27, 28, 29, 39, 46 and 12 more
SimpleReceiverAdapterUpdate.constructor, SimpleReceiverAdapterUpdate.getReceiverBridgeAdaptersToRemove, SimpleReceiverAdapterUpdate.getReceiverBridgeAdaptersToAllow