Skip to content

Dedicated log marker for invalid txs removed from the txpool#6826

Merged
fab-10 merged 2 commits intobesu-eth:mainfrom
fab-10:optionally-log-tx-rlp-when-discarding-from-txpool
Mar 29, 2024
Merged

Dedicated log marker for invalid txs removed from the txpool#6826
fab-10 merged 2 commits intobesu-eth:mainfrom
fab-10:optionally-log-tx-rlp-when-discarding-from-txpool

Conversation

@fab-10
Copy link
Copy Markdown
Contributor

@fab-10 fab-10 commented Mar 27, 2024

PR description

Transactions that during block creation are found to be invalid are removed from the pool, and could be difficult to retrieve the content of the tx, so if needed for debug, with this PR is possible to enable the log the RLP of the invalid tx, along with some other info, these log lines have the marker INVALID_TX_REMOVED and the following fields, that can be used to format the log line as required:

  • txhash hash of the tx
  • txlog human readable log of the tx
  • reason why the tx was invalid
  • txrlp the RLP encoding of the tx

Log4j2 example configuration to enable the invalid tx log:

<?xml version="1.0" encoding="UTF-8"?>
<Configuration monitorInterval="30" status="INFO">
  <Properties>
    <Property name="root.log.level">INFO</Property>
  </Properties>
  <Appenders>
    <Console name="Console">
      <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSSZZZ} | %t | %-5level | %c{1} | %msg%n"/>
    </Console>
    <Routing name="Router">
      <Routes pattern="$${event:Marker}">
        <Route key="INVALID_TX_REMOVED">
          <Console name="ConsoleITR" target="SYSTEM_OUT">
            <PatternLayout pattern="Invalid tx removed:%X{txlog}, reason:%X{reason}; RLP={%X{txrlp}}}%n"/>
          </Console>
        </Route>
        <Route ref="Console"/>
      </Routes>
    </Routing>
  </Appenders>
  <Loggers>
        <Logger additivity="false" name="org.hyperledger.besu.ethereum.eth.transactions">
            <AppenderRef ref="Router"/>
        </Logger>
    <Root level="${sys:root.log.level}">
      <AppenderRef ref="Console"/>
    </Root>
  </Loggers>
</Configuration>

Fixed Issue(s)

Thanks for sending a pull request! Have you done the following?

  • Checked out our contribution guidelines?
  • Considered documentation and added the doc-change-required label to this PR if updates are required.
  • Considered the changelog and included an update if required.
  • For database changes (e.g. KeyValueSegmentIdentifier) considered compatibility and performed forwards and backwards compatibility tests

Locally, you can run these tests to catch failures early:

  • unit tests: ./gradlew build
  • acceptance tests: ./gradlew acceptanceTest
  • integration tests: ./gradlew integrationTest
  • reference tests: ./gradlew ethereum:referenceTests:referenceTests

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
…xpool

Signed-off-by: Justin Florentine <justin+github@florentine.us>
LOG.atInfo()
.addMarker(INVALID_TX_REMOVED)
.addKeyValue("txhash", pendingTransaction::getHash)
.addKeyValue("txlog", pendingTransaction::toTraceLog)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The size of the tracelog and the raw data gives me concerns about this as a griefing vector. What if we separated those two fields into a debug call and leave hash and reason in at info?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

If your concern is about the size of the logged message, then the way I set up the log with the marker and key-value, is indeed to avoid that this line is logged by default, and you need to explicitly configure log4j to enabled this log, and you can choose which of the keys to log.

LOG.atInfo()
.addMarker(INVALID_TX_REMOVED)
.addKeyValue("txhash", pendingTransaction::getHash)
.addKeyValue("txlog", pendingTransaction::toTraceLog)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same separation advice as above.

Copy link
Copy Markdown
Contributor

@jflo jflo left a comment

Choose a reason for hiding this comment

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

love Log4j use here, we should probably add a section on how to use this to https://besu.hyperledger.org/public-networks/how-to/monitor/logging

@fab-10 fab-10 merged commit 1679525 into besu-eth:main Mar 29, 2024
@fab-10 fab-10 deleted the optionally-log-tx-rlp-when-discarding-from-txpool branch March 29, 2024 14:48
@macfarla macfarla added the doc-change-required Indicates an issue or PR that requires doc to be updated label Apr 9, 2024
amsmota pushed a commit to Citi/besu that referenced this pull request Apr 16, 2024
…h#6826)

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
Signed-off-by: Justin Florentine <justin+github@florentine.us>
Co-authored-by: Justin Florentine <justin+github@florentine.us>
Signed-off-by: amsmota <antonio.mota@citi.com>
amsmota pushed a commit to Citi/besu that referenced this pull request Apr 16, 2024
…h#6826)

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
Signed-off-by: Justin Florentine <justin+github@florentine.us>
Co-authored-by: Justin Florentine <justin+github@florentine.us>
Signed-off-by: amsmota <antonio.mota@citi.com>
@bgravenorst bgravenorst removed the doc-change-required Indicates an issue or PR that requires doc to be updated label Apr 17, 2024
matthew1001 pushed a commit to kaleido-io/besu that referenced this pull request Jun 7, 2024
…h#6826)

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
Signed-off-by: Justin Florentine <justin+github@florentine.us>
Co-authored-by: Justin Florentine <justin+github@florentine.us>
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.

4 participants