Skip to content

Instantly share code, notes, and snippets.

View alonmuroch's full-sized avatar

Alon Muroch alonmuroch

View GitHub Profile
**Service Level Agreement (SLA)**
This Service Level Agreement ("SLA") is entered into by and between [Service Provider Name] ("Provider") and [Client Name] ("Client") on [Date].
**1. Scope**
This SLA outlines the agreed-upon levels of service and support provided by the Provider to the Client for the duration of the agreement.
**2. Services Provided**
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.8.2 <0.9.0;
/**
* @title Voting
* @dev Store & retrieve value in a variable
* @custom:dev-run-script ./scripts/deploy_with_ethers.ts
*/
contract Voting {
SignedMessage{
Signers: []types.OperatorID{1, 2, 3, 4},
Signature: []byte{},
Message: Message{
MsgType: RoundChangeMsgType,
Round: 2,
Height: 10,
Identifier: []byte{},
Root: [32]byte{},
DataRound: 1,
function registerValidator(
uint256[] operatorIds,
bytes[] signatures,
bytes[] encryptedShares,
bytes[] sharesPublicKeys
uint8 setSize,
bytes withdrawalCredentials,
bytes publicKey,
) external {
// verify signature
// ProcessMessage pulls messages from the queue to be processed sequentially
func (i *Instance) ProcessMessage() (processedMsg bool, err error) {
if netMsg := i.MsgQueue.PopMessage(msgqueue.IBFTMessageIndexKey(i.State.Lambda.Get(), i.State.SeqNumber.Get(), i.State.Round.Get())); netMsg != nil {
var pp pipeline.Pipeline
switch netMsg.SignedMessage.Message.Type {
case proto.RoundState_PrePrepare:
pp = i.prePrepareMsgPipeline()
case proto.RoundState_Prepare:
pp = i.prepareMsgPipeline()
case proto.RoundState_Commit:
@alonmuroch
alonmuroch / is_in_inactivity_leak.py
Created January 11, 2021 08:36
is_in_inactivity_leak
def is_in_inactivity_leak(state: BeaconState) -> bool:
return get_finality_delay(state) > MIN_EPOCHS_TO_INACTIVITY_PENALTY
@alonmuroch
alonmuroch / get_base_reward.py
Created January 11, 2021 08:18
get_base_reward
def get_base_reward(state: BeaconState, index: ValidatorIndex) -> Gwei:
total_balance = get_total_active_balance(state)
effective_balance = state.validators[index].effective_balance
return Gwei(effective_balance * BASE_REWARD_FACTOR // integer_squareroot(total_balance) // BASE_REWARDS_PER_EPOCH)
@alonmuroch
alonmuroch / get_attestation_deltas.py
Created January 11, 2021 08:11
get_attestation_deltas
def get_attestation_deltas(state: BeaconState) -> Tuple[Sequence[Gwei], Sequence[Gwei]]:
"""
Return attestation reward/penalty deltas for each validator.
"""
source_rewards, source_penalties = get_source_deltas(state)
target_rewards, target_penalties = get_target_deltas(state)
head_rewards, head_penalties = get_head_deltas(state)
inclusion_delay_rewards, _ = get_inclusion_delay_deltas(state)
_, inactivity_penalties = get_inactivity_penalty_deltas(state)
@alonmuroch
alonmuroch / get_attestation_component_deltas.py
Created January 11, 2021 08:10
get_attestation_component_deltas
def get_attestation_component_deltas(state: BeaconState,
attestations: Sequence[PendingAttestation]
) -> Tuple[Sequence[Gwei], Sequence[Gwei]]:
"""
Helper with shared logic for use by get source, target, and head deltas functions
"""
rewards = [Gwei(0)] * len(state.validators)
penalties = [Gwei(0)] * len(state.validators)
total_balance = get_total_active_balance(state)
unslashed_attesting_indices = get_unslashed_attesting_indices(state, attestations)
@alonmuroch
alonmuroch / python
Created January 11, 2021 08:05
get_attestation_deltas
def get_attestation_deltas(state: BeaconState) -> Tuple[Sequence[Gwei], Sequence[Gwei]]:
"""
Return attestation reward/penalty deltas for each validator.
"""
source_rewards, source_penalties = get_source_deltas(state)
target_rewards, target_penalties = get_target_deltas(state)
head_rewards, head_penalties = get_head_deltas(state)
inclusion_delay_rewards, _ = get_inclusion_delay_deltas(state)
_, inactivity_penalties = get_inactivity_penalty_deltas(state)