Skip to content

Commit

Permalink
Merge branch 'main' into moving-funds-commitment
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaszslabon committed Dec 8, 2023
2 parents eb9a329 + 1d813c5 commit f1c8275
Show file tree
Hide file tree
Showing 53 changed files with 2,187 additions and 11,141 deletions.
5 changes: 2 additions & 3 deletions cmd/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,7 @@ func initMaintainerFlags(command *cobra.Command, cfg *config.Config) {
&cfg.Maintainer.Spv.HistoryDepth,
"spv.historyDepth",
spv.DefaultHistoryDepth,
"Number of blocks to look back for past deposit sweep proposal "+
"submitted events.",
"Number of blocks to look back for past wallet-related events.",
)

command.Flags().IntVar(
Expand Down Expand Up @@ -386,5 +385,5 @@ func initDeveloperFlags(command *cobra.Command) {
initContractAddressFlag(chainEthereum.RandomBeaconContractName)
initContractAddressFlag(chainEthereum.TokenStakingContractName)
initContractAddressFlag(chainEthereum.WalletRegistryContractName)
initContractAddressFlag(chainEthereum.WalletCoordinatorContractName)
initContractAddressFlag(chainEthereum.WalletProposalValidatorContractName)
}
8 changes: 4 additions & 4 deletions cmd/flags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,15 +344,15 @@ var cmdFlagsTests = map[string]struct {
expectedValueFromFlag: common.HexToAddress("0x861b021462e7864a7413edF0113030B892978617"),
defaultValue: common.HexToAddress(ethereumThreshold.TokenStakingAddress),
},
"developer.walletCoordinatorAddress": {
"developer.walletProposalValidatorAddress": {
readValueFunc: func(c *config.Config) interface{} {
address, _ := c.Ethereum.ContractAddress(chainEthereum.WalletCoordinatorContractName)
address, _ := c.Ethereum.ContractAddress(chainEthereum.WalletProposalValidatorContractName)
return address
},
flagName: "--developer.walletCoordinatorAddress",
flagName: "--developer.walletProposalValidatorAddress",
flagValue: "0xE7d33d8AA55B73a93059a24b900366894684a497",
expectedValueFromFlag: common.HexToAddress("0xE7d33d8AA55B73a93059a24b900366894684a497"),
defaultValue: common.HexToAddress(ethereumTbtc.WalletCoordinatorAddress),
defaultValue: common.HexToAddress(ethereumTbtc.WalletProposalValidatorAddress),
},
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func buildContractAddresses(lineLength int, prefix, suffix string, ethereumConfi
chainEthereum.BridgeContractName,
chainEthereum.WalletRegistryContractName,
chainEthereum.TokenStakingContractName,
chainEthereum.WalletCoordinatorContractName,
chainEthereum.WalletProposalValidatorContractName,
}

entries := []string{}
Expand Down
2 changes: 1 addition & 1 deletion cmd/maintainercli.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ var estimateDepositsSweepFeeCommandDescription = "Estimates the satoshi " +
"fee for the entire Bitcoin deposits sweep transaction, based on " +
"the number of input deposits. By default, provides estimations for " +
"transactions containing a various number of input deposits, from 1 up " +
"to the maximum count allowed by the WalletCoordinator contract. " +
"to the maximum count allowed by the WalletProposalValidator contract. " +
"The --deposits-count flag can be used to obtain a fee estimation for " +
"a Bitcoin sweep transaction containing a specific count of input " +
"deposits. All estimations assume the wallet main UTXO is used as one " +
Expand Down
56 changes: 28 additions & 28 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func TestReadConfigFromFile(t *testing.T) {
"maintainerproxy": "0xC6D21c2871586A2B098c0ad043fF0D47a3c7e7ae",
"lightrelay": "0x68e20afD773fDF1231B5cbFeA7040e73e79cAc36",
"lightrelaymaintainerproxy": "0x30cd93828613D5945A2916a22E0f0e9bC561EAB5",
"walletcoordinator": "0xfdc315b0e608b7cDE9166D9D69a1506779e3E0CA",
"walletproposalvalidator": "0xfdc315b0e608b7cDE9166D9D69a1506779e3E0CA",
},
},
"Developer - RandomBeacon": {
Expand Down Expand Up @@ -129,9 +129,9 @@ func TestReadConfigFromFile(t *testing.T) {
},
expectedValue: "0x30cd93828613D5945A2916a22E0f0e9bC561EAB5",
},
"Ethereum.Developer - WalletCoordinator": {
"Ethereum.Developer - WalletProposalValidator": {
readValueFunc: func(c *Config) interface{} {
address, _ := c.Ethereum.ContractAddress(ethereum.WalletCoordinatorContractName)
address, _ := c.Ethereum.ContractAddress(ethereum.WalletProposalValidatorContractName)
return address.String()
},
expectedValue: "0xfdc315b0e608b7cDE9166D9D69a1506779e3E0CA",
Expand Down Expand Up @@ -333,40 +333,40 @@ func TestReadConfig_ReadContracts(t *testing.T) {
ethereumEcdsa.WalletRegistryAddress = "0xdb3dd6d4f43d39c996d0afeb6fbabc284f9ffb1a"
ethereumThreshold.TokenStakingAddress = "0xaa7b41039ea8f9ec2d89bbe96e19f97b6c267a27"
ethereumTbtc.BridgeAddress = "0x9490165195503fcf6a0fd20ac113223fefb66ed5"
ethereumTbtc.WalletCoordinatorAddress = "0xE7d33d8AA55B73a93059a24b900366894684a497"
ethereumTbtc.WalletProposalValidatorAddress = "0xE7d33d8AA55B73a93059a24b900366894684a497"

var configReadTests = map[string]struct {
configFilePath string

expectedRandomBeaconAddress string
expectedWalletRegistryAddress string
expectedTokenStakingAddress string
expectedBridgeAddress string
expectedWalletCoordinatorAddress string
expectedRandomBeaconAddress string
expectedWalletRegistryAddress string
expectedTokenStakingAddress string
expectedBridgeAddress string
expectedWalletProposalValidatorAddress string
}{
"no developer contracts addresses configured": {
configFilePath: "../test/config_no_contracts.toml",
expectedRandomBeaconAddress: "0xd1640b381327c2d5425d6d3d605539a3db72f857",
expectedWalletRegistryAddress: "0xdb3dd6d4f43d39c996d0afeb6fbabc284f9ffb1a",
expectedTokenStakingAddress: "0xaa7b41039ea8f9ec2d89bbe96e19f97b6c267a27",
expectedBridgeAddress: "0x9490165195503fcf6a0fd20ac113223fefb66ed5",
expectedWalletCoordinatorAddress: "0xE7d33d8AA55B73a93059a24b900366894684a497",
configFilePath: "../test/config_no_contracts.toml",
expectedRandomBeaconAddress: "0xd1640b381327c2d5425d6d3d605539a3db72f857",
expectedWalletRegistryAddress: "0xdb3dd6d4f43d39c996d0afeb6fbabc284f9ffb1a",
expectedTokenStakingAddress: "0xaa7b41039ea8f9ec2d89bbe96e19f97b6c267a27",
expectedBridgeAddress: "0x9490165195503fcf6a0fd20ac113223fefb66ed5",
expectedWalletProposalValidatorAddress: "0xE7d33d8AA55B73a93059a24b900366894684a497",
},
"developer contracts addresses configured": {
configFilePath: "../test/config.toml",
expectedRandomBeaconAddress: "0xcf64c2a367341170cb4e09cf8c0ed137d8473ceb",
expectedWalletRegistryAddress: "0x143ba24e66fce8bca22f7d739f9a932c519b1c76",
expectedTokenStakingAddress: "0xa363a197f1bbb8877f50350234e3f15fb4175457",
expectedBridgeAddress: "0x138D2a0c87BA9f6BE1DCc13D6224A6aCE9B6b6F0",
expectedWalletCoordinatorAddress: "0xfdc315b0e608b7cDE9166D9D69a1506779e3E0CA",
configFilePath: "../test/config.toml",
expectedRandomBeaconAddress: "0xcf64c2a367341170cb4e09cf8c0ed137d8473ceb",
expectedWalletRegistryAddress: "0x143ba24e66fce8bca22f7d739f9a932c519b1c76",
expectedTokenStakingAddress: "0xa363a197f1bbb8877f50350234e3f15fb4175457",
expectedBridgeAddress: "0x138D2a0c87BA9f6BE1DCc13D6224A6aCE9B6b6F0",
expectedWalletProposalValidatorAddress: "0xfdc315b0e608b7cDE9166D9D69a1506779e3E0CA",
},
"mxied contracts addresses configured": {
configFilePath: "../test/config_mixed_contracts.toml",
expectedRandomBeaconAddress: "0xd1640b381327c2d5425d6d3d605539a3db72f857",
expectedWalletRegistryAddress: "0x143ba24e66fce8bca22f7d739f9a932c519b1c76",
expectedTokenStakingAddress: "0xaa7b41039ea8f9ec2d89bbe96e19f97b6c267a27",
expectedBridgeAddress: "0x9490165195503fcf6a0fd20ac113223fefb66ed5",
expectedWalletCoordinatorAddress: "0xE7d33d8AA55B73a93059a24b900366894684a497",
configFilePath: "../test/config_mixed_contracts.toml",
expectedRandomBeaconAddress: "0xd1640b381327c2d5425d6d3d605539a3db72f857",
expectedWalletRegistryAddress: "0x143ba24e66fce8bca22f7d739f9a932c519b1c76",
expectedTokenStakingAddress: "0xaa7b41039ea8f9ec2d89bbe96e19f97b6c267a27",
expectedBridgeAddress: "0x9490165195503fcf6a0fd20ac113223fefb66ed5",
expectedWalletProposalValidatorAddress: "0xE7d33d8AA55B73a93059a24b900366894684a497",
},
}

Expand Down Expand Up @@ -400,7 +400,7 @@ func TestReadConfig_ReadContracts(t *testing.T) {
validate(ethereum.WalletRegistryContractName, test.expectedWalletRegistryAddress)
validate(ethereum.TokenStakingContractName, test.expectedTokenStakingAddress)
validate(ethereum.BridgeContractName, test.expectedBridgeAddress)
validate(ethereum.WalletCoordinatorContractName, test.expectedWalletCoordinatorAddress)
validate(ethereum.WalletProposalValidatorContractName, test.expectedWalletProposalValidatorAddress)
})
}
}
6 changes: 3 additions & 3 deletions config/contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func initializeContractAddressesAliases() {
aliasEthereumContract(chainEthereum.MaintainerProxyContractName)
aliasEthereumContract(chainEthereum.LightRelayContractName)
aliasEthereumContract(chainEthereum.LightRelayMaintainerProxyContractName)
aliasEthereumContract(chainEthereum.WalletCoordinatorContractName)
aliasEthereumContract(chainEthereum.WalletProposalValidatorContractName)
}

// resolveContractsAddresses verifies if contracts addresses are configured, if not
Expand Down Expand Up @@ -93,7 +93,7 @@ func (c *Config) resolveContractsAddresses() {
ethereumThreshold.TokenStakingAddress,
)
resolveContractAddress(
chainEthereum.WalletCoordinatorContractName,
ethereumTbtc.WalletCoordinatorAddress,
chainEthereum.WalletProposalValidatorContractName,
ethereumTbtc.WalletProposalValidatorAddress,
)
}
2 changes: 1 addition & 1 deletion configs/config.toml.SAMPLE
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,4 @@ Port = 9601
# RandomBeaconAddress = "0xBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
# WalletRegistryAddress = "0xBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
# BridgeAddress = "0xBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
# WalletCoordinatorAddress = "0xBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
# WalletProposalValidatorAddress = "0xBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
2 changes: 1 addition & 1 deletion docs/resources/client-start-help
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Flags:
--developer.randomBeaconAddress string Address of the RandomBeacon smart contract
--developer.tokenStakingAddress string Address of the TokenStaking smart contract
--developer.walletRegistryAddress string Address of the WalletRegistry smart contract
--developer.walletCoordinatorAddress string Address of the WalletCoordinator smart contract
--developer.walletProposalValidatorAddress string Address of the WalletProposalValidator smart contract

Global Flags:
-c, --config string Path to the configuration file. Supported formats: TOML, YAML, JSON.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace: default

commonLabels:
app: keep-maintainer
# The current setup runs spv and walletCoordination modules as a workaround
# The current setup runs only the spv module as a workaround
# for reasons mentioned in `patches` property below.
type: all
network: sepolia
Expand Down Expand Up @@ -45,9 +45,6 @@ patches:
- op: add
path: /spec/template/spec/containers/0/args/-
value: --spv
- op: add
path: /spec/template/spec/containers/0/args/-
value: --walletCoordination
- op: replace
path: /spec/template/spec/containers/0/env/0/valueFrom/secretKeyRef/name
value: eth-network-sepolia
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,6 @@ spec:
configMapKeyRef:
name: keep-maintainer-config
key: electrum-api-url
- name: REDEMPTION_REQUEST_AMOUNT_LIMIT
valueFrom:
configMapKeyRef:
name: keep-maintainer-config
key: redemption-request-amount-limit
command:
- keep-client
- maintainer
Expand All @@ -62,8 +57,6 @@ spec:
- /mnt/keep-maintainer/keyfile/keep-maintainer-keyfile
- --bitcoin.electrum.url
- $(ELECTRUM_API_URL)
- --walletCoordination.redemptionRequestAmountLimit
- $(REDEMPTION_REQUEST_AMOUNT_LIMIT)
volumeMounts:
- name: eth-account-keyfile
mountPath: /mnt/keep-maintainer/keyfile
Expand Down
4 changes: 2 additions & 2 deletions pkg/bitcoin/electrum/electrum.go
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,7 @@ func requestWithRetry[K interface{}](
requestName string,
) (K, error) {
startTime := time.Now()
logger.Infof("starting [%s] request to Electrum server", requestName)
logger.Debugf("starting [%s] request to Electrum server", requestName)

var result K

Expand Down Expand Up @@ -1070,7 +1070,7 @@ func requestWithRetry[K interface{}](
return "success"
}

logger.Infof("[%s] request to Electrum server completed with [%s] after [%s]",
logger.Debugf("[%s] request to Electrum server completed with [%s] after [%s]",
requestName,
solveRequestOutcome(err),
time.Since(startTime),
Expand Down
4 changes: 2 additions & 2 deletions pkg/chain/ethereum/ethereum.go
Original file line number Diff line number Diff line change
Expand Up @@ -443,9 +443,9 @@ func (bc *baseChain) currentBlock() (*types.Block, error) {
}

// blockByNumber returns the block for the given block number. Times out
// if the underlying client call takes more than 10 seconds.
// if the underlying client call takes more than 30 seconds.
func (bc *baseChain) blockByNumber(number uint64) (*types.Block, error) {
ctx, cancelCtx := context.WithTimeout(context.Background(), 10*time.Second)
ctx, cancelCtx := context.WithTimeout(context.Background(), 30*time.Second)
defer cancelCtx()

return bc.client.BlockByNumber(ctx, big.NewInt(int64(number)))
Expand Down
Loading

0 comments on commit f1c8275

Please sign in to comment.