diff --git a/src/shared_context.h b/src/shared_context.h index 4c1591404..cc8fa283d 100644 --- a/src/shared_context.h +++ b/src/shared_context.h @@ -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" @@ -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; diff --git a/src_common/eth_plugin_interface.h b/src_common/eth_plugin_interface.h index 6d872f5bc..dcf11660d 100644 --- a/src_common/eth_plugin_interface.h +++ b/src_common/eth_plugin_interface.h @@ -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.")