MCPcopy Create free account
hub / github.com/circlefin/arc-node / buildProtocolConfigGenesisAllocs

Function buildProtocolConfigGenesisAllocs

scripts/genesis/ProtocolConfig.ts:100–205  ·  view source on GitHub ↗
(ctx: BuilderContext, config: ProtocolConfigConfig)

Source from the content-addressed store, hash-verified

98export type ProtocolConfigConfig = z.infer<typeof schemaProtocolConfig>
99
100export const buildProtocolConfigGenesisAllocs = async (ctx: BuilderContext, config: ProtocolConfigConfig) => {
101 const {
102 proxy,
103 implementation: impl,
104 owner,
105 controller,
106 pauser,
107 feeParams,
108 consensusParams,
109 } = schemaProtocolConfig.parse(config)
110
111 const [implAddress, implAlloc] = await buildImplContractAlloc(ctx, impl?.contractName ?? DEFAULT_IMPL_CONTRACT)
112 const [proxyAddress, proxyAlloc] = await buildSystemContractAlloc({
113 ctx,
114 contractName: proxy?.contractName ?? AdminUpgradeableProxy.CONTRACT_NAME,
115 address: proxy.address ?? DEFAULT_PROXY_ADDRESS,
116 storage: [
117 StorageSlot(AdminUpgradeableProxy.ADMIN_SLOT, addressToBytes32(proxy.admin)),
118 StorageSlot(AdminUpgradeableProxy.IMPL_SLOT, addressToBytes32(implAddress)),
119
120 /*
121 * OwnableUpgradeable -- ERC-7201 slot for openzeppelin.storage.Ownable
122 * `keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Ownable")) - 1)) & ~bytes32(uint256(0xff))`
123 */
124 StorageSlot(
125 slotIndex(0x9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300n),
126 addressToBytes32(owner),
127 ),
128
129 // Initializable
130 setInitializers(PROTOCOL_CONFIG_VERSION),
131
132 /*
133 * ERC-7201 Controller storage
134 * Slot: 0x958f8fec699b51a1249f513eceda5429078000657f74abd1721bba363087af00
135 * struct ProtocolConfigControllerStorage {
136 * address controller;
137 * }
138 */
139 StorageSlot(slotIndex(PROTOCOL_CONFIG_CONTROLLER_STORAGE_LOCATION), addressToBytes32(controller)),
140
141 /*
142 * ERC-7201 Pausable storage for ProtocolConfig
143 * Slot: 0x0642d7922329a434cf4fd17a3c95eb692c24fd95f9f94d0b55420a5d895f4a00
144 * struct PausableStorage {
145 * address pauser; // 20 bytes, offset 0
146 * bool paused; // 1 byte, offset 20 (packed in same slot)
147 * }
148 */
149 StorageSlot(slotIndex(PAUSABLE_STORAGE_LOCATION), addressToBytes32(pauser)),
150 // Note: pauser and paused packed in same slot. paused defaults to false (byte 20 = 0x00)
151
152 /*
153 * ERC-7201 ProtocolConfig storage
154 * Slot: 0x668f09ce856848ead6cb1ddee963f15ef833cea8958030868f867aec84385200
155 * Slot 0: alpha (uint64) | kRate (uint64) | inverseElasticityMultiplier (uint64) | padding (64 bits)
156 * Slot 1: minBaseFee (uint256)
157 * Slot 2: maxBaseFee (uint256)

Callers 1

buildGenesisFunction · 0.90

Calls 8

buildImplContractAllocFunction · 0.90
buildSystemContractAllocFunction · 0.90
StorageSlotFunction · 0.90
addressToBytes32Function · 0.90
slotIndexFunction · 0.90
setInitializersFunction · 0.90
toBytes32Function · 0.90
parseMethod · 0.45

Tested by

no test coverage detected