Skip to content

Instantly share code, notes, and snippets.

View GalloDaSballo's full-sized avatar
:electron:
Always improving

Alex The Entreprenerd GalloDaSballo

:electron:
Always improving
View GitHub Profile

I was asked to recompute the savings for various findings, boasting 100+ gas per +=

This is factually incorrect, using += will save 13 gas (for some reason), when

// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.17;

import "../../lib/test.sol";
import "../../lib/Console.sol";

Report

Gas Optimizations

Issue Instances
GAS-1 Use assembly to check for address(0) 2
GAS-2 Using bools for storage incurs overhead 5

Obvious stuff

All tests are missing, no tests = guarantee that the code is unsafe

Personal Thoughts

Not sure why the controller was brought on, but am assuming is as pseudo-registry.

If you with to validate a vault you could compare vs the registry directly via registry.getProductionVaults

    /**
     * @notice Set/unset Admin Access for a given address.
     *
     * @param admin - Address of the new admin (or the one to be removed)
     * @param isEnabled - Enable/Disable Admin Access
     */
    function setAdmin(address admin, bool isEnabled) public onlyAdmin {
        require(admin != address(0), "INVALID_ADDRESS");
 _admins[admin] = isEnabled;
@GalloDaSballo
GalloDaSballo / compare.py
Last active August 6, 2022 17:38
Compare order of operations with wdiv and wmul
from random import seed
from random import random
NUMBER_OF_SIMS = 100_000
TOKEN_AMOUNT_MIN = 0
TOKEN_AMOUNT_MAX = 10 ** 26
"""
uint256 inkAtEnd = uint256(artIn).wdiv(auction_.art).wmul(auction_.ink);
"""
@GalloDaSballo
GalloDaSballo / PlaneTicket.sol
Created May 26, 2021 14:58
ERC721 Demo of Plane Tickets
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.12;
// Import OpenZeppelin ERC721
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v3.3.0/contracts/token/ERC721/ERC721.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v3.3.0/contracts/access/Ownable.sol";
// Inherit from OpenZeppelin ERC721
contract PlaneTicket is ERC721, Ownable {
// Add our own features (planId, seatId, timeStamp)
import React, { useState, useEffect } from "react";
import CopyToClipboard from "react-copy-to-clipboard";
import CopySuccess from "../static/images/icons/copy-success.svg";
import styles from "./TextInputWithCopy.module.scss";
const TextInputWithCopy = ({
label,
text,
}: {
label: string;
module.exports = {
extends: "airbnb-typescript-prettier",
parser: "@typescript-eslint/parser",
parserOptions: {
project: "./tsconfig.json",
tsconfigRootDir: __dirname,
sourceType: "module",
},
rules: {
"@typescript-eslint/no-inferrable-types": "off",