Skip to content

Instantly share code, notes, and snippets.

@tcoulter
tcoulter / fmulfdiv.sol
Created October 20, 2021 06:07
Sweet sweet overflow protection in Yul (almost assembly)
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
contract Test {
function fmul(
uint256 x,
uint256 y,
uint256 baseUnit
) public pure returns (uint256 z) {
@tcoulter
tcoulter / fmulfdiv
Created October 20, 2021 06:06
Sweet sweet overflow checking in Yul (almost assembly)
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
contract Test {
function fmul(
uint256 x,
uint256 y,
uint256 baseUnit
) public pure returns (uint256 z) {

Keybase proof

I hereby claim:

  • I am tcoulter on github.
  • I am tcoulter (https://keybase.io/tcoulter) on keybase.
  • I have a public key whose fingerprint is 95FE 0223 BC6D C1A5 1F70 31F2 6743 D44B B5B3 9962

To claim this, I am signing this object:

* Micheal Jackson / Jackson 5
* Cake by the Ocean - SWAAY
* Timberlake
* Signed, Sealed, Delivered, I'm yours - Stevie Wonder
* Classic - MKTO
* Shake It Off - Tay Tay
* Love you like a love song - Selena Gomez
* Somebody To Love - Queen
* Somewhere over the rainbow - Israel K.
* Call Me Maybe - CRJ
I0724 14:13:28.503609 32419 worker.go:503] commit new work on block 980702 with 43 txs & 0 uncles. Took 1.898667859s
I0724 14:13:31.576241 32419 chain_manager.go:656] imported 1 block(s) (0 queued 0 ignored) including 43 txs in 1.30471223s. #980702 [24108463 / 24108463]
I0724 14:13:31.580755 32419 chain_manager.go:656] imported 0 block(s) (0 queued 1 ignored) including 0 txs in 4.446447ms. #980701 [fd705139 / fd705139]
I0724 14:13:31.982940 32419 worker.go:503] commit new work on block 980703 with 32 txs & 0 uncles. Took 406.54895ms
I0724 14:13:39.630266 32419 chain_manager.go:656] imported 0 block(s) (0 queued 1 ignored) including 0 txs in 7.604206ms. #980702 [24108463 / 24108463]
I0724 14:13:47.319476 32419 chain_manager.go:656] imported 1 block(s) (0 queued 0 ignored) including 35 txs in 1.152045376s. #980703 [60b79085 / 60b79085]
I0724 14:13:47.323508 32419 chain_manager.go:656] imported 0 block(s) (0 queued 1 ignored) including 0 txs in 3.984976ms. #980702 [24108463 / 24108463]
I0724 14:13:
I0723 21:16:54.163520 12805 chain_manager.go:656] imported 1 block(s) (0 queued 0 ignored) including 0 txs in 4.986954ms. #975229 [616acd42 / 616acd42]
I0723 21:16:54.169712 12805 worker.go:503] commit new work on block 975230 with 0 txs & 0 uncles. Took 6.032478ms
I0723 21:16:54.793651 12805 chain_manager.go:656] imported 0 block(s) (0 queued 2 ignored) including 0 txs in 6.315455ms. #975229 [ea6fafde / 616acd42]
I0723 21:17:06.575332 12805 chain_manager.go:656] imported 1 block(s) (0 queued 0 ignored) including 0 txs in 5.714357ms. #975230 [0c2bcff1 / 0c2bcff1]
I0723 21:17:06.750051 12805 worker.go:503] commit new work on block 975231 with 15 txs & 0 uncles. Took 174.586859ms
I0723 21:17:07.379859 12805 chain_manager.go:656] imported 0 block(s) (0 queued 2 ignored) including 0 txs in 4.999469ms. #975230 [616acd42 / 0c2bcff1]
I0723 21:17:27.861276 12805 chain_manager.go:656] imported 1 block(s) (0 queued 0 ignored) including 17 txs in 226.932169ms. #975231 [42fca884 / 42fca884]
I0723 21:17:27.8
desktop@steamos:~$ ./mygeth
I0722 13:58:38.162138 10855 backend.go:288] Protocol Versions: [61 60], Network Id: 0
I0722 13:58:38.167376 10855 backend.go:317] Blockchain DB Version: 3
I0722 13:58:38.174356 10855 chain_manager.go:257] Last block (#962262) 8aa576760b3353f2f295b8f7b77b6bdb19263281cf200ae2d1d1e80147cef4ac TD=9980022322110980
I0722 13:58:39.330708 10855 cmd.go:122] Starting Geth/v0.9.39/linux/go1.4.2
I0722 13:58:39.330985 10855 server.go:311] Starting Server
I0722 13:58:40.197929 10855 udp.go:205] Listening, enode://db4a0c2622f93c6ccd246a118cf668afa8fa6c71608dec9d321fe3f77bdd5ec919e93ba2df41f0adc9a1906c0d2a98796a0380ec22da42659b2ed3a2c4ab22ae@50.136.197.236:30303
I0722 13:58:40.200362 10855 backend.go:542] Server started
Unlocking account 0 | Attempt 1/3
Passphrase: I0722 13:58:40.200931 10855 server.go:548] Listening on [::]:30303
desktop@steamos:~/workspace/godev/src/github.com/ethereum/go-ethereum$ ~/mygeth
I0722 10:06:09.229737 30695 backend.go:288] Protocol Versions: [61 60], Network Id: 0
I0722 10:06:09.231227 30695 backend.go:317] Blockchain DB Version: 3
I0722 10:06:09.236881 30695 chain_manager.go:257] Last block (#960903) cf51c99a37cb9a6d5b46e6c00eaa64403a9fa291b14861dc6ac08f71f9d7b3e7 TD=9958129842950075
I0722 10:06:09.544340 30695 cmd.go:122] Starting Geth/v0.9.39/linux/go1.4.2
I0722 10:06:09.544598 30695 server.go:311] Starting Server
I0722 10:06:09.786974 30695 udp.go:205] Listening, enode://db4a0c2622f93c6ccd246a118cf668afa8fa6c71608dec9d321fe3f77bdd5ec919e93ba2df41f0adc9a1906c0d2a98796a0380ec22da42659b2ed3a2c4ab22ae@50.136.197.236:30303
I0722 10:06:09.787374 30695 server.go:548] Listening on [::]:30303
I0722 10:06:09.788427 30695 backend.go:542] Server started
Unlocking account 0 | Attempt 1/3
desktop@steamos:~/workspace/godev/src/github.com/ethereum/go-ethereum$ ~/mygeth
I0722 10:06:09.229737 30695 backend.go:288] Protocol Versions: [61 60], Network Id: 0
I0722 10:06:09.231227 30695 backend.go:317] Blockchain DB Version: 3
I0722 10:06:09.236881 30695 chain_manager.go:257] Last block (#960903) cf51c99a37cb9a6d5b46e6c00eaa64403a9fa291b14861dc6ac08f71f9d7b3e7 TD=9958129842950075
I0722 10:06:09.544340 30695 cmd.go:122] Starting Geth/v0.9.39/linux/go1.4.2
I0722 10:06:09.544598 30695 server.go:311] Starting Server
I0722 10:06:09.786974 30695 udp.go:205] Listening, enode://db4a0c2622f93c6ccd246a118cf668afa8fa6c71608dec9d321fe3f77bdd5ec919e93ba2df41f0adc9a1906c0d2a98796a0380ec22da42659b2ed3a2c4ab22ae@50.136.197.236:30303
I0722 10:06:09.787374 30695 server.go:548] Listening on [::]:30303
I0722 10:06:09.788427 30695 backend.go:542] Server started
Unlocking account 0 | Attempt 1/3
I0722 09:02:11.036811 21265 chain_manager.go:678] imported 1 block(s) (0 queued 0 ignored) including 99 txs in 654.075541ms. #960901 [1d87fcff / 1d87fcff]
I0722 09:02:11.041045 21265 chain_manager.go:678] imported 0 block(s) (0 queued 1 ignored) including 0 txs in 4.122032ms. #960900 [8b14875b / 8b14875b]
I0722 09:02:11.107641 21265 worker.go:503] commit new work on block 960902 with 28 txs & 1 uncles. Took 69.535098ms
I0722 09:02:11.606881 21265 chain_manager.go:678] imported 1 block(s) (0 queued 0 ignored) including 99 txs in 565.775408ms. #960901 [363dabc5 / 363dabc5]
I0722 09:02:12.055733 21265 chain_manager.go:678] imported 1 block(s) (0 queued 0 ignored) including 10 txs in 40.586279ms. #960902 [c21f6cfe / c21f6cfe]
I0722 09:02:12.068629 21265 chain_manager.go:678] imported 0 block(s) (0 queued 1 ignored) including 0 txs in 12.83329ms. #960900 [8b14875b / 8b14875b]
I0722 09:02:12.083467 21265 worker.go:503] commit new work on block 960903 with 18 txs & 1 uncles. Took 14.895461ms
I0722 09:0