Comments (4)
In an effort to implement this, the very first thing that will need to happen is a refactor of the VM runner.
There are a couple of issues to resolve:
- Split up the
near_vm_runner::run
method into aninstantiate
andrun_method
;- not quite as written, but #11667 implements this in a way that's agnostic over where exactly the split occurs.
- Instantiation must be split up so that the
start
method can be run at a later time. This may be particularly troublesome for VMs that we don't control implementation of. For instancewasmtime
provides "pre-instantiate" sort of method, but that does less work than we'd ideally like. - In
near_vm_runner
we have the split here already, but the instantiation is mixed up together with the loading of the executable, which is probably something we should fix as well.- All the caches make things more difficult than they ideally should be...
- We may need to keep the cache of loaded contracts for use-cases like ReadRPC which will not be able to predict upcoming requests, but we could possibly drop that cache in nearcore.
- Figure out what type represents an instance: do we store it within a VM (and make the VM only able to run a single method?) or do we do some type erasure shenanigans to obtain a type that makes sense to return from an object-safe trait?
- Implementing this requires significant-enough changes to the code structure to require a protocol version change. How do we maintain backward compatibility when the old runtimes cannot allow for the same sort of logic flow...?
from nearcore.
cc #11808
from nearcore.
I have a question: instead of thinking about dynamic vs. static, could we just use an approach where at the beginning of apply, we eagerly go over receipts and load contracts into a queue, then we when need to execute a function call receipt, we pop prepared contracts from the front of queue. We need a concurrent queue here, but otherwise it should be easier to implement.
from nearcore.
I would argue that the described solution is a form of a static approach where N
of preloaded contracts is implicitly bounded by available memory or the maximum number of delayed+incoming+local receipts. If we don't carefully manage the number of prepared receipts we'd be looking at >1 TiB of memory to store the prepared contracts (assuming ~20k of delayed receipts and 64MiB of contract data memory per prepared contract.)
Traditional queues are somewhat poor of a data structure for this problem too. For instance local receipts are constructed within apply and processed right after they are constructed before delayed or incoming receipts. But then if those local receipts do not fit into the current chunk, they get pushed to the back of the delayed receipt queue. As thus the ordering in which the receipts get executed is quite dynamic in the grand scheme of things, and is somewhat ambiguous at the beginning of apply
.
For these reasons I don't think ordered data structures or starting preparation work in apply
are the right way forward.
from nearcore.
Related Issues (20)
- [Forknet][BUG] Fix number of seats for a forknet
- Update cli tools to handle the ShardCongested error HOT 1
- `2.0.0-rc.1` with `load_mem_tries_for_tracked_shards = true` panics HOT 3
- Statelessnet code cleanup HOT 1
- Flat storage contains delta for older shards version HOT 3
- Crash in test validator_switch_key HOT 5
- Ensure sanity of protocol structs
- resharding - fix and reenable nayduck tests
- Archival node fails to sync state if Cold DB is not setup at startup
- nayduck: sync_state_dump HOT 1
- Consider returning http errors for certain rpc errors HOT 3
- License attribution not displayed on Github HOT 1
- Adjust upgradability test for multiple protocol updates
- Take state writing off the critical path HOT 2
- [Tracking issue] 2024 H2 single shard performance HOT 1
- High availability configuration: multiple nodes with the same validator key
- Existence of validator signer should not be used to check is-validator condition
- Archival node database size optimizations
- Ensure that protocol version has increased HOT 1
- [TestLoop] test doesn't end when run_until timeouts HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nearcore.