Skip to content

Instantly share code, notes, and snippets.

@thaarok
thaarok / SFClibCode.md
Last active November 6, 2024 15:21
SFClib code checking

SFClib code checking

Using hardhat-tracer to get slot key, where is sfclib address in SFC during npx hardhat test --fulltrace:

[CALL] UnitTestSFC(0x5fbdb2315678afecb367f032d93f642f64180aa3).initialize(sealedEpoch: 12, _totalSupply: 0, nodeDriver: [NodeDriverAuth], lib: 0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9, _c: [UnitTestConstantsManager], owner: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266)
[SSTORE] 0x0000000000000000000000000000000000000000000000000000000000000080 ← 0x000000000000000000000000dc64a140aa3e981100a9beca4e685f962f0cf6c9

Read storage slot with sfclib address from SFC:

@thaarok
thaarok / pubkey2address.md
Created September 3, 2024 18:10
Ethereum pubkey to address

Example data: (Opera fakenet)

Pubkey: 0xc0048d505c351f4837cec72bce6f4254f5e4bc3f2c9a4816841db64319eee8b714ef9173fbf66d039b782624713791840846b2788d4b65a425adeba85a4b57efe0cd

Converts to address: 0x239fA7623354eC26520dE878B52f13Fe84b06971

Solidity:

    function pubkeyToAddress(bytes calldata pubkey) external pure returns(address) {
 require(pubkey.length == 66 && pubkey[0] == 0xc0, "malformed pubkey");
package main
import (
"context"
"fmt"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/rpc"
)
package genesis
// go-gzip, no hashing elapsed=49.274027963s
// pgzip.NewReaderN(reader, 1024, 100*1024) , no hashing, elapsed=1m13.959573387s
import (
"archive/tar"
"crypto/sha256"
"encoding/hex"
"fmt"
adb shell
pm list packages -f
# xiaomi calendar
pm disable-user --user 0 com.xiaomi.calendar
# aplikační trezor
pm disable-user --user 0 com.mi.android.globalminusscreen
# čistič
@thaarok
thaarok / ethereum-keystore-load.go
Last active April 25, 2023 18:35
Reading ethereum JSON keystore to obtain PrivateKey object.
package driver
import (
"crypto/ecdsa"
"github.com/gochain/gochain/v4/accounts/keystore"
"os"
"testing"
)
const PrivateKeyStore = "~/.opera/fakenet-1/keystore/UTC--2023-04-25T07-50-08.017708542Z--239fa"
@thaarok
thaarok / comparison.py
Last active December 23, 2022 06:22
TeamCity-aggregator
#!/bin/python3
import os
import re
import collections
configs = set()
buildNumbers = set()
totalTimeTable = collections.defaultdict(dict)
buildTxsTable = collections.defaultdict(dict)
txsPerSecTable = collections.defaultdict(dict)
func TestGoHashSerialization(t *testing.T) {
hasher := sha256.New()
hasher.Write([]byte{0x2})
bytes, err := hasher.(encoding.BinaryMarshaler).MarshalBinary()
if err != nil {
t.Fatalf("%s", err)
}
hasher2 := sha256.New()
err = hasher2.(encoding.BinaryUnmarshaler).UnmarshalBinary(bytes)

Replacing go-ethereum/lachesis-base with custom branch for development:

go mod edit -replace github.com/ethereum/go-ethereum=github.com/hkalina/go-ethereum@86abe1a01dc15bb3282628cc39eb7b451e6c1113
go mod edit -replace github.com/Fantom-foundation/lachesis-base=github.com/hkalina/lachesis-base@01569740d42de172b09866c8bb45e9aabd8b0235
GOPRIVATE=github.com/Fantom-foundation go mod tidy

Running Opera with websocket:

build/opera --genesis /media/sda2/opera/testnet.g --ipcpath /home/jkalina/.opera/opera.ipc \