-
Notifications
You must be signed in to change notification settings - Fork 256
chore(testing): allow PoL deployment over devnet #2842
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 26 commits
1444470
738ddcd
ad2bac6
b7f3c35
a99123b
a17b2d4
4e064cd
3903d19
2ca2979
c6abf8d
1fe330b
106190d
e5869ff
edece5f
b5c5e65
186afff
3c91da6
c8e0c11
9d824c4
01d1a51
71baf86
101919d
eef3330
7e2207c
fa81410
2c9adef
5fffd8a
a0fcb9d
91ea7b8
83362e3
cbf09f6
b851677
34fd457
0db4520
914c0a0
6e1215b
9b964c0
b045f51
3654798
d06caac
f3a39eb
89bdc03
2c3bfd8
d97c12b
da3d59a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| # PoL deployment on devnet | ||
|
|
||
| We will need two repositories: | ||
|
|
||
| - BeaconKit repo, `main` [branch](https://github.com/berachain/beacon-kit/tree/main). | ||
| - Contracts repo, `main` [branch](https://github.com/berachain/contracts/tree/main), to deploy PoL smart contracts. | ||
|
|
||
| ## Run BeaconKit | ||
|
|
||
| Compile and run BeaconKit from the branch mentioned above, with the usual `make start` and `make start-geth` or `make start-reth`. | ||
|
|
||
| When deploying PoL from scratch make sure that: | ||
|
|
||
| - `<BGT_CONTRACT_ADDRESS>` matches with `specData.EVMInflationAddressDeneb1` | ||
| - `<DISTRIBUTOR_ADDRESS>` matches with `polDistributorAddress` in `testing\files\eth-genesis.json` | ||
|
|
||
| ## Deploy PoL contracts | ||
|
|
||
| On the contracts repo, run the following commands: | ||
|
|
||
| ```bash | ||
| export FOUNDRY_PROFILE="deploy"; | ||
| export IS_TESTNET=false; | ||
| export USE_SOFTWARE_WALLET=true; | ||
| export ETH_FROM="0x20f33ce90a13a4b5e7697e3544c3083b8f8a51d4"; | ||
| export RPC_URL="http://localhost:8545"; | ||
| export ETH_FROM_PK="0xfffdbb37105441e14b0ee6330d855d8504ff39e705c3afa8f859ac9865f99306"; | ||
| ``` | ||
|
|
||
| where `ETH_FROM` and `ETH_FROM_PK` are the preloaded EVM keys as described in `BeaconKit` [README](https://github.com/berachain/beacon-kit/blob/main/README.md). | ||
|
|
||
| First off check address for relevant commands. Run | ||
|
|
||
| ```bash | ||
| forge script script/pol/POLPredictAddresses.s.sol -vv | ||
| ``` | ||
|
|
||
| and copy the output in the file `script/pol/POLAddresses.sol` file. Usually just two contracts addresses, `BERACHEF_ADDRESS` and `REWARD_VAULT_FACTORY_ADDRESS` should have changed, but there may be more. | ||
|
|
||
| **Very important check**: before deploying PoL make sure you are using the right BGT contract address is specified in BeaconKit chain specs. | ||
| Run | ||
|
|
||
| ```bash | ||
| cast balance <BGT_CONTRACT_ADDRESS> --rpc-url $RPC_URL | ||
| ``` | ||
|
|
||
| and observe the balance going up every time the validator produces a block. | ||
|
|
||
| Once that is done run the following commands: | ||
|
|
||
| ```bash | ||
| forge script script/pol/deployment/2_DeployBGT.s.sol --private-key $ETH_FROM_PK --sender $ETH_FROM --rpc-url $RPC_URL --broadcast -vv; | ||
| forge script script/pol/deployment/3_DeployPoL.s.sol --private-key $ETH_FROM_PK --sender $ETH_FROM --rpc-url $RPC_URL --broadcast -vv; | ||
| forge script script/pol/actions/ChangePOLParameters.s.sol --private-key $ETH_FROM_PK --sender $ETH_FROM --rpc-url $RPC_URL --broadcast -vv; | ||
| ``` | ||
|
|
||
| Now we need to generate 5 tokens to be associated with the 5 reward vaults we will have in the default reward allocations. Run: | ||
|
|
||
| ```bash | ||
| forge script script/misc/testnet/DeployToken.s.sol --sig "deployBST(uint256)" 1 --sender $ETH_FROM --private-key $ETH_FROM_PK --rpc-url $RPC_URL --broadcast; | ||
| forge script script/misc/testnet/DeployToken.s.sol --sig "deployBST(uint256)" 2 --sender $ETH_FROM --private-key $ETH_FROM_PK --rpc-url $RPC_URL --broadcast; | ||
| forge script script/misc/testnet/DeployToken.s.sol --sig "deployBST(uint256)" 3 --sender $ETH_FROM --private-key $ETH_FROM_PK --rpc-url $RPC_URL --broadcast; | ||
| forge script script/misc/testnet/DeployToken.s.sol --sig "deployBST(uint256)" 4 --sender $ETH_FROM --private-key $ETH_FROM_PK --rpc-url $RPC_URL --broadcast; | ||
| forge script script/misc/testnet/DeployToken.s.sol --sig "deployBST(uint256)" 5 --sender $ETH_FROM --private-key $ETH_FROM_PK --rpc-url $RPC_URL --broadcast; | ||
| ``` | ||
|
|
||
| and for each command note down the token address, which is indicated in the logs at the line `BST deployed at: <TOKEN_ADDRESS>`. | ||
|
|
||
| These addresses must be written in `script/pol/actions/DeployRewardVault.s.sol`. You will find in the script tokens named `LP_BERA_HONEY`, `LP_BERA_ETH`, ... `LP_BEE_HONEY`[^1]. Finally run: | ||
|
|
||
| ```bash | ||
| forge script script/pol/actions/DeployRewardVault.s.sol --private-key $ETH_FROM_PK --sender $ETH_FROM --rpc-url $RPC_URL --broadcast -vv; | ||
| ``` | ||
|
|
||
| Once you run this file note down the Reward Vaults addresses, which should have appear in the log lines like: `RewardVault deployed at <REWARD_VAULT_ADDRESS> for staking token <TOKEN_ADDRESS>`. | ||
|
|
||
| Now consider `script/pol/actions/WhitelistRewardVault.s.sol`. On this file: | ||
|
|
||
| - Drop anything related to `REWARD_VAULT_USDS_HONEY`, since we only need 5 tokens. | ||
| - Assign the reward vaults addresses from above to `REWARD_VAULT_BERA_HONEY/ETH/WBTC...`[^2]. | ||
|
|
||
| Finally run: | ||
|
|
||
| ```bash | ||
| forge script script/pol/actions/WhitelistRewardVault.s.sol --private-key $ETH_FROM_PK --sender $ETH_FROM --rpc-url $RPC_URL --broadcast -vv; | ||
| cast send <BERACHEF_ADDRESS> "setMaxWeightPerVault(uint96)" 2000 --private-key $ETH_FROM_PK --rpc-url $RPC_URL -vv; | ||
| ``` | ||
|
|
||
| Now consider `script/pol/actions/SetDefaultRewardAllocation`. On this file: | ||
|
|
||
| - Replace `REWARD_VAULT_BERA_HONEY/ETH/WBTC`... with `REWARD_VAULT_1/2/3`... for every variable and variable content in the file. | ||
| - Set `REWARD_VAULT_BERA_HONEY/ETH/WBTC..._WEIGHT`s to `2000`. | ||
| - Assign reward vaults addresses from above in `REWARD_VAULT_BERA_HONEY/ETH/WBTC...` | ||
|
|
||
| Finally run: | ||
|
|
||
| ```bash | ||
| forge script script/pol/actions/SetDefaultRewardAllocation.s.sol:WhitelistIncentiveTokenScript --private-key $ETH_FROM_PK --sender $ETH_FROM --rpc-url $RPC_URL --broadcast -vv; | ||
| ``` | ||
|
|
||
| ## Check BGT distribution is carried out | ||
|
|
||
| Post Pectra11 fork, BGT distribution is automatically carried out by the execution layer. A way to check distribution is happening is checking that the validator producing blocks is receiving its base-rate BGTs via | ||
|
|
||
| ```bash | ||
| cast call <BGT_CONTRACT_ADDRESS> "balanceOf(address)(uint256)" <OPERATOR_ADDRESS> --rpc-url $RPC_URL | ||
| ``` | ||
|
|
||
| [^1]: You may consider renaming the tokens with `LP_TOKEN_1`, `LP_TOKEN_2`, ... `LP_TOKEN_5`. | ||
| [^2]: Again you may consider renaming the Reward vaults with `REWARD_VAULT_1/2/3/4/5`. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,7 +29,11 @@ import ( | |
| "github.com/berachain/beacon-kit/chain" | ||
| "github.com/berachain/beacon-kit/cli/commands/genesis" | ||
| servertypes "github.com/berachain/beacon-kit/cli/commands/server/types" | ||
| genesisutils "github.com/berachain/beacon-kit/cli/utils/genesis" | ||
| "github.com/berachain/beacon-kit/config/spec" | ||
| "github.com/berachain/beacon-kit/consensus-types/types" | ||
| "github.com/berachain/beacon-kit/primitives/bytes" | ||
| "github.com/berachain/beacon-kit/primitives/crypto" | ||
| "github.com/berachain/beacon-kit/primitives/encoding/json" | ||
| "github.com/cosmos/cosmos-sdk/client" | ||
| "github.com/ethereum/go-ethereum/common" | ||
|
|
@@ -117,18 +121,24 @@ func setupMockCLGenesis(t *testing.T, tmpDir string) string { | |
| require.NoError(t, os.MkdirAll(configDir, 0o755)) | ||
| mockCLGenesisPath := filepath.Join(configDir, "genesis.json") | ||
|
|
||
| mockCLGenesis := map[string]interface{}{ | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the structure of these genesis was wrong ("data" key does not exist in genesis), so modified it to reuse existing data structures. |
||
| "app_state": map[string]interface{}{ | ||
| "beacon": map[string]interface{}{ | ||
| "deposits": []interface{}{ | ||
| map[string]interface{}{ | ||
| "data": map[string]interface{}{ | ||
| "amount": "32000000000", | ||
| "pubkey": "0x1234", | ||
| "withdrawal_address": "0x5678", | ||
| "signature": "0x9abc", | ||
| "deposit_message_root": "0xdef0", | ||
| }, | ||
| pkBytes := []byte{ | ||
| 138, 238, 24, 44, 160, 141, 152, 10, 53, 122, 247, 15, | ||
| 129, 25, 168, 67, 55, 148, 56, 108, 55, 192, 218, 25, | ||
| 237, 85, 204, 12, 10, 149, 243, 239, 80, 219, 58, 74, | ||
| 158, 219, 231, 105, 42, 97, 95, 186, 120, 53, 228, 51, | ||
| } | ||
| pk, err := bytes.ToBytes48(pkBytes) | ||
| require.NoError(t, err) | ||
|
|
||
| mockCLGenesis := genesisutils.Genesis{ | ||
| AppState: genesisutils.AppState{ | ||
| Beacon: genesisutils.Beacon{ | ||
| Deposits: types.Deposits{ | ||
| { | ||
| Pubkey: pk, | ||
| Credentials: types.WithdrawalCredentials{}, | ||
| Amount: 32000000000, | ||
| Signature: crypto.BLSSignature{}, | ||
| }, | ||
| }, | ||
| }, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,9 +27,6 @@ import ( | |
| ) | ||
|
|
||
| const ( | ||
| // devnetEVMInflationAddress is the address of the EVM inflation contract. | ||
| devnetEVMInflationAddress = "0x6942069420694206942069420694206942069420" | ||
|
|
||
|
Comment on lines
-31
to
-32
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. devnet should have the same contracts used in mainnet/bepolia |
||
| // devnetEVMInflationPerBlock is the amount of native EVM balance (in units | ||
| // of Gwei) to be minted per EL block. | ||
| devnetEVMInflationPerBlock = 10 * params.GWei | ||
|
|
@@ -51,10 +48,6 @@ const ( | |
| // devnet is configured to start on electra1. | ||
| devnetElectra1ForkTime = 0 | ||
|
|
||
| // devnetEVMInflationAddressDeneb1 is the address of the EVM inflation contract | ||
| // after the Deneb1 fork. | ||
| devnetEVMInflationAddressDeneb1 = "0x4206942069420694206942069420694206942069" | ||
|
|
||
| // devnetEVMInflationPerBlockDeneb1 is the amount of native EVM balance (in units | ||
| // of Gwei) to be minted per EL block after the Deneb1 fork. | ||
| devnetEVMInflationPerBlockDeneb1 = 11 * params.GWei | ||
|
|
@@ -81,11 +74,11 @@ func DevnetChainSpecData() *chain.SpecData { | |
| specData.Electra1ForkTime = devnetElectra1ForkTime | ||
|
|
||
| // EVM inflation is different from mainnet to test. | ||
| specData.EVMInflationAddressGenesis = common.NewExecutionAddressFromHex(devnetEVMInflationAddress) | ||
| specData.EVMInflationAddressGenesis = common.NewExecutionAddressFromHex(defaultEVMInflationAddress) | ||
| specData.EVMInflationPerBlockGenesis = devnetEVMInflationPerBlock | ||
|
|
||
| // EVM inflation is different from mainnet for now, after the Deneb1 fork. | ||
| specData.EVMInflationAddressDeneb1 = common.NewExecutionAddressFromHex(devnetEVMInflationAddressDeneb1) | ||
| specData.EVMInflationAddressDeneb1 = common.NewExecutionAddressFromHex(mainnetEVMInflationAddressDeneb1) | ||
| specData.EVMInflationPerBlockDeneb1 = devnetEVMInflationPerBlockDeneb1 | ||
|
|
||
| // Staking is different from mainnet for now. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would say should ideally be in contracts repo. If it has to be in bkit, would prefer in beacon-kit/contracts/docs
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that ideally smart contract could make a script to automate deployment. Such a script should live in contracts repo.
However we are not there yet so I would keep this in beaconKit. Moved to
beacon-kit/contractsas the main README.md.