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

Split block and tx context, use out parameter #624

Closed
wants to merge 1 commit into from

Conversation

chfast
Copy link
Member

@chfast chfast commented Feb 9, 2022

This split transaction and block context into separate structs. They have different lifetimes so the Host can keep the same block context while processing multiple transactions.

We also return these by out-parameter because otherwise additional copy is needed in VM.

include/evmc/evmc.h Outdated Show resolved Hide resolved
// Licensed under the Apache License, Version 2.0.

package evmc

/*
#cgo CFLAGS: -I${SRCDIR}/../../../include -Wall -Wextra -Wno-unused-parameter

#include <evmc/evmc.h>
#include <evmc/helpers.h>
#include </home/chfast/Projects/ethereum/evmc/include/evmc/evmc.h>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably unintentional change

@chfast
Copy link
Member Author

chfast commented Mar 4, 2022

This can be made to work as desired without without ABI change using C restrict. But only in to-be-released clang 14.

diff --git a/include/evmc/evmc.hpp b/include/evmc/evmc.hpp
index 2007b94..8655531 100644
--- a/include/evmc/evmc.hpp
+++ b/include/evmc/evmc.hpp
@@ -563,6 +563,11 @@ public:
         return result{host->call(context, &message)};
     }

+    void helper(evmc_tx_context& __restrict__ tx) const noexcept
+    {
+        tx = host->get_tx_context(context);
+    }
+
     /// @copydoc HostInterface::get_tx_context()
     ///
     /// The implementation caches the received transaction context
@@ -572,7 +577,7 @@ public:
     evmc_tx_context get_tx_context() const noexcept final
     {
         if (tx_context.block_timestamp == 0)
-            tx_context = host->get_tx_context(context);
+            helper(tx_context);
         return tx_context;
     }

So I plan to do the ABI change but only in the aspect of parameter passing. The split will not be done until I collect stats about transaction access usage.

@chfast chfast force-pushed the block_tx_context branch from 067e480 to bed1362 Compare March 6, 2022 10:37
@chfast
Copy link
Member Author

chfast commented Mar 9, 2022

For now #631 should be enough.

@chfast chfast closed this Mar 9, 2022
@chfast chfast deleted the block_tx_context branch March 9, 2022 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants