-
Notifications
You must be signed in to change notification settings - Fork 110
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
chore: add begin block deployments to mock mainnet #1189
Changes from 3 commits
5cfece2
a66d0b7
4ab0843
329b172
2bb0665
22f9107
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 | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -5,9 +5,91 @@ package keeper | |||||||||
|
||||||||||
import ( | ||||||||||
"context" | ||||||||||
"fmt" | ||||||||||
|
||||||||||
errorsmod "cosmossdk.io/errors" | ||||||||||
sdk "github.com/cosmos/cosmos-sdk/types" | ||||||||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" | ||||||||||
"github.com/zeta-chain/zetacore/common" | ||||||||||
) | ||||||||||
|
||||||||||
func (k Keeper) BlockOneDeploySystemContracts(_ context.Context) error { | ||||||||||
func (k Keeper) BlockOneDeploySystemContracts(goCtx context.Context) error { | ||||||||||
ctx := sdk.UnwrapSDKContext(goCtx) | ||||||||||
|
||||||||||
// setup uniswap v2 factory | ||||||||||
uniswapV2Factory, err := k.DeployUniswapV2Factory(ctx) | ||||||||||
if err != nil { | ||||||||||
return sdkerrors.Wrapf(err, "failed to DeployUniswapV2Factory") | ||||||||||
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. We still |
||||||||||
} | ||||||||||
ctx.EventManager().EmitEvent( | ||||||||||
sdk.NewEvent(sdk.EventTypeMessage, | ||||||||||
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. We're using |
||||||||||
sdk.NewAttribute("UniswapV2Factory", uniswapV2Factory.String()), | ||||||||||
), | ||||||||||
) | ||||||||||
|
||||||||||
// setup WZETA contract | ||||||||||
wzeta, err := k.DeployWZETA(ctx) | ||||||||||
if err != nil { | ||||||||||
return sdkerrors.Wrapf(err, "failed to DeployWZetaContract") | ||||||||||
} | ||||||||||
ctx.EventManager().EmitEvent( | ||||||||||
sdk.NewEvent(sdk.EventTypeMessage, | ||||||||||
sdk.NewAttribute("DeployWZetaContract", wzeta.String()), | ||||||||||
), | ||||||||||
) | ||||||||||
|
||||||||||
router, err := k.DeployUniswapV2Router02(ctx, uniswapV2Factory, wzeta) | ||||||||||
if err != nil { | ||||||||||
return sdkerrors.Wrapf(err, "failed to DeployUniswapV2Router02") | ||||||||||
} | ||||||||||
ctx.EventManager().EmitEvent( | ||||||||||
sdk.NewEvent(sdk.EventTypeMessage, | ||||||||||
sdk.NewAttribute("DeployUniswapV2Router02", router.String()), | ||||||||||
), | ||||||||||
) | ||||||||||
|
||||||||||
connector, err := k.DeployConnectorZEVM(ctx, wzeta) | ||||||||||
if err != nil { | ||||||||||
return sdkerrors.Wrapf(err, "failed to DeployConnectorZEVM") | ||||||||||
} | ||||||||||
ctx.EventManager().EmitEvent( | ||||||||||
sdk.NewEvent(sdk.EventTypeMessage, | ||||||||||
sdk.NewAttribute("DeployConnectorZEVM", connector.String()), | ||||||||||
), | ||||||||||
) | ||||||||||
ctx.Logger().Info("Deployed Connector ZEVM at " + connector.String()) | ||||||||||
|
||||||||||
SystemContractAddress, err := k.DeploySystemContract(ctx, wzeta, uniswapV2Factory, router) | ||||||||||
if err != nil { | ||||||||||
return sdkerrors.Wrapf(err, "failed to SystemContractAddress") | ||||||||||
} | ||||||||||
ctx.EventManager().EmitEvent( | ||||||||||
sdk.NewEvent(sdk.EventTypeMessage, | ||||||||||
sdk.NewAttribute("SystemContractAddress", SystemContractAddress.String()), | ||||||||||
), | ||||||||||
) | ||||||||||
|
||||||||||
// set the system contract | ||||||||||
system, _ := k.GetSystemContract(ctx) | ||||||||||
system.SystemContract = SystemContractAddress.String() | ||||||||||
k.SetSystemContract(ctx, system) | ||||||||||
//err = k.SetGasPrice(ctx, big.NewInt(1337), big.NewInt(1)) | ||||||||||
if err != nil { | ||||||||||
return err | ||||||||||
} | ||||||||||
Comment on lines
+76
to
+79
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.
Suggested change
We're handling the error but the method is commented out |
||||||||||
_, err = k.SetupChainGasCoinAndPool(ctx, common.EthChain().ChainId, "ETH", "ETH", 18) | ||||||||||
if err != nil { | ||||||||||
return errorsmod.Wrapf(err, fmt.Sprintf("failed to setupChainGasCoinAndPool for %s", common.EthChain().ChainName)) | ||||||||||
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. You don't need |
||||||||||
} | ||||||||||
|
||||||||||
_, err = k.SetupChainGasCoinAndPool(ctx, common.BscMainnetChain().ChainId, "BNB", "BNB", 18) | ||||||||||
if err != nil { | ||||||||||
return errorsmod.Wrapf(err, fmt.Sprintf("failed to setupChainGasCoinAndPool for %s", common.BscMainnetChain().ChainName)) | ||||||||||
} | ||||||||||
_, err = k.SetupChainGasCoinAndPool(ctx, common.BtcMainnetChain().ChainId, "BTC", "BTC", 8) | ||||||||||
if err != nil { | ||||||||||
return errorsmod.Wrapf(err, fmt.Sprintf("failed to setupChainGasCoinAndPool for %s", common.BtcMainnetChain().ChainName)) | ||||||||||
} | ||||||||||
return nil | ||||||||||
} | ||||||||||
func (k Keeper) TestUpdateSystemContractAddress(_ context.Context) error { | ||||||||||
|
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.
It looks like there are code we could factorize with the other networks privnet, testnet.
I think we would benefit of having a single function
BlockOneSetup
that group the setup operations logic common to all network and implement tests for this function since an error here or an inconsistency can prevent the network from working.Could be another PR