Skip to content

solver: resolve a contract call's inputs under the lock before the worker thread runs it - #93

Open
EnzinoBB wants to merge 1 commit into
CREDITSCOM:masterfrom
CreditsCommunity:official/contract-call-inputs
Open

EnzinoBB wants to merge 1 commit into
CREDITSCOM:masterfrom
CreditsCommunity:official/contract-call-inputs

Conversation

@EnzinoBB

@EnzinoBB EnzinoBB commented Nov 1, 2026

Copy link
Copy Markdown

Why this PR

SmartContracts::execute_async hands contract calls to a worker thread, and execute() then read exe_queue and known_contracts (get_transaction, get_deploy_transaction, the payable naming convention) without public_access_lock, while the main thread could change them; the plain bool executor_ready was written from both threads. These are data races that can crash the node or execute a call with wrong inputs.

What changes

solver/src/smartcontracts.cpp, solver/include/solver/smartcontracts.hpp: the starter transaction, the deploy transaction and the method-name convention are resolved in execute_async, which runs under the lock, and passed to execute(); its synchronous callers already hold the lock and keep resolving them there. executor_ready is atomic. The values are the ones execute() looked up before, so results are unchanged.

Effect on the network

None: same inputs, same results, without the races.

Tests

Built and run on 4a95aaa (GCC 13); covered in the fork by private-network runs with a contract load.

Same change in the community fork: CreditsCommunity#31, running on mainnet community nodes.

…rker runs it

execute_async hands the calls to a worker thread, and execute() then read
exe_queue and known_contracts (get_transaction, get_deploy_transaction, the
payable convention) without public_access_lock while the main thread could
change them, and wrote the plain bool executor_ready from both threads.

Resolve the starter transaction, the deploy transaction and the method
name convention in execute_async, which runs under the lock, and let
execute() use them; its synchronous callers already hold the lock and keep
resolving them there. executor_ready becomes atomic. The values are the
ones execute() looked up before, so results are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

1 participant