Skip to content

Commit

Permalink
Increase context size available for plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
fbeutin-ledger committed Apr 16, 2024
1 parent 985dd92 commit c8a8081
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/shared_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "ethUstream.h"
#include "tx_content.h"
#include "chainConfig.h"
#include "eth_plugin_interface.h"
#include "asset_info.h"
#ifdef HAVE_NBGL
#include "nbgl_types.h"
Expand Down Expand Up @@ -56,9 +57,9 @@ typedef struct tokenContext_t {
uint8_t contractAddress[ADDRESS_LENGTH];
uint8_t methodSelector[SELECTOR_LENGTH];
};
// This needs to be strictly 4 bytes aligned since pointers to it will be casted as
// plugin context struct pointers (structs that contain up to 4 bytes wide elements)
uint8_t pluginContext[5 * INT256_LENGTH] __attribute__((aligned(4)));
// This needs to be strictly 4 bytes aligned since pointers so it can be cast as plugin
// context struct pointers (structs that contain up to 4 bytes wide elements)
uint8_t pluginContext[PLUGIN_CONTEXT_SIZE] __attribute__((aligned(4)));
};

uint8_t pluginStatus;
Expand Down
3 changes: 2 additions & 1 deletion src_common/eth_plugin_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,9 @@ typedef struct ethPluginSharedRO_s {


// Plugin-only memory allocated by the Ethereum application and used by the plugin.
#define PLUGIN_CONTEXT_SIZE (5 * INT256_LENGTH)
#define PLUGIN_CONTEXT_SIZE (10 * INT256_LENGTH)
// It is recommended to cast the raw uin8_t array to a structure meaningful for your plugin

// Helper to check that the actual plugin context structure is not bigger than the allocated memory
#define ASSERT_SIZEOF_PLUGIN_CONTEXT(s) \
_Static_assert(sizeof(s) <= PLUGIN_CONTEXT_SIZE, "Plugin context structure is too big.")
Expand Down

0 comments on commit c8a8081

Please sign in to comment.