Skip to content

Commit

Permalink
fix(lr): deposit parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
loicttn committed Apr 29, 2024
1 parent 43d3d0e commit c0275fc
Show file tree
Hide file tree
Showing 33 changed files with 48 additions and 12 deletions.
7 changes: 7 additions & 0 deletions src/kiln_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ typedef enum {
LR_DELEGATE_TO_OPERATOR = 0,
LR_DELEGATE_TO_SIGNATURE_OFFSET,
LR_DELEGATE_TO_APPROVER_SALT,
LR_DELEGATE_TO_SIGNATURE_SIG_OFFSET,
LR_DELEGATE_TO_SIGNATURE_EXPIRY,
LR_DELEGATE_TO_SIGNATURE_SIG_LENGTH,
LR_DELEGATE_TO_SIGNATURE_SIG_ITEMS,
LR_DELEGATE_TO_UNEXPECTED_PARAMETER
} lr_delegate_to_parameters;

Expand All @@ -175,6 +179,9 @@ typedef struct {
} lr_deposit_t;

typedef struct {
// -- utils
uint16_t current_item_count;
// -- display
char operator_address[ADDRESS_STR_LEN];
bool is_kiln;
} lr_delegate_to_t;
Expand Down
35 changes: 32 additions & 3 deletions src/provide_parameter/eigenlayer.c
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,11 @@ void handle_lr_delegate_to(ethPluginProvideParameter_t *msg, context_t *context)
// [4] operator
// [36] signature_offset
// [68] approver_salt
// [100] signature
// [100] signature.signature.offset
// [132] signature.expiry
// [164] signature.signature.length
// [192] signature.signature.items

lr_delegate_to_t *params = &context->param_data.lr_delegate_to;

Expand All @@ -645,8 +650,8 @@ void handle_lr_delegate_to(ethPluginProvideParameter_t *msg, context_t *context)
sizeof(params->operator_address),
0);

params->is_kiln = false;
if (compare_addresses((const char *) buffer, lr_kiln_operator_address)) {
if (compare_addresses((const char *) params->operator_address,
lr_kiln_operator_address)) {
params->is_kiln = true;
}
}
Expand All @@ -657,7 +662,31 @@ void handle_lr_delegate_to(ethPluginProvideParameter_t *msg, context_t *context)
context->next_param = LR_DELEGATE_TO_APPROVER_SALT;
break;
case LR_DELEGATE_TO_APPROVER_SALT:
context->next_param = LR_DELEGATE_TO_UNEXPECTED_PARAMETER;
context->next_param = LR_DELEGATE_TO_SIGNATURE_SIG_OFFSET;
break;
case LR_DELEGATE_TO_SIGNATURE_SIG_OFFSET:
context->next_param = LR_DELEGATE_TO_SIGNATURE_EXPIRY;
break;
case LR_DELEGATE_TO_SIGNATURE_EXPIRY:
context->next_param = LR_DELEGATE_TO_SIGNATURE_SIG_LENGTH;
break;
case LR_DELEGATE_TO_SIGNATURE_SIG_LENGTH:
U2BE_from_parameter(msg->parameter, &params->current_item_count);
PRINTF("LR_DELEGATE_TO_SIGNATURE_SIG_LENGTH: %d\n", params->current_item_count);

if (params->current_item_count == 0) {
context->next_param = LR_DELEGATE_TO_UNEXPECTED_PARAMETER;
} else {
context->next_param = LR_DELEGATE_TO_SIGNATURE_SIG_ITEMS;
}
break;
case LR_DELEGATE_TO_SIGNATURE_SIG_ITEMS:
// we skip parsing signature items as they are not needed for clearsigning

params->current_item_count -= 1;
if (params->current_item_count == 0) {
context->next_param = LR_DELEGATE_TO_UNEXPECTED_PARAMETER;
}
break;
default:
PRINTF("Param not supported: %d\n", context->next_param);
Expand Down
Binary file added tests/snapshots/nanos_delegate_to_is_kiln/00000.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/snapshots/nanos_delegate_to_is_kiln/00001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/snapshots/nanos_delegate_to_is_kiln/00002.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/snapshots/nanos_delegate_to_is_kiln/00003.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/snapshots/nanos_delegate_to_is_kiln/00004.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/snapshots/nanos_delegate_to_is_kiln/00005.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/snapshots/nanos_delegate_to_is_kiln/00006.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/snapshots/nanox_delegate_to_is_kiln/00000.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/snapshots/nanox_delegate_to_is_kiln/00001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/snapshots/nanox_delegate_to_is_kiln/00002.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/snapshots/nanox_delegate_to_is_kiln/00003.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/snapshots/nanox_delegate_to_is_kiln/00004.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/snapshots/nanox_delegate_to_is_kiln/00005.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/snapshots/nanox_delegate_to_is_kiln/00006.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 9 additions & 9 deletions tests/src/lrDelegateTo.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ nano_models.forEach(function (model) {
const contract = new ethers.Contract(contractAddr, abi);

const { data } = await contract.populateTransaction.delegateTo(
'0x1f8c8b1d78d01bcc42ebdd34fae60181bd697662', // kiln operator
'0x1f8C8b1d78d01bCc42ebdd34Fae60181bD697662', // kiln operator
{
signature: '0x',
expiry: 0,
signature: '0x1111111111111111',
expiry: 42424242,
},
0
ethers.utils.formatBytes32String('salt')
);

let unsignedTx = genericTx;
Expand All @@ -51,14 +51,14 @@ nano_models.forEach(function (model) {
}
);
const tx = eth.signTransaction("44'/60'/0'/0", serializedTx, resolution);
const right_clicks = model.letter === 'S' ? 7 : 5;
const right_clicks = model.letter === 'S' ? 5 : 5;

await waitForAppScreen(sim);
await sim.navigateAndCompareSnapshots(
'.',
model.name + '_delegate_to_is_kiln',
[right_clicks, 0]
);
);
await tx;
}),
30000
Expand All @@ -72,10 +72,10 @@ nano_models.forEach(function (model) {
const { data } = await contract.populateTransaction.delegateTo(
'0x645a845f80576a25f1b412330a108780f6c4573d', // not kiln operator
{
signature: '0x',
expiry: 0,
signature: '0x1111111111111111',
expiry: 42424242424242,
},
0
ethers.utils.formatBytes32String('salt')
);

let unsignedTx = genericTx;
Expand Down

0 comments on commit c0275fc

Please sign in to comment.