Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
danil-lashin committed Nov 22, 2021
1 parent 6dc8070 commit 0b05063
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions keys-generator/cmd/mhub-keys-generator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,34 @@ import (
"github.com/ethereum/go-ethereum/crypto/secp256k1"
"github.com/status-im/keycard-go/hexutils"
"os"
"strconv"
)

const ethSignaturePrefix = "\x19Ethereum Signed Message:\n32"

func main() {
app.SetAddressConfig()

if len(os.Args) == 4 && os.Args[1] == "make_delegate_sign" {
if len(os.Args) == 5 && os.Args[1] == "make_delegate_sign" {
ethPrivateKey := os.Args[2]
cosmosAddr := os.Args[3]
nonce, err := strconv.Atoi(os.Args[4])

valAddress, err := sdk.AccAddressFromBech32(cosmosAddr)
if err != nil {
panic(err)
}
signMsgBz := app.MakeEncodingConfig().Marshaler.MustMarshal(&types.DelegateKeysSignMsg{
ValidatorAddress: sdk.ValAddress(valAddress).String(),
Nonce: 0,
Nonce: uint64(nonce),
})
hash := append([]uint8(ethSignaturePrefix), crypto.Keccak256Hash(signMsgBz).Bytes()...)
sig, err := secp256k1.Sign(crypto.Keccak256Hash(hash).Bytes(), hexutils.HexToBytes(ethPrivateKey))
if err != nil {
panic(err)
}

fmt.Printf("%x", sig)
fmt.Printf("0x%x\n", sig)

return
}
Expand All @@ -48,5 +50,5 @@ func main() {
publicKeyECDSA, _ := publicKey.(*ecdsa.PublicKey)
address := crypto.PubkeyToAddress(*publicKeyECDSA).Hex()
fmt.Printf("Ethereum address: %s\n", address)
fmt.Printf("Minter address: Mx%s\n", address[:2])
fmt.Printf("Minter address: Mx%s\n", address[2:])
}
2 changes: 1 addition & 1 deletion module/x/mhub2/keeper/external_event_vote.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func (k Keeper) recordEventVote(ctx sdk.Context, chainId types.ChainID, event ty
// and prevents validators from submitting two claims with the same nonce
lastEventNonce := k.getLastEventNonceByValidator(ctx, chainId, val)
expectedNonce := lastEventNonce + 1
if event.GetEventNonce() != expectedNonce {
if event.GetEventNonce() != expectedNonce && lastEventNonce != 0 {
return nil, sdkerrors.Wrapf(types.ErrInvalid,
"non contiguous event nonce expected %v observed %v for validator %v",
expectedNonce,
Expand Down

0 comments on commit 0b05063

Please sign in to comment.