Skip to content

Commit

Permalink
Merge pull request #151 from lbtsm/main
Browse files Browse the repository at this point in the history
fix map2other error
  • Loading branch information
mapdev33 authored Apr 24, 2024
2 parents d53e25f + f87e57d commit 6994150
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 25 deletions.
16 changes: 1 addition & 15 deletions chains/ethereum/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,28 +59,14 @@ func mapToOther(m *chain.Maintainer, latestBlock *big.Int) error {
return err
}
istanbulExtra := mapprotocol.ConvertIstanbulExtra(ist)
var input []byte
if m.Cfg.ApiUrl == "" {
input, err = mapprotocol.PackInput(mapprotocol.Map2Other, mapprotocol.MethodUpdateBlockHeader, h, istanbulExtra, aggPK)
} else {
proof, err := mapprotocol.GetZkProof(m.Cfg.ApiUrl, m.Cfg.Id, latestBlock.Uint64())
if err != nil {
return err
}
validators, err := mapprotocol.GetCurValidators(m.Conn.Client(), latestBlock)
if err != nil {
return err
}
input, err = mapprotocol.PackInput(mapprotocol.Other, mapprotocol.MethodUpdateBlockHeader, validators, h, istanbulExtra, proof)
}
input, err := mapprotocol.PackInput(mapprotocol.Map2Other, mapprotocol.MethodUpdateBlockHeader, h, istanbulExtra, aggPK)
if err != nil {
return err
}
m.Log.Debug("sync block ", "current", latestBlock, "data", common.Bytes2Hex(input))
msgpayload := []interface{}{input}
waitCount := len(m.Cfg.SyncChainIDList)
for _, cid := range m.Cfg.SyncChainIDList {
// Only when the latestblock is greater than the height of the synchronized block, the synchronization is performed
if v, ok := mapprotocol.SyncOtherMap[cid]; ok && latestBlock.Cmp(v) <= 0 {
waitCount--
m.Log.Info("map to other current less than synchronized headerHeight", "toChainId", cid, "synced height", v,
Expand Down
11 changes: 1 addition & 10 deletions internal/chain/block_map2other.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package chain
import (
"context"
"fmt"
"math/big"
"strings"
"time"

Expand All @@ -24,22 +23,14 @@ func (w *Writer) execMap2OtherMsg(m msg.Message) bool {
case <-w.stop:
return false
default:
id, _ := m.Payload[0].(*big.Int)
marshal, _ := m.Payload[1].([]byte)
err := w.conn.LockAndUpdateOpts(needNonce)
if err != nil {
w.log.Error("Failed to update nonce", "err", err)
time.Sleep(constant.TxRetryInterval)
continue
}

data, err := mapprotocol.PackInput(mapprotocol.LightManger, mapprotocol.MethodUpdateBlockHeader, id, marshal)
if err != nil {
w.log.Error("map2other Failed to pack abi data", "err", err)
w.conn.UnlockOpts()
return false
}
tx, err := w.sendTx(&w.cfg.LightNode, nil, data)
tx, err := w.sendTx(&w.cfg.LightNode, nil, m.Payload[0].([]byte))
w.conn.UnlockOpts()
if err == nil {
// message successfully handled
Expand Down

0 comments on commit 6994150

Please sign in to comment.