Skip to content

feat(abstract-eth): add recover consolidation for eth #6550

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

abhi-bitgo
Copy link
Contributor

Adding the recover consolidation functionality for eth and hteth which would be used for unsigned consolidation in WRW

ticket: WIN-5700

@abhi-bitgo abhi-bitgo force-pushed the win-5700-eth-consolidation-recovery branch from 960e8af to 3b58e6a Compare July 25, 2025 13:29
@abhi-bitgo abhi-bitgo changed the title feat(eth): add recover consolidation for eth feat(abstract-eth): add recover consolidation for eth Jul 25, 2025
@abhi-bitgo abhi-bitgo force-pushed the win-5700-eth-consolidation-recovery branch 2 times, most recently from dfef449 to d50d402 Compare July 29, 2025 10:06
@abhi-bitgo abhi-bitgo marked this pull request as ready for review July 29, 2025 12:28
@abhi-bitgo abhi-bitgo requested review from a team as code owners July 29, 2025 12:28
@mullapudipruthvik
Copy link
Contributor

@claude review this PR as Grug

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds consolidation recovery functionality for Ethereum-based coins (ETH and HTETH) to support unsigned consolidation operations in WRW. The implementation includes methods to generate forwarder addresses, derive addresses from public keys, and recover funds from multiple consolidation addresses.

Key changes:

  • Added network configuration properties for wallet V4 forwarder addresses
  • Implemented consolidation recovery methods in the abstract Ethereum class
  • Added comprehensive address generation and scanning functionality

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
modules/statics/src/networks.ts Added wallet V4 forwarder factory and implementation addresses to Ethereum and Holesky network configurations
modules/statics/test/unit/resources/amsTokenConfig.ts Updated test configuration with new forwarder addresses
modules/abstract-eth/src/abstractEthLikeNewCoins.ts Implemented core consolidation recovery functionality including address generation, derivation, and transaction building
Comments suppressed due to low confidence (1)

modules/abstract-eth/src/abstractEthLikeNewCoins.ts:1318

  • Using 'any' type reduces type safety. Consider defining a proper interface or union type for consolidation transactions.
    const consolidationTransactions: any[] = [];

);
possibleConsolidationAddresses.push(forwarderAddress);
} catch (e) {
console.log(`Failed to generate forwarder address: ${e.message}`);
Copy link
Preview

Copilot AI Aug 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using console.log for error logging is not appropriate for production code. Consider using a proper logging framework or throwing/handling the error appropriately.

Suggested change
console.log(`Failed to generate forwarder address: ${e.message}`);
debug(`Failed to generate forwarder address: ${e instanceof Error ? e.message : e}`);

Copilot uses AI. Check for mistakes.

const derivedAddress = this.deriveAddressFromPublicKey(params.userKey, index);
possibleConsolidationAddresses.push(derivedAddress);
} catch (e) {
console.log(`Failed to generate derived address: ${e}`);
Copy link
Preview

Copilot AI Aug 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using console.log for error logging is not appropriate for production code. Consider using a proper logging framework or throwing/handling the error appropriately.

Suggested change
console.log(`Failed to generate derived address: ${e}`);
debug(`Failed to generate derived address: ${e}`);

Copilot uses AI. Check for mistakes.

}
}

// lastScanIndex = i;
Copy link
Preview

Copilot AI Aug 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commented out code should be removed or properly implemented if needed.

Suggested change
// lastScanIndex = i;

Copilot uses AI. Check for mistakes.

chain: params.replayProtectionOptions?.chain || 0,
hardfork: params.replayProtectionOptions?.hardfork || 'london',
},
bitgoKey: '',
Copy link
Preview

Copilot AI Aug 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting bitgoKey to an empty string may be problematic. Consider using a proper default value or making this parameter optional if it's not required.

Suggested change
bitgoKey: '',
...(params.bitgoKey !== undefined ? { bitgoKey: params.bitgoKey } : {}),

Copilot uses AI. Check for mistakes.


if (params.userKey) {
try {
const derivedAddress = this.deriveAddressFromPublicKey(params.userKey, index);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

derivedAddress is returned for every getConsolidationAddress call, why is that ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have any means to differentiate between v6 and v5 wallet thus we try to derive address every time.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in that case this would execute for v6 wallet as well right ?
const forwarderAddress = this.generateForwarderAddress( params.walletContractAddress, params.bitgoFeeAddress, forwarderFactoryAddress, forwarderImplementationAddress, index ); possibleConsolidationAddresses.push(forwarderAddress);

const salt = addHexPrefix(index.toString(16));
const saltBuffer = setLengthLeft(toBuffer(salt), 32);

const { createForwarderParams, createForwarderTypes } = getCreateForwarderParamsAndTypes(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is specific for v4 wallet, can you not make it generic ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we are not sure which version is being used, we have kept this in a try statement in order to handle the failure

Copy link
Contributor

@mullapudipruthvik mullapudipruthvik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also please add test cases

@abhi-bitgo abhi-bitgo force-pushed the win-5700-eth-consolidation-recovery branch 4 times, most recently from ce56893 to b0e63e4 Compare August 7, 2025 13:36

if (params.userKey) {
try {
const derivedAddress = this.deriveAddressFromPublicKey(params.userKey, index);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in that case this would execute for v6 wallet as well right ?
const forwarderAddress = this.generateForwarderAddress( params.walletContractAddress, params.bitgoFeeAddress, forwarderFactoryAddress, forwarderImplementationAddress, index ); possibleConsolidationAddresses.push(forwarderAddress);

basecoin = bitgo.coin('hteth') as Hteth;
});

it('should generate an unsigned consolidation', async function () {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a test case for v5 and v6 separately

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to write separate test cases since all the values are provided and based on the which wallet version we are assuming, we are using the relevant values and generating address for consolidation

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in that case this would execute for v6 wallet as well right ?
const forwarderAddress = this.generateForwarderAddress( params.walletContractAddress, params.bitgoFeeAddress, forwarderFactoryAddress, forwarderImplementationAddress, index ); possibleConsolidationAddresses.push(forwarderAddress);

yes, this will run in both the cases since we have no means of verifying which wallet version is this

Copy link
Contributor

@mullapudipruthvik mullapudipruthvik Aug 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are you sure whether this would throw an error for V6 wallet?
better to add a testcase to verify

@mullapudipruthvik mullapudipruthvik requested a review from a team August 12, 2025 07:50
@abhi-bitgo abhi-bitgo force-pushed the win-5700-eth-consolidation-recovery branch from 383997d to aabf004 Compare August 13, 2025 06:02
@abhi-bitgo abhi-bitgo force-pushed the win-5700-eth-consolidation-recovery branch from aabf004 to 596e192 Compare August 13, 2025 06:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants