You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 25, 2023. It is now read-only.
Hey @decanus, poking around on here! I agree it would be good to move away from inouts, as they're definitely not considered "Swifty" in most cases.
I see a couple ways this could be accomplished. One would be to simply have each static method return a mutated BeaconState, so the implementation of processBlock for example would look like this:
staticfunc processBlock(state:BeaconState, block:BeaconBlock)->BeaconState{assert(state.slot == block.slot)varstate= state
state =blockSignature(state: state, block: block)
state =randao(state: state, block: block)
state =eth1data(state: state, block: block)
state =proposerSlashings(state: state, block: block)
state =attesterSlashings(state: state, block: block)
state =attestations(state: state, block: block)
state =deposits(state: state, block: block)
state =voluntaryExits(state: state, block: block)return state
}
This would be a more functional style.
Alternatively, I can see an argument for a more OO style by using an extension to implement these as instance methods on the BeaconState struct itself. That would end up looking more like this:
staticfunc processBlock(state:BeaconState, block:BeaconBlock)->BeaconState{assert(state.slot == block.slot)varstate= state
return state
.blockSignature(block: block).randao(block: block).eth1data(block: block).proposerSlashings(block: block).attesterSlashings(block: block).attestations(block: block).deposits(block: block).voluntaryExits(block: block)}
I think the latter approach is a little more idiomatic, but don't feel strongly either way. What do you think? I might take a stab at this!
StateTransitions uses
inout
everywhere, might be nicer to use returns of the state.The text was updated successfully, but these errors were encountered: