github.com/klaytn/klaytn@v1.12.1/blockchain/system/constant.go (about)

     1  // Copyright 2023 The klaytn Authors
     2  // This file is part of the klaytn library.
     3  //
     4  // The klaytn library is free software: you can redistribute it and/or modify
     5  // it under the terms of the GNU Lesser General Public License as published by
     6  // the Free Software Foundation, either version 3 of the License, or
     7  // (at your option) any later version.
     8  //
     9  // The klaytn library is distributed in the hope that it will be useful,
    10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    12  // GNU Lesser General Public License for more details.
    13  //
    14  // You should have received a copy of the GNU Lesser General Public License
    15  // along with the klaytn library. If not, see <http://www.gnu.org/licenses/>.
    16  
    17  package system
    18  
    19  import (
    20  	"errors"
    21  
    22  	"github.com/klaytn/klaytn/common"
    23  	"github.com/klaytn/klaytn/common/hexutil"
    24  	contracts "github.com/klaytn/klaytn/contracts/system_contracts"
    25  	"github.com/klaytn/klaytn/log"
    26  )
    27  
    28  var (
    29  	logger = log.NewModuleLogger(log.Blockchain)
    30  
    31  	// Canonical system contract names registered in Registry.
    32  	AddressBookName = "AddressBook"
    33  	GovParamName    = "GovParam"
    34  	Kip103Name      = "TreasuryRebalance"
    35  	Kip113Name      = "KIP113"
    36  
    37  	AllContractNames = []string{
    38  		AddressBookName,
    39  		GovParamName,
    40  		Kip103Name,
    41  		Kip113Name,
    42  	}
    43  
    44  	// This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1 used in the
    45  	// EIP-1967 proxy contract. See https://eips.ethereum.org/EIPS/eip-1967#implementation-slot
    46  	ImplementationSlot = common.Hex2Bytes("360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc")
    47  
    48  	// Some system contracts are allocated at special addresses.
    49  	AddressBookAddr = common.HexToAddress("0x0000000000000000000000000000000000000400") // TODO: replace contracts/reward/contract/utils.go
    50  	RegistryAddr    = common.HexToAddress("0x0000000000000000000000000000000000000401")
    51  	// The following addresses are only used for testing.
    52  	Kip113ProxyAddrMock = common.HexToAddress("0x0000000000000000000000000000000000000402")
    53  	Kip113LogicAddrMock = common.HexToAddress("0x0000000000000000000000000000000000000403")
    54  
    55  	// System contract binaries to be injected at hardfork or used in testing.
    56  	RegistryCode     = hexutil.MustDecode("0x" + contracts.RegistryBinRuntime)
    57  	RegistryMockCode = hexutil.MustDecode("0x" + contracts.RegistryMockBinRuntime)
    58  	Kip113Code       = hexutil.MustDecode("0x" + contracts.KIP113BinRuntime)
    59  	Kip113MockCode   = hexutil.MustDecode("0x" + contracts.KIP113MockBinRuntime)
    60  
    61  	ERC1967ProxyCode = hexutil.MustDecode("0x" + contracts.ERC1967ProxyBinRuntime)
    62  
    63  	// Errors
    64  	ErrRegistryNotInstalled = errors.New("Registry contract not installed")
    65  	ErrKip113BadResult      = errors.New("KIP113 call returned bad data")
    66  	ErrKip113BadPop         = errors.New("KIP113 PoP verification failed")
    67  )