Skip to content

Commit

Permalink
Merge pull request #137 from ava-labs/update-subnet-sdk
Browse files Browse the repository at this point in the history
Update SubnetSDK FeeConfig and Precompiles
  • Loading branch information
sukantoraymond authored Sep 5, 2024
2 parents f73fc8a + 5b08e31 commit bd87250
Showing 1 changed file with 2 additions and 35 deletions.
37 changes: 2 additions & 35 deletions subnet/subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ import (
"github.com/ava-labs/subnet-evm/commontype"
"github.com/ava-labs/subnet-evm/core"
"github.com/ava-labs/subnet-evm/params"
"github.com/ava-labs/subnet-evm/precompile/contracts/txallowlist"
"github.com/ethereum/go-ethereum/common"
)

type SubnetParams struct {
Expand Down Expand Up @@ -221,21 +219,8 @@ func createEvmGenesis(
return nil, fmt.Errorf("genesis params precompiles cannot be empty")
}

if conf != nil && conf.GenesisPrecompiles[txallowlist.ConfigKey] != nil {
allowListCfg, ok := conf.GenesisPrecompiles[txallowlist.ConfigKey].(*txallowlist.Config)
if !ok {
return nil, fmt.Errorf(
"expected config of type txallowlist.AllowListConfig, but got %T",
allowListCfg,
)
}

if err := ensureAdminsHaveBalance(
allowListCfg.AdminAddresses,
allocation); err != nil {
return nil, err
}
}
conf.FeeConfig = subnetEVMParams.FeeConfig
conf.GenesisPrecompiles = subnetEVMParams.Precompiles

conf.ChainID = subnetEVMParams.ChainID

Expand All @@ -258,24 +243,6 @@ func createEvmGenesis(
return prettyJSON.Bytes(), nil
}

func ensureAdminsHaveBalance(admins []common.Address, alloc core.GenesisAlloc) error {
if len(admins) < 1 {
return nil
}

for _, admin := range admins {
// we can break at the first admin who has a non-zero balance
if bal, ok := alloc[admin]; ok &&
bal.Balance != nil &&
bal.Balance.Uint64() > uint64(0) {
return nil
}
}
return errors.New(
"none of the addresses in the transaction allow list precompile have any tokens allocated to them. Currently, no address can transact on the network. Airdrop some funds to one of the allow list addresses to continue",
)
}

func vmID(vmName string) (ids.ID, error) {
if len(vmName) > 32 {
return ids.Empty, fmt.Errorf("VM name must be <= 32 bytes, found %d", len(vmName))
Expand Down

0 comments on commit bd87250

Please sign in to comment.