diff --git a/KIPs/kip-149.md b/KIPs/kip-149.md index 1927c7c7..1fb262cb 100644 --- a/KIPs/kip-149.md +++ b/KIPs/kip-149.md @@ -29,7 +29,7 @@ This standard defines the separation of data and logic contracts in system contr ### Definitions -- System contract: A contract that affects protocol. The currently deployed system contracts are as follows: **AddressBook**, **Voting**([KIP-81](https://github.com/klaytn/kips/blob/main/KIPs/kip-81.md)), **StakingTracker**, **TreasuryRebalance**([KIP-103](https://github.com/klaytn/kips/blob/main/KIPs/kip-103.md)) +- System contract: A contract that affects protocol. The currently deployed system contracts are as follows: **AddressBook**, **GovParam**, **Voting**([KIP-81](https://github.com/klaytn/kips/blob/main/KIPs/kip-81.md)), **StakingTracker**, **TreasuryRebalance**([KIP-103](https://github.com/klaytn/kips/blob/main/KIPs/kip-103.md)) - System contract upgrade: The process of updating an existing logic contract while maintaining a proxy contract. The upgraded logic contract must be compatible with the previous interface. @@ -172,18 +172,48 @@ After a target block number, a Klaytn node should read all the active addresses In the Chain Config, the following field is introduced. All node operators in a network must update `genesis.json` configuration with the same value. The configuration values for Baobab and Cypress networks are hard-coded on the client source code. -- `registryAddress`: the reserved address for the Registry contract, which is `0x0000000000000000000000000000000000000401`. +- `RegistryAddress`: the reserved address for the Registry contract, which is `0x0000000000000000000000000000000000000401`. + +- `Kip149CompatibleBlock`: the target block number that a Klaytn node deploys Registry. + +- `RegistryConfig`: the initial data config for the Registry. It is used when injecting the initial state after deploying the Registry. + +```go +// In klaytn/params/config.go +type RegistryConfig struct { + Records map[string][]common.Address // Map for pre-deployed system contracts + Owner common.Address // Address for initial owner of Registry +} + +var ChainConfig = &ChainConfig{ + ... + RegistryAddress: common.HexToAddress("0x0000000000000000000000000000000000000401"), + Kip149CompatibleBlock: TBD, + // RegistryInit will be used when injecting initial state for the Registry + RegistryInit: &RegistryConfig{ + Records: map[string][]common.Address{ + "AddressBook": { + AddressBookAddress, + }, + "TreasuryRebalance": { + KIP103Address, + }, + ... + }, + Owner: OwnerAddress, + }, +} +``` -- `kip149CompatibleBlock`: the target block number that a Klaytn node deploys Registry. #### Execution -The Registry deployment is executed at the `Finalize` function, which means the end of the block generation. It reads the reserved address and runtime bytecode and deploys the Registry by the bytecode injection. Also, it injects the state for pre-deployed system contracts here. Note that the Registry contract will be deployed at th parent block of the `kip149CompatibleBlock` since it needs to be ready at the `kip149CompatibleBlock`. +The Registry deployment is executed at the `Finalize` function, which means the end of the block generation. It reads the reserved address and runtime bytecode and deploys the Registry by the bytecode injection. Also, it injects the initial state provided by `RegistryConfig` for the Registry here. Note that the Registry contract will be deployed at th parent block of the `kip149CompatibleBlock` since it needs to be ready at the `kip149CompatibleBlock`. ```go // Note that it is deployed at the parent block of the kip-149 fork block if chain.Config().IsKIP149ForkBlockParent(header.Number) { - // Inject the bytecode for the Registry contract and the state for pre-deployed system contracts + // Inject the bytecode for the Registry and the state of owner and pre-deployed system contracts err := registry.InstallRegistry(state) if err != nil { logger.Error("failed to set the registry contract code", "err", err)