Skip to content
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

Create migration app #330

Merged
merged 3 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions cmd/migration/config/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
[Eth]
Chain = "Ethereum"
NetworkAddress = "http://127.0.0.1:8545" # a network address
PrivateKeyFile = "keys/ethereum.sk" # the path to the file containing the relayer eth private key
SafeContractAddress = "A6504Cc508889bbDBd4B748aFf6EA6b5D0d2684c"
GasLimitBase = 350000
GasLimitForEach = 30000
[Eth.GasStation]
Enabled = true
URL = "https://api.etherscan.io/api?module=gastracker&action=gasoracle" # gas station URL. Suggestion to provide the api-key here
GasPriceMultiplier = 1000000000 # the value to be multiplied with the fetched value. Useful in test chains. On production chain should be 1000000000
PollingIntervalInSeconds = 60 # number of seconds between gas price polling
RequestRetryDelayInSeconds = 5 # number of seconds of delay after one failed request
MaxFetchRetries = 3 # number of fetch retries before printing an error
RequestTimeInSeconds = 2 # maximum timeout (in seconds) for the gas price request
MaximumAllowedGasPrice = 300 # maximum value allowed for the fetched gas price value
# GasPriceSelector available options: "SafeGasPrice", "ProposeGasPrice", "FastGasPrice"
GasPriceSelector = "SafeGasPrice" # selector used to provide the gas price

[MultiversX]
NetworkAddress = "https://devnet-gateway.multiversx.com" # the network address
MultisigContractAddress = "erd1qqqqqqqqqqqqqpgqtvnswnzxxz8susupesys0hvg7q2z5nawrcjq06qdus"
[MultiversX.Proxy]
CacherExpirationSeconds = 600 # the caching time in seconds

# valid options for ProxyRestAPIEntityType are "observer" and "proxy". Any other value will trigger an error.
# "observer" is useful when querying an observer, directly and "proxy" is useful when querying a squad's proxy (gateway)
RestAPIEntityType = "observer"
FinalityCheck = true
MaxNoncesDelta = 7 # the number of maximum blocks allowed to be "in front" of what the metachain has notarized

[Logs]
LogFileLifeSpanInSec = 86400 # 24h
LogFileLifeSpanInMB = 1024 # 1GB

[WhitelistedTokens]
List = [
"ETHUSDC-220753",
"ETHUTK-8cdf7a",
"ETHUSDT-9c73c6",
"ETHBUSD-450923",
"ETHHMT-18538a",
"ETHCGG-ee4e0c",
"ETHINFRA-60a3bf",
"ETHWBTC-74e282",
"ETHWETH-e1c126",
"ETHWSDAI-572803",
"ETHWDAI-bd65f9",
"ETHUMB-291202",
]
79 changes: 79 additions & 0 deletions cmd/migration/config/migration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{
"OldSafeContractAddress": "0x92A26975433A61CF1134802586aa669bAB8B69f3",
"NewSafeContractAddress": "0x37aaaf95887624a363effB7762D489E3C05c2a02",
"BatchID": 3547,
"DepositsInfo": [
{
"DepositNonce": 4651,
"Token": "ETHUSDC-220753",
"ContractAddress": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
"Amount": "7245293620507"
},
{
"DepositNonce": 4652,
"Token": "ETHUTK-8cdf7a",
"ContractAddress": "0xdc9Ac3C20D1ed0B540dF9b1feDC10039Df13F99c",
"Amount": "224564169411881824066539333"
},
{
"DepositNonce": 4653,
"Token": "ETHUSDT-9c73c6",
"ContractAddress": "0xdAC17F958D2ee523a2206206994597C13D831ec7",
"Amount": "305146464594"
},
{
"DepositNonce": 4654,
"Token": "ETHBUSD-450923",
"ContractAddress": "0x4Fabb145d64652a948d72533023f6E7A623C7C53",
"Amount": "22294352736330153151984"
},
{
"DepositNonce": 4655,
"Token": "ETHHMT-18538a",
"ContractAddress": "0xd1ba9BAC957322D6e8c07a160a3A8dA11A0d2867",
"Amount": "435000000000000000000"
},
{
"DepositNonce": 4656,
"Token": "ETHCGG-ee4e0c",
"ContractAddress": "0x1fE24F25b1Cf609B9c4e7E12D802e3640dFA5e43",
"Amount": "1500138370967581082219795"
},
{
"DepositNonce": 4657,
"Token": "ETHINFRA-60a3bf",
"ContractAddress": "0x013062189dc3dcc99e9Cee714c513033b8d99e3c",
"Amount": "141172595980399500424091"
},
{
"DepositNonce": 4658,
"Token": "ETHWBTC-74e282",
"ContractAddress": "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599",
"Amount": "3898848955"
},
{
"DepositNonce": 4659,
"Token": "ETHWETH-e1c126",
"ContractAddress": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
"Amount": "725921417141355037005"
},
{
"DepositNonce": 4660,
"Token": "ETHWSDAI-572803",
"ContractAddress": "0x83F20F44975D03b1b09e64809B757c47f942BEeA",
"Amount": "5431516086574385345409"
},
{
"DepositNonce": 4661,
"Token": "ETHWDAI-bd65f9",
"ContractAddress": "0x6B175474E89094C44Da98b954EedeAC495271d0F",
"Amount": "127608014625114134146189"
},
{
"DepositNonce": 4662,
"Token": "ETHUMB-291202",
"ContractAddress": "0x6fC13EACE26590B80cCCAB1ba5d51890577D83B2",
"Amount": "4669367702477323508554075"
}
]
}
34 changes: 34 additions & 0 deletions cmd/migration/disabled/statusHandler.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package disabled

import "github.com/multiversx/mx-bridge-eth-go/core"

// StatusHandler represents the disabled status handler implementation
type StatusHandler struct {
}

// SetIntMetric does nothing
func (handler *StatusHandler) SetIntMetric(_ string, _ int) {
}

// AddIntMetric does nothing
func (handler *StatusHandler) AddIntMetric(_ string, _ int) {
}

// SetStringMetric does nothing
func (handler *StatusHandler) SetStringMetric(_ string, _ string) {
}

// Name returns an empty string
func (handler *StatusHandler) Name() string {
return ""
}

// GetAllMetrics returns an empty map
func (handler *StatusHandler) GetAllMetrics() core.GeneralMetrics {
return make(core.GeneralMetrics)
}

// IsInterfaceNil returns true if there is no value under the interface
func (handler *StatusHandler) IsInterfaceNil() bool {
return handler == nil
}
57 changes: 57 additions & 0 deletions cmd/migration/flags.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package main

import (
"github.com/multiversx/mx-bridge-eth-go/config"
logger "github.com/multiversx/mx-chain-logger-go"
"github.com/urfave/cli"
)

var (
logLevel = cli.StringFlag{
Name: "log-level",
Usage: "This flag specifies the logger `level(s)`. It can contain multiple comma-separated value. For example" +
", if set to *:INFO the logs for all packages will have the INFO level. However, if set to *:INFO,api:DEBUG" +
" the logs for all packages will have the INFO level, excepting the api package which will receive a DEBUG" +
" log level.",
Value: "*:" + logger.LogDebug.String(),
}
configurationFile = cli.StringFlag{
Name: "config",
Usage: "The `" + filePathPlaceholder + "` for the main configuration file. This TOML file contain the main " +
"configurations such as storage setups, epoch duration and so on.",
Value: "config/config.toml",
}
mode = cli.StringFlag{
Name: "mode",
Usage: "This flag specifies the operation mode. Usage: generate, sign or execute",
Value: generateMode,
}
migrationJsonFile = cli.StringFlag{
Name: "migration-file",
Usage: "The input or output .json file containing the migration data",
Value: "config/migration.json",
}
newSafeAddress = cli.StringFlag{
Name: "new-safe-address",
Usage: "The new safe address on Ethereum",
Value: "",
}
)

func getFlags() []cli.Flag {
return []cli.Flag{
logLevel,
configurationFile,
mode,
migrationJsonFile,
newSafeAddress,
}
}
func getFlagsConfig(ctx *cli.Context) config.ContextFlagsConfig {
flagsConfig := config.ContextFlagsConfig{}

flagsConfig.LogLevel = ctx.GlobalString(logLevel.Name)
flagsConfig.ConfigurationFile = ctx.GlobalString(configurationFile.Name)

return flagsConfig
}
1 change: 1 addition & 0 deletions cmd/migration/keys/ethereum.sk
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9bb971db41e3815a669a71c3f1bcb24e0b81f21e04bf11faa7a34b9b40e7cfb1
Loading
Loading