Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed issues: RPC DERO.GetTransactions & RPC transfer with integrated addresses; show raw tx when registration fails #85

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

8lecramm
Copy link
Contributor

Under certain conditions, the node throws a panic message when initiating a RPC call with an orphaned transaction.

curl http://pi:10102/json_rpc -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":"0","method":"DERO.GetTransaction","params":{"txs_hashes":["0000007c31430f3ce55f41c2ef91898618ed3ef7c5e82693b67af50d726d235e"]}}'
{
  "jsonrpc": "2.0",
  "id": "0",
  "error": {
    "code": -32098,
    "message": "panic occured. stack trace goroutine 245257 [running]:\nruntime/debug.Stack()\n\t/usr/local/go/src/runtime/debug/stack.go:24 +0x68\ngithub.com/deroproject/derohe/cmd/derod/rpc.GetTransaction.func1()\n\t/home/marcel/go/src/github.com/deroproject/derohe/cmd/derod/rpc/rpc_dero_gettransactions.go:39 +0x38\npanic({0x5add80, 0x4005d69860})\n\t/usr/local/go/src/runtime/panic.go:838 +0x20c\ngithub.com/deroproject/derohe/blockchain.(*Blockchain).Find_Blocks_Height_Range(0x4000076c60, 0x401333ba00?, 0x17)\n\t/home/marcel/go/src/github.com/deroproject/derohe/blockchain/storetopo.go:282 +0x2dc\ngithub.com/deroproject/derohe/blockchain.(*Blockchain).IS_TX_Valid(0x4000076c60, {0x0, 0x0, 0x0, 0x7c, 0x31, 0x43, 0xf, 0x3c, 0xe5, ...})\n\t/home/marcel/go/src/github.com/deroproject/derohe/blockchain/blockchain.go:1355 +0xb0\ngithub.com/deroproject/derohe/cmd/derod/rpc.GetTransaction({0x4005762390?, 0x40043f2560?}, {{0x4006280300?, 0xd?, 0x40077ef638?}, 0xa986c?})\n\t/home/marcel/go/src/github.com/deroproject/derohe/cmd/derod/rpc/rpc_dero_gettransactions.go:98 +0x35c\nreflect.Value.call({0x5469e0?, 0x684b50?, 0x4000044d98?}, {0x5e5c5d, 0x4}, {0x40057624b0, 0x2, 0x110fb0?})\n\t/usr/local/go/src/reflect/value.go:556 +0x5e4\nreflect.Value.Call({0x5469e0?, 0x684b50?, 0x57c8e0?}, {0x40057624b0, 0x2, 0x2})\n\t/usr/local/go/src/reflect/value.go:339 +0x98\ngithub.com/deroproject/derohe/vendor/github.com/creachadair/jrpc2/handler.(*FuncInfo).Wrap.func10({0x739360?, 0x4005762390?}, 0x4000044e18?)\n\t/home/marcel/go/src/github.com/deroproject/derohe/vendor/github.com/creachadair/jrpc2/handler/handler.go:244 +0x130\ngithub.com/deroproject/derohe/vendor/github.com/creachadair/jrpc2/handler.Func.Handle(0x4000149360?, {0x739360?, 0x4005762390?}, 0x1?)\n\t/home/marcel/go/src/github.com/deroproject/derohe/vendor/github.com/creachadair/jrpc2/handler/handler.go:25 +0x3c\ngithub.com/deroproject/derohe/vendor/github.com/creachadair/jrpc2.(*Server).invoke(0x40000702a0, {0x7392b8?, 0x40062802c0?}, {0x735a20, 0x400047fb20}, 0x4006280280)\n\t/home/marcel/go/src/github.com/deroproject/derohe/vendor/github.com/creachadair/jrpc2/server.go:379 +0x100\ngithub.com/deroproject/derohe/vendor/github.com/creachadair/jrpc2.(*Server).dispatch.func1()\n\t/home/marcel/go/src/github.com/deroproject/derohe/vendor/github.com/creachadair/jrpc2/server.go:230 +0x16c\ngithub.com/deroproject/derohe/vendor/github.com/creachadair/jrpc2.(*Server).serve.func1()\n\t/home/marcel/go/src/github.com/deroproject/derohe/vendor/github.com/creachadair/jrpc2/server.go:152 +0x5c\ncreated by github.com/deroproject/derohe/vendor/github.com/creachadair/jrpc2.(*Server).serve\n\t/home/marcel/go/src/github.com/deroproject/derohe/vendor/github.com/creachadair/jrpc2/server.go:150 +0x28\n"
  }
}

Copy link

@deroholic deroholic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and confirmed. This fixes the problem.

fixed an issue when trying to send a TX with more than 1 integrated address
@8lecramm
Copy link
Contributor Author

8lecramm commented Sep 18, 2022

The second commit fixes an issue when trying to create a TX with more than 1 integrated address.
See issue #92
This function will return in any case.

if addr.IsIntegratedAddress() && len(transfers[t].Payload_RPC) == 0 {
	for _, arg := range addr.Arguments {
		if arg.Name == rpc.RPC_DESTINATION_PORT && addr.Arguments.Has(rpc.RPC_DESTINATION_PORT, rpc.DataUint64) {
			transfers[t].Payload_RPC = append(transfers[t].Payload_RPC, rpc.Argument{Name: rpc.RPC_DESTINATION_PORT, DataType: rpc.DataUint64, Value: addr.Arguments.Value(rpc.RPC_DESTINATION_PORT, rpc.DataUint64).(uint64)})
			continue
		} else {
			fmt.Printf("integrtated address, but don't know how to process\n")
			err = fmt.Errorf("integrated address used, but don't know how to process %+v", addr.Arguments)
		}
	}
	return   <----   at wrong place
}

The calling function tries to create the TX twice before throwing an error.
The first TX with an integrated address goes through, but crashes at the second one.

@8lecramm 8lecramm changed the title fix: avoid panic when calling DERO.GetTransactions fixed issues: RPC DERO.GetTransactions & RPC transfer with integrated addresses Sep 18, 2022
@8lecramm
Copy link
Contributor Author

8lecramm commented Oct 2, 2022

The 3rd commit shows the raw TX data when registration fails.
The data can be used to register the wallet via DERO.SendRawTransaction RPC call.
Screenshot_20221002_022546

@8lecramm 8lecramm changed the title fixed issues: RPC DERO.GetTransactions & RPC transfer with integrated addresses fixed issues: RPC DERO.GetTransactions & RPC transfer with integrated addresses; show raw tx when registration fails Oct 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants