Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

Flow #452

Merged
merged 137 commits into from Oct 18, 2022
Merged

Flow #452

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
137 commits
Select commit Hold shift + click to select a range
a999672
wip on flow
thedavidmeister Aug 27, 2022
68d4b0d
wip on flow stack
thedavidmeister Aug 27, 2022
8868d1d
flow wip
thedavidmeister Aug 28, 2022
59cc29b
fix flow contract
thedavidmeister Aug 28, 2022
cefe1c7
flow erc20 contract
thedavidmeister Aug 29, 2022
eb49a8b
lint
thedavidmeister Aug 29, 2022
e1ca91a
flow erc 721
thedavidmeister Aug 30, 2022
f391a6c
flow erc1155
thedavidmeister Aug 31, 2022
ee68505
flow factories
thedavidmeister Aug 31, 2022
1fe4478
remove EmissionsERC20 tests + utils
marcusnewton Sep 1, 2022
b934606
WIP fix tests
marcusnewton Sep 1, 2022
d0616cc
update test errors
marcusnewton Sep 1, 2022
8a57c9a
Merge branch '2022-08-26-emissions-mores-stuff' of github.com:beehive…
thedavidmeister Sep 1, 2022
a0feb70
fix tests
thedavidmeister Sep 1, 2022
1c8ee40
fix ob tests
marcusnewton Sep 2, 2022
376f2a7
WIP Merge branch 'develop' into 2022-08-26-emissions-mores-stuff
marcusnewton Sep 2, 2022
0f5bc2e
fix merge
thedavidmeister Sep 2, 2022
4bf01b9
remove remaining EmissionsERC20 tests
marcusnewton Sep 5, 2022
29a2364
WIP test sentinel
marcusnewton Sep 5, 2022
ad8ea61
sentinel tests
marcusnewton Sep 5, 2022
8d2815d
WIP Flow tests
marcusnewton Sep 6, 2022
cc45cd1
test Flow.previewFlow() with native IO
marcusnewton Sep 6, 2022
ef0cb6e
update test
marcusnewton Sep 6, 2022
fb095ec
fix tests
thedavidmeister Sep 12, 2022
8d259fc
prettier
thedavidmeister Sep 12, 2022
2a771d2
push failing tests
marcusnewton Sep 13, 2022
b8967ea
WIP test stackToFlow
marcusnewton Sep 14, 2022
a64ccdd
test successive consumeSentinel calls
marcusnewton Sep 14, 2022
83e2f62
fix flow test
thedavidmeister Sep 14, 2022
75525d3
lint
marcusnewton Sep 15, 2022
b7126f2
fix tests
marcusnewton Sep 15, 2022
e41a924
rename test file
marcusnewton Sep 15, 2022
46f71b2
WIP test flow ERC20
marcusnewton Sep 15, 2022
197f2bd
workaround for eval not writing to memory
thedavidmeister Sep 15, 2022
cc7dd5f
Merge branch '2022-08-26-emissions-mores-stuff' of github.com:beehive…
thedavidmeister Sep 15, 2022
8515e27
memory safe
thedavidmeister Sep 15, 2022
022adea
remove console log
thedavidmeister Sep 15, 2022
c967e0d
disable optimiser
thedavidmeister Sep 15, 2022
c0c20e9
add console log
thedavidmeister Sep 15, 2022
adfd75f
WIP test flow transfers
marcusnewton Sep 16, 2022
f9897fc
test Flow payable
marcusnewton Sep 16, 2022
1788c20
WIP Flow tests
marcusnewton Sep 16, 2022
1a38d98
payable flow
thedavidmeister Sep 16, 2022
bb78f6b
Merge branch '2022-08-26-emissions-mores-stuff' of github.com:beehive…
thedavidmeister Sep 16, 2022
6a175c4
receive function on flow
thedavidmeister Sep 16, 2022
4771a22
fix compilation
thedavidmeister Sep 16, 2022
1220cf5
debug deserialize pointer
thedavidmeister Sep 18, 2022
565dea0
debug pure and view state op
thedavidmeister Sep 18, 2022
c1689fd
debug console log
thedavidmeister Sep 18, 2022
1f6860e
debug non memory safe state
thedavidmeister Sep 18, 2022
4c6764e
hack
thedavidmeister Sep 18, 2022
cad962b
test native token flow
marcusnewton Sep 19, 2022
6c57a34
WIP test Flow.sol ERC20<->ERC20 flow
marcusnewton Sep 19, 2022
429a477
test Flow token transfer approval
marcusnewton Sep 20, 2022
26961cd
WIP previewFlow tests
marcusnewton Sep 20, 2022
814a8be
implement 1155 receiver for flow
thedavidmeister Sep 20, 2022
c580924
Merge branch '2022-08-26-emissions-mores-stuff' of github.com:beehive…
thedavidmeister Sep 20, 2022
9d5ae8e
fix tests
thedavidmeister Sep 20, 2022
88cbd05
cheaper workaround for eval
thedavidmeister Sep 21, 2022
269b15a
WIP fix 721 sentinels
marcusnewton Sep 21, 2022
4d89dca
workaround memory pointer
thedavidmeister Sep 21, 2022
86061b0
Merge branch '2022-08-26-emissions-mores-stuff' of github.com:beehive…
thedavidmeister Sep 21, 2022
99a5aeb
integrity check for flows
thedavidmeister Sep 21, 2022
0d031f3
lint
thedavidmeister Sep 21, 2022
af80182
native token flows
marcusnewton Sep 21, 2022
03c75e1
Fixed flow.ts tests
SocioDroid Sep 21, 2022
3b115f0
flows list
thedavidmeister Sep 21, 2022
8802199
Merge branch '2022-08-26-emissions-mores-stuff' of github.com:beehive…
thedavidmeister Sep 21, 2022
4414120
failing flow.ts tests
marcusnewton Sep 23, 2022
86c0556
add event for saving vm state
thedavidmeister Sep 23, 2022
6edadf6
better error handling
thedavidmeister Sep 23, 2022
b2c1cb1
lint
marcusnewton Sep 23, 2022
1fcf5e1
WIP test with flow id
marcusnewton Sep 23, 2022
962d96e
fix flow source index
thedavidmeister Sep 23, 2022
5c240b7
ids
marcusnewton Sep 23, 2022
388fa92
add 721 holder to flow
thedavidmeister Sep 23, 2022
06c1863
test flowERC20 flows
marcusnewton Sep 23, 2022
12f979f
lint
thedavidmeister Sep 23, 2022
7774783
Merge branch '2022-08-26-emissions-mores-stuff' of github.com:beehive…
thedavidmeister Sep 23, 2022
14a2463
lint
marcusnewton Sep 23, 2022
ae21607
min stack handling for flows
thedavidmeister Sep 23, 2022
8095c4f
Merge branch '2022-08-26-emissions-mores-stuff' of github.com:beehive…
thedavidmeister Sep 23, 2022
474794e
mint burn test
marcusnewton Sep 23, 2022
c425428
fix tests
thedavidmeister Sep 23, 2022
42e2648
fix tests
thedavidmeister Sep 24, 2022
8b8872b
lint
marcusnewton Sep 26, 2022
b0251bf
fix tests
marcusnewton Sep 26, 2022
61af6d7
sale price test
marcusnewton Sep 27, 2022
4eb0389
fix tests
thedavidmeister Sep 27, 2022
0542745
fix missing mint burn FlowERC20
marcusnewton Sep 27, 2022
f0f76e5
fix previewFlow tests
marcusnewton Sep 27, 2022
1827984
guard against core source for flow
thedavidmeister Sep 27, 2022
fa3ea52
Merge branch '2022-08-26-emissions-mores-stuff' of github.com:beehive…
thedavidmeister Sep 27, 2022
0273ac0
fix tests
thedavidmeister Sep 27, 2022
7e4b523
flow tests, WIP payable flows for FlowERCX
marcusnewton Sep 28, 2022
e60853c
fix unsupported reentrancy guard usage
marcusnewton Sep 29, 2022
0295e4d
fix payable flow
marcusnewton Sep 30, 2022
351313d
fix SaleStorage slots
marcusnewton Sep 30, 2022
25cdc64
test minting burning flows
marcusnewton Sep 30, 2022
78c8784
test transferPreflight hook
marcusnewton Sep 30, 2022
e7db40f
fix optimizer in flow
thedavidmeister Oct 2, 2022
4b9b6f5
uncomment test
marcusnewton Sep 30, 2022
e79c87e
fix Flow.sol tests
marcusnewton Oct 3, 2022
c8f5de0
fix Flow io tests
marcusnewton Oct 3, 2022
bc76ec2
fix tests
thedavidmeister Oct 3, 2022
6c8e055
fix tests
marcusnewton Oct 4, 2022
6b2389e
fix erc721 flow tests
marcusnewton Oct 4, 2022
af06432
add flow erc1155 tests
marcusnewton Oct 4, 2022
2690b13
add balanceOf checks in test
marcusnewton Oct 4, 2022
8f27dd5
fix 1155
thedavidmeister Oct 4, 2022
90f2e66
refactor flow to transfer list
thedavidmeister Oct 5, 2022
b06412f
extended flow logic
thedavidmeister Oct 5, 2022
2436f21
flow.ts fix for extended flow logic
SocioDroid Oct 8, 2022
0cb0a7d
previewFlow refactor wip
SocioDroid Oct 8, 2022
fbea278
previewFlow.ts refactoring
SocioDroid Oct 9, 2022
308387e
lint
marcusnewton Oct 10, 2022
74afe1b
fix tests
thedavidmeister Oct 10, 2022
d973c67
FlowERC20 tests refactor
SocioDroid Oct 10, 2022
4e9446a
FlowERC721 refactoring done, FlowERC1155 wip
SocioDroid Oct 11, 2022
fd07eb4
Struct order fix Flow/previewFlow.ts
SocioDroid Oct 11, 2022
933b002
compareStructs fix
SocioDroid Oct 11, 2022
ff16c16
FlowERC1155 fix
SocioDroid Oct 12, 2022
a3cb092
lint
marcusnewton Oct 13, 2022
cc1d719
lint
marcusnewton Oct 13, 2022
7d1bd1e
fix tests
marcusnewton Oct 13, 2022
73f192a
lint
marcusnewton Oct 13, 2022
4b701e1
fix mint/burn OOMs in tests
marcusnewton Oct 13, 2022
066c736
fix expected rebase ratio
marcusnewton Oct 13, 2022
f4b3f3f
test fix
SocioDroid Oct 13, 2022
ea8771e
test fixes
SocioDroid Oct 13, 2022
fe51c21
test FlowERC20 rebase ratio
marcusnewton Oct 14, 2022
15a37f0
test FlowERC1155 rebase ratio
marcusnewton Oct 14, 2022
e1fdbb7
remove rebasing
thedavidmeister Oct 17, 2022
0211d68
remove rebasing
thedavidmeister Oct 17, 2022
1adddc7
fix tests
marcusnewton Oct 18, 2022
9551b10
only use can transfer on non-mint non-burn
thedavidmeister Oct 18, 2022
df7134b
fix tests
thedavidmeister Oct 18, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .solhint.json
Expand Up @@ -2,7 +2,7 @@
"extends": "solhint:recommended",
"rules": {
"max-line-length": "off",
"compiler-version": ["error", "=0.8.15 || ^0.8.0"],
"compiler-version": ["error", "=0.8.17 || ^0.8.0"],
"no-inline-assembly": "off",
"not-rely-on-time": "off",
"no-empty-blocks": "off",
Expand Down
3 changes: 2 additions & 1 deletion .vscode/settings.json
Expand Up @@ -2,5 +2,6 @@
"nixEnvSelector.suggestion": false,
"solidity.compileUsingRemoteVersion": "v0.8.15+commit.e14f2714",
"solidity.compileUsingLocalVersion": "v0.8.15+commit.e14f2714",
"nixEnvSelector.nixFile": "${workspaceRoot}/shell.nix"
"nixEnvSelector.nixFile": "${workspaceRoot}/shell.nix",
"editor.rulers": [80]
}
48 changes: 48 additions & 0 deletions contracts/array/LibUint256Array.sol
Expand Up @@ -37,6 +37,54 @@ library LibUint256Array {
return array_;
}

function arrayFrom(
uint256 a_,
uint256 b_,
uint256 c_
) internal pure returns (uint256[] memory) {
uint256[] memory array_ = new uint256[](3);
assembly ("memory-safe") {
mstore(add(array_, 0x20), a_)
mstore(add(array_, 0x40), b_)
mstore(add(array_, 0x60), c_)
}
return array_;
}

function arrayFrom(
uint256 a_,
uint256 b_,
uint256 c_,
uint256 d_
) internal pure returns (uint256[] memory) {
uint256[] memory array_ = new uint256[](4);
assembly ("memory-safe") {
mstore(add(array_, 0x20), a_)
mstore(add(array_, 0x40), b_)
mstore(add(array_, 0x60), c_)
mstore(add(array_, 0x80), d_)
}
return array_;
}

function arrayFrom(
uint256 a_,
uint256 b_,
uint256 c_,
uint256 d_,
uint256 e_
) internal pure returns (uint256[] memory) {
uint256[] memory array_ = new uint256[](5);
assembly ("memory-safe") {
mstore(add(array_, 0x20), a_)
mstore(add(array_, 0x40), b_)
mstore(add(array_, 0x60), c_)
mstore(add(array_, 0x80), d_)
mstore(add(array_, 0xA0), e_)
}
return array_;
}

/// Building arrays from literal components is a common task that introduces
/// boilerplate that is either inefficient or error prone.
/// @param a_ The head of the new array.
Expand Down
158 changes: 0 additions & 158 deletions contracts/claim/EmissionsERC20.sol

This file was deleted.

26 changes: 0 additions & 26 deletions contracts/claim/IClaim.sol

This file was deleted.

2 changes: 1 addition & 1 deletion contracts/debug/LibDebug.sol
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: CAL
pragma solidity =0.8.15;
pragma solidity =0.8.17;

import "hardhat/console.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/escrow/RedeemableERC20ClaimEscrow.sol
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: CAL
pragma solidity =0.8.15;
pragma solidity =0.8.17;

import {RedeemableERC20} from "../redeemableERC20/RedeemableERC20.sol";
import {MathUpgradeable as Math} from "@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/escrow/SaleEscrow.sol
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: CAL
pragma solidity =0.8.15;
pragma solidity =0.8.17;

import "../sale/ISale.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/factory/Factory.sol
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: CAL
pragma solidity =0.8.15;
pragma solidity =0.8.17;

import {IFactory} from "./IFactory.sol";
import {ReentrancyGuardUpgradeable as ReentrancyGuard} from "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/factory/FactoryCurator.sol
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: CAL
pragma solidity =0.8.15;
pragma solidity =0.8.17;

import "./IFactory.sol";
import {IERC20Upgradeable as IERC20} from "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
Expand Down
62 changes: 62 additions & 0 deletions contracts/flow/basic/Flow.sol
@@ -0,0 +1,62 @@
// SPDX-License-Identifier: CAL
pragma solidity =0.8.17;

import "../vm/FlowVM.sol";
import "../libraries/LibFlow.sol";
import {ReentrancyGuardUpgradeable as ReentrancyGuard} from "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";

struct FlowConfig {
// This is NOT USED by `Flow` but removing it causes the compiler to fail to
// compile the code with optimizations. Removing this seems to cause the EVM
// stack to overflow.
StateConfig stateConfig;
StateConfig[] flows;
}

contract Flow is ReentrancyGuard, FlowVM {
using LibVMState for VMState;

event Initialize(address sender, FlowConfig config);

/// flow index => id => time
mapping(SourceIndex => mapping(uint256 => uint256)) private _flows;

constructor(address vmIntegrity_) FlowVM(vmIntegrity_) {}

/// @param config_ allowed flows set at initialization.
function initialize(FlowConfig calldata config_) external initializer {
__FlowVM_init(config_.flows, LibUint256Array.arrayFrom(1, 4));
emit Initialize(msg.sender, config_);
}

function _previewFlow(VMState memory state_)
internal
view
returns (FlowTransfer memory)
{
StackTop stackTop_ = flowStack(state_);
return LibFlow.stackToFlow(state_.stackBottom, stackTop_);
}

function previewFlow(uint256 flow_, uint256 id_)
external
view
virtual
returns (FlowTransfer memory)
{
return _previewFlow(_loadFlowState(flow_, id_));
}

function flow(uint256 flow_, uint256 id_)
external
payable
virtual
nonReentrant
returns (FlowTransfer memory)
{
VMState memory state_ = _loadFlowState(flow_, id_);
FlowTransfer memory flowTransfer_ = _previewFlow(state_);
registerFlowTime(IdempotentFlag.wrap(state_.scratch), flow_, id_);
return LibFlow.flow(flowTransfer_, address(this), payable(msg.sender));
}
}