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

fix: incorrect data merkleRoot length #262

Conversation

AmanRaj1608
Copy link
Contributor

Fixes the issue reported by rage trade. ethers/lib/utils keccak256 returns the 32 bytes output on getHexRoot.

maybe affected by merkletreejs/merkletreejs#86 or same as merkletreejs/merkletreejs#33 ?

@linear
Copy link

linear bot commented Aug 24, 2023

Copy link
Contributor

@livingrockrises livingrockrises left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -1,7 +1,8 @@
import { Signer, ethers } from 'ethers'
import MerkleTree from 'merkletreejs'
import { getUserOpHash, NODE_CLIENT_URL } from '@biconomy/common'
import { hexConcat, arrayify, keccak256, hexZeroPad, defaultAbiCoder } from 'ethers/lib/utils'
import { hexConcat, arrayify, hexZeroPad, defaultAbiCoder } from 'ethers/lib/utils'
import { keccak256 } from 'ethereumjs-util'
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need to use keccak256 from ethereumjs-util in other places too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only for generating the merkle root this is required for now as the addLeaves needs buffer which we was generating and the length was incorrect

Copy link
Contributor

@livingrockrises livingrockrises Aug 24, 2023

Choose a reason for hiding this comment

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

in MultiChain Validator it would be fine? as we use keccak256 as arg in MerkleTree class

     import {
  keccak256,
  arrayify,
  defaultAbiCoder,
  hexConcat,
  hexZeroPad,
  Bytes
} from 'ethers/lib/utils'
      

     const merkleTree = new MerkleTree(leaves, keccak256, { sortPairs: true })

      const multichainSignature = await this.signer.signMessage(arrayify(merkleTree.getHexRoot()))

      Logger.log('merkle root ', merkleTree.getHexRoot())

@livingrockrises livingrockrises merged commit da4ae18 into feat/modular-SA-V2-integration Aug 24, 2023
@AmanRaj1608 AmanRaj1608 deleted the SMA-71-merkle-length--error-fix branch September 29, 2023 03:33
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