Fix Wanchain (#615)

* fix Wanchain app sign error

* remove redundant path

---------

Co-authored-by: zhwir <zhwir@163.com>
This commit is contained in:
apaillier-ledger
2024-07-26 10:46:52 +02:00
committed by GitHub
parent 63894999f5
commit 44b5a23785
4 changed files with 4 additions and 61 deletions

View File

@@ -103,26 +103,6 @@ static void processAccessList(txContext_t *context) {
}
}
static void processType(txContext_t *context) {
if (context->currentFieldIsList) {
PRINTF("Invalid type for RLP_TYPE\n");
THROW(EXCEPTION);
}
if (context->currentFieldLength > MAX_INT256) {
PRINTF("Invalid length for RLP_TYPE\n");
THROW(EXCEPTION);
}
if (context->currentFieldPos < context->currentFieldLength) {
uint32_t copySize =
MIN(context->commandLength, context->currentFieldLength - context->currentFieldPos);
copyTxData(context, NULL, copySize);
}
if (context->currentFieldPos == context->currentFieldLength) {
context->currentField++;
context->processingField = false;
}
}
static void processChainID(txContext_t *context) {
if (context->currentFieldIsList) {
PRINTF("Invalid type for RLP_CHAINID\n");
@@ -321,14 +301,6 @@ static bool processEIP1559Tx(txContext_t *context) {
switch (context->currentField) {
case EIP1559_RLP_CONTENT: {
processContent(context);
if ((context->processingFlags & TX_FLAG_TYPE) == 0) {
context->currentField++;
}
break;
}
// This gets hit only by Wanchain
case EIP1559_RLP_TYPE: {
processType(context);
break;
}
case EIP1559_RLP_CHAINID: {
@@ -377,13 +349,6 @@ static bool processEIP2930Tx(txContext_t *context) {
switch (context->currentField) {
case EIP2930_RLP_CONTENT:
processContent(context);
if ((context->processingFlags & TX_FLAG_TYPE) == 0) {
context->currentField++;
}
break;
// This gets hit only by Wanchain
case EIP2930_RLP_TYPE:
processType(context);
break;
case EIP2930_RLP_CHAINID:
processChainID(context);
@@ -420,13 +385,6 @@ static bool processLegacyTx(txContext_t *context) {
switch (context->currentField) {
case LEGACY_RLP_CONTENT:
processContent(context);
if ((context->processingFlags & TX_FLAG_TYPE) == 0) {
context->currentField++;
}
break;
// This gets hit only by Wanchain
case LEGACY_RLP_TYPE:
processType(context);
break;
case LEGACY_RLP_NONCE:
processNonce(context);
@@ -592,16 +550,12 @@ static parserStatus_e processTxInternal(txContext_t *context) {
PRINTF("end of here\n");
}
parserStatus_e processTx(txContext_t *context,
const uint8_t *buffer,
uint32_t length,
uint32_t processingFlags) {
parserStatus_e processTx(txContext_t *context, const uint8_t *buffer, uint32_t length) {
parserStatus_e result;
BEGIN_TRY {
TRY {
context->workBuffer = buffer;
context->commandLength = length;
context->processingFlags = processingFlags;
result = processTxInternal(context);
PRINTF("result: %d\n", result);
}

View File

@@ -36,8 +36,6 @@ typedef enum customStatus_e {
typedef customStatus_e (*ustreamProcess_t)(struct txContext_t *context);
#define TX_FLAG_TYPE 0x01
// First variant of every Tx enum.
#define RLP_NONE 0
@@ -49,7 +47,6 @@ typedef customStatus_e (*ustreamProcess_t)(struct txContext_t *context);
typedef enum rlpLegacyTxField_e {
LEGACY_RLP_NONE = RLP_NONE,
LEGACY_RLP_CONTENT,
LEGACY_RLP_TYPE, // For wanchain
LEGACY_RLP_NONCE,
LEGACY_RLP_GASPRICE,
LEGACY_RLP_STARTGAS,
@@ -65,7 +62,6 @@ typedef enum rlpLegacyTxField_e {
typedef enum rlpEIP2930TxField_e {
EIP2930_RLP_NONE = RLP_NONE,
EIP2930_RLP_CONTENT,
EIP2930_RLP_TYPE, // For wanchain
EIP2930_RLP_CHAINID,
EIP2930_RLP_NONCE,
EIP2930_RLP_GASPRICE,
@@ -80,7 +76,6 @@ typedef enum rlpEIP2930TxField_e {
typedef enum rlpEIP1559TxField_e {
EIP1559_RLP_NONE = RLP_NONE,
EIP1559_RLP_CONTENT,
EIP1559_RLP_TYPE, // For wanchain
EIP1559_RLP_CHAINID,
EIP1559_RLP_NONCE,
EIP1559_RLP_MAX_PRIORITY_FEE_PER_GAS,
@@ -125,7 +120,6 @@ typedef struct txContext_t {
uint32_t rlpBufferPos;
const uint8_t *workBuffer;
uint32_t commandLength;
uint32_t processingFlags;
ustreamProcess_t customProcessor;
txContent_t *content;
void *extra;
@@ -137,10 +131,7 @@ void initTx(txContext_t *context,
txContent_t *content,
ustreamProcess_t customProcessor,
void *extra);
parserStatus_e processTx(txContext_t *context,
const uint8_t *buffer,
uint32_t length,
uint32_t processingFlags);
parserStatus_e processTx(txContext_t *context, const uint8_t *buffer, uint32_t length);
parserStatus_e continueTx(txContext_t *context);
void copyTxData(txContext_t *context, uint8_t *out, uint32_t length);
uint8_t readTxByte(txContext_t *context);

View File

@@ -51,6 +51,7 @@ static const network_info_t NETWORK_MAPPING[] = {
{.chain_id = 336, .name = "Shiden", .ticker = "SDN"},
{.chain_id = 369, .name = "PulseChain", .ticker = "PLS"},
{.chain_id = 592, .name = "Astar", .ticker = "ASTR"},
{.chain_id = 888, .name = "Wanchain", .ticker = "WAN"},
{.chain_id = 1030, .name = "Conflux", .ticker = "CFX"},
{.chain_id = 1088, .name = "Metis Andromeda", .ticker = "METIS"},
{.chain_id = 1101, .name = "Polygon zkEVM", .ticker = "ETH"},

View File

@@ -69,10 +69,7 @@ void handleSign(uint8_t p1,
PRINTF("Parser not initialized\n");
THROW(0x6985);
}
txResult = processTx(&txContext,
workBuffer,
dataLength,
(chainConfig->chainId == 888 ? TX_FLAG_TYPE : 0)); // Wanchain exception
txResult = processTx(&txContext, workBuffer, dataLength);
switch (txResult) {
case USTREAM_SUSPENDED:
break;