-
Notifications
You must be signed in to change notification settings - Fork 25
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
update governance deploy #96
update governance deploy #96
Conversation
@@ -165,38 +173,40 @@ func DeployGovContracts(opts *bind.TransactOpts, backend IBackend, optionDomains | |||
} | |||
} | |||
|
|||
// deploy proxys | |||
// deploy proxies | |||
txs = make([]*types.Transaction, 0) |
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.
common code for no size slice initialization
txs = txs[:0]
@@ -208,6 +218,7 @@ func DeployGovContracts(opts *bind.TransactOpts, backend IBackend, optionDomains | |||
} | |||
|
|||
// setup registry | |||
logger.Info("Setting registry...") | |||
txs = make([]*types.Transaction, 0) |
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.
common code for no size slice initialization
txs = txs[:0]
@@ -208,6 +218,7 @@ func DeployGovContracts(opts *bind.TransactOpts, backend IBackend, optionDomains | |||
} | |||
|
|||
// setup registry | |||
logger.Info("Setting registry...") | |||
txs = make([]*types.Transaction, 0) | |||
if tx, err := gov.Registry.SetContractDomain(opts, metclient.ToBytes32("GovernanceContract"), gov.address.Gov); err != nil { |
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.
You can use the code below.
optionDomains["GovernanceContract"] = gov.address.Gov
optionDomains["Staking"] = gov.address.Staking
optionDomains["BallotStorage"] = gov.address.BallotStorage
optionDomains["EnvStorage"] = gov.address.EnvStorage
for name, address := range optionDomains {
if tx, err := gov.Registry.SetContractDomain(opts, metclient.ToBytes32(name), address); err != nil {
return nil, nil, errors.Wrap(err, fmt.Sprintf("SetContractDomain(%s)", name))
} else {
txs = append(txs, tx)
}
}
@@ -438,7 +460,6 @@ type InitEnvStorage struct { | |||
BLOCK_GASLIMIT *big.Int | |||
BASE_FEE_MAX_CHANGE_RATE *big.Int | |||
GAS_TARGET_PERCENTAGE *big.Int | |||
Options map[string]*big.Int | |||
} |
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.
- Remove duplicate code using reflect and tag
- Easily check method names and variable names
- Process all without missing members
type InitEnvStorage struct {
BLOCKS_PER *big.Int `method:"blocksPer"`
BALLOT_DURATION_MIN *big.Int `method:"ballotDurationMin"`
BALLOT_DURATION_MAX *big.Int `method:"ballotDurationMax"`
STAKING_MIN *big.Int `method:"stakingMin"`
STAKING_MAX *big.Int `method:"stakingMax"`
MAX_IDLE_BLOCK_INTERVAL *big.Int `method:"MaxIdleBlockInterval"`
BLOCK_CREATION_TIME *big.Int `method:"blockCreationTime"`
BLOCK_REWARD_AMOUNT *big.Int `method:"blockRewardAmount"`
MAX_PRIORITY_FEE_PER_GAS *big.Int `method:"maxPriorityFeePerGas"`
BLOCK_REWARD_DISTRIBUTION_BLOCK_PRODUCER *big.Int `method:"blockRewardDistributionBlockProducer"`
BLOCK_REWARD_DISTRIBUTION_STAKING_REWARD *big.Int `method:"blockRewardDistributionStakingReward"`
BLOCK_REWARD_DISTRIBUTION_ECOSYSTEM *big.Int `method:"blockRewardDistributionEcosystem"`
BLOCK_REWARD_DISTRIBUTION_MAINTENANCE *big.Int `method:"blockRewardDistributionMaintenance"`
MAX_BASE_FEE *big.Int `method:"maxBaseFee"`
BLOCK_GASLIMIT *big.Int `method:"blockGasLimit"`
BASE_FEE_MAX_CHANGE_RATE *big.Int `method:"baseFeeMaxChangeRate"`
GAS_TARGET_PERCENTAGE *big.Int `method:"gasTargetPercentage"`
}
func (cfg InitEnvStorage) Args() (names [][32]byte, values []*big.Int) {
v := reflect.ValueOf(cfg)
t := reflect.TypeOf(cfg)
numField := v.NumField()
names = [][32]byte{}
values = []*big.Int{}
for i := 0; i < numField; i++ {
value, ok := v.Field(i).Interface().(*big.Int)
if ok && value != nil && value.Sign() > 0 {
tag := t.Field(i).Tag.Get("method")
names = append(names, crypto.Keccak256Hash([]byte(tag)))
values = append(values, value)
}
}
return
}
@@ -527,20 +541,19 @@ var DefaultInitEnvStorage InitEnvStorage = InitEnvStorage{ | |||
BALLOT_DURATION_MIN: big.NewInt(86400), | |||
BALLOT_DURATION_MAX: big.NewInt(604800), | |||
STAKING_MIN: new(big.Int).Mul(big.NewInt(1500000), big.NewInt(params.Ether)), | |||
STAKING_MAX: new(big.Int).Mul(big.NewInt(1500000), big.NewInt(params.Ether)), |
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.
common code
var DefaultInitEnvStorage InitEnvStorage = InitEnvStorage{
->
var DefaultInitEnvStorage = InitEnvStorage{
Fix the logic to deploy using the structure of
wemix/bind
.Removed unnecessary files