From b1678ecb4967ffc07b448e5eeba4daa902b737f7 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Mon, 15 Apr 2024 15:49:34 -0400 Subject: [PATCH] add base54 encoding and decoding --- cmd/zetae2e/local/local.go | 2 +- go.mod | 2 +- go.sum | 10 ++++++++-- x/crosschain/keeper/evm_deposit.go | 6 +++++- x/crosschain/keeper/evm_hooks.go | 4 ++-- x/crosschain/types/errors.go | 1 + 6 files changed, 18 insertions(+), 7 deletions(-) diff --git a/cmd/zetae2e/local/local.go b/cmd/zetae2e/local/local.go index 04d927af96..3d4f42e340 100644 --- a/cmd/zetae2e/local/local.go +++ b/cmd/zetae2e/local/local.go @@ -241,9 +241,9 @@ func localE2ETest(cmd *cobra.Command, _ []string) { e2etests.TestERC20DepositRestrictedName, } zetaTests := []string{ + e2etests.TestMessagePassingZEVMName, e2etests.TestZetaWithdrawName, e2etests.TestMessagePassingName, - e2etests.TestMessagePassingZEVMName, e2etests.TestMessagePassingRevertFailName, e2etests.TestMessagePassingRevertSuccessName, } diff --git a/go.mod b/go.mod index 6ab97b11e2..5b7cdfa9a2 100644 --- a/go.mod +++ b/go.mod @@ -43,7 +43,7 @@ require ( github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 github.com/zeta-chain/go-tss v0.1.1-0.20240208222330-f3be0d4a0d98 github.com/zeta-chain/keystone/keys v0.0.0-20231105174229-903bc9405da2 - github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20240409202853-ee53ce11c29f + github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20240415192848-ad076a028d30 google.golang.org/genproto/googleapis/api v0.0.0-20231120223509-83a465c0220f gopkg.in/yaml.v2 v2.4.0 ) diff --git a/go.sum b/go.sum index 33003e46a7..2a6a26690c 100644 --- a/go.sum +++ b/go.sum @@ -1855,6 +1855,7 @@ github.com/ipfs/go-datastore v0.6.0/go.mod h1:rt5M3nNbSO/8q1t4LNkLyUwRs8HupMeN/8 github.com/ipfs/go-detect-race v0.0.1 h1:qX/xay2W3E4Q1U7d9lNs1sU9nvguX0a7319XbyQ6cOk= github.com/ipfs/go-detect-race v0.0.1/go.mod h1:8BNT7shDZPo99Q74BpGMK+4D8Mn4j46UU0LZ723meps= github.com/ipfs/go-ipfs-util v0.0.2 h1:59Sswnk1MFaiq+VcaknX7aYEyGyGDAA73ilhEK2POp8= +github.com/ipfs/go-ipfs-util v0.0.2/go.mod h1:CbPtkWJzjLdEcezDns2XYaehFVNXG9zrdrtMecczcsQ= github.com/ipfs/go-log v1.0.5 h1:2dOuUCB1Z7uoczMWgAyDck5JLb72zHzrMnGnCNNbvY8= github.com/ipfs/go-log v1.0.5/go.mod h1:j0b8ZoR+7+R99LD9jZ6+AJsrzkPbSXbZfGakb5JPtIo= github.com/ipfs/go-log/v2 v2.1.3/go.mod h1:/8d0SH3Su5Ooc31QlL1WysJhvyOTDCjcCZ9Axpmri6g= @@ -2771,6 +2772,7 @@ github.com/sourcegraph/go-diff v0.5.1/go.mod h1:j2dHj3m8aZgQO8lMTcTnBcXkRRRqi34c github.com/sourcegraph/go-diff v0.5.3/go.mod h1:v9JDtjCE4HHHCZGId75rg8gkKKa98RVjBcBGsVmMmak= github.com/sourcegraph/go-diff v0.6.1/go.mod h1:iBszgVvyxdc8SFZ7gm69go2KDdt3ag071iBaWPF6cjs= github.com/sourcegraph/syntaxhighlight v0.0.0-20170531221838-bd320f5d308e/go.mod h1:HuIsMU8RRBOtsCgI77wP899iHVBQpCmg4ErYMZB+2IA= +github.com/spacemonkeygo/spacelog v0.0.0-20180420211403-2296661a0572/go.mod h1:w0SWMsp6j9O/dk4/ZpIhL+3CkG8ofA2vuv7k+ltqUMc= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI= github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= @@ -3054,8 +3056,12 @@ github.com/zeta-chain/go-tss v0.1.1-0.20240208222330-f3be0d4a0d98 h1:GCSRgszQbAR github.com/zeta-chain/go-tss v0.1.1-0.20240208222330-f3be0d4a0d98/go.mod h1:+lJfk/qqt+oxXeVuJV+PzpUoxftUfoTRf2eF3qlbyFI= github.com/zeta-chain/keystone/keys v0.0.0-20231105174229-903bc9405da2 h1:gd2uE0X+ZbdFJ8DubxNqLbOVlCB12EgWdzSNRAR82tM= github.com/zeta-chain/keystone/keys v0.0.0-20231105174229-903bc9405da2/go.mod h1:x7Bkwbzt2W2lQfjOirnff0Dj+tykdbTG1FMJPVPZsvE= -github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20240409202853-ee53ce11c29f h1:CybkB7TrE025xTzapribnshq4PEA/EAGH6AxIRAqBFI= -github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20240409202853-ee53ce11c29f/go.mod h1:v79f+eY6PMpmLv188FAubst4XV2Mm8mUmx1OgmdFG3c= +github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20240415173111-d7407762b0d6 h1:5MPsY8ktDn5LMrJ19PaTCnbAHfnAgQ/3Ea/p5vV6Gd8= +github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20240415173111-d7407762b0d6/go.mod h1:v79f+eY6PMpmLv188FAubst4XV2Mm8mUmx1OgmdFG3c= +github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20240415174839-9598d475188f h1:DZv7FnSR2WllH5QyDRWlmTUCdqG90eYGE1KlCxFaFYc= +github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20240415174839-9598d475188f/go.mod h1:v79f+eY6PMpmLv188FAubst4XV2Mm8mUmx1OgmdFG3c= +github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20240415192848-ad076a028d30 h1:V1Kl0xLsdL2l9ThMEx/NLqRvr8zTAAyq2IoM+nhPMhE= +github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20240415192848-ad076a028d30/go.mod h1:v79f+eY6PMpmLv188FAubst4XV2Mm8mUmx1OgmdFG3c= github.com/zondax/hid v0.9.0/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM= github.com/zondax/hid v0.9.2 h1:WCJFnEDMiqGF64nlZz28E9qLVZ0KSJ7xpc5DLEyma2U= github.com/zondax/hid v0.9.2/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM= diff --git a/x/crosschain/keeper/evm_deposit.go b/x/crosschain/keeper/evm_deposit.go index 679b521d50..1cf653a471 100644 --- a/x/crosschain/keeper/evm_deposit.go +++ b/x/crosschain/keeper/evm_deposit.go @@ -1,6 +1,7 @@ package keeper import ( + "encoding/base64" "encoding/hex" "fmt" @@ -27,7 +28,10 @@ func (k Keeper) HandleEVMDeposit(ctx sdk.Context, cctx *types.CrossChainTx) (boo inboundSender := cctx.GetInboundTxParams().Sender inboundSenderChainID := cctx.GetInboundTxParams().SenderChainId inboundCoinType := cctx.InboundTxParams.CoinType - data := []byte(cctx.RelayedMessage) + data, err := base64.StdEncoding.DecodeString(cctx.RelayedMessage) + if err != nil { + return false, errors.Wrap(types.ErrUnableToDecodeMessageString, err.Error()) + } if len(ctx.TxBytes()) > 0 { // add event for tendermint transaction hash format hash := tmbytes.HexBytes(tmtypes.Tx(ctx.TxBytes()).Hash()) diff --git a/x/crosschain/keeper/evm_hooks.go b/x/crosschain/keeper/evm_hooks.go index 0841bd9359..0bdda7a6ae 100644 --- a/x/crosschain/keeper/evm_hooks.go +++ b/x/crosschain/keeper/evm_hooks.go @@ -1,6 +1,7 @@ package keeper import ( + "encoding/base64" "encoding/hex" "fmt" "math/big" @@ -224,8 +225,7 @@ func (k Keeper) ProcessZetaSentEvent(ctx sdk.Context, event *connectorzevm.ZetaC return fmt.Errorf("ProcessZetaSentEvent: failed to convert chainID: %s", err.Error()) } amount := math.NewUintFromBigInt(event.ZetaValueAndGas) - // TODO : check encoding and decoding of message - messageString := string(event.Message[:]) + messageString := base64.StdEncoding.EncodeToString(event.Message) // Bump gasLimit by event index (which is very unlikely to be larger than 1000) to always have different ZetaSent events msgs. msg := types.NewMsgVoteOnObservedInboundTx( "", diff --git a/x/crosschain/types/errors.go b/x/crosschain/types/errors.go index 62720aaf66..f2c6c32fca 100644 --- a/x/crosschain/types/errors.go +++ b/x/crosschain/types/errors.go @@ -41,4 +41,5 @@ var ( ErrUnableProcessRefund = errorsmod.Register(ModuleName, 1148, "unable to process refund") ErrUnableToFindZetaAccounting = errorsmod.Register(ModuleName, 1149, "unable to find zeta accounting") ErrInsufficientZetaAmount = errorsmod.Register(ModuleName, 1150, "insufficient zeta amount") + ErrUnableToDecodeMessageString = errorsmod.Register(ModuleName, 1151, "unable to decode message bytes") )