Skip to content

Instantly share code, notes, and snippets.

View FoobarProtocol's full-sized avatar
🤐
Stealth

Foobar Protocol FoobarProtocol

🤐
Stealth
View GitHub Profile
@FoobarProtocol
FoobarProtocol / echidna_example.sol
Last active September 14, 2024 02:05
This is the test echidna file that we created to go with the tutorial. There are errors in here on purpose. We're going to refine this smart contract and the finalized version will be submitted in an entirely separate contract
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity 0.7.6;
import "./GnosisSafe.sol";
contract GnosisSafeTest is GnosisSafe {
constructor() {
// Initialize the Gnosis Safe with some owners and a threshold
address[] memory owners = new address[](3);
owners[0] = address(0x1);
@FoobarProtocol
FoobarProtocol / gnosis_safe_flattened.sol
Created September 14, 2024 01:42
Gnosis Safe Implementation proxy contract (flattened)
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity 0.7.6;
// src/common/Enum.sol
/// @title Enum - Collection of enums
/// @author Richard Meissner - <[email protected]>
contract Enum {
enum Operation {
Call,
@FoobarProtocol
FoobarProtocol / SignMessageLib.spec.ts.js
Created September 8, 2024 20:25
This is the framework owners interact with to sign individual messages. Likely one of the sources of compromise for the WazirX team at this point. Can be found in this GitHub directory by Safe & it serves as one of the de-facto tests for <1.3.0 signing mechanisms
import { expect } from "chai";
import hre, { deployments, waffle } from "hardhat";
import "@nomiclabs/hardhat-ethers";
import { getSafeWithOwners } from "../utils/setup";
import { executeContractCallWithSigners, calculateSafeMessageHash } from "../../src/utils/execution";
import { chainId } from "../utils/encoding";
describe("SignMessageLib", async () => {
const [user1, user2] = waffle.provider.getWallets();
@FoobarProtocol
FoobarProtocol / GPT_iteration.py
Created December 29, 2023 05:08
OpenAI Skeleton for Those Looking to Iteratively Employ ChatGPT
#!/usr/bin/env python3
import json
import openai
import time
import os
import logging
from openai.error import InvalidRequestError, RateLimitError
from concurrent.futures import ThreadPoolExecutor
@FoobarProtocol
FoobarProtocol / CodeT5_fine_tune_iteration.py
Created October 23, 2023 21:51
This is one iteration of the fine-tuning script for CodeT5+; warning I don't think that this script is complete
import argparse
import os
import torch
from accelerate import Accelerator
from datasets import load_dataset
from peft import LoraConfig, get_peft_model, prepare_model_for_int8_training, set_peft_model_state_dict
from torch.utils.data import IterableDataset
from tqdm import tqdm
from transformers import AutoConfig, AutoModelForCausalLM, AutoTokenizer, Trainer, TrainingArguments, logging, set_seed
@FoobarProtocol
FoobarProtocol / Split_CSV_Files.py
Created October 21, 2023 23:48
This is a really robust self-created script that partitions CSV files contingent on user input so let's get to using it shall we?
import argparse
import csv
import os
# Function to calculate total rows in CSV
def get_total_rows(csv_file):
with open(csv_file, 'r') as f:
return sum(1 for row in csv.reader(f)) - 1 # Exclude header
# Function to split CSV files
@FoobarProtocol
FoobarProtocol / DataPreprocessing.py
Created October 21, 2023 23:47
Very comprehensive dataset preprocessing for solidity smart contracts. Immaculately commented too. You're welcome if you've stumbled upon this #givingbacktothecommunity ; explains the logic behind all decisions that I've made when it comes to that too.
# Importing necessary libraries for data preprocessing and visualization
import matplotlib.pyplot as plt
import numpy as np
from tqdm.notebook import trange
import pandas as pd
import random
import torch
import re
from datasets import load_dataset
from simplet5 import SimpleT5
@FoobarProtocol
FoobarProtocol / Datagen_Evolved_Seeds.py
Created October 21, 2023 23:46
This is some really high quality code here from 'Peyton Cleveland' (guy from GitHub here - https://github.com/PeytonCleveland/Fair-Use/blob/main/Darwin-JSTS/main.py)
import os
import logging
import csv
import argparse
from tqdm import tqdm
import sys
from dotenv import load_dotenv
import openai
logging.basicConfig(level=logging.INFO,
@FoobarProtocol
FoobarProtocol / Convert Alpaca to Evol Dataset.py
Created October 21, 2023 23:46
This brief piece of code outlines how to convert an alpca
def convert_alpaca_to_evol(
file_path: str,
lines: bool = False,
output_file: str = "converted_alpaca.json"
):
"""Convert the Instruction/Input/Output format of Alpaca Instruct datasets
to the Evol-Instruct format of Instruction/Output. Inputs are appended to the
instructions.
Args:
@FoobarProtocol
FoobarProtocol / main_evol_instruct.py
Created October 21, 2023 23:45
This is the `main.py` from the Evol_Instruct repo that got removed by the researchers (this makes calls to the different transformative prompts; this is meant to be separated from the Auroboros technique)
import json
import random
from openai_access import call_chatgpt
from depth import createConstraintsPrompt, createDeepenPrompt, createConcretizingPrompt, createReasoningPrompt
from breadth import createBreadthPrompt
fr = open('alpaca_data.json','r')