Skip to content

Instantly share code, notes, and snippets.

View riemannulus's full-sized avatar
🏖️
State of drift in the sea of infomatik

Lee, Suho riemannulus

🏖️
State of drift in the sea of infomatik
View GitHub Profile
@riemannulus
riemannulus / explain.cs
Created May 17, 2023 06:59
Psuedo IAccount
[Pure]
internal class AccountStateDeltaImpl : IValidatorSupportStateDelta, IAccountStateDelta
{
[Pure]
IAccount? IAccountStateView.GetAccount(Address address)
{
return UpdatedAccount.TryGetValue(address, out IAccount? account)
? account
: AccountGetter(address);
}
@riemannulus
riemannulus / StateDeltaImpl.cs
Created May 4, 2023 12:16
Example of StateDeltaImpl.cs
class StateDeltaImpl : IAccountStateDelta, IValidatorStateDelta, IGasStateDelta {
[Pure]
IReadOnlyList<IValue?> IAccountStateView.GetStates(IReadOnlyList<Address> addresses)
{
ActionContext.GetStateTimer.Value?.Start();
int length = addresses.Count;
// note gas is does not static value
AddGas(length)
@riemannulus
riemannulus / HackAndSlash.cs
Created May 2, 2023 17:16
Example IAction Execute for gas
IAccountStateDelta Execute(IActionContext context)
{
UInt256 gasCap = context.AvaliableGas();
UInt256 HASGas = 10;
if(gasCap < HASGas)
{
return context.PreivousState.UseGas(gasCap);
}
return Battle(context).UseGas(HASGas);
}
@riemannulus
riemannulus / ActionEvaluator.cs
Last active May 4, 2023 10:21
Psuedo ActionEvaluator
IEnumerable<ActionEvaluation> EvaluateBlock(IPreEvaluationBlock block, IAccountStateDelta prevState)
{
UInt256 remainingGasPerBlock = block.GasLimit();
IEnumerable<ActionEvaluation> evaluations
= ExecuteActions(_beginBlockActions, prevState, remainingGasPerBlock, 0);
foreach(ActionEvaluation eval in evaluations)
{
yield return eval;
prevState = eval.OutputState.UseGas(0);
}
@riemannulus
riemannulus / download-snapshot.sh
Created December 15, 2022 15:00
download snapshot shell script pbft internal
#!/usr/bin/env bash
base_url=${1:-https://9c-snapshot-dev.s3.us-east-2.amazonaws.com/9c-pbft-internal}
save_dir=${2:-"9c-main-snapshot_$(date +%Y%m%d_%H)"}
echo "Start download snapshot"
# strip tailing slash
base_url=${base_url%/}
function get_snapshot_value() {
@riemannulus
riemannulus / Gossip.cs
Created December 2, 2022 15:49
StartAsyncForWaitForUntilLeast23NodeAlive
public async Task StartAsync(CancellationToken ctx)
{
_cancellationTokenSource = CancellationTokenSource.CreateLinkedTokenSource(ctx);
Task transportTask = _transport.StartAsync(ctx);
await _transport.WaitForRunningAsync();
try
{
await _protocol.BootstrapAsync(_seeds, TimeSpan.FromSeconds(1), 3, ctx);
}
catch (PeerDiscoveryException pde)
@riemannulus
riemannulus / Gossip.cs
Created December 2, 2022 15:47
WaitForUntilLeast23NodeAlive
public async Task WaitForUntilLeast23NodeAlive(CancellationToken ctx)
{
async Task<bool> PongResponse(BoundPeer peer)
{
try
{
var result = await _transport.SendMessageAsync(
peer,
new PingMsg(),
TimeSpan.FromSeconds(1),
@riemannulus
riemannulus / .bashrc
Last active January 10, 2021 05:29
Add upstream
function add_upstream() {
url=$(git config --get remote.origin.url)
repo=${url##*/}
if [[ "$repo" =~ ".git" ]]; then
repo=$(echo "$repo" | awk -F. '{print $1}')
fi
user=$(echo "$url" | awk -F/ '{print $4}')
if [ -z "$user" ]; then
user=$(echo "$url" | awk -F: '{print $2}' | awk -F/ '{print $1}')
fi
#!/bin/bash
# Copyright 2016 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@riemannulus
riemannulus / keybase.md
Created April 18, 2019 14:08
keybase.md

Keybase proof

I hereby claim:

  • I am riemannulus on github.
  • I am riemannulus (https://keybase.io/riemannulus) on keybase.
  • I have a public key ASAd_FhiK4sqZG8IN54qYgQQo6gNXRL4hS5nKCKkAsnm0Ao

To claim this, I am signing this object: