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

[BUG] BEEF format transaction leads to panic #786

Open
boecklim opened this issue Feb 21, 2025 · 3 comments
Open

[BUG] BEEF format transaction leads to panic #786

boecklim opened this issue Feb 21, 2025 · 3 comments
Labels
bug Something isn't working

Comments

@boecklim
Copy link
Collaborator

Bug Description

The following BEEF format transaction currently leads to a panic in api service

0100beef01fe845a190002020202f976277c0f32efe67da5d464bf5fbce01d3e65870dd3d3cb87245021f1be1bfe03010100001c2b3fcb5bcb1f9096036aa407ac31464e49749cb8599d24893b1f49355aed33020100000001f976277c0f32efe67da5d464bf5fbce01d3e65870dd3d3cb87245021f1be1bfe000000006a47304402201ce65046e321b3a0456d3be45f9584caa9c8706b2e7e3801bd589dcd9d9ee75402200c74d82afc10f7ddaade618c3aae28adf8eef83a82a01f838fe12bf04dfd7aa841210290fa4beff95c17c19eeacf303c2464a9e438c457acdd01d66a2f05bf7534bc48ffffffff020100000000000000fdbe012103ec770a0ef11815b010153864632dd4cf7d85c5645faa1f038a5f3a0d44a8800cac302369bb9d263511ea661b4d02581c068dc6d56a7a1c13ca06074f2b4aa39529cc67903d9e808445d7cf2e97124a8816983ae493c1bf95309ad45777c76a8d9313a6f6732371c702a23efcf6923be08d4642c45f8c34ccead6988dec7fee6f0257718ceb93bf3f01f71cd2993522ee8a4d9fa5dd75e8f32fa14507acf3c1b41dd7885bb77b6121f8247d47afc102a9d0efcf5973e9a6aa7a40c6d0544d11a6c9581231acffa2b58a1b8ae296c119ab78ff4ef750f4713bf5df5a29ee667ee20f0b701d89c07dec7b43abb09b2902ec73c6e51f084650defc9371a3d8498e76cc5a26b8eebe81aad4f391537797d75bc73a3c6fba73a9914e2e5dff18ae66417840c19e7deabbe30a7a4637f467f9a0a3a39a27d94f44e47456dab634591ec5d20674f70f01475c14912f5b0f55e3cd47ff973a7e49364a317fbe3f7bd0430b5a825516ea603fe02fc21b71cbacbeb6b9463044022056fe48ac928d8e5a39e771d3a2c7f25f0a81b378fe58d81b3a646476f7e4da5b022053a29f83c15c26ba46d423af5f516393cce94f065cf22f92e5e1b1e91bdb8c406d6d6d7568020000000000001976a914112c881f9315c9a16bd49712da9748713dea9dcb88ac00000000000100000002379ed1061fda9dac056023a2028fb734bf0103041ca350b4122ba3dfc9dc6fa60000000049483045022100d3941aa4cc7bceb273bd2e39e9a09414292852bc6554ec4960631d1f96c8570102200c7f3c41cc4bc7b0ff1d3bc9b5f8986a1386456a51bebadd789c34dd29aa9e9b43ffffffffdf6f3a0fd2ad4d6b2dd5c088c985dc0dde2b844b6a668f3d003d012176b15d04000000006b483045022100e95d4813a48d62335824f9e6fad8ee9cd23bd0a1db6fb1749a1628129c95d35c02203b0d4fdbe8376b2b717d74f46042dd41a01815ef4c3ed3a4cd9250cc18922642412103a9aa931dd249669dfa8f1dc7c79c08e66069057f1121376defdb041cdaba6fc9ffffffff016a020000000000001976a914ad79e58854fc750c263b7d0407a912930729f17288ac000000000100

Steps to Reproduce

  1. Send mentioned beef format transaction to testnet ARC instance https://arc-test.taal.com (which is where the panic was discovered)

Expected Behavior

BEEF transaction is parsed and either successfully validated and processed or fails validation and according error message is returned

Actual Behavior

When submitting the BEEF tx, the response seems to be pending and is not responsive.

Stack Traces or Screenshots

{"time":"2025-02-19T13:57:09.339563929Z","level":"-","prefix":"echo","file":"recover.go","line":"119","message":"[PANIC RECOVER] runtime error: index out of range [0] with length 0 goroutine 13872 [running]:\ngithub.com/bitcoin-sv/arc/cmd/arc/services.setAPIEcho.Recover.RecoverWithConfig.func3.1.1()\n\t/go/pkg/mod/github.com/labstack/echo/[email protected]/middleware/recover.go:99 +0x156\npanic({0x25240c0?, 0xc0006ec2a0?})\n\t/usr/local/go/src/runtime/panic.go:785 +0x132\ngo.opentelemetry.io/otel/sdk/trace.(*recordingSpan).End.deferwrap1()\n\t/go/pkg/mod/go.opentelemetry.io/otel/[email protected]/trace/span.go:467 +0x25\ngo.opentelemetry.io/otel/sdk/trace.(*recordingSpan).End(0xc0007c4d20, {0x0, 0x0, 0x0?})\n\t/go/pkg/mod/go.opentelemetry.io/otel/[email protected]/trace/span.go:506 +0xb7b\npanic({0x25240c0?, 0xc0006ec2a0?})\n\t/usr/local/go/src/runtime/panic.go:785 +0x132\ngithub.com/bitcoin-sv/arc/internal/api/handler.ArcDefaultHandler.postTransaction({{0x2ba5a00, 0xc00069ef50}, 0xc0002a01c0, 0xc0006ff1c0, 0x293b850, {0xc0006a45a0, 0x2, 0x2}, {0x2b80610, 0xc000a04720}, ...}, ...)\n\t/app/internal/api/handler/default.go:294 +0x167f\ngithub.com/bitcoin-sv/arc/internal/api/handler.ArcDefaultHandler.POSTTransaction({{0x2ba5a00, 0xc00069ef50}, 0xc0002a01c0, 0xc0006ff1c0, 0x293b850, {0xc0006a45a0, 0x2, 0x2}, {0x2b80610, 0xc000a04720}, ...}, ...)\n\t/app/internal/api/handler/default.go:318 +0x2ab\ngithub.com/bitcoin-sv/arc/pkg/api.(*ServerInterfaceWrapper).POSTTransaction(0xc000a00600, {0x2bd5508, 0xc00067a1e0})\n\t/app/pkg/api/arc.go:2391 +0x12ae\ngithub.com/labstack/echo/v4.(*Echo).add.func1({0x2bd5508, 0xc00067a1e0})\n\t/go/pkg/mod/github.com/labstack/echo/[email protected]/echo.go:581 +0x4b\ngithub.com/oapi-codegen/echo-middleware.OapiRequestValidatorWithOptions.func1.1({0x2bd5508, 0xc00067a1e0})\n\t/go/pkg/mod/github.com/oapi-codegen/[email protected]/oapi_validate.go:105 +0xc2\ngithub.com/labstack/echo-contrib/echoprometheus.MiddlewareConfig.ToMiddleware.func3.1({0x2bd5508, 0xc00067a1e0})\n\t/go/pkg/mod/github.com/labstack/[email protected]/echoprometheus/prometheus.go:246 +0x282\ngithub.com/labstack/echo/v4/middleware.RequestLoggerConfig.ToMiddleware.func1.1({0x2bd5508, 0xc00067a1e0})\n\t/go/pkg/mod/github.com/labstack/echo/[email protected]/middleware/request_logger.go:286 +0x16b\ngo.opentelemetry.io/contrib/instrumentation/github.com/labstack/echo/otelecho.Middleware.func1.1({0x2bd5508, 0xc00067a1e0})\n\t/go/pkg/mod/go.opentelemetry.io/contrib/instrumentation/github.com/labstack/echo/[email protected]/echo.go:80 +0x687\ngithub.com/bitcoin-sv/arc/cmd/arc/services.setAPIEcho.func1.1({0x2bd5508, 0xc00067a1e0})\n\t/app/cmd/arc/services/api.go:206 +0x1ef\ngithub.com/labstack/echo/v4/middleware.CORSWithConfig.func1.1({0x2bd5508, 0xc00067a1e0})\n\t/go/pkg/mod/github.com/labstack/echo/[email protected]/middleware/cors.go:215 +0x482\ngithub.com/bitcoin-sv/arc/cmd/arc/services.setAPIEcho.Recover.RecoverWithConfig.func3.1({0x2bd5508, 0xc00067a1e0})\n\t/go/pkg/mod/github.com/labstack/echo/[email protected]/middleware/recover.go:130 +0x114\ngithub.com/labstack/echo/v4.(*Echo).ServeHTTP(0xc0006e0908, {0x2b8b9c0, 0xc000996000}, 0xc0001a4140)\n\t/go/pkg/mod/github.com/labstack/echo/[email protected]/echo.go:668 +0x323\nnet/http.serverHandler.ServeHTTP({0x2b7fbc0?}, {0x2b8b9c0?, 0xc000996000?}, 0x6?)\n\t/usr/local/go/src/net/http/server.go:3210 +0x8e\nnet/http.(*conn).serve(0xc00077c000, {0x2b9fbe0, 0xc000b23050})\n\t/usr/local/go/src/net/http/server.go:2092 +0x5d0\ncreated by net/http.(*Server).Serve in goroutine 32\n\t/usr/local/go/src/net/http/server.go:3360 +0x485\n\ngoroutine 1 [select, 882 minutes]:\nmain.run()\n\t/app/cmd/arc/main.go:145 +0xf12\nmain.main()\n\t/app/cmd/arc/main.go:23 +0x13\n\ngoroutine 22 [select]:\ngithub.com/go-redis/redis/v8/internal/pool.(*ConnPool).reaper(0xc00067bb80, 0xc000290000?)\n\t/go/pkg/mod/github.com/go-redis/redis/[email protected]/internal/pool/pool.go:485 +0xb7\ncreated by github.com/go-redis/redis/v8/internal/pool.NewConnPool in goroutine 1\n\t/go/pkg/mod/github.com/go-redis/redis/[email protected]/internal/pool/pool.go:111 +0x1ef\n\ngoroutine 23 [IO wait, 882 minutes]:\ninternal/poll.runtime_pollWait(0x7f64504abf28, 0x72)\n\t/usr/local/go/src/runtime/netpoll.go:351 +0x85\ninternal/poll.(*pollDesc).wait(0xc000796180?, 0x10?, 0x0)\n\t/usr/local/go/src/internal/poll/fd_poll_runtime.go:84 +0x27\ninternal/poll.(*pollD\n"}

Environment

  • ARC version: [e.g. 1.3.24]

Additional Information

Provide any additional context or information about the bug.

@boecklim boecklim added the bug Something isn't working label Feb 21, 2025
@sirdeggen
Copy link
Collaborator

The topological order of these transactions is incorrect. You need to sort them.

0100beef // version 1 
01 // one bump
fe845a190002020202f976277c0f32efe67da5d464bf5fbce01d3e65870dd3d3cb87245021f1be1bfe03010100001c2b3fcb5bcb1f9096036aa407ac31464e49749cb8599d24893b1f49355aed33
02 // 2 txs
0100000001f976277c0f32efe67da5d464bf5fbce01d3e65870dd3d3cb87245021f1be1bfe000000006a47304402201ce65046e321b3a0456d3be45f9584caa9c8706b2e7e3801bd589dcd9d9ee75402200c74d82afc10f7ddaade618c3aae28adf8eef83a82a01f838fe12bf04dfd7aa841210290fa4beff95c17c19eeacf303c2464a9e438c457acdd01d66a2f05bf7534bc48ffffffff020100000000000000fdbe012103ec770a0ef11815b010153864632dd4cf7d85c5645faa1f038a5f3a0d44a8800cac302369bb9d263511ea661b4d02581c068dc6d56a7a1c13ca06074f2b4aa39529cc67903d9e808445d7cf2e97124a8816983ae493c1bf95309ad45777c76a8d9313a6f6732371c702a23efcf6923be08d4642c45f8c34ccead6988dec7fee6f0257718ceb93bf3f01f71cd2993522ee8a4d9fa5dd75e8f32fa14507acf3c1b41dd7885bb77b6121f8247d47afc102a9d0efcf5973e9a6aa7a40c6d0544d11a6c9581231acffa2b58a1b8ae296c119ab78ff4ef750f4713bf5df5a29ee667ee20f0b701d89c07dec7b43abb09b2902ec73c6e51f084650defc9371a3d8498e76cc5a26b8eebe81aad4f391537797d75bc73a3c6fba73a9914e2e5dff18ae66417840c19e7deabbe30a7a4637f467f9a0a3a39a27d94f44e47456dab634591ec5d20674f70f01475c14912f5b0f55e3cd47ff973a7e49364a317fbe3f7bd0430b5a825516ea603fe02fc21b71cbacbeb6b9463044022056fe48ac928d8e5a39e771d3a2c7f25f0a81b378fe58d81b3a646476f7e4da5b022053a29f83c15c26ba46d423af5f516393cce94f065cf22f92e5e1b1e91bdb8c406d6d6d7568020000000000001976a914112c881f9315c9a16bd49712da9748713dea9dcb88ac00000000
00 //  no bump
0100000002379ed1061fda9dac056023a2028fb734bf0103041ca350b4122ba3dfc9dc6fa60000000049483045022100d3941aa4cc7bceb273bd2e39e9a09414292852bc6554ec4960631d1f96c8570102200c7f3c41cc4bc7b0ff1d3bc9b5f8986a1386456a51bebadd789c34dd29aa9e9b43ffffffffdf6f3a0fd2ad4d6b2dd5c088c985dc0dde2b844b6a668f3d003d012176b15d04000000006b483045022100e95d4813a48d62335824f9e6fad8ee9cd23bd0a1db6fb1749a1628129c95d35c02203b0d4fdbe8376b2b717d74f46042dd41a01815ef4c3ed3a4cd9250cc18922642412103a9aa931dd249669dfa8f1dc7c79c08e66069057f1121376defdb041cdaba6fc9ffffffff016a020000000000001976a914ad79e58854fc750c263b7d0407a912930729f17288ac00000000
0100 // bump at index 0

@sirdeggen
Copy link
Collaborator

The correct order:

0100beef // version 1 
01 // one bump
fe845a190002020202f976277c0f32efe67da5d464bf5fbce01d3e65870dd3d3cb87245021f1be1bfe03010100001c2b3fcb5bcb1f9096036aa407ac31464e49749cb8599d24893b1f49355aed33
02 // 2 txs
0100000002379ed1061fda9dac056023a2028fb734bf0103041ca350b4122ba3dfc9dc6fa60000000049483045022100d3941aa4cc7bceb273bd2e39e9a09414292852bc6554ec4960631d1f96c8570102200c7f3c41cc4bc7b0ff1d3bc9b5f8986a1386456a51bebadd789c34dd29aa9e9b43ffffffffdf6f3a0fd2ad4d6b2dd5c088c985dc0dde2b844b6a668f3d003d012176b15d04000000006b483045022100e95d4813a48d62335824f9e6fad8ee9cd23bd0a1db6fb1749a1628129c95d35c02203b0d4fdbe8376b2b717d74f46042dd41a01815ef4c3ed3a4cd9250cc18922642412103a9aa931dd249669dfa8f1dc7c79c08e66069057f1121376defdb041cdaba6fc9ffffffff016a020000000000001976a914ad79e58854fc750c263b7d0407a912930729f17288ac00000000
0100 // bump at index 0
0100000001f976277c0f32efe67da5d464bf5fbce01d3e65870dd3d3cb87245021f1be1bfe000000006a47304402201ce65046e321b3a0456d3be45f9584caa9c8706b2e7e3801bd589dcd9d9ee75402200c74d82afc10f7ddaade618c3aae28adf8eef83a82a01f838fe12bf04dfd7aa841210290fa4beff95c17c19eeacf303c2464a9e438c457acdd01d66a2f05bf7534bc48ffffffff020100000000000000fdbe012103ec770a0ef11815b010153864632dd4cf7d85c5645faa1f038a5f3a0d44a8800cac302369bb9d263511ea661b4d02581c068dc6d56a7a1c13ca06074f2b4aa39529cc67903d9e808445d7cf2e97124a8816983ae493c1bf95309ad45777c76a8d9313a6f6732371c702a23efcf6923be08d4642c45f8c34ccead6988dec7fee6f0257718ceb93bf3f01f71cd2993522ee8a4d9fa5dd75e8f32fa14507acf3c1b41dd7885bb77b6121f8247d47afc102a9d0efcf5973e9a6aa7a40c6d0544d11a6c9581231acffa2b58a1b8ae296c119ab78ff4ef750f4713bf5df5a29ee667ee20f0b701d89c07dec7b43abb09b2902ec73c6e51f084650defc9371a3d8498e76cc5a26b8eebe81aad4f391537797d75bc73a3c6fba73a9914e2e5dff18ae66417840c19e7deabbe30a7a4637f467f9a0a3a39a27d94f44e47456dab634591ec5d20674f70f01475c14912f5b0f55e3cd47ff973a7e49364a317fbe3f7bd0430b5a825516ea603fe02fc21b71cbacbeb6b9463044022056fe48ac928d8e5a39e771d3a2c7f25f0a81b378fe58d81b3a646476f7e4da5b022053a29f83c15c26ba46d423af5f516393cce94f065cf22f92e5e1b1e91bdb8c406d6d6d7568020000000000001976a914112c881f9315c9a16bd49712da9748713dea9dcb88ac00000000
00 //  no bump

@sirdeggen
Copy link
Collaborator

  BUMP 0
    block: 1661572
    txids: [
      'fe1bbef121502487cbd3d30d87653e1de0bc5fbf64d4a57de6ef320f7c2776f9'
    ]
  TX 0
    txid: fe1bbef121502487cbd3d30d87653e1de0bc5fbf64d4a57de6ef320f7c2776f9
    bumpIndex: 0
    rawTx length=306
  TX 1
    txid: e11ee1c7c0b272e27005980c9326002444a0f25b8397115e83867f37d71234e7
    rawTx length=648
    inputs: [
      'fe1bbef121502487cbd3d30d87653e1de0bc5fbf64d4a57de6ef320f7c2776f9'
    ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants