Skip to content

Commit

Permalink
update heco cross chain msg (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiqiangxu authored Sep 17, 2021
1 parent 14817ff commit f4a7fe4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
4 changes: 2 additions & 2 deletions native/service/cross_chain_manager/heco/heco_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"math/big"

ecommon "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/light"
"github.com/ethereum/go-ethereum/rlp"
Expand All @@ -35,6 +34,7 @@ import (
"github.com/polynetwork/poly/native"
scom "github.com/polynetwork/poly/native/service/cross_chain_manager/common"
"github.com/polynetwork/poly/native/service/governance/side_chain_manager"
"github.com/polynetwork/poly/native/service/header_sync/eth"
"github.com/polynetwork/poly/native/service/header_sync/heco"
)

Expand Down Expand Up @@ -147,7 +147,7 @@ type ProofAccount struct {
Codehash ecommon.Hash
}

func verifyMerkleProof(hecoProof *Proof, blockData *types.Header, contractAddr []byte) ([]byte, error) {
func verifyMerkleProof(hecoProof *Proof, blockData *eth.Header, contractAddr []byte) ([]byte, error) {
//1. prepare verify account
nodeList := new(light.NodeList)

Expand Down
31 changes: 16 additions & 15 deletions native/service/cross_chain_manager/heco/heco_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,15 @@ import (
"encoding/hex"
"encoding/json"
"fmt"
"io/ioutil"
"math/big"
"net/http"
"strconv"
"strings"
"testing"
"time"

"github.com/ethereum/go-ethereum/common/hexutil"
etypes "github.com/ethereum/go-ethereum/core/types"
"github.com/ontio/ontology-crypto/keypair"
"github.com/ontio/ontology/core/states"
"github.com/polynetwork/poly/account"
Expand All @@ -19,21 +26,15 @@ import (
"github.com/polynetwork/poly/core/types"
"github.com/polynetwork/poly/native"
ccmcom "github.com/polynetwork/poly/native/service/cross_chain_manager/common"
"github.com/polynetwork/poly/native/service/cross_chain_manager/eth"
eth2 "github.com/polynetwork/poly/native/service/cross_chain_manager/eth"
"github.com/polynetwork/poly/native/service/governance/node_manager"
"github.com/polynetwork/poly/native/service/governance/side_chain_manager"
synccom "github.com/polynetwork/poly/native/service/header_sync/common"
"github.com/polynetwork/poly/native/service/header_sync/eth"
"github.com/polynetwork/poly/native/service/header_sync/heco"
"github.com/polynetwork/poly/native/service/utils"
"github.com/polynetwork/poly/native/storage"
"gotest.tools/assert"
"io/ioutil"
"math/big"
"net/http"
"strconv"
"strings"
"testing"
"time"
)

var (
Expand Down Expand Up @@ -237,12 +238,12 @@ type BlockReq struct {
}

type BlockRep struct {
JsonRPC string `json:"jsonrpc"`
Result *etypes.Header `json:"result"`
Id uint `json:"id"`
JsonRPC string `json:"jsonrpc"`
Result *eth.Header `json:"result"`
Id uint `json:"id"`
}

func (this *HecoClient) GetBlockHeader(height uint64) (*etypes.Header, error) {
func (this *HecoClient) GetBlockHeader(height uint64) (*eth.Header, error) {
params := []interface{}{fmt.Sprintf("0x%x", height), true}
req := &BlockReq{
JsonRpc: "2.0",
Expand Down Expand Up @@ -372,7 +373,7 @@ func getLatestHeight(native *native.NativeService) (height uint64) {
return
}

func untilGetBlockHeader(t *testing.T, c *HecoClient, height uint64) *etypes.Header {
func untilGetBlockHeader(t *testing.T, c *HecoClient, height uint64) *eth.Header {
for {
hdr, err := c.GetBlockHeader(height)
if err == nil {
Expand Down Expand Up @@ -446,7 +447,7 @@ func TestProofHandle(t *testing.T) {
key := hex.EncodeToString(big.NewInt(int64(KeyIndex)).Bytes())
proofHeight := uint32(CrossChainTxHeight + BlocksToWait)
proofHeightHex := hexutil.EncodeBig(big.NewInt(int64(proofHeight)))
keyBytes, err := eth.MappingKeyAt(key, "01")
keyBytes, err := eth2.MappingKeyAt(key, "01")
if err != nil {
fmt.Printf("handleLockDepositEvents - MappingKeyAt error:%s\n", err.Error())
return
Expand Down

0 comments on commit f4a7fe4

Please sign in to comment.