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

Don't execute smartcontracts twice on the leader #56

Open
ineiti opened this issue Nov 16, 2023 · 4 comments
Open

Don't execute smartcontracts twice on the leader #56

ineiti opened this issue Nov 16, 2023 · 4 comments

Comments

@ineiti
Copy link
Member

ineiti commented Nov 16, 2023

Currently the leader executes each smartcontract twice. Probably once to know if the contract is legit, and then once with the doPBFT method.

It should execute the contract only once. Either use the result of this run, or only run it in the doPBFT method.

@ineiti ineiti moved this from Backlog to To do in Engineer's TODO Nov 16, 2023
@ineiti ineiti removed this from Engineer's TODO Nov 16, 2023
@ineiti ineiti added this to D-Voting Nov 16, 2023
@ineiti ineiti moved this to Todo in D-Voting Nov 16, 2023
@pierluca
Copy link
Collaborator

I believe this is because the whole Dela software doesn't treat one's own node differently from the other nodes. As such, when something needs to be processed by all nodes, it'll be sent for all nodes to process.

In this particular case, I suspect the leader executes the contract once, when building a block and before proposing it to all the nodes (incl. itself), then a second time once the block is sent to all the nodes (incl. the leader itself) for validation/integration in the blockchain.

@ineiti
Copy link
Member Author

ineiti commented Jan 26, 2024

So there should be a cache to avoid executing the contract twice.

I'm not sure if my calculations are exact. But even for the worst case (meaning my calculations were right), voting time would go down from 100ms to 80ms. So I don't think it's worth it. But I keep it around in case we do need this small speedup.

@PascalinDe PascalinDe moved this from Todo to Backlog in D-Voting Mar 7, 2024
@PascalinDe
Copy link
Member

is this still an issue?

@ineiti
Copy link
Member Author

ineiti commented Oct 11, 2024

It is an issue, but currently "premature optimization" :) If there are very slow smart contracts, it can double the transactions per second.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Backlog
Development

No branches or pull requests

3 participants