Commit 2afe8a07 authored by suyanlong's avatar suyanlong

fix config info bug

parent c528d06b
...@@ -10,7 +10,12 @@ default: ...@@ -10,7 +10,12 @@ default:
mkdir -p build mkdir -p build
$(GO) build -o build/chain33-client-evmxgo ./cmd/evmxgo/*.go $(GO) build -o build/chain33-client-evmxgo ./cmd/evmxgo/*.go
$(GO) build -o build/chain33-client-paracross ./cmd/paracross/*.go $(GO) build -o build/chain33-client-paracross ./cmd/paracross/*.go
cp build/chain33-client-* build/plugins/ mkdir -p build/plugins
mkdir -p build/evmxgo
cp build/chain33-client-* build/plugins/
cp paracross/paracross.toml build/plugins/paracross/
cp evmxgo/evmxgo.toml build/plugins/evmxgo/
cp config/sidecar.toml build/
help: Makefile help: Makefile
@echo "Choose a command run:" @echo "Choose a command run:"
......
...@@ -21,6 +21,6 @@ make chain33 ...@@ -21,6 +21,6 @@ make chain33
备注:只能使用以上流程,其它流程不允许。如不允许在公链发起提币,不允许在联盟链发起锁币。针对程序来说。 备注:只能使用以上流程,其它流程不允许。如不允许在公链发起提币,不允许在联盟链发起锁币。针对程序来说。
### 在用户层来说,怎么发起由前端决定。 ### 在用户层来说,如何发起由前端决定。
...@@ -7,6 +7,7 @@ chain_id = "3" ...@@ -7,6 +7,7 @@ chain_id = "3"
start_height = 1 start_height = 1
height_diff = 0 height_diff = 0
fee = 100000 fee = 100000
is_test = true
[log] [log]
level = "debug" level = "debug"
......
...@@ -37,12 +37,13 @@ type Chain33 struct { ...@@ -37,12 +37,13 @@ type Chain33 struct {
Addr string `toml:"addr" json:"addr"` Addr string `toml:"addr" json:"addr"`
Name string `toml:"name" json:"name"` Name string `toml:"name" json:"name"`
PrivateKey string `mapstructure:"private_key" toml:"private_key" json:"private_key"` PrivateKey string `mapstructure:"private_key" toml:"private_key" json:"private_key"`
ChainID string `mapstructure:"chain_id" json:"chain_id"` ChainID int32 `mapstructure:"chain_id" json:"chain_id"`
StartHeight int64 `mapstructure:"start_height" json:"start_height"` // 起始高度 StartHeight int64 `mapstructure:"start_height" json:"start_height"` // 起始高度
HeightDiff int64 `mapstructure:"height_diff" json:"height_diff"` // 高度差 HeightDiff int64 `mapstructure:"height_diff" json:"height_diff"` // 高度差
Fee int64 `mapstructure:"Fee" json:"Fee"` // 单笔交易的手续费 Fee int64 `mapstructure:"Fee" json:"Fee"` // 单笔交易的手续费
EventFilter string `mapstructure:"event_filter" toml:"event_filter" json:"event_filter"` EventFilter string `mapstructure:"event_filter" toml:"event_filter" json:"event_filter"`
TimeoutHeight int64 `mapstructure:"timeout_height" json:"timeout_height"` TimeoutHeight int64 `mapstructure:"timeout_height" json:"timeout_height"`
IsTest bool `mapstructure:"is_test" json:"is_test"`
} }
type Service struct { type Service struct {
...@@ -57,7 +58,7 @@ func DefaultConfig() *Config { ...@@ -57,7 +58,7 @@ func DefaultConfig() *Config {
Addr: "40.125.164.122:8801", Addr: "40.125.164.122:8801",
Name: "chain33", Name: "chain33",
PrivateKey: "", PrivateKey: "",
ChainID: "1", ChainID: 1,
StartHeight: 3, StartHeight: 3,
HeightDiff: 6, HeightDiff: 6,
Fee: 1e5, Fee: 1e5,
...@@ -69,8 +70,8 @@ func DefaultConfig() *Config { ...@@ -69,8 +70,8 @@ func DefaultConfig() *Config {
DbCache: 100, DbCache: 100,
}, },
Router: Router{ Router: Router{
FromChain: "1", FromChain: "paracross",
ToChain: "3", ToChain: "evmxgo",
}, },
Log: Log{ Log: Log{
Level: "info", Level: "info",
......
...@@ -26,17 +26,18 @@ rule = "info" ...@@ -26,17 +26,18 @@ rule = "info"
[[appchains]] [[appchains]]
enable = true enable = true
type = "appchain" type = "appchain"
did = "3" did = "paracross"
config = "paracross/paracross.toml" config = "paracross/paracross.toml"
plugin = "chain33-client-paracross" plugin = "chain33-client-paracross"
plugin_id = "paracross"
[[appchains]] [[appchains]]
enable = true enable = true
type = "appchain" type = "appchain"
did = "1" did = "evmxgo"
config = "evmxgo/evmxgo.toml" config = "evmxgo/evmxgo.toml"
plugin = "chain33-client-evmxgo" plugin = "chain33-client-evmxgo"
plugin_id = "evmxgo"
[router] [router]
enable = false enable = false
......
...@@ -45,16 +45,17 @@ var ( ...@@ -45,16 +45,17 @@ var (
) )
type Evmxgo struct { type Evmxgo struct {
eventC chan *pb.IBTP // 发送给sidecar eventC chan *pb.IBTP // 发送给sidecar
appChainID string chainID int32
toChainID string fromID string
ticker *time.Ticker toID string
done chan bool ticker *time.Ticker
client *rpc.Client done chan bool
pk string // 签名,仅仅是和当前链挂钩的私钥。 client *rpc.Client
height *atomic.Int64 // 已经解析的高度。1、初始化时设置; 2、服务每次重启后设置 pk string // 签名,仅仅是和当前链挂钩的私钥。
db *util.KVDBList // 记录已完成的hashID、高度等信息。 height *atomic.Int64 // 已经解析的高度。1、初始化时设置; 2、服务每次重启后设置
fee int64 db *util.KVDBList // 记录已完成的hashID、高度等信息。
fee int64
} }
func (e *Evmxgo) incHeight() int64 { func (e *Evmxgo) incHeight() int64 {
...@@ -95,7 +96,7 @@ func (e *Evmxgo) Type() string { ...@@ -95,7 +96,7 @@ func (e *Evmxgo) Type() string {
} }
func (e *Evmxgo) ID() string { func (e *Evmxgo) ID() string {
return e.appChainID return e.fromID
} }
// configPath 完整路径 // configPath 完整路径
...@@ -111,10 +112,11 @@ func (e *Evmxgo) Initialize(configPath string, ID string, extra []byte) error { ...@@ -111,10 +112,11 @@ func (e *Evmxgo) Initialize(configPath string, ID string, extra []byte) error {
logger.Info("print chain33Config", "chain33Config", util.Sprint(chain33Config)) logger.Info("print chain33Config", "chain33Config", util.Sprint(chain33Config))
logger.Info("print privateKey", "privateKey", chain33Config.Chain33.PrivateKey) logger.Info("print privateKey", "privateKey", chain33Config.Chain33.PrivateKey)
e.pk = chain33Config.Chain33.PrivateKey e.pk = chain33Config.Chain33.PrivateKey
e.appChainID = chain33Config.Chain33.ChainID e.chainID = chain33Config.Chain33.ChainID
e.toChainID = chain33Config.Router.ToChain e.fromID = chain33Config.Router.FromChain
e.toID = chain33Config.Router.ToChain
e.fee = chain33Config.Chain33.Fee e.fee = chain33Config.Chain33.Fee
logger.SetLevel(hclog.LevelFromString(chain33Config.Log.Level)) // logger.SetLevel(hclog.LevelFromString(chain33Config.Log.Level))
// 初始化chain33 client rpc // 初始化chain33 client rpc
client, err := rpc.NewClient("", chain33Config.Chain33.Addr) client, err := rpc.NewClient("", chain33Config.Chain33.Addr)
...@@ -187,7 +189,7 @@ func (e *Evmxgo) pollAppChain() chan *types.Event { ...@@ -187,7 +189,7 @@ func (e *Evmxgo) pollAppChain() chan *types.Event {
time.Sleep(2 * time.Second) time.Sleep(2 * time.Second)
} else { } else {
height1 := height + 1 height1 := height + 1
blockInfo, err := e.client.QueryBlockInfo(height1, height1, true) // TODO 分组获取 blockInfo, err := e.client.QueryBlockInfo(height1, height1, true)
if err != nil { if err != nil {
logger.Error("call QueryBlockInfo", "error", err) logger.Error("call QueryBlockInfo", "error", err)
} else { } else {
...@@ -210,7 +212,7 @@ func (e *Evmxgo) pollAppChain() chan *types.Event { ...@@ -210,7 +212,7 @@ func (e *Evmxgo) pollAppChain() chan *types.Event {
Amount string `json:"amount,omitempty"` Amount string `json:"amount,omitempty"`
BridgeToken string `json:"bridgeToken,omitempty"` BridgeToken string `json:"bridgeToken,omitempty"`
Recipient string `json:"recipient,omitempty"` Recipient string `json:"recipient,omitempty"`
Extra []byte `json:"extra,omitempty"` // Extra []byte `json:"extra,omitempty"` TODO?
} }
Action struct { Action struct {
MintMap *MintMap `json:"mintMap,omitempty"` MintMap *MintMap `json:"mintMap,omitempty"`
...@@ -219,8 +221,10 @@ func (e *Evmxgo) pollAppChain() chan *types.Event { ...@@ -219,8 +221,10 @@ func (e *Evmxgo) pollAppChain() chan *types.Event {
) )
action := &Action{} action := &Action{}
err := json.Unmarshal(tx.Payload, &action) err := json.Unmarshal(tx.Payload, &action)
// action := &evmxgotypes.EvmxgoAction{}
// err := types33.Decode(tx.Payload, action)
if err != nil { if err != nil {
logger.Error("Unmarshal payload", logger.Error("MintMap Unmarshal tx.payload to action",
"height:", item.Block.Height, "height:", item.Block.Height,
"tx:", util.FormatJSON(tx), "tx:", util.FormatJSON(tx),
"error", err, "error", err,
...@@ -234,7 +238,7 @@ func (e *Evmxgo) pollAppChain() chan *types.Event { ...@@ -234,7 +238,7 @@ func (e *Evmxgo) pollAppChain() chan *types.Event {
TxID: tx.Hash, TxID: tx.Hash,
BlockNumber: uint64(item.Block.Height), BlockNumber: uint64(item.Block.Height),
Contract: &types.Contract{ Contract: &types.Contract{
ChainID: e.appChainID, ChainID: e.fromID,
ExecName: ID, ExecName: ID,
Address: address.ExecAddress(ID), // TODO 合约地址 Address: address.ExecAddress(ID), // TODO 合约地址
CallMethod: evmxgotypes.NameMintMapAction, CallMethod: evmxgotypes.NameMintMapAction,
...@@ -246,24 +250,14 @@ func (e *Evmxgo) pollAppChain() chan *types.Event { ...@@ -246,24 +250,14 @@ func (e *Evmxgo) pollAppChain() chan *types.Event {
Symbol: types.Symbol(mintEvent.Symbol), Symbol: types.Symbol(mintEvent.Symbol),
Height: height1, Height: height1,
Nonce: tx.Nonce, Nonce: tx.Nonce,
Extra: mintEvent.Extra, // Extra: mintEvent.Extra,
}, },
} }
srcEvent := &types.Event{} srcEvent := &types.Event{}
err = types33.Decode(mintEvent.Extra, srcEvent) //err = types33.Decode(mintEvent.Extra, srcEvent)
if err != nil { //if err != nil {
logger.Error("types33.Decode(mintEvent.Extra, &srcEvent)", "error", err) // logger.Error("types33.Decode(mintEvent.Extra, &srcEvent)", "error", err)
continue // continue
}
// 铸币成功,置换DB中的状态。
// 1、发送交易时返回的hash; 2、日志解析
//bindHash, _ := e.db.Get([]byte(tx.Hash))
//if bindHash != nil {
// e.deleteUndoneEvent(string(bindHash))
// _ = e.db.Delete([]byte(tx.Hash))
// _ = e.db.Delete(bindHash)
// // key := fmt.Sprintf("%s-%s-%d-%s", "lock", event.TxID)
//} //}
e.saveMint(event) e.saveMint(event)
e.updateLockMint(srcEvent, event) e.updateLockMint(srcEvent, event)
...@@ -285,7 +279,7 @@ func (e *Evmxgo) pollAppChain() chan *types.Event { ...@@ -285,7 +279,7 @@ func (e *Evmxgo) pollAppChain() chan *types.Event {
action := &Action{} action := &Action{}
err := json.Unmarshal(tx.Payload, &action) err := json.Unmarshal(tx.Payload, &action)
if err != nil { if err != nil {
logger.Error("Unmarshal payload", logger.Error("BurnMap Unmarshal tx.payload to action",
"height:", item.Block.Height, "height:", item.Block.Height,
"tx:", util.FormatJSON(tx), "tx:", util.FormatJSON(tx),
"error", err, "error", err,
...@@ -300,7 +294,7 @@ func (e *Evmxgo) pollAppChain() chan *types.Event { ...@@ -300,7 +294,7 @@ func (e *Evmxgo) pollAppChain() chan *types.Event {
TxID: tx.Hash, TxID: tx.Hash,
BlockNumber: uint64(item.Block.Height), BlockNumber: uint64(item.Block.Height),
Contract: &types.Contract{ Contract: &types.Contract{
ChainID: e.appChainID, ChainID: cast.ToString(e.chainID),
ExecName: ID, ExecName: ID,
Address: address.ExecAddress(ID), // TODO 合约地址 Address: address.ExecAddress(ID), // TODO 合约地址
CallMethod: evmxgotypes.NameBurnMapAction, CallMethod: evmxgotypes.NameBurnMapAction,
...@@ -455,8 +449,8 @@ func (e *Evmxgo) loop() { ...@@ -455,8 +449,8 @@ func (e *Evmxgo) loop() {
data, _ := payload.Marshal() data, _ := payload.Marshal()
tmp := time.Now().UnixNano() tmp := time.Now().UnixNano()
ibtp := &pb.IBTP{ ibtp := &pb.IBTP{
From: e.appChainID, From: e.fromID,
To: e.toChainID, To: e.toID,
Nonce: uint64(event.Payload.Nonce), // TODO 唯一标识。随机nonce Nonce: uint64(event.Payload.Nonce), // TODO 唯一标识。随机nonce
Type: pb.IBTP_INTERCHAIN, Type: pb.IBTP_INTERCHAIN,
Timestamp: tmp, Timestamp: tmp,
...@@ -574,14 +568,14 @@ func (e *Evmxgo) CreateTx(execName, action string, param types33.Message) (*type ...@@ -574,14 +568,14 @@ func (e *Evmxgo) CreateTx(execName, action string, param types33.Message) (*type
} }
// 填写nonce,execer,to, fee 等信息, 后面会增加一个修改transaction的函数,会加上execer fee 等的修改 // 填写nonce,execer,to, fee 等信息, 后面会增加一个修改transaction的函数,会加上execer fee 等的修改
tx.Nonce = rand.Int63() tx.Nonce = rand.Int63()
tx.ChainID = cast.ToInt32(e.appChainID) tx.ChainID = e.chainID
tx.Execer = []byte(execName) tx.Execer = []byte(execName)
// 平行链,所有的to地址都是合约地址 // 平行链,所有的to地址都是合约地址
if tx.To == "" { if tx.To == "" {
tx.To = address.ExecAddress(string(tx.Execer)) tx.To = address.ExecAddress(string(tx.Execer))
} }
if tx.Fee == 0 { if tx.Fee == 0 {
tx.Fee, err = tx.GetRealFee(e.fee) // TODO 手续费可配置 tx.Fee, err = tx.GetRealFee(e.fee)
if err != nil { if err != nil {
return nil, err return nil, err
} }
......
...@@ -3,13 +3,13 @@ ...@@ -3,13 +3,13 @@
addr = "http://192.168.0.15:8801" addr = "http://192.168.0.15:8801"
#用于跨链交易签名的私钥 #用于跨链交易签名的私钥
private_key = "0xb9135831281bb9a09e2610680258270faecbeb4a73e0cec261ef0970c32cca5a" private_key = "0xb9135831281bb9a09e2610680258270faecbeb4a73e0cec261ef0970c32cca5a"
chain_id = "1" chain_id = 0
start_height = 1 start_height = 1
height_diff = 0 height_diff = 0
fee = 100000 fee = 100000
[log] [log]
level = "debug" level = "trace"
[db] [db]
name = "evmxgo" name = "evmxgo"
...@@ -18,4 +18,5 @@ db_path = "./evmxgo" ...@@ -18,4 +18,5 @@ db_path = "./evmxgo"
db_cache = 100 db_cache = 100
[router] [router]
to_chain = "3" from_chain = "evmxgo"
to_chain = "paracross"
...@@ -3,6 +3,7 @@ package paracross ...@@ -3,6 +3,7 @@ package paracross
import ( import (
"bytes" "bytes"
"context" "context"
"errors"
"fmt" "fmt"
"math/rand" "math/rand"
"os" "os"
...@@ -40,14 +41,14 @@ var ( ...@@ -40,14 +41,14 @@ var (
) )
type Paracross struct { type Paracross struct {
eventC chan *pb.IBTP // 发送给sidecar eventC chan *pb.IBTP // 发送给sidecar
chainID int32 chainID int32
appChainID string fromID string
toChainID string toID string
ticker *time.Ticker ticker *time.Ticker
done chan bool done chan bool
height *atomic.Int64 // 已经解析的高度。1、初始化时设置; 2、服务每次重启后设置 height *atomic.Int64 // 已经解析的高度。1、初始化时设置; 2、服务每次重启后设置
db *util.KVDBList // 记录已完成的hashID、高度等信息。 db *util.KVDBList // 记录已完成的hashID、高度等信息。
// 模拟平行链节点 // 模拟平行链节点
paraHeight *atomic.Uint64 // paraHeightHash = Hash(paraHeight) paraHeight *atomic.Uint64 // paraHeightHash = Hash(paraHeight)
...@@ -63,6 +64,8 @@ type Paracross struct { ...@@ -63,6 +64,8 @@ type Paracross struct {
// 分类块中的交易为:已完成、未完成的交易。 // 分类块中的交易为:已完成、未完成的交易。
notify chan int64 // 高度完成提醒 notify chan int64 // 高度完成提醒
heightDiff int64 // 高度差 heightDiff int64 // 高度差
isTest bool
} }
func (p *Paracross) incParaHeight() uint64 { func (p *Paracross) incParaHeight() uint64 {
...@@ -109,7 +112,7 @@ func (p *Paracross) Type() string { ...@@ -109,7 +112,7 @@ func (p *Paracross) Type() string {
} }
func (p *Paracross) ID() string { func (p *Paracross) ID() string {
return p.appChainID return p.fromID
} }
func (p *Paracross) Initialize(configPath string, ID string, extra []byte) error { func (p *Paracross) Initialize(configPath string, ID string, extra []byte) error {
...@@ -124,12 +127,13 @@ func (p *Paracross) Initialize(configPath string, ID string, extra []byte) error ...@@ -124,12 +127,13 @@ func (p *Paracross) Initialize(configPath string, ID string, extra []byte) error
logger.Info("print chain33Config", "chain33Config", util.Sprint(chain33Config)) logger.Info("print chain33Config", "chain33Config", util.Sprint(chain33Config))
logger.Info("print privateKey", "privateKey", chain33Config.Chain33.PrivateKey) logger.Info("print privateKey", "privateKey", chain33Config.Chain33.PrivateKey)
p.privateKey = util33.HexToPrivkey(chain33Config.Chain33.PrivateKey) p.privateKey = util33.HexToPrivkey(chain33Config.Chain33.PrivateKey)
p.appChainID = chain33Config.Chain33.ChainID p.chainID = chain33Config.Chain33.ChainID
p.chainID = cast.ToInt32(p.appChainID) p.toID = chain33Config.Router.ToChain
p.toChainID = chain33Config.Router.ToChain p.fromID = chain33Config.Router.FromChain
p.title = chain33Config.Chain33.Title p.title = chain33Config.Chain33.Title
p.MinTxFeeRate = chain33Config.Chain33.Fee p.MinTxFeeRate = chain33Config.Chain33.Fee
logger.SetLevel(hclog.LevelFromString(chain33Config.Log.Level)) p.isTest = chain33Config.Chain33.IsTest
// logger.SetLevel(hclog.LevelFromString(chain33Config.Log.Level))
config33 = fmt.Sprintf(config33, p.title, chain33Config.Chain33.Addr) config33 = fmt.Sprintf(config33, p.title, chain33Config.Chain33.Addr)
logger.Info(config33) logger.Info(config33)
...@@ -251,7 +255,7 @@ func (p *Paracross) pollAppchain() chan *types.Event { ...@@ -251,7 +255,7 @@ func (p *Paracross) pollAppchain() chan *types.Event {
TxID: string(tx.Hash()), TxID: string(tx.Hash()),
BlockNumber: uint64(height1), BlockNumber: uint64(height1),
Contract: &types.Contract{ Contract: &types.Contract{
ChainID: p.appChainID, ChainID: cast.ToString(p.chainID),
ExecName: ID, ExecName: ID,
Address: address.ExecAddress(ID), // TODO 合约地址 Address: address.ExecAddress(ID), // TODO 合约地址
CallMethod: "AssetsWithdraw", CallMethod: "AssetsWithdraw",
...@@ -275,7 +279,7 @@ func (p *Paracross) pollAppchain() chan *types.Event { ...@@ -275,7 +279,7 @@ func (p *Paracross) pollAppchain() chan *types.Event {
TxID: util.ToHex(tx.Hash()), TxID: util.ToHex(tx.Hash()),
BlockNumber: uint64(height1), BlockNumber: uint64(height1),
Contract: &types.Contract{ Contract: &types.Contract{
ChainID: p.appChainID, ChainID: cast.ToString(p.chainID),
ExecName: ID, ExecName: ID,
Address: address.ExecAddress(ID), // TODO 合约地址 Address: address.ExecAddress(ID), // TODO 合约地址
CallMethod: "AssetTransfer", CallMethod: "AssetTransfer",
...@@ -309,7 +313,7 @@ func (p *Paracross) pollAppchain() chan *types.Event { ...@@ -309,7 +313,7 @@ func (p *Paracross) pollAppchain() chan *types.Event {
TxID: util.ToHex(tx.Hash()), TxID: util.ToHex(tx.Hash()),
BlockNumber: uint64(height1), BlockNumber: uint64(height1),
Contract: &types.Contract{ Contract: &types.Contract{
ChainID: p.appChainID, ChainID: cast.ToString(p.chainID),
ExecName: ID, ExecName: ID,
Address: address.ExecAddress(ID), // TODO 合约地址 Address: address.ExecAddress(ID), // TODO 合约地址
CallMethod: "AssetsWithdraw", CallMethod: "AssetsWithdraw",
...@@ -508,8 +512,8 @@ func (p *Paracross) loop() { ...@@ -508,8 +512,8 @@ func (p *Paracross) loop() {
data, _ := payload.Marshal() data, _ := payload.Marshal()
tmp := time.Now().UnixNano() tmp := time.Now().UnixNano()
ibtp := &pb.IBTP{ ibtp := &pb.IBTP{
From: p.appChainID, From: p.fromID,
To: p.toChainID, To: p.toID,
Nonce: uint64(event.Payload.Nonce), // TODO 唯一标识。随机nonce Nonce: uint64(event.Payload.Nonce), // TODO 唯一标识。随机nonce
Type: pb.IBTP_INTERCHAIN, Type: pb.IBTP_INTERCHAIN,
Timestamp: tmp, Timestamp: tmp,
...@@ -523,7 +527,6 @@ func (p *Paracross) loop() { ...@@ -523,7 +527,6 @@ func (p *Paracross) loop() {
func (p *Paracross) SubmitIBTP(ibtp *pb.IBTP) (*pb.SubmitIBTPResponse, error) { func (p *Paracross) SubmitIBTP(ibtp *pb.IBTP) (*pb.SubmitIBTPResponse, error) {
logger.Debug("SubmitIBTP recv ibtp", "ibtp", util.FormatJSON(ibtp)) logger.Debug("SubmitIBTP recv ibtp", "ibtp", util.FormatJSON(ibtp))
ibtpRes := &pb.SubmitIBTPResponse{} ibtpRes := &pb.SubmitIBTPResponse{}
ibtpRes = nil
switch ibtp.Type { switch ibtp.Type {
case pb.IBTP_INTERCHAIN: case pb.IBTP_INTERCHAIN:
// 上链之前,先查询,是否存在 // 上链之前,先查询,是否存在
...@@ -573,26 +576,44 @@ func (p *Paracross) SubmitIBTP(ibtp *pb.IBTP) (*pb.SubmitIBTPResponse, error) { ...@@ -573,26 +576,44 @@ func (p *Paracross) SubmitIBTP(ibtp *pb.IBTP) (*pb.SubmitIBTPResponse, error) {
tx.Sign(types33.SECP256K1, p.privateKey) tx.Sign(types33.SECP256K1, p.privateKey)
ret, err := p.grpcClient.SendTransaction(p.ctx, tx) ret, err := p.grpcClient.SendTransaction(p.ctx, tx)
if err != nil { if err != nil {
logger.Error("SendTransaction ", "error", err)
return nil, err return nil, err
} }
ibtpRes.Result = ibtp
if ret.IsOk { if ret.IsOk {
p.saveBurn(event) p.saveBurn(event)
logger.Info("SendTransaction tx ok", "hash", string(ret.Msg)) logger.Info("SendTransaction tx ok", "hash", string(ret.Msg))
ibtpRes.Status = true
} else { } else {
ibtpRes.Status = false
logger.Error("SendTransaction error", "msg", string(ret.Msg)) logger.Error("SendTransaction error", "msg", string(ret.Msg))
} }
return ibtpRes, nil
} }
default: default:
logger.Error("ibtp.Type error: ", "type", ibtp.Type) logger.Error("ibtp.Type error: ", "type", ibtp.Type)
} }
return ibtpRes, nil // ibtpRes.Status = false
// ibtpRes.Result = ibtp
// return ibtpRes, nil
return nil, errors.New("ibtp.Type error")
} }
// 模拟status // 模拟status
func (p *Paracross) getNodeStatus(curTxHashs [][]byte, blockDetail *types33.BlockDetail) (*paracorssTypes.ParacrossNodeStatus, error) { func (p *Paracross) getNodeStatus(curTxHashs [][]byte, blockDetail *types33.BlockDetail) (*paracorssTypes.ParacrossNodeStatus, error) {
txs := blockDetail.Block.Txs[1:] var (
receipts := blockDetail.Receipts[1:] txs []*types33.Transaction
receipts []*types33.ReceiptData
)
if p.isTest {
txs = blockDetail.Block.Txs
receipts = blockDetail.Receipts
} else {
txs = blockDetail.Block.Txs[1:]
receipts = blockDetail.Receipts[1:]
}
isCommitTx := make(map[string]bool) isCommitTx := make(map[string]bool)
// 包含我的平行链交易, // 包含我的平行链交易,
var paraTxHashs [][]byte var paraTxHashs [][]byte
......
...@@ -4,13 +4,14 @@ Title = "user.p.test." ...@@ -4,13 +4,14 @@ Title = "user.p.test."
addr = "192.168.0.15:8802" addr = "192.168.0.15:8802"
#用于跨链交易签名的私钥 #用于跨链交易签名的私钥
private_key = "0xb9135831281bb9a09e2610680258270faecbeb4a73e0cec261ef0970c32cca5a" private_key = "0xb9135831281bb9a09e2610680258270faecbeb4a73e0cec261ef0970c32cca5a"
chain_id = "3" chain_id = 0
start_height = 10 start_height = 10
height_diff = 0 height_diff = 0
fee = 100000 fee = 100000
is_test = true
[log] [log]
level = "debug" level = "trace"
[db] [db]
name = "paracross" name = "paracross"
...@@ -19,4 +20,5 @@ db_path = "./paracross" ...@@ -19,4 +20,5 @@ db_path = "./paracross"
db_cache = 100 db_cache = 100
[router] [router]
to_chain = "1" from_chain = "paracross"
to_chain = "evmxgo"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment