Skip to content

Instantly share code, notes, and snippets.

View jessiepathfinder's full-sized avatar
🏠
Working from home

Jessie Pathfinder jessiepathfinder

🏠
Working from home
View GitHub Profile
import torch
import torch.nn as nn
import torch.optim as optim
import hashlib
import numpy as np
import math
from scipy.stats import binomtest
from functorch.compile import memory_efficient_fusion
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.8.9;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "./StorageProofs.sol";
contract BridgeDrain{
mapping(bytes32 => bytes32) public remoteAccountStateRoot;
mapping(address => uint256) public lastVotedBlockNumber;
pragma solidity ^0.7.0;
pragma experimental "ABIEncoderV2";
library Bits {
uint constant internal ONE = uint(1);
uint constant internal ONES = uint(~0);
// Sets the bit at the given 'index' in 'self' to '1'.
// Returns the modified value.
@jessiepathfinder
jessiepathfinder / Type.java
Created October 22, 2022 10:33
DataFixerUpper rewrite cache with eviction
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
package com.mojang.datafixers.types;
import com.google.common.collect.Maps;
import com.mojang.datafixers.util.Either;
import com.mojang.datafixers.util.Pair;
import com.mojang.datafixers.DSL;
import com.mojang.datafixers.DataFixUtils;
import com.mojang.datafixers.Dynamic;
/// <summary>
/// An extremely lightweight implementation of async mutexes
/// </summary>
public sealed class AsyncMutex{
private readonly object locker = new object();
private volatile int locked;
private readonly Queue<Action<bool>> queue = new Queue<Action<bool>>();
public bool TryEnter() => Interlocked.Exchange(ref locked, 1) == 0;

MyEUBIWallet problems - why the're a MyEUBIWallet v2.0

When I first started working on MyEUBIWallet, it was my first time making a web application in years. I made mistakes, like lack of proper safety checks.

MyEUBIWallet v1.0 was plauged by improper failure handling. If the user enters an invalid address, for example, MyEUBIWallet v1.0 will just simply freeze. Also, MyEUBIWallet v1.0 is unsafe due to the lack of comfirmation prompts, which are added in MyEUBIWallet v2.0.

MyEUBIWallet v2.0 introduces better safety checks, stronger XSS protection, and more graceful failure handling. Also MyEUBIWallet v2.0 have major UI and performance improvements.

Now, I'm working on MyEUBIWallet v3.0, since I made serious UI design mistakes in MyEUBIWallet v2.0. Also, I want to make a wallet that is fit for what EUBI is now, not what EUBI used to be.

//Also, we used OpenZeppelin's libraries
pragma solidity ^0.8.0;
import './token/ERC20/extensions/ERC20FlashMint.sol';
import './utils/math/Math.sol';
//Synthetic gastoken: use CDPs not refunds
contract SyntheticGastoken is ERC20FlashMint{
using Math for uint256;
//How much Ethereum collateral the borrower have remaining
mapping(address => uint256) public collateralRemaining;
//SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.8.0;
interface IFlashMintReceiver{
function FlashMintReceived(uint256 amount, bytes memory data) external;
}
contract ERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*

MintME.com coin REKT post mortem

How are smart contract addresses computed

On MintME, smart contract addresses are computed using the hash of the deployer's address and nounce. The nounce is incremented every time you send a transaction.

How the REKT happened

When the MintME hardfork was performed, the devs stored the final state of the old blockchain in the initial state of the new blockchain. The devs failed to carry over address nounces, which meant that anyone can change smart contracts they have deployed.

// File: patricia_tree/PatriciaTreeFace.sol
pragma solidity ^0.5.17;
pragma experimental ABIEncoderV2;
/*
* Interface for patricia trees.
*