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

fix Wanchain app sign error #553

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion makefile_conf/chain/wanchain.mk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
PATH_APP_LOAD_PARAMS += "44'/5718350'"
PATH_APP_LOAD_PARAMS += "44'/60'" "44'/5718350'"
TICKER = "WAN"
CHAIN_ID = 888
APPNAME = "Wanchain"
46 changes: 1 addition & 45 deletions src/ethUstream.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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: {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -594,14 +552,12 @@ static parserStatus_e processTxInternal(txContext_t *context) {

parserStatus_e processTx(txContext_t *context,
const uint8_t *buffer,
uint32_t length,
uint32_t processingFlags) {
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);
}
Expand Down
9 changes: 1 addition & 8 deletions src/ethUstream.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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;
Expand All @@ -139,8 +133,7 @@ void initTx(txContext_t *context,
void *extra);
parserStatus_e processTx(txContext_t *context,
const uint8_t *buffer,
uint32_t length,
uint32_t processingFlags);
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);
1 change: 1 addition & 0 deletions src/network.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ static const network_info_t NETWORK_MAPPING[] = {
{.chain_id = 59144, .name = "Linea", .ticker = "ETH"},
{.chain_id = 11155111, .name = "Sepolia", .ticker = "ETH"},
{.chain_id = 17000, .name = "Holesky", .ticker = "ETH"},
{.chain_id = 888, .name = "Wanchain", .ticker = "WAN"},
};

static const network_info_t *get_network_from_chain_id(const uint64_t *chain_id) {
Expand Down
3 changes: 1 addition & 2 deletions src_features/signTx/cmd_signTx.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ void handleSign(uint8_t p1,
}
txResult = processTx(&txContext,
workBuffer,
dataLength,
(chainConfig->chainId == 888 ? TX_FLAG_TYPE : 0)); // Wanchain exception
dataLength);
switch (txResult) {
case USTREAM_SUSPENDED:
break;
Expand Down