OneBTC contract size is currently over the 24KB limit. There are a couple strategies to reducing the size.
Current change
The least disruptive method, without changing the architecture significantly is moving any shared library (static linked) into dynamically linked libraries.
In hashmesan@8f0ec01 , the SecP256K1Lib and TXValidate libraries were identified to convert to linked library.
- The library interface must be changed from
internal to external
- The libraries deployed separately and linked... see below
const Secp256k1Lib = await Secp256k1.new();
OneBtc.link("Secp256k1", Secp256k1Lib.address);
const TxValidateLib = await TxValidate.new();
OneBtc.link("TxValidate", TxValidateLib.address);
oneBtc = await deployProxy(OneBtc, [RelayMock.address, ExchangeRateOracleWrapper.address],{unsafeAllowLinkedLibraries: true});
As per warning
Warning: Potentially unsafe deployment of OneBtc
You are using the `unsafeAllow.external-library-linking` flag to include external libraries.
Make sure you have manually checked that the linked libraries are upgrade safe.
We must be cautious of using any shared datastructure that might change in the upgraded library OR interfaces change that may break the dependencies. We can always deploy brand new library every time which avoid this issue altogether.
Future change
Later on if we hit the 24k again, we may have to separate Issue , Redeem, and Replace as libraries and isolate storage into OneBTC. This is a huge architecture change we need to avoid as much as we can.
OneBTC contract size is currently over the 24KB limit. There are a couple strategies to reducing the size.
Current change
The least disruptive method, without changing the architecture significantly is moving any shared library (static linked) into dynamically linked libraries.
In hashmesan@8f0ec01 , the
SecP256K1LibandTXValidatelibraries were identified to convert to linked library.internaltoexternalAs per warning
We must be cautious of using any shared datastructure that might change in the upgraded library OR interfaces change that may break the dependencies. We can always deploy brand new library every time which avoid this issue altogether.
Future change
Later on if we hit the 24k again, we may have to separate
Issue,Redeem, andReplaceas libraries and isolate storage intoOneBTC. This is a huge architecture change we need to avoid as much as we can.