Skip to content

Commit

Permalink
feat: add the eth/gas denomination for supporting eth as the gas fees
Browse files Browse the repository at this point in the history
  • Loading branch information
ai-chen2050 committed Feb 14, 2025
1 parent 28b1672 commit 2a6d1bd
Show file tree
Hide file tree
Showing 20 changed files with 134 additions and 100 deletions.
18 changes: 9 additions & 9 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,28 @@ linters:
enable:
# - depguard
- dogsled
- dupl
- errcheck
# - dupl
# - errcheck
- goconst
- gocritic
# - gocritic
# - gofumpt
- revive
# - gosec
- gosimple
# - govet
- ineffassign
# - ineffassign
# - lll TODO: enable
# - misspell
- nakedret
- prealloc
- exportloopref
- staticcheck
- stylecheck
# - staticcheck
# - stylecheck
- typecheck
- unconvert
# - unconvert
- unparam
- unused
- nolintlint
# - unused
# - nolintlint
- asciicheck
- exportloopref
- gomodguard
Expand Down
2 changes: 1 addition & 1 deletion app/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func GenesisStateWithValSet(app *Evmos, genesisState simapp.GenesisState,
MinSelfDelegation: math.ZeroInt(),
}
validators = append(validators, validator)
delegations = append(delegations, stakingtypes.NewDelegation(genAccs[0].GetAddress().String(), val.Address.String(), math.LegacyOneDec()))
delegations = append(delegations, stakingtypes.NewDelegation(genAccs[0].GetAddress().String(), sdk.ValAddress(val.Address).String(), math.LegacyOneDec()))

}
// set validators and delegations
Expand Down
15 changes: 14 additions & 1 deletion cmd/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,13 @@ const (
const (
// DisplayDenom defines the denomination displayed to users in client applications.
DisplayDenom = "hetu"
// BaseDenom defines to the default denomination used in Hetu (staking, EVM, governance, etc.)
// BaseDenom defines to the default denomination used in Hetu (staking, governance, etc.)
BaseDenom = "ahetu"

// DisplayETHDenom defines the denomination displayed to users in client applications.
DisplayETHDenom = "eth"
// BaseDenom defines to the default denomination used in Hetu (EVM, gas, etc.)
BaseETHDenom = "gas"
)

// SetBech32Prefixes sets the global prefixes to be used when serializing addresses and public keys to Bech32 strings.
Expand All @@ -71,4 +76,12 @@ func RegisterDenoms() {
if err := sdk.RegisterDenom(BaseDenom, math.LegacyNewDecWithPrec(1, types.BaseDenomUnit)); err != nil {
panic(err)
}

if err := sdk.RegisterFeeDenom(DisplayETHDenom, math.LegacyOneDec()); err != nil {
panic(err)
}

if err := sdk.RegisterFeeDenom(BaseETHDenom, math.LegacyNewDecWithPrec(1, types.BaseDenomUnit)); err != nil {
panic(err)
}
}
2 changes: 1 addition & 1 deletion cmd/hetud/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ func txCommand() *cobra.Command {
// initAppConfig helps to override default appConfig template and configs.
// return "", nil if no custom configuration is required for the application.
func initAppConfig() (string, interface{}) {
customAppTemplate, customAppConfig := servercfg.AppConfig(cmdcfg.BaseDenom)
customAppTemplate, customAppConfig := servercfg.AppConfig(cmdcfg.BaseETHDenom)

srvCfg, ok := customAppConfig.(servercfg.Config)
if !ok {
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ require (
github.com/cosmos/btcutil v1.0.5
github.com/cosmos/cosmos-db v1.1.0
github.com/cosmos/cosmos-proto v1.0.0-beta.5
github.com/cosmos/cosmos-sdk v0.50.11
github.com/cosmos/cosmos-sdk v0.50.9-hetu
github.com/cosmos/go-bip39 v1.0.0
github.com/cosmos/gogoproto v1.7.0
github.com/cosmos/ibc-apps/modules/rate-limiting/v8 v8.0.0
github.com/cosmos/ibc-go/modules/capability v1.0.1
github.com/cosmos/ibc-go/v8 v8.5.1
github.com/cosmos/ibc-go/v8 v8.4.0
github.com/cosmos/rosetta v0.50.3-1
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc
github.com/ethereum/go-ethereum v1.10.26
Expand Down Expand Up @@ -269,7 +269,7 @@ replace (
// use cosmos keyring
github.com/99designs/keyring => github.com/cosmos/keyring v1.2.0
github.com/cometbft/cometbft => github.com/hetu-project/hetu-parallel-engine/hetu-cometbft v0.0.0-20250127071645-b3f53d769924
github.com/cosmos/cosmos-sdk => github.com/hetu-project/cosmos-sdk v0.50.9-hetu
github.com/cosmos/cosmos-sdk => github.com/hetu-project/cosmos-sdk v0.50.9-hetu.3

// use geth fork
github.com/ethereum/go-ethereum => github.com/hetu-project/go-ethereum v1.10.26-hetu
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,8 @@ github.com/cosmos/ibc-apps/modules/rate-limiting/v8 v8.0.0 h1:AQO9NIAP3RFqvBCj7I
github.com/cosmos/ibc-apps/modules/rate-limiting/v8 v8.0.0/go.mod h1:/ZpKJSW/SKPkFS7jTqkPVn7kOHUUfRNzu+8aS7YOL8o=
github.com/cosmos/ibc-go/modules/capability v1.0.1 h1:ibwhrpJ3SftEEZRxCRkH0fQZ9svjthrX2+oXdZvzgGI=
github.com/cosmos/ibc-go/modules/capability v1.0.1/go.mod h1:rquyOV262nGJplkumH+/LeYs04P3eV8oB7ZM4Ygqk4E=
github.com/cosmos/ibc-go/v8 v8.5.1 h1:3JleEMKBjRKa3FeTKt4fjg22za/qygLBo7mDkoYTNBs=
github.com/cosmos/ibc-go/v8 v8.5.1/go.mod h1:P5hkAvq0Qbg0h18uLxDVA9q1kOJ0l36htMsskiNwXbo=
github.com/cosmos/ibc-go/v8 v8.4.0 h1:K2PfX0AZ+1XKZytHGEMuSjQXG/MZshPb83RSTQt2+cE=
github.com/cosmos/ibc-go/v8 v8.4.0/go.mod h1:zh6x1osR0hNvEcFrC/lhGD08sMfQmr9wHVvZ/mRWMCs=
github.com/cosmos/ics23/go v0.11.0 h1:jk5skjT0TqX5e5QJbEnwXIS2yI2vnmLOgpQPeM5RtnU=
github.com/cosmos/ics23/go v0.11.0/go.mod h1:A8OjxPE67hHST4Icw94hOxxFEJMBG031xIGF/JHNIY0=
github.com/cosmos/keyring v1.2.0 h1:8C1lBP9xhImmIabyXW4c3vFjjLiBdGCmfLUfeZlV1Yo=
Expand Down Expand Up @@ -763,8 +763,8 @@ github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE
github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ=
github.com/hdevalence/ed25519consensus v0.2.0 h1:37ICyZqdyj0lAZ8P4D1d1id3HqbbG1N3iBb1Tb4rdcU=
github.com/hdevalence/ed25519consensus v0.2.0/go.mod h1:w3BHWjwJbFU29IRHL1Iqkw3sus+7FctEyM4RqDxYNzo=
github.com/hetu-project/cosmos-sdk v0.50.9-hetu h1:BRR/9/kjvJdUKGFeiMEv2hPVaMxk1UURpVEG30Y6J+M=
github.com/hetu-project/cosmos-sdk v0.50.9-hetu/go.mod h1:TMH6wpoYBcg7Cp5BEg8fneLr+8XloNQkf2MRNF9V6JE=
github.com/hetu-project/cosmos-sdk v0.50.9-hetu.3 h1:3EZg38jqPjYGUXAlLQOR5Eix+kL/NV5wdDRI5vpXWUs=
github.com/hetu-project/cosmos-sdk v0.50.9-hetu.3/go.mod h1:TMH6wpoYBcg7Cp5BEg8fneLr+8XloNQkf2MRNF9V6JE=
github.com/hetu-project/cosmos-sdk/store v0.0.0-20240718141609-414cbd051fbe h1:eWGpgQ7lYWEKwUBPzof7CRP6rKGIIAGX/C7JxrMSzcc=
github.com/hetu-project/cosmos-sdk/store v0.0.0-20240718141609-414cbd051fbe/go.mod h1:Bm6h8ZkYgVTytHK5vhHOMKw9OHyiumm3b1UbkYIJ/Ug=
github.com/hetu-project/go-ethereum v1.10.26-hetu h1:YgzTOXOs1jCuBslUifM0KfrImNIPxt1pEhLPuOu2aEI=
Expand Down
6 changes: 1 addition & 5 deletions gometalinter.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@
},
"Enable": [
"golint",
"vet",
"ineffassign",
"unparam",
"unconvert",
"misspell"
"unparam"
],
"Deadline": "500s",
"Vendor": true,
Expand Down
28 changes: 14 additions & 14 deletions ibc/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (

func init() {
cfg := sdk.GetConfig()
cfg.SetBech32PrefixForAccount("evmos", "evmospub")
cfg.SetBech32PrefixForAccount("hetu", "hetupub")
}

func TestGetTransferSenderRecipient(t *testing.T) {
Expand Down Expand Up @@ -57,7 +57,7 @@ func TestGetTransferSenderRecipient(t *testing.T) {
Data: transfertypes.ModuleCdc.MustMarshalJSON(
&transfertypes.FungibleTokenPacketData{
Sender: "cosmos1",
Receiver: "hetu1x2w87cvt5mqjncav4lxy8yfreynn273xyw6ylm",
Receiver: "hetu1x2w87cvt5mqjncav4lxy8yfreynn273xnhq2pu",
Amount: "123456",
},
),
Expand Down Expand Up @@ -85,28 +85,28 @@ func TestGetTransferSenderRecipient(t *testing.T) {
Data: transfertypes.ModuleCdc.MustMarshalJSON(
&transfertypes.FungibleTokenPacketData{
Sender: "cosmos1qql8ag4cluz6r4dz28p3w00dnc9w8ueulg2gmc",
Receiver: "hetu1x2w87cvt5mqjncav4lxy8yfreynn273xyw6ylm",
Receiver: "hetu1x2w87cvt5mqjncav4lxy8yfreynn273xnhq2pu",
Amount: "123456",
},
),
},
"hetu1qql8ag4cluz6r4dz28p3w00dnc9w8ueu2nsn28",
"hetu1x2w87cvt5mqjncav4lxy8yfreynn273xyw6ylm",
"hetu1qql8ag4cluz6r4dz28p3w00dnc9w8ueua22a5q",
"hetu1x2w87cvt5mqjncav4lxy8yfreynn273xnhq2pu",
false,
},
{
"valid - evmos sender, cosmos recipient",
channeltypes.Packet{
Data: transfertypes.ModuleCdc.MustMarshalJSON(
&transfertypes.FungibleTokenPacketData{
Sender: "hetu1x2w87cvt5mqjncav4lxy8yfreynn273xyw6ylm",
Sender: "hetu1x2w87cvt5mqjncav4lxy8yfreynn273xnhq2pu",
Receiver: "cosmos1qql8ag4cluz6r4dz28p3w00dnc9w8ueulg2gmc",
Amount: "123456",
},
),
},
"hetu1x2w87cvt5mqjncav4lxy8yfreynn273xyw6ylm",
"hetu1qql8ag4cluz6r4dz28p3w00dnc9w8ueu2nsn28",
"hetu1x2w87cvt5mqjncav4lxy8yfreynn273xnhq2pu",
"hetu1qql8ag4cluz6r4dz28p3w00dnc9w8ueua22a5q",
false,
},
{
Expand All @@ -115,13 +115,13 @@ func TestGetTransferSenderRecipient(t *testing.T) {
Data: transfertypes.ModuleCdc.MustMarshalJSON(
&transfertypes.FungibleTokenPacketData{
Sender: "osmo1qql8ag4cluz6r4dz28p3w00dnc9w8ueuhnecd2",
Receiver: "hetu1x2w87cvt5mqjncav4lxy8yfreynn273xyw6ylm",
Receiver: "hetu1x2w87cvt5mqjncav4lxy8yfreynn273xnhq2pu",
Amount: "123456",
},
),
},
"hetu1qql8ag4cluz6r4dz28p3w00dnc9w8ueu2nsn28",
"hetu1x2w87cvt5mqjncav4lxy8yfreynn273xyw6ylm",
"hetu1qql8ag4cluz6r4dz28p3w00dnc9w8ueua22a5q",
"hetu1x2w87cvt5mqjncav4lxy8yfreynn273xnhq2pu",
false,
},
}
Expand Down Expand Up @@ -165,7 +165,7 @@ func TestGetTransferAmount(t *testing.T) {
Data: transfertypes.ModuleCdc.MustMarshalJSON(
&transfertypes.FungibleTokenPacketData{
Sender: "cosmos1qql8ag4cluz6r4dz28p3w00dnc9w8ueulg2gmc",
Receiver: "hetu1x2w87cvt5mqjncav4lxy8yfreynn273xyw6ylm",
Receiver: "hetu1x2w87cvt5mqjncav4lxy8yfreynn273xnhq2pu",
Amount: "",
},
),
Expand All @@ -179,7 +179,7 @@ func TestGetTransferAmount(t *testing.T) {
Data: transfertypes.ModuleCdc.MustMarshalJSON(
&transfertypes.FungibleTokenPacketData{
Sender: "cosmos1qql8ag4cluz6r4dz28p3w00dnc9w8ueulg2gmc",
Receiver: "hetu1x2w87cvt5mqjncav4lxy8yfreynn273xyw6ylm",
Receiver: "hetu1x2w87cvt5mqjncav4lxy8yfreynn273xnhq2pu",
Amount: "test",
},
),
Expand All @@ -193,7 +193,7 @@ func TestGetTransferAmount(t *testing.T) {
Data: transfertypes.ModuleCdc.MustMarshalJSON(
&transfertypes.FungibleTokenPacketData{
Sender: "cosmos1qql8ag4cluz6r4dz28p3w00dnc9w8ueulg2gmc",
Receiver: "hetu1x2w87cvt5mqjncav4lxy8yfreynn273xyw6ylm",
Receiver: "hetu1x2w87cvt5mqjncav4lxy8yfreynn273xnhq2pu",
Amount: "10000",
},
),
Expand Down
11 changes: 6 additions & 5 deletions local_node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ if [[ $overwrite == "y" || $overwrite == "Y" ]]; then
jq '.app_state["staking"]["params"]["bond_denom"]="ahetu"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS"
jq '.app_state["crisis"]["constant_fee"]["denom"]="ahetu"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS"
jq '.app_state["gov"]["deposit_params"]["min_deposit"][0]["denom"]="ahetu"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS"
jq '.app_state["evm"]["params"]["evm_denom"]="ahetu"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS"
jq '.app_state["evm"]["params"]["evm_denom"]="gas"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS"
jq '.app_state["inflation"]["params"]["mint_denom"]="ahetu"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS"

# Set gas limit in genesis
Expand All @@ -87,7 +87,7 @@ if [[ $overwrite == "y" || $overwrite == "Y" ]]; then

# Claim module account:
# 0xA61808Fe40fEb8B3433778BBC2ecECCAA47c8c47 || hetu15cvq3ljql6utxseh0zau9m8ve2j8erz89c94rj
jq -r --arg amount_to_claim "$amount_to_claim" '.app_state["bank"]["balances"] += [{"address":"hetu15cvq3ljql6utxseh0zau9m8ve2j8erz89c94rj","coins":[{"denom":"ahetu", "amount":$amount_to_claim}]}]' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS"
jq -r --arg amount_to_claim "$amount_to_claim" '.app_state["bank"]["balances"] += [{"address":"hetu15cvq3ljql6utxseh0zau9m8ve2j8erz89c94rj","coins":[{"denom":"ahetu", "amount":$amount_to_claim}, {"denom":"gas", "amount":$amount_to_claim}]}]' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS"

if [[ $1 == "pending" ]]; then
if [[ "$OSTYPE" == "darwin"* ]]; then
Expand Down Expand Up @@ -134,13 +134,14 @@ if [[ $overwrite == "y" || $overwrite == "Y" ]]; then

# Allocate genesis accounts (cosmos formatted addresses)
for KEY in "${KEYS[@]}"; do
hetud add-genesis-account "$KEY" 100000000000000000000000000ahetu --keyring-backend $KEYRING --home "$HOMEDIR"
hetud add-genesis-account "$KEY" 100000000000000000000000000ahetu,100000000000000000000000000gas --keyring-backend $KEYRING --home "$HOMEDIR"
done

# bc is required to add these big numbers
total_supply=$(echo "${#KEYS[@]} * 100000000000000000000000000 + $amount_to_claim" | bc)
jq -r --arg total_supply "$total_supply" '.app_state["bank"]["supply"][0]["amount"]=$total_supply' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS"

jq -r --arg total_supply "$total_supply" '.app_state["bank"]["supply"][1]["amount"]=$total_supply' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS"

# Sign genesis transaction
echo "gentx: Sign genesis transaction"
hetud gentx "${KEYS[0]}" 1000000000000000000000ahetu --keyring-backend $KEYRING --chain-id $CHAINID --home "$HOMEDIR"
Expand All @@ -166,4 +167,4 @@ fi

# Start the node (remove the --pruning=nothing flag if historical queries are not needed)
echo "start: localnode"
hetud start --metrics "$TRACE" --log_level $LOGLEVEL --minimum-gas-prices=0.0001ahetu --json-rpc.api eth,txpool,personal,net,debug,web3 --api.enable --home "$HOMEDIR"
hetud start --metrics "$TRACE" --log_level $LOGLEVEL --minimum-gas-prices=0.0001gas --json-rpc.api eth,txpool,personal,net,debug,web3 --api.enable --home "$HOMEDIR"
8 changes: 4 additions & 4 deletions tests/e2e/init-node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ hetud init "$MONIKER" --chain-id "$CHAINID"
jq '.app_state.staking.params.bond_denom="ahetu"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS"
jq '.app_state.crisis.constant_fee.denom="ahetu"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS"
jq '.app_state.gov.deposit_params.min_deposit[0].denom="ahetu"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS"
jq '.app_state.evm.params.evm_denom="ahetu"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS"
jq '.app_state.evm.params.evm_denom="gas"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS"
jq '.app_state.inflation.params.mint_denom="ahetu"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS"

# set gov proposing && voting period
Expand All @@ -66,13 +66,13 @@ jq '.app_state.claims.params.duration_until_decay="100000s"' "$GENESIS" >"$TMP_G

# Claim module account:
# 0xA61808Fe40fEb8B3433778BBC2ecECCAA47c8c47 || hetu15cvq3ljql6utxseh0zau9m8ve2j8erz89c94rj
jq -r --arg amount_to_claim "$amount_to_claim" '.app_state.bank.balances += [{"address":"hetu15cvq3ljql6utxseh0zau9m8ve2j8erz89c94rj","coins":[{"denom":"ahetu", "amount":$amount_to_claim}]}]' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS"
jq -r --arg amount_to_claim "$amount_to_claim" '.app_state.bank.balances += [{"address":"hetu15cvq3ljql6utxseh0zau9m8ve2j8erz89c94rj","coins":[{"denom":"ahetu", "amount":$amount_to_claim}, {"denom":"gas", "amount":$amount_to_claim}]}]' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS"

# disable produce empty block
sed -i 's/create_empty_blocks = true/create_empty_blocks = false/g' "$CONFIG_TOML"

# Allocate genesis accounts (cosmos formatted addresses)
hetud add-genesis-account $KEY 100000000000000000000000000ahetu --keyring-backend $KEYRING
hetud add-genesis-account $KEY 100000000000000000000000000ahetu,100000000000000000000000000gas --keyring-backend $KEYRING

# Update total supply with claim values
# Bc is required to add this big numbers
Expand Down Expand Up @@ -107,4 +107,4 @@ hetud collect-gentxs
hetud validate-genesis

# Start the node (remove the --pruning=nothing flag if historical queries are not needed)
hetud start "$TRACE" --log_level $LOGLEVEL --minimum-gas-prices=0.0001ahetu --json-rpc.api eth,txpool,personal,net,debug,web3
hetud start "$TRACE" --log_level $LOGLEVEL --minimum-gas-prices=0.0001gas --json-rpc.api eth,txpool,personal,net,debug,web3
Loading

0 comments on commit 2a6d1bd

Please sign in to comment.