In eth2 staking there are penalties for a non active validator, to encourage validators to perform their duty. A validator which is inactive for a significant amount of time will see his balance decrease until it reaches 16ETH, in which time that validator will get ejected from the the active validator stake.
Here is how long it will take.
Every epoch a function called get_attestation_deltas is called which calculates for each validator the rewards and penalties under those 5 parameters: attestation source, target head, inclusion delay and inactivity leak.
The first 3 components (source, target, head) are all calculated based on a function called get_attestation_component_deltas which checks if a validator performed his attestation duty (line 13), a penalty is added to the amount of get_base_reward.
get_base_reward is a dynamic function which changes based on the amount of total ETH at stake and total effective balance. It’s basically a ratio between the working capital of the validator(effective balance) which is 32 ETH max and the total balances which can be higher than 32.
As we try to calculate the penalties for an offline validator, we can see from the example above that for each of the 3 components (target, source and head) the validator loses 7240*3 Gwei every epoch (6.4 minutes).
It’s important to note that the penalty rate decreases as the effective balance of the validator decreases. If the effective balance is 25 then: 25*10⁹*64/(sqrt_int(5M*10⁹)*4) = 5656 Gwei.
For get_inclusion_delay_deltas there are no penalties only additional rewards. Inactivity penalties depend on the whole state being in an inactivity leak status which is only if the whole validator set can’t finalized epochs anymore, not relevant for a single validator.
It seems that for being a single offline validator, every epoch we stand to lose 7240 Gwei. This number decreases as the effective balance decreases:
It seems an offline validator will take many months to reach 16ETH balance for it to get ejected.