Skip to content

Instantly share code, notes, and snippets.

View ydm's full-sized avatar

Йордан Миладинов ydm

  • Sofia, Bulgaria
View GitHub Profile
0x97d1245fa4c247c2c15c2e71121f7a84206a111de9469cdef7aba95217f845e7516b793ceabdcee07d46163995a848af
0xa6639b0ce898ee6adbd2c32972bba86e084c78a47ee09756bb988833786d2b37ef7be827cade1ef309b55ab9a87b5c7b
0x818258f53a5e1156cd1f20b3df1e371cd76d9444193e97dd49344b067e9694b5d53681a96dec50c299b82dd5759ffeac
0xa06009d367c0be5f0ba18fe0652e9a5c4813759399c2ba283f4f20e6af7bf4b3dcecb0025ce691eb6e40851841b80c2c
0xad00bbf2438f27d7d41d90c85812b07686a21958706e8db6c04fb44aeeafd10984f0489db644390c5b70c5c3f3331bd6
0x803d44d14b14786672e532e66633be4a228b7808fd69f4e9fcfbdae25f9ae3d7ea6c21a8c074206fb61d368361b4b4e8
0xa7fa42f457ca1312d9e9e7f12b24e4aba74a7fba386c8dcb8333e1d6e5abdecea30f8fc3e1e77ab8e07db109d454bb23
0xa2e5f8c890245ea0e7b9d37b7b23c568fb33aad3f9518ad2359c0773016c20afd554021485da3199761d04316725ea68
0xae644cdc6a11d4841c24e4d47b5235a07776916b52a7e8afe7ab28dd078e89e75ea6406ac3bbe54f50c4eb30319b6d85
#!/bin/bash
BEACON_NODE=http://testing.mainnet.beacon-api.nimbus.team
curl \
--no-progress-meter \
"${BEACON_NODE}/eth/v2/beacon/blocks/head" \
| jq '.data.message.body.execution_payload.withdrawals | last | .index'
def get_balance_churn_limit(state: BeaconState) -> Gwei:
"""
Return the churn limit for the current epoch.
"""
churn = max(
MIN_PER_EPOCH_CHURN_LIMIT_ELECTRA,
get_total_active_balance(state) // CHURN_LIMIT_QUOTIENT
)
return churn - churn % EFFECTIVE_BALANCE_INCREMENT
#
# Phase0
#
def is_eligible_for_activation_queue(validator: Validator) -> bool:
"""
Check if ``validator`` is eligible to be placed into the activation queue.
"""
return (
validator.activation_eligibility_epoch == FAR_FUTURE_EPOCH
| File                                 | Class                                 | Prefix                    | Base? |
|--------------------------------------+---------------------------------------+---------------------------+-------|
| src/ape/api/config.py                | ApeConfig(BaseSettings)               | APE_API_                  | no    |
| src/ape/api/config.py                | DeploymentConfig(PluginConfig)        | APE_API_                  | no    |
| src/ape/api/config.py                | PluginConfig(BaseSettings)            | APE_API_                  | yes   |
| src/ape_cache/config.py              | CacheConfig(PluginConfig)             | APE_CACHE_                | no    |
| src/ape_compile/config.py            | Config(PluginConfig)                  | APE_COMPILE_              | no    |
| src/ape_console/config.py            | ConsoleConfig(PluginConfig)           | APE_CONSOLE_              | no    |
| src/ape_ethereum/ecosystem.py        | BaseEthereumConfig(PluginConfig)      | APE
@ydm
ydm / divide.ts
Created January 7, 2025 02:27
divide :: biging -> bigint -> number
function divide(a: bigint, b: bigint): number {
const PRECISION: bigint = 18n;
const EXP: bigint = 10n**PRECISION;
if (b === 0n) {
return 0;
}
const integer: bigint = a/b;
const remainder: bigint = a%b;
const fractional: bigint = (remainder * EXP) / b;
const result: bigint = integer * EXP + fractional;
```
$ python
Python 3.12.4 (main, Jun 7 2024, 06:33:07) [GCC 14.1.1 20240522] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print(int(1e6) * int(1e18))
1000000000000000000000000
>>> print(int(1e6 * 1e18))
999999999999999983222784
>>>
```
@ydm
ydm / Test.sol.md
Last active December 17, 2024 01:10
DIagram of forge-std/Test.sol
---
title: github.com/ydm/mermaider
---
classDiagram
class `CommonBase` {
    <<abstract>>
    -address VM_ADDRESS
    -address CONSOLE
    -address CREATE2_FACTORY
@ydm
ydm / secom.py
Last active October 22, 2024 21:21
Secure communication using asymmetric cryptography
#!/usr/bin/env python
from pathlib import Path
from base64 import b64encode, b64decode
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.asymmetric import padding
from cryptography.hazmat.primitives.serialization.ssh import (
SSHPrivateKeyTypes,