Files
linea-monorepo/transaction-exclusion-api/README.md
jonesho fad0db4fc6 3822 rejected transaction api service (#101)
* feat: first commit for transaction exclusion api service

* feat: removed debug logs and improved params error handling

* fix: jacocoRootReport error

* feat: improved json request param parsings

* feat: added docker container and github workflow pipeline for transaction exclusion api

* feat: added rejection stage in response and use txHash and rejectReason as primary key of tables

* feat: separate database into read and write config and each with dedicated connection

* fix: e2e testing error

* feat: removed redundant commands in Makefile

* feat: updated transaction exclusion api default image tag in compose file

* feat: added metric and change param name from reasonMessage to reason

* feat: added integration and unit tests and use reasonMessage for both request and response

* fix: transaction-exclusion-api unit test

* feat: added e2e tests and remove reasonMessage from get response and redundant codes

* feat: updated README.md and removed abi file

* feat: updated image version of transaction exclusion api service in compose file

* feat: updated README and added more test cases

* feat: updated transaction exclusion api default image tag in compose file

* feat: decoupled transaction exclusion api from coordinator package

* feat: removed unnecessary dependencies to prover client

* feat: moved persistence:db package to jvm-libs

* feat: removed migration file dir location config from transaction exclusion api

* fix: db migration location for fee history integration test

* changed db column name timestamp to reject_timestamp and add dto for ModuleOverflow to remove all jackson dependencies in core module

* feat: rejected transaction dao and config refactoring

* feat: removed repository service and using persistence retryer

* feat: updated transaction exclusion api default image tag in compose file

* feat: updated log and increase retry backoff delay to avoid repetitive error logs

* feat: added support of list request on save method and added dto for RejectedTransaction

* feat: revised gradle.build dependencies

* feat: switch from shadow jar to zipped jar

* feat: updated transaction exclusion api default image tag in compose file

* feat: updated sql and tables and changes for PR comments

* feat: improved log message for duplicate key error

* feat: updated transaction exclusion api default image tag in compose file

* feat: avoid redundant logs on periodic db cleanup

* feat: revised request handlers plus better test assertions on insertion

* fix: test case

* feat: parse save method json request with jackson

* feat: extracted db migrations from the coordinator and transaction-exclusion app

* feat: decoupled coordinator modules from jvm-libs persistence db test module

* feat: updated dockerfile of transaction-exclusion-api

* feat: removed the find check before metric increment on save rejected transaction

* feat: updated docker base image for tx-exclusion-api image buid and queryable window config

* feat: skip migration scripts on read db instance

* feat: updated more percise jvm-libs change filtering on transaction-exclusion-api

* feat: updated coordinator config for geth node l2 gas pricing recipients

* feat: update runners with specific version and removed the use of retry for transaction exclusion api testing

* feat: add integration test for transaction exclusion app

* feat: update local stack docker compose and workflow for transaction exclusion

* feat: add e2e test for transaction exclusion

* feat: skip the sequencer test in transaction exclusion e2e test

* feat: revert sequencer config poa-block-txs-selection-max-time

* feat: remove incorrect comment

* feat: added explicitly assertion if tx exclusion is not defined and simplify the localStackPostgresDbOnly in build.gradle

* feat: remove beforeAll in test suite with it.concurrent

* feat: set coordinator config blob-compressor-version as V1_0_1 explicitly for traces-v2

* feat: update coordinator config test

* feat: change default prefix not to be coordinator specific

* feat: place persistence:db under jvm-libs:generic and fixed conflicts from latest main

* fix: remove dependency to resolve circular dependency issue

* test: switch from localStackPostgresDbOnlyComposeUp to localStackComposeUp

* feat: replace GITHUB_SHA with github.event.pull_request.head.sha in computing commit tag

* feat: update filter change file lists for transaction exclusion api
2024-10-22 15:50:44 +08:00

4.0 KiB

Transaction Exclusion API Service

This micro-service will receive the transactions rejected by sequencer or other Linea Besu nodes, persist them into a local database and expose a JSON-RPC v2 API to allow Linea users to query why their transactions were not included.

V1 API Methods

linea_saveRejectedTransactionV1

curl -H 'content-type:application/json' --data '{
    "id": "1",
    "jsonrpc": "2.0",
    "method": "linea_saveRejectedTransactionV1",
    "params": {
        "txRejectionStage": "SEQUENCER",
        "timestamp": "2024-08-22T09:18:51Z",
        "blockNumber": 12345,
        "transactionRLP": "0x02f8388204d2648203e88203e88203e8941195cf65f83b3a5768f3c496d3a05ad6412c64b38203e88c666d93e9cc5f73748162cea9c0017b8201c8",
        "reasonMessage": "Transaction line count for module ADD=402 is above the limit 70",
        "overflows": [
            {
                "module": "ADD",
                "count": 402,
                "limit": 70
            },
            {
                "module": "MUL",
                "count": 587,
                "limit": 400
            }
        ]
    }
}' http://127.0.0.1:8082

linea_getTransactionExclusionStatusV1

curl -H 'content-type:application/json' --data '{
    "jsonrpc": "2.0",
    "id": "53",
    "method": "linea_getTransactionExclusionStatusV1",
    "params": [
        "0xf5bf951edfefbaa6d9ed78c88942147cf98c8ef1f3d3416f99d2534675096569"
    ]
}' http://127.0.0.1:8082

linea_saveRejectedTransactionV1 Response Examples:

The rejected transaction was successfully saved:

{
    "jsonrpc": "2.0",
    "id": 1,
    "result": {
        "status": "SAVED",
        "txHash": "0x526e56101cf39c1e717cef9cedf6fdddb42684711abda35bae51136dbb350ad7"
    }
}

The rejected transaction with the same tx hash and reason message was saved before:

{
    "jsonrpc": "2.0",
    "id": 1,
    "result": {
        "status": "DUPLICATE_ALREADY_SAVED_BEFORE",
        "txHash": "0x526e56101cf39c1e717cef9cedf6fdddb42684711abda35bae51136dbb350ad7"
    }
}

Invalid request params errors:

{
    "jsonrpc": "2.0",
    "id": 1,
    "error": {
        "code": -32602,
        "message": "Missing [timestamp] from the given request params"
    }
}
{
    "jsonrpc": "2.0",
    "id": 1,
    "error": {
        "code": -32602,
        "message": "Timestamp is not in ISO-8601: Text '2024-09-08T09:23:56Zdd' could not be parsed, unparsed text found at index 20"
    }
}

Other error:

{
    "jsonrpc": "2.0",
    "id": 1,
    "error": {
        "code": -32000,
        "message": "Server error",
        "data": "Database connection refused: localhost/127.0.0.1:5432"
    }
}

linea_getTransactionExclusionStatusV1 Response Examples:

The rejected transaction was successfully found:

{
    "jsonrpc": "2.0",
    "id": 53,
    "result": {
        "txHash": "0x526e56101cf39c1e717cef9cedf6fdddb42684711abda35bae51136dbb350ad7",
        "from": "0x4d144d7b9c96b26361d6ac74dd1d8267edca4fc2",
        "nonce": "0x64",
        "txRejectionStage": "SEQUENCER",
        "reasonMessage": "Transaction line count for module ADD=402 is above the limit 70",
        "blockNumber": "0x3039",
        "timestamp": "2024-08-22T09:18:51Z"
    }
}

The rejected transaction was not found:

{
    "jsonrpc": "2.0",
    "id": 53,
    "result": null
}

Invalid request params errors:

{
    "jsonrpc": "2.0",
    "id": 53,
    "error": {
        "code": -32602,
        "message": "Hex string of transaction hash cannot be parsed:  expected to have 32 bytes, but got 33"
    }
}
{
    "jsonrpc": "2.0",
    "id": 53,
    "error": {
        "code": -32602,
        "message": "Hex string of transaction hash cannot be parsed: For input string: \"tt\" under radix 16"
    }
}

Other error:

{
    "jsonrpc": "2.0",
    "id": 53,
    "error": {
        "code": -32000,
        "message": "Server error",
        "data": "Database connection refused: localhost/127.0.0.1:5432"
    }
}