-
Notifications
You must be signed in to change notification settings - Fork 37
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
[contracts] Compute all config rather than store in state #601
Comments
@ponderingdemocritus can I work on this? |
@ponderingdemocritus i don't get the description. could you rephrase |
When we use config values throughout the app, we often pull from the config model then hardcode the value into a model. We do this for `sec_per_km'. This means that if we change the config, all entities that existed in the past, now have the old config. If we move to computing the config on the fly whenever it is used, it means that we can change the config model, and every entity value changes. |
oh i see |
@EjembiEmmanuel i can walk you through it if you're willing to work on it asap |
I am willing to work on this though if he's not available |
@credence0x yes, you can I'm available to work on it. |
seems he is. is there any other issue you'd like to take? @Dprof-in-tech |
@EjembiEmmanuel pls text me on discord. @credence0x |
@credence0x I've sent you a friend request on Discord |
@ponderingdemocritus i can only see this issue with |
yes - just do those |
Is this done or should I work on this? |
Currently throughout the app when we use a config value in models, we read the config then store that in the state of a model.
This hard codes the config value for all future interactions with this model.
We need to move this so all config values are computed on the fly, rather than hard coding when a model is created. This will reduce gas costs, and also allow the config to change within a session.
This issue basically concerns the
CapacityConfig
andSpeedConfig
.Regarding capacity configuration, you'll see that we hardcode the
Capacity
value of entities hereeternum/contracts/src/systems/combat/contracts.cairo
Line 120 in cc2089f
instead of doing that, we could store the entity type of in the
EntityMetadata
modelthen whenever we need to get the capacity of the entity, we can get it by checking the current capacity config value of the entity type e.g
then we use the capacity computed on the fly when determining the weight of entities
eternum/contracts/src/models/weight.cairo
Lines 10 to 35 in cc2089f
With regard to
SpeedConfig
, we will have to stop storingArrivalTime
and instead store the start time of a journey so that we can always calculate the arrival time on the fly by multiplying an entity's speed with the distance of journeyThe text was updated successfully, but these errors were encountered: