Skip to content

Commit

Permalink
fix(cli): Fix peer_id generation (#1656)
Browse files Browse the repository at this point in the history
<!--  Thanks for sending a pull request! -->

## What this PR does / why we need it?

This PR fixes a bug in the key generation , where peer_id is hex
encoded.

### What is the impact of this PR?

#### Before 

```
/axon$ ./target/release/axon generate-keypair -n 1 -p .
{
  "keypairs": [
    {
      "index": 0,
      "net_private_key": "0x3e7ee435ec780adc22913cf43dcf81849596e66436d6ea92473b5aa38ce59355",
      "public_key": "0x02817154cbb0946980b352378b7366fc86dff6ca5f71a3c3767accd4d35481aa16",
      "address": "0x1F781E1FA61dce22A256873Af1E4066D6f2Db042",
      "peer_id": "0x516d5475796e324b445a66685271665763666f79656a424e53737554414b75567432616a6e4d6331524858664737",
      "bls_private_key": "0x72e19bff8b6a260ff33c57fede34d3ff5cad1891f48674db952413f45324da07",
      "bls_public_key": "0x9688b98d4c203d42e0d73b7bd233c5e73b5a92804fc7ac5446ee80d9758d0da9f6250fea030377a697e29059c0e98f29"
    }
  ]
}
```

#### After

```
 ./target/release/axon generate-keypair -n 1 -p . | grep peer_id
      "peer_id": "QmS93dMohH8pvvV9ULSGSX7YmPuEbx7gr29Qfyfp1Ch5KA",
```

No Breaking Change
  • Loading branch information
Flouse authored Jan 11, 2024
2 parents 4e88781 + 571510e commit b4054ec
Show file tree
Hide file tree
Showing 5 changed files with 2,015 additions and 2,358 deletions.
6 changes: 3 additions & 3 deletions core/cli/src/args/generate_keypair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl GenerateKeypairArgs {
key_pair.bls_private_key.as_bytes(),
i,
)?;
keypairs.push(Keypair::generate(i)?);
keypairs.push(key_pair);
}

println!(
Expand All @@ -64,7 +64,7 @@ pub struct Keypair {
pub net_private_key: Hex,
pub public_key: Hex,
pub address: Address,
pub peer_id: Hex,
pub peer_id: String,
pub bls_private_key: Hex,
pub bls_public_key: Hex,
}
Expand Down Expand Up @@ -94,7 +94,7 @@ impl Keypair {
net_private_key: Hex::encode(&net_seckey),
public_key: Hex::encode(&pubkey),
address: Address::from_pubkey_bytes(pubkey).map_err(Error::Running)?,
peer_id: Hex::encode(secio_keypair.public_key().peer_id().to_base58()),
peer_id: secio_keypair.public_key().peer_id().to_base58(),
bls_private_key: Hex::encode(&bls_seckey),
bls_public_key: Hex::encode(bls_pub_key.to_bytes()),
})
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/jest/setup.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { bootstrap } from "@chainsafe/dappeteer";
import { RECOMMENDED_METAMASK_VERSION } from "@chainsafe/dappeteer/dist/index";
import { bootstrap } from "dappeteer-new";
import { RECOMMENDED_METAMASK_VERSION } from "dappeteer-new/dist/index";

import Config from "../config";
import createTransactionData from "../src/create_test_data/createTestDataManage";
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
},
"license": "MIT",
"dependencies": {
"dappeteer-new": "^5.2.1",
"@chainsafe/dappeteer": "^5.2.0",
"@ethereumjs/common": "^3.1.1",
"@ethereumjs/tx": "^4.2.0",
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/src/web3_clientVersion.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ describe("web3_clientVersion", () => {
() => document.getElementById("clientVersion").innerText !== "",
);

await expect(page.$eval("#clientVersion", (e) => e.innerText)).resolves.toBe("MetaMask/v10.31.0");
await expect(page.$eval("#clientVersion", (e) => e.innerText)).resolves.toBe("MetaMask/v11.0.0");
});
});
Loading

0 comments on commit b4054ec

Please sign in to comment.