Commit c46616b3 authored by Maurelian's avatar Maurelian Committed by GitHub

feat: Use encodeCall for type safety (#13561)

* feat: Use encodeCall for type safety

A very common issue (both from experience and observation) is
failing to correctly encode the initializer arguments in
`encodeSystemConfigInitializer()`. This fixes that.

I believe that at one point we needed to be able to pass the 4 bytes
selector in as a string, but that no longer seems to be the case.

* semver

* feat: expand use of encodeCall to rest of OPCM

* semver lock
parent dd87dca5
...@@ -16,8 +16,8 @@ ...@@ -16,8 +16,8 @@
"sourceCodeHash": "0xa91b445bdc666a02ba18e3b91ba94b6d54bbe65da714002fc734814201319d57" "sourceCodeHash": "0xa91b445bdc666a02ba18e3b91ba94b6d54bbe65da714002fc734814201319d57"
}, },
"src/L1/OPContractsManager.sol": { "src/L1/OPContractsManager.sol": {
"initCodeHash": "0x9b704574a7005dc2aa8d6a3e0d85572493cc4bbd60033a23e437632a5fef7720", "initCodeHash": "0x4b413cbe79bd10d41d8f3e9f0408e773dd49ced823d457b9f9aa92f446828105",
"sourceCodeHash": "0x05ed7ad68e4e9bca7334314e794a1f66e5899532bb01cfa3a7716cb2688df9d5" "sourceCodeHash": "0xe5179a20ae40d4e4773c52df98bac67e73e04044bec9e8750073b4e2f14fe81b"
}, },
"src/L1/OptimismPortal2.sol": { "src/L1/OptimismPortal2.sol": {
"initCodeHash": "0xfd14fd690752519064d6de6c3e15d69ec9146bc8714e56ac286305773dbb1533", "initCodeHash": "0xfd14fd690752519064d6de6c3e15d69ec9146bc8714e56ac286305773dbb1533",
......
...@@ -34,9 +34,8 @@ contract OPContractsManagerInterop is OPContractsManager { ...@@ -34,9 +34,8 @@ contract OPContractsManagerInterop is OPContractsManager {
override override
returns (bytes memory) returns (bytes memory)
{ {
bytes4 selector = ISystemConfigInterop.initialize.selector;
(IResourceMetering.ResourceConfig memory referenceResourceConfig, ISystemConfig.Addresses memory opChainAddrs) = (IResourceMetering.ResourceConfig memory referenceResourceConfig, ISystemConfig.Addresses memory opChainAddrs) =
defaultSystemConfigParams(selector, _input, _output); defaultSystemConfigParams(_input, _output);
// TODO For now we assume that the dependency manager is the same as system config owner. // TODO For now we assume that the dependency manager is the same as system config owner.
// This is currently undefined since it's not part of the standard config, so we may need // This is currently undefined since it's not part of the standard config, so we may need
...@@ -45,8 +44,9 @@ contract OPContractsManagerInterop is OPContractsManager { ...@@ -45,8 +44,9 @@ contract OPContractsManagerInterop is OPContractsManager {
// we will make the change described in https://github.com/ethereum-optimism/optimism/issues/11783. // we will make the change described in https://github.com/ethereum-optimism/optimism/issues/11783.
address dependencyManager = address(_input.roles.systemConfigOwner); address dependencyManager = address(_input.roles.systemConfigOwner);
return abi.encodeWithSelector( return abi.encodeCall(
selector, ISystemConfigInterop.initialize,
(
_input.roles.systemConfigOwner, _input.roles.systemConfigOwner,
_input.basefeeScalar, _input.basefeeScalar,
_input.blobBasefeeScalar, _input.blobBasefeeScalar,
...@@ -57,6 +57,7 @@ contract OPContractsManagerInterop is OPContractsManager { ...@@ -57,6 +57,7 @@ contract OPContractsManagerInterop is OPContractsManager {
chainIdToBatchInboxAddress(_input.l2ChainId), chainIdToBatchInboxAddress(_input.l2ChainId),
opChainAddrs, opChainAddrs,
dependencyManager dependencyManager
)
); );
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment