Skip to content
This repository has been archived by the owner on May 13, 2022. It is now read-only.

How much should I fill in for burrow to metamask chainid? #1411

Closed
bitbeb opened this issue Dec 15, 2020 · 7 comments · Fixed by #1460
Closed

How much should I fill in for burrow to metamask chainid? #1411

bitbeb opened this issue Dec 15, 2020 · 7 comments · Fixed by #1460

Comments

@bitbeb
Copy link

bitbeb commented Dec 15, 2020

How much should I fill in for burrow to metamask chainid?

thank you

@silasdavis
Copy link
Contributor

Hi @bitbeb I recently changed our behaviour here, before we were using a stub ChainID but that offers no reply protection.

I am currently using the following code: https://github.com/hyperledger/burrow/blob/master/crypto/signature.go#L120-L122 to establish a web3-compatible integer ChainID based on our string one. You would need your tool to provide that integer value (check how any CLI wants it to be encoded).

If there is a better standard I could use here vis-a-vis string-to-integer chain id please let me know.

@bitbeb
Copy link
Author

bitbeb commented Mar 11, 2021

Hi @bitbeb I recently changed our behaviour here, before we were using a stub ChainID but that offers no reply protection.

I am currently using the following code: https://github.com/hyperledger/burrow/blob/master/crypto/signature.go#L120-L122 to establish a web3-compatible integer ChainID based on our string one. You would need your tool to provide that integer value (check how any CLI wants it to be encoded).

If there is a better standard I could use here vis-a-vis string-to-integer chain id please let me know.

Hello! May I ask what I got according to your method big.int The result indicates that the number is too large. The chainid of my buorrw is "chainname": "burrowchain"_ FAB3C1",
"ChainId": "BurrowChain_ FAB3C1-AB0FD1",

https://github.com/hyperledger/burrow/blob/master/crypto/signature.go#L120-L122 to

chainID:98398506046391950612428913232117193968501817186218405401892336238027608097865

@silasdavis
Copy link
Contributor

silasdavis commented Mar 15, 2021

Hm, I can see there may be an issue here, however I'm not quite sure how you obtained 98398506046391950612428913232117193968501817186218405401892336238027608097865 for chainID, could you post the code that generates that?

In Burrow the ChainID is derived from the ChainName (human readable, non-unique) and the the hash of the genesis hash: https://github.com/hyperledger/burrow/blob/0708b48608b9932753591a53a7661740e1b3d4e9/genesis/genesis.go#L118-L123

However, if you want to use an explicit ChainID you can set that in the GenesisDoc and it will be used.

For metamask compatibility I think if you set your ChainID in genesis doc (burrow configure does not have an option for ChainID) to the string of a decimal integer like "123456". Here is an example (I ran burrow spec -n MyLovelyChain | burrow configure -s- and edited the TOML output):

BurrowDir = ".burrow"

[GenesisDoc]
  GenesisTime = 2021-03-15T16:26:51Z
  ChainName = "MyLovelyChain"
  ChainID = "123456"
  [GenesisDoc.Params]
    ProposalThreshold = 3
  [GenesisDoc.GlobalPermissions]
    [GenesisDoc.GlobalPermissions.Base]
      Perms = "send | call | createContract | createAccount | bond | name | proposal | input | batch | hasBase | hasRole"
      SetBit = "root | send | call | createContract | createAccount | bond | name | proposal | input | batch | identify | hasBase | setBase | unsetBase | setGlobal | hasRole | addRole | removeRole"

  [[GenesisDoc.Accounts]]
    Address = "B93C649C7A7E924B6F95F95FDD554CB42D87272C"
    Amount = 9999999999
    Name = "Validator_0"
    PublicKey = "{\"CurveType\":\"ed25519\",\"PublicKey\":\"611629636B4FD54705007CCDC061BBDCBA81C75980D1F15F24BB555823369C43\"}"
    [GenesisDoc.Accounts.Permissions]
      [GenesisDoc.Accounts.Permissions.Base]
        Perms = "bond"
        SetBit = "bond"

  [[GenesisDoc.Validators]]
    Address = "B93C649C7A7E924B6F95F95FDD554CB42D87272C"
    Amount = 9999999998
    Name = "Validator_0"
    PublicKey = "{\"CurveType\":\"ed25519\",\"PublicKey\":\"611629636B4FD54705007CCDC061BBDCBA81C75980D1F15F24BB555823369C43\"}"

    [[GenesisDoc.Validators.UnbondTo]]
      Address = "B93C649C7A7E924B6F95F95FDD554CB42D87272C"
      Amount = 9999999998
      PublicKey = "{\"CurveType\":\"ed25519\",\"PublicKey\":\"611629636B4FD54705007CCDC061BBDCBA81C75980D1F15F24BB555823369C43\"}"

Then I think you should be able to use the chain ID "123456" in metamask and other tooling

@bitbeb
Copy link
Author

bitbeb commented Mar 18, 2021

func (genesisDoc *GenesisDoc) ChainID() string {
if genesisDoc.chainID == "" {
//genesisDoc.chainID = fmt.Sprintf("%s-%X", genesisDoc.ChainName, genesisDoc.ShortHash())
genesisDoc.chainID = "1869"
}
return genesisDoc.chainID
}

After modifying the ID according to your method, you still can't link
{
"jsonrpc": "2.0",
"id": "",
"result": {
"ChainName": "MyLovelyChain",
"ChainId": "1869",
"GenesisHash": "8DCBA6F801624691E84E45E4D16EEE5EC08801946FC6609320B452683BA2017B"
}
}
The metamask RPC endpoint uses a different chain ID: 6249

@bitbeb
Copy link
Author

bitbeb commented Mar 18, 2021

BurrowDir = ".burrow"

[GenesisDoc]
GenesisTime = 2021-03-18T07:48:22Z
ChainName = "MyLovelyChain"
"ChainId" = "1869"
[GenesisDoc.Params]
ProposalThreshold = 3
[GenesisDoc.GlobalPermissions]
[GenesisDoc.GlobalPermissions.Base]
Perms = "send | call | createContract | createAccount | bond | name | proposal | input | batch | hasBase | hasRole"
SetBit = "root | send | call | createContract | createAccount | bond | name | proposal | input | batch | identify | hasBase | setBase | unsetBase | setGlobal | hasRole | addRole | removeRole"

[[GenesisDoc.Accounts]]
Address = "DA5AA1CC6898096323AC57A09BB263436541291E"
PublicKey = "{"CurveType":"ed25519","PublicKey":"E39A397E4C0644E36779D598EBE80F7B90AA9CA6334117985425B19790D50348"}"
Amount = 1000000
Name = "Account_0"
[GenesisDoc.Accounts.Permissions]
[GenesisDoc.Accounts.Permissions.Base]
Perms = "send | call | createContract | createAccount | bond | name | proposal | input | batch | hasBase | hasRole"
SetBit = "root | send | call | createContract | createAccount | bond | name | proposal | input | batch | identify

@bitbeb
Copy link
Author

bitbeb commented Mar 18, 2021

func (genesisDoc *GenesisDoc) ChainID() string {
if genesisDoc.chainID == "" {
genesisDoc.chainID = "1869"
}
return genesisDoc.chainID
}

@silasdavis
Copy link
Contributor

A few things:

  • First sorry I was wrong to say you could set ChainID in genesis (this used to be the case), after Allow overriding of ChainID #1460 is merged you will be able to set it again.

  • Note in your example you are using ChainId it needs to be ChainID as the key (we really ought to report unknown keys but this would require some validation logic to be written for all config, this would be a good thing so I made an issue for it [CLI] Validate Burrow config #1461)

  • I have lightly smoke tested this with metamask and they now agree on ChainID, the issue you were seeing even when hard-coding ChainID was that metamask was interpreting the return value as base 16 and 0x1869 == 6249

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants