Skip to content

Commit 4e5f9b3

Browse files
committed
Disable EIP 7702 features when not activated
1 parent 1d11b83 commit 4e5f9b3

File tree

7 files changed

+47
-3
lines changed

7 files changed

+47
-3
lines changed

src/network.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,9 @@ uint64_t get_tx_chain_id(void) {
179179
break;
180180
case EIP2930:
181181
case EIP1559:
182+
#ifdef HAVE_EIP7702
182183
case EIP7702:
184+
#endif // HAVE_EIP7702
183185
chain_id = u64_from_BE(tmpContent.txContent.chainID.value,
184186
tmpContent.txContent.chainID.length);
185187
break;

src/shared_context.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,17 +94,23 @@ typedef struct messageSigningContext712_t {
9494
uint8_t messageHash[32];
9595
} messageSigningContext712_t;
9696

97+
#ifdef HAVE_EIP7702
98+
9799
typedef struct authSigningContext7702_t {
98100
bip32_path_t bip32;
99101
uint8_t authHash[INT256_LENGTH];
100102
} authSigningContext7702_t;
101103

104+
#endif // HAVE_EIP7702
105+
102106
typedef union {
103107
publicKeyContext_t publicKeyContext;
104108
transactionContext_t transactionContext;
105109
messageSigningContext_t messageSigningContext;
106110
messageSigningContext712_t messageSigningContext712;
111+
#ifdef HAVE_EIP7702
107112
authSigningContext7702_t authSigningContext7702;
113+
#endif // HAVE_EIP7702
108114
} tmpCtx_t;
109115

110116
typedef union {

src_features/signTx/cmd_signTx.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ static uint16_t handle_first_sign_chunk(const uint8_t *payload,
5151
switch (tx_type) {
5252
case EIP1559:
5353
case EIP2930:
54+
#ifdef HAVE_EIP7702
5455
case EIP7702:
56+
#endif // HAVE_EIP7702
5557
break;
5658
default:
5759
PRINTF("Transaction type %d not supported\n", tx_type);

src_features/signTx/ethUstream.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ static bool processAccessList(txContext_t *context) {
149149
return true;
150150
}
151151

152+
#ifdef HAVE_EIP7702
153+
152154
static bool processAuthList(txContext_t *context) {
153155
if (check_empty_list(context, "RLP_AUTH_LIST") == false) {
154156
return false;
@@ -168,6 +170,8 @@ static bool processAuthList(txContext_t *context) {
168170
return true;
169171
}
170172

173+
#endif // HAVE_EIP7702
174+
171175
static bool processChainID(txContext_t *context) {
172176
if (check_fields(context, "RLP_CHAINID", INT256_LENGTH) == false) {
173177
return false;
@@ -378,6 +382,8 @@ static bool processV(txContext_t *context) {
378382
return true;
379383
}
380384

385+
#ifdef HAVE_EIP7702
386+
381387
static bool processEIP7702Tx(txContext_t *context) {
382388
bool ret = false;
383389
switch (context->currentField) {
@@ -430,6 +436,8 @@ static bool processEIP7702Tx(txContext_t *context) {
430436
return ret;
431437
}
432438

439+
#endif // HAVE_EIP7702
440+
433441
static bool processEIP1559Tx(txContext_t *context) {
434442
bool ret = false;
435443
switch (context->currentField) {
@@ -654,11 +662,13 @@ static parserStatus_e processTxInternal(txContext_t *context) {
654662
return USTREAM_FAULT;
655663
}
656664
break;
665+
#ifdef HAVE_EIP7702
657666
case EIP7702:
658667
if (processEIP7702Tx(context) == false) {
659668
return USTREAM_FAULT;
660669
}
661670
break;
671+
#endif // HAVE_EIP7702
662672
default:
663673
PRINTF("Transaction type %d is not supported\n", context->txType);
664674
return USTREAM_FAULT;

src_features/signTx/ethUstream.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,23 @@ typedef enum customStatus_e {
3535
// First variant of every Tx enum.
3636
#define RLP_NONE 0
3737

38+
#ifdef HAVE_EIP7702
39+
3840
#define PARSING_IS_DONE(ctx) \
3941
((ctx->txType == LEGACY && ctx->currentField == LEGACY_RLP_DONE) || \
4042
(ctx->txType == EIP2930 && ctx->currentField == EIP2930_RLP_DONE) || \
4143
(ctx->txType == EIP1559 && ctx->currentField == EIP1559_RLP_DONE) || \
4244
(ctx->txType == EIP7702 && ctx->currentField == EIP7702_RLP_DONE))
4345

46+
#else
47+
48+
#define PARSING_IS_DONE(ctx) \
49+
((ctx->txType == LEGACY && ctx->currentField == LEGACY_RLP_DONE) || \
50+
(ctx->txType == EIP2930 && ctx->currentField == EIP2930_RLP_DONE) || \
51+
(ctx->txType == EIP1559 && ctx->currentField == EIP1559_RLP_DONE))
52+
53+
#endif // HAVE_EIP7702
54+
4455
typedef enum rlpLegacyTxField_e {
4556
LEGACY_RLP_NONE = RLP_NONE,
4657
LEGACY_RLP_CONTENT,
@@ -85,6 +96,8 @@ typedef enum rlpEIP1559TxField_e {
8596
EIP1559_RLP_DONE
8697
} rlpEIP1559TxField_e;
8798

99+
#ifdef HAVE_EIP7702
100+
88101
typedef enum rlpEIP7702TxField_e {
89102
EIP7702_RLP_NONE = RLP_NONE,
90103
EIP7702_RLP_CONTENT,
@@ -101,6 +114,8 @@ typedef enum rlpEIP7702TxField_e {
101114
EIP7702_RLP_DONE
102115
} rlpEIP7702TxField_e;
103116

117+
#endif // HAVE_EIP7702
118+
104119
#define MIN_TX_TYPE 0x00
105120
#define MAX_TX_TYPE 0x7f
106121

@@ -109,7 +124,9 @@ typedef enum rlpEIP7702TxField_e {
109124
typedef enum txType_e {
110125
EIP2930 = 0x01,
111126
EIP1559 = 0x02,
127+
#ifdef HAVE_EIP7702
112128
EIP7702 = 0x04,
129+
#endif // HAVE_EIP7702
113130
LEGACY = 0xc0 // Legacy tx are greater than or equal to 0xc0.
114131
} txType_e;
115132

src_features/signTx/logic_signTx.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,11 @@ static uint32_t splitBinaryParameterPart(char *result, size_t result_size, uint8
3939
customStatus_e customProcessor(txContext_t *context) {
4040
if (((context->txType == LEGACY && context->currentField == LEGACY_RLP_DATA) ||
4141
(context->txType == EIP2930 && context->currentField == EIP2930_RLP_DATA) ||
42-
(context->txType == EIP1559 && context->currentField == EIP1559_RLP_DATA) ||
43-
(context->txType == EIP7702 && context->currentField == EIP7702_RLP_DATA)) &&
42+
(context->txType == EIP1559 && context->currentField == EIP1559_RLP_DATA)
43+
#ifdef HAVE_EIP7702
44+
|| (context->txType == EIP7702 && context->currentField == EIP7702_RLP_DATA)
45+
#endif // HAVE_EIP7702
46+
) &&
4447
(context->currentFieldLength != 0)) {
4548
context->content->dataPresent = true;
4649
// If handling a new contract rather than a function call, abort immediately

src_features/signTx/ui_common_signTx.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ uint32_t io_seproxyhal_touch_tx_ok(void) {
1919
G_io_apdu_buffer + 1 + 32,
2020
&info));
2121

22-
if (txContext.txType == EIP1559 || txContext.txType == EIP2930 || txContext.txType == EIP7702) {
22+
if (txContext.txType == EIP1559 || txContext.txType == EIP2930
23+
#ifdef HAVE_EIP7702
24+
|| txContext.txType == EIP7702
25+
#endif // HAVE_EIP7702
26+
) {
2327
if (info & CX_ECCINFO_PARITY_ODD) {
2428
G_io_apdu_buffer[0] = 1;
2529
} else {

0 commit comments

Comments
 (0)