Commit 156d4750 authored by heyubin's avatar heyubin

add by hyb for chainid

parent 14c457cf
......@@ -124,7 +124,7 @@ func DposPerf() {
fmt.Println("=======start NormPut!=======")
for i := 0; i < loopCount; i++ {
NormPut()
NormPut(cfg)
time.Sleep(time.Second)
}
......@@ -462,7 +462,7 @@ func getprivkey(key string) crypto.PrivKey {
return priv
}
func prepareTxList() *types.Transaction {
func prepareTxList(cfg *types.Chain33Config) *types.Transaction {
var key string
var value string
var i int
......@@ -475,6 +475,7 @@ func prepareTxList() *types.Transaction {
tx := &types.Transaction{Execer: []byte("norm"), Payload: types.Encode(action), Fee: fee}
tx.To = address.ExecAddress("norm")
tx.Nonce = random.Int63()
tx.ChainID = cfg.GetChainID()
tx.Sign(types.SECP256K1, getprivkey("CC38546E9E659D15E6B4893F0AB32A06D103931A8230B0BDE71459D2B27D6944"))
return tx
}
......@@ -489,8 +490,8 @@ func clearTestData() {
fmt.Println("test data clear successfully!")
}
func NormPut() {
tx := prepareTxList()
func NormPut(cfg *types.Chain33Config) {
tx := prepareTxList(cfg)
reply, err := c.SendTransaction(context.Background(), tx)
if err != nil {
......
......@@ -97,7 +97,7 @@ func sendReplyList(q queue.Queue) {
for msg := range client.Recv() {
if msg.Ty == types.EventTxList {
count++
createReplyList("test" + strconv.Itoa(count))
createReplyList(client.GetConfig(), "test"+strconv.Itoa(count))
msg.Reply(client.NewMessage("consensus", types.EventReplyTxList,
&types.ReplyTxList{Txs: transactions}))
if count == 5 {
......@@ -124,7 +124,8 @@ func getprivkey(key string) crypto.PrivKey {
return priv
}
func createReplyList(account string) {
func createReplyList(cfg *types.Chain33Config, account string) {
var result []*types.Transaction
for j := 0; j < txSize; j++ {
//tx := &types.Transaction{}
......@@ -134,6 +135,7 @@ func createReplyList(account string) {
tx.To = "14qViLJfdGaP4EeHnDyJbEGQysnCpwn1gZ"
tx.Nonce = random.Int63()
tx.ChainID = cfg.GetChainID()
tx.Sign(types.SECP256K1, getprivkey("CC38546E9E659D15E6B4893F0AB32A06D103931A8230B0BDE71459D2B27D6944"))
result = append(result, tx)
......
......@@ -334,6 +334,7 @@ func NormPut(privkey string, key string, value string) {
tx := &types.Transaction{Execer: []byte("norm"), Payload: types.Encode(action), Fee: fee}
tx.To = address.ExecAddress("norm")
tx.Nonce = r.Int63()
tx.ChainID = c.Version().ChainID
tx.Sign(types.SECP256K1, getprivkey(privkey))
reply, err := c.SendTransaction(context.Background(), tx)
......
......@@ -440,6 +440,7 @@ func LoadProposer(source *tmtypes.Validator) (*ttypes.Validator, error) {
// CreateBlockInfoTx make blockInfo to the first transaction of the block and execer is valnode
func CreateBlockInfoTx(pubkey string, state *tmtypes.State, block *tmtypes.TendermintBlock) *types.Transaction {
blockSave := *block
blockSave.Data = nil
blockInfo := &tmtypes.TendermintBlockInfo{
......
......@@ -74,13 +74,13 @@ func TendermintPerf(t *testing.T) {
time.Sleep(2 * time.Second)
ConfigManager()
for i := 0; i < loopCount; i++ {
NormPut()
NormPut(q.GetConfig().GetChainID())
time.Sleep(time.Second)
}
CheckState(t, cs.(*Client))
AddNode()
for i := 0; i < loopCount*3; i++ {
NormPut()
NormPut(q.GetConfig().GetChainID())
time.Sleep(time.Second)
}
time.Sleep(2 * time.Second)
......@@ -148,7 +148,7 @@ func generateValue(i, valI int) string {
return string(value)
}
func prepareTxList() *types.Transaction {
func prepareTxList(chainid int32) *types.Transaction {
var key string
var value string
var i int
......@@ -161,6 +161,7 @@ func prepareTxList() *types.Transaction {
tx := &types.Transaction{Execer: []byte("norm"), Payload: types.Encode(action), Fee: fee}
tx.To = address.ExecAddress("norm")
tx.Nonce = r.Int63()
tx.ChainID = chainid
tx.Sign(types.SECP256K1, getprivkey("CC38546E9E659D15E6B4893F0AB32A06D103931A8230B0BDE71459D2B27D6944"))
return tx
}
......@@ -173,8 +174,8 @@ func clearTestData() {
fmt.Println("test data clear successfully!")
}
func NormPut() {
tx := prepareTxList()
func NormPut(chainid int32) {
tx := prepareTxList(chainid)
reply, err := c.SendTransaction(context.Background(), tx)
if err != nil {
......@@ -199,6 +200,7 @@ func AddNode() {
tx := &types.Transaction{Execer: []byte("valnode"), Payload: types.Encode(action), Fee: fee}
tx.To = address.ExecAddress("valnode")
tx.Nonce = r.Int63()
tx.ChainID = c.Version().ChainID
tx.Sign(types.SECP256K1, getprivkey("CC38546E9E659D15E6B4893F0AB32A06D103931A8230B0BDE71459D2B27D6944"))
reply, err := c.SendTransaction(context.Background(), tx)
......@@ -221,6 +223,7 @@ func ConfigManager() {
tx := &types.Transaction{Execer: []byte("manage"), Payload: types.Encode(modify), Fee: fee}
tx.To = address.ExecAddress("manage")
tx.Nonce = r.Int63()
tx.ChainID = c.Version().ChainID
tx.Sign(types.SECP256K1, getprivkey("CC38546E9E659D15E6B4893F0AB32A06D103931A8230B0BDE71459D2B27D6944"))
reply, err := c.SendTransaction(context.Background(), tx)
......
......@@ -238,7 +238,7 @@ func DposPerf() {
}
time.Sleep(2 * time.Second)
for i := 0; i < loopCount; i++ {
NormPut()
NormPut(q.GetConfig())
time.Sleep(time.Second)
}
time.Sleep(2 * time.Second)
......@@ -336,8 +336,8 @@ func getprivkey(key string) crypto.PrivKey {
return priv
}
func NormPut() {
tx := prepareTxList()
func NormPut(cfg *types.Chain33Config) {
tx := prepareTxList(cfg)
reply, err := c.SendTransaction(context.Background(), tx)
if err != nil {
......@@ -350,7 +350,8 @@ func NormPut() {
}
}
func prepareTxList() *types.Transaction {
func prepareTxList(cfg *types.Chain33Config) *types.Transaction {
var key string
var value string
var i int
......@@ -363,6 +364,7 @@ func prepareTxList() *types.Transaction {
tx := &types.Transaction{Execer: []byte("norm"), Payload: types.Encode(action), Fee: fee}
tx.To = address.ExecAddress("norm")
tx.Nonce = random.Int63()
tx.ChainID = cfg.GetChainID()
tx.Sign(types.SECP256K1, getprivkey(genesisKey))
return tx
}
......
......@@ -43,6 +43,7 @@ func createPingTx(cfg *types.Chain33Config, op string, parm *Tx) (*types.Transac
Payload: types.Encode(action),
Nonce: rand.New(rand.NewSource(time.Now().UnixNano())).Int63(),
To: address.ExecAddress(cfg.ExecName(EchoX)),
ChainID: cfg.GetChainID(),
}
return tx, nil
}
......
......@@ -296,7 +296,7 @@ func createEvmTx(cfg *types.Chain33Config, action proto.Message, execer, caller,
random := rand.New(rand.NewSource(time.Now().UnixNano()))
tx.Nonce = random.Int63()
tx.ChainID = cfg.GetChainID()
txHex := types.Encode(tx)
rawTx := hex.EncodeToString(txHex)
......@@ -348,7 +348,7 @@ func createEvmTransferTx(cfg *types.Chain33Config, cmd *cobra.Command, caller, e
random := rand.New(rand.NewSource(time.Now().UnixNano()))
tx.Nonce = random.Int63()
tx.ChainID = cfg.GetChainID()
txHex := types.Encode(tx)
rawTx := hex.EncodeToString(txHex)
......
......@@ -40,7 +40,7 @@ func (c *channelClient) Create(ctx context.Context, in evmtypes.EvmContractCreat
random := rand.New(rand.NewSource(time.Now().UnixNano()))
tx.Nonce = random.Int63()
tx.ChainID = cfg.GetChainID()
txHex := types.Encode(tx)
return &types.UnsignTx{Data: txHex}, nil
......@@ -69,7 +69,7 @@ func (c *channelClient) Call(ctx context.Context, in evmtypes.EvmContractCallReq
random := rand.New(rand.NewSource(time.Now().UnixNano()))
tx.Nonce = random.Int63()
tx.ChainID = cfg.GetChainID()
txHex := types.Encode(tx)
return &types.UnsignTx{Data: txHex}, nil
......@@ -103,7 +103,7 @@ func (c *channelClient) Transfer(ctx context.Context, in evmtypes.EvmContractTra
random := rand.New(rand.NewSource(time.Now().UnixNano()))
tx.Nonce = random.Int63()
tx.ChainID = cfg.GetChainID()
txHex := types.Encode(tx)
return &types.UnsignTx{Data: txHex}, nil
......
......@@ -361,7 +361,7 @@ func testGuessImp(t *testing.T) {
fmt.Println("=======start NormPut!=======")
for i := 0; i < loopCount; i++ {
NormPut()
NormPut(cfg)
time.Sleep(time.Second)
}
......@@ -503,7 +503,7 @@ func getprivkey(key string) crypto.PrivKey {
return priv
}
func prepareTxList() *types.Transaction {
func prepareTxList(cfg *types.Chain33Config) *types.Transaction {
var key string
var value string
var i int
......@@ -516,12 +516,13 @@ func prepareTxList() *types.Transaction {
tx := &types.Transaction{Execer: []byte("norm"), Payload: types.Encode(action), Fee: fee}
tx.To = address.ExecAddress("norm")
tx.Nonce = random.Int63()
tx.ChainID = cfg.GetChainID()
tx.Sign(types.SECP256K1, getprivkey("CC38546E9E659D15E6B4893F0AB32A06D103931A8230B0BDE71459D2B27D6944"))
return tx
}
func NormPut() {
tx := prepareTxList()
func NormPut(cfg *types.Chain33Config) {
tx := prepareTxList(cfg)
reply, err := c.SendTransaction(context.Background(), tx)
if err != nil {
......
......@@ -363,7 +363,7 @@ func testGuessImp(t *testing.T) {
fmt.Println("=======start NormPut!=======")
for i := 0; i < loopCount; i++ {
NormPut()
NormPut(cfg)
time.Sleep(time.Second)
}
......@@ -721,7 +721,7 @@ func getprivkey(key string) crypto.PrivKey {
return priv
}
func prepareTxList() *types.Transaction {
func prepareTxList(cfg *types.Chain33Config) *types.Transaction {
var key string
var value string
var i int
......@@ -734,12 +734,13 @@ func prepareTxList() *types.Transaction {
tx := &types.Transaction{Execer: []byte("norm"), Payload: types.Encode(action), Fee: fee}
tx.To = address.ExecAddress("norm")
tx.Nonce = random.Int63()
tx.ChainID = cfg.GetChainID()
tx.Sign(types.SECP256K1, getprivkey("CC38546E9E659D15E6B4893F0AB32A06D103931A8230B0BDE71459D2B27D6944"))
return tx
}
func NormPut() {
tx := prepareTxList()
func NormPut(cfg *types.Chain33Config) {
tx := prepareTxList(cfg)
reply, err := c.SendTransaction(context.Background(), tx)
if err != nil {
......
......@@ -127,6 +127,7 @@ func constructHashlockInstance() drivers.Driver {
func ConstructLockTx() *types.Transaction {
var lockAmount int64 = 90
var locktime int64 = 70
var fee int64 = 1e6
......
......@@ -260,6 +260,7 @@ func CreateRawMinerTx(cfg *types.Chain33Config, value *ParacrossMinerAction) (*t
Payload: types.Encode(action),
Nonce: 0, //for consensus purpose, block hash need same, different auth node need keep totally same vote tx
To: address.ExecAddress(cfg.ExecName(ParaX)),
ChainID: cfg.GetChainID(),
}
err := tx.SetRealFee(cfg.GetMinTxFeeRate())
if err != nil {
......
......@@ -537,6 +537,7 @@ func (policy *privacyPolicy) createPublic2PrivacyTx(req *privacytypes.ReqCreateP
Payload: types.Encode(action),
Nonce: policy.getWalletOperate().Nonce(),
To: address.ExecAddress(cfg.ExecName(privacytypes.PrivacyX)),
ChainID: cfg.GetChainID(),
}
tx.SetExpire(cfg, time.Duration(req.Expire))
tx.Signature = &types.Signature{
......@@ -621,6 +622,7 @@ func (policy *privacyPolicy) createPrivacy2PrivacyTx(req *privacytypes.ReqCreate
Fee: privacytypes.PrivacyTxFee,
Nonce: policy.getWalletOperate().Nonce(),
To: address.ExecAddress(cfg.ExecName(privacytypes.PrivacyX)),
ChainID: cfg.GetChainID(),
}
tx.SetExpire(cfg, time.Duration(req.Expire))
if !isMainetCoins {
......@@ -711,6 +713,7 @@ func (policy *privacyPolicy) createPrivacy2PublicTx(req *privacytypes.ReqCreateP
Fee: privacytypes.PrivacyTxFee,
Nonce: policy.getWalletOperate().Nonce(),
To: address.ExecAddress(cfg.ExecName(privacytypes.PrivacyX)),
ChainID: cfg.GetChainID(),
}
tx.SetExpire(cfg, time.Duration(req.Expire))
if !isMainetCoins {
......
......@@ -217,6 +217,7 @@ func (mock *PrivacyMock) createPublic2PrivacyTx(req *ty.ReqCreatePrivacyTx) *typ
Payload: types.Encode(action),
Nonce: mock.walletOp.Nonce(),
To: address.ExecAddress(ty.PrivacyX),
ChainID: cfg.GetChainID(),
}
cfg := mock.walletOp.GetAPI().GetConfig()
txSize := types.Size(tx) + ty.SignatureSize
......
......@@ -323,6 +323,7 @@ func (r *Relayd) transaction(payload []byte) *types.Transaction {
Payload: payload,
Nonce: rand.Int63(),
To: address.ExecAddress(ty.RelayX),
ChainID: r.config.Chain33Cfg..GetChainID(),
}
minFee := types.DefaultMinFee
......
......@@ -139,6 +139,7 @@ func (s *suiteRelay) TestExec_1() {
tx.Execer = []byte(ty.RelayX)
tx.To = address.ExecAddress(ty.RelayX)
tx.Nonce = 1 //for different order id
tx.ChainID = chainTestCfg.GetChainID()
tx.Payload = types.Encode(sell)
tx.Sign(types.SECP256K1, privFrom)
......@@ -489,6 +490,8 @@ func (s *suiteBtcHeader) TestSaveBtcHead_1() {
tx.Execer = []byte(ty.RelayX)
tx.To = address.ExecAddress(ty.RelayX)
tx.Nonce = 2 //for different order id
tx.ChainID = chainTestCfg.GetChainID()
tx.Payload = types.Encode(sell)
tx.Sign(types.SECP256K1, privFrom)
......
......@@ -170,6 +170,7 @@ func TestPrecreate(t *testing.T) {
Fee: feeForToken,
Nonce: r.Int63(),
To: address.ExecAddress(execName),
ChainID: mainClient.Version().GetChainID(),
}
tx.Sign(types.SECP256K1, privkey)
......@@ -211,6 +212,7 @@ func TestFinish(t *testing.T) {
Fee: feeForToken,
Nonce: r.Int63(),
To: address.ExecAddress(execName),
ChainID: mainClient.Version().GetChainID(),
}
tx.Sign(types.SECP256K1, privkey)
......@@ -246,6 +248,7 @@ func TestTransferToken(t *testing.T) {
tx := &types.Transaction{Execer: []byte(execName), Payload: types.Encode(transfer), Fee: fee, To: addrexec}
tx.Nonce = r.Int63()
tx.ChainID = mainClient.Version().GetChainID()
tx.Sign(types.SECP256K1, privkey)
reply, err := mainClient.SendTransaction(context.Background(), tx)
......@@ -326,6 +329,8 @@ func TestTokenMint(t *testing.T) {
tx := &types.Transaction{Execer: []byte(execName), Payload: types.Encode(transfer), Fee: fee, To: addrexec}
tx.Nonce = r.Int63()
tx.ChainID = mainClient.Version().GetChainID()
tx.Sign(types.SECP256K1, privkey)
reply, err := mainClient.SendTransaction(context.Background(), tx)
......
......@@ -147,6 +147,7 @@ func CreateUnfreezeCreateTx(cfg *types.Chain33Config, title string, parm *Unfree
Payload: types.Encode(create),
Nonce: rand.New(rand.NewSource(time.Now().UnixNano())).Int63(),
To: address.ExecAddress(getRealExecName(cfg, cfg.GetParaName())),
ChainID: cfg.GetChainID(),
}
tx.SetRealFee(cfg.GetMinTxFeeRate())
return tx, nil
......@@ -176,6 +177,7 @@ func CreateUnfreezeWithdrawTx(cfg *types.Chain33Config, title string, parm *Unfr
Payload: types.Encode(withdraw),
Nonce: rand.New(rand.NewSource(time.Now().UnixNano())).Int63(),
To: address.ExecAddress(getRealExecName(cfg, cfg.GetParaName())),
ChainID: cfg.GetChainID(),
}
tx.SetRealFee(cfg.GetMinTxFeeRate())
return tx, nil
......@@ -205,6 +207,7 @@ func CreateUnfreezeTerminateTx(cfg *types.Chain33Config, title string, parm *Unf
Payload: types.Encode(terminate),
Nonce: rand.New(rand.NewSource(time.Now().UnixNano())).Int63(),
To: address.ExecAddress(getRealExecName(cfg, cfg.GetParaName())),
ChainID: cfg.GetChainID(),
}
tx.SetRealFee(cfg.GetMinTxFeeRate())
return tx, nil
......
......@@ -75,6 +75,7 @@ func (x *suiteX2Ethereum) SetupSuite() {
tx.Execer = []byte(types2.X2ethereumX)
tx.To = address.ExecAddress(types2.X2ethereumX)
tx.Nonce = 1
tx.ChainID = chainTestCfg.GetChainID()
tx.Sign(types.SECP256K1, privFrom)
x.action = newAction(x2eth, tx, 0)
......
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