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

Increase context size available for plugins #552

Closed
wants to merge 1 commit into from
Closed
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
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