Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V2.1 #206

Merged
merged 44 commits into from
Dec 1, 2023
Merged

V2.1 #206

Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
1954b76
Rename ParameterType.AbiEncoded to ParameterType.Calldata
cristovaoth Jun 29, 2023
b064fb8
Diving Decoder tests in several files
cristovaoth Jun 29, 2023
300546d
Separate Static decoder tests
cristovaoth Jun 29, 2023
5ccfa01
Extract Decoder Dynamic tests
cristovaoth Jun 29, 2023
3702591
Introducing the concept of Sibling Type Match and Compatibility
cristovaoth Jun 30, 2023
5b26f7c
Rename AbiEncoded in comments to Calldata
cristovaoth Jun 30, 2023
f7737f5
Introducing the new AbiEncoded node. Expanding TypeEquivalent to incl…
cristovaoth Jun 30, 2023
f2ad9dd
Introduce more checker information via context
cristovaoth Jul 2, 2023
3b5fda6
Rename
cristovaoth Jul 2, 2023
540f72d
Introduce custom checker adaptar for ERC721IsOwnedByAvatar
cristovaoth Jul 3, 2023
ee40bd1
Renaming Custom Checker Name
cristovaoth Jul 4, 2023
e7b6b3b
Merge pull request #207 from gnosis/is-owned-by-avatar
jfschwarz Aug 22, 2023
682fd22
bump package version
jfschwarz Aug 30, 2023
a6c9b63
upgrade solidity
jfschwarz Aug 30, 2023
da048b0
trial to fix yarn install
jfschwarz Aug 30, 2023
4518dc5
upgrade subgraph deps
jfschwarz Aug 30, 2023
2b20431
upgrade hardhat
jfschwarz Sep 5, 2023
89c1e82
fix coverage
jfschwarz Sep 5, 2023
d2bb9ac
Remove uncessary check: it should be possible to create an allowance …
cristovaoth Sep 7, 2023
d8b571b
Add test that exposes Allowance Event bug
cristovaoth Sep 17, 2023
bd1cd96
Remove event emission from flushPrepare stage. Should only be emitted…
cristovaoth Sep 17, 2023
0ce09d8
Cleaning up Allowance field names, and their description
cristovaoth Sep 17, 2023
e6c2beb
feat: natspec on Allowance struct
auryn-macmillan Sep 18, 2023
6a7fb90
Fix docs typo
cristovaoth Sep 18, 2023
171f92c
Upgrade to OpenZeppelin v5
cristovaoth Oct 9, 2023
a76e120
Add tests to expose PRE-01M and TYG-01M
cristovaoth Oct 10, 2023
b1d2f5d
Fix PRE-01M and TYG-01M
cristovaoth Oct 10, 2023
a10c49c
Address Informational: AIO-01C
cristovaoth Oct 10, 2023
5554958
Address Informational: PCR-02C
cristovaoth Oct 10, 2023
58dd895
Fix PBR-01M
cristovaoth Oct 11, 2023
41881ea
Use latest zodiac
cristovaoth Oct 30, 2023
6c0fa1c
Don't rely on zodiac tooling function anymore
cristovaoth Oct 30, 2023
f55d00d
Saving bytecode by moving moduleOnly access modifier into authorize f…
cristovaoth Oct 30, 2023
6e8500e
Test file rename
cristovaoth Oct 30, 2023
4d851d2
Bump zodiac version
cristovaoth Oct 31, 2023
b7be7e3
Update deploy and verify tooling
cristovaoth Nov 2, 2023
76904e5
Also verify Libraries
cristovaoth Nov 4, 2023
d4b6539
Include latest audit
cristovaoth Nov 6, 2023
a19c0eb
Make operation available to CustomConditionChecker.
cristovaoth Nov 29, 2023
5e787b9
Fix type in command description
cristovaoth Nov 29, 2023
902e5f9
fix build
jfschwarz Nov 29, 2023
3d74cba
remove v1 audits
jfschwarz Dec 1, 2023
48fbb7c
add G0 audit report for v2.1
jfschwarz Dec 1, 2023
7521fdb
Update README.md
jfschwarz Dec 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions packages/evm/contracts/Decoder.sol
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,13 @@ library Decoder {
result
);
result.size += 32;
} else if (paramType == ParameterType.AbiEncoded) {
} else if (
paramType == ParameterType.Calldata ||
paramType == ParameterType.AbiEncoded
) {
__block__(
data,
location + 32 + 4,
location + 32 + (paramType == ParameterType.Calldata ? 4 : 0),
node,
node.children.length,
false,
Expand Down
44 changes: 35 additions & 9 deletions packages/evm/contracts/Integrity.sol
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ library Integrity {
if (
paramType != ParameterType.Tuple &&
paramType != ParameterType.Array &&
paramType != ParameterType.Calldata &&
paramType != ParameterType.AbiEncoded
) {
revert UnsuitableParameterType(index);
Expand Down Expand Up @@ -162,7 +163,7 @@ library Integrity {
(conditions[i].operator == Operator.EtherWithinAllowance ||
conditions[i].operator == Operator.CallWithinAllowance) &&
conditions[conditions[i].parent].paramType !=
ParameterType.AbiEncoded
ParameterType.Calldata
) {
revert UnsuitableParent(i);
}
Expand Down Expand Up @@ -201,6 +202,7 @@ library Integrity {
}
} else if (
condition.paramType == ParameterType.Tuple ||
condition.paramType == ParameterType.Calldata ||
condition.paramType == ParameterType.AbiEncoded
) {
if (childBounds.length == 0) {
Expand Down Expand Up @@ -236,7 +238,7 @@ library Integrity {
condition.paramType == ParameterType.Array) &&
childrenBounds[i].length > 1
) {
compatiblechildTypeTree(conditions, i, childrenBounds);
_compatibleSiblingTypes(conditions, i, childrenBounds);
}
}

Expand All @@ -246,32 +248,56 @@ library Integrity {
childrenBounds
);

if (typeTree.paramType != ParameterType.AbiEncoded) {
if (typeTree.paramType != ParameterType.Calldata) {
revert UnsuitableRootNode();
}
}

function compatiblechildTypeTree(
function _compatibleSiblingTypes(
ConditionFlat[] memory conditions,
uint256 index,
Topology.Bounds[] memory childrenBounds
) private pure {
uint256 start = childrenBounds[index].start;
uint256 end = childrenBounds[index].end;

bytes32 id = typeTreeId(
Topology.typeTree(conditions, start, childrenBounds)
);
for (uint256 j = start + 1; j < end; ++j) {
if (
id !=
typeTreeId(Topology.typeTree(conditions, j, childrenBounds))
!_isTypeMatch(conditions, start, j, childrenBounds) &&
!_isTypeEquivalent(conditions, start, j, childrenBounds)
) {
revert UnsuitableChildTypeTree(index);
}
}
}

function _isTypeMatch(
ConditionFlat[] memory conditions,
uint256 i,
uint256 j,
Topology.Bounds[] memory childrenBounds
) private pure returns (bool) {
return
typeTreeId(Topology.typeTree(conditions, i, childrenBounds)) ==
typeTreeId(Topology.typeTree(conditions, j, childrenBounds));
}

function _isTypeEquivalent(
ConditionFlat[] memory conditions,
uint256 i,
uint256 j,
Topology.Bounds[] memory childrenBounds
) private pure returns (bool) {
ParameterType leftParamType = Topology
.typeTree(conditions, i, childrenBounds)
.paramType;
return
(leftParamType == ParameterType.Calldata ||
jfschwarz marked this conversation as resolved.
Show resolved Hide resolved
leftParamType == ParameterType.AbiEncoded) &&
Topology.typeTree(conditions, j, childrenBounds).paramType ==
ParameterType.Dynamic;
}

function typeTreeId(
Topology.TypeTree memory node
) private pure returns (bytes32) {
Expand Down
2 changes: 1 addition & 1 deletion packages/evm/contracts/Topology.sol
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ library Topology {
} else if (
paramType == ParameterType.Dynamic ||
paramType == ParameterType.Array ||
paramType == ParameterType.AbiEncoded
paramType == ParameterType.Calldata
) {
return false;
} else {
Expand Down
3 changes: 2 additions & 1 deletion packages/evm/contracts/Types.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ enum ParameterType {
Dynamic,
Tuple,
Array,
Calldata,
AbiEncoded
}

Expand All @@ -33,7 +34,7 @@ enum Operator {
/* 04: */ _Placeholder04,
// ------------------------------------------------------------
// 05-14: COMPLEX EXPRESSIONS
// paramType: AbiEncoded / Tuple / Array,
// paramType: Calldata / AbiEncoded / Tuple / Array,
// ✅ children
// 🚫 compValue
/* 05: */ Matches,
Expand Down
2 changes: 1 addition & 1 deletion packages/evm/contracts/packers/Packer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ library Packer {
} else if (
paramType == ParameterType.Dynamic ||
paramType == ParameterType.Array ||
paramType == ParameterType.AbiEncoded
paramType == ParameterType.Calldata
) {
return false;
} else {
Expand Down
40 changes: 20 additions & 20 deletions packages/evm/test/Allowance.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe("Allowance", async () => {
await scopeFunction([
{
parent: 0,
paramType: ParameterType.AbiEncoded,
paramType: ParameterType.Calldata,
operator: Operator.Matches,
compValue: "0x",
},
Expand Down Expand Up @@ -66,7 +66,7 @@ describe("Allowance", async () => {
await scopeFunction([
{
parent: 0,
paramType: ParameterType.AbiEncoded,
paramType: ParameterType.Calldata,
operator: Operator.Matches,
compValue: "0x",
},
Expand Down Expand Up @@ -112,7 +112,7 @@ describe("Allowance", async () => {

await scopeFunction(
toConditionsFlat({
paramType: ParameterType.AbiEncoded,
paramType: ParameterType.Calldata,
operator: Operator.Matches,
compValue: "0x",
children: [
Expand Down Expand Up @@ -177,7 +177,7 @@ describe("Allowance", async () => {
await roles.connect(owner).setAllowance(allowanceKey, 1000, 0, 0, 0, 0);

const conditionsFlat = toConditionsFlat({
paramType: ParameterType.AbiEncoded,
paramType: ParameterType.Calldata,
operator: Operator.Matches,
compValue: "0x",
children: [
Expand Down Expand Up @@ -240,7 +240,7 @@ describe("Allowance", async () => {
await roles.connect(owner).setAllowance(allowanceKey, 1000, 0, 0, 0, 0);

const conditionsFlat = toConditionsFlat({
paramType: ParameterType.AbiEncoded,
paramType: ParameterType.Calldata,
operator: Operator.Matches,
compValue: "0x",
children: [
Expand Down Expand Up @@ -312,7 +312,7 @@ describe("Allowance", async () => {
await roles.connect(owner).setAllowance(allowanceKey3, 100, 0, 0, 0, 0);

const conditionsFlat = toConditionsFlat({
paramType: ParameterType.AbiEncoded,
paramType: ParameterType.Calldata,
operator: Operator.Matches,
compValue: "0x",
children: [
Expand Down Expand Up @@ -407,7 +407,7 @@ describe("Allowance", async () => {
await roles.connect(owner).setAllowance(allowanceKey2, 100, 0, 0, 0, 0);

const conditionsFlat = toConditionsFlat({
paramType: ParameterType.AbiEncoded,
paramType: ParameterType.Calldata,
operator: Operator.Matches,
compValue: "0x",
children: [
Expand Down Expand Up @@ -467,7 +467,7 @@ describe("Allowance", async () => {
await roles.connect(owner).setAllowance(allowanceKey2, 100, 0, 0, 0, 0);

const conditionsFlat = toConditionsFlat({
paramType: ParameterType.AbiEncoded,
paramType: ParameterType.Calldata,
operator: Operator.Matches,
compValue: "0x",
children: [
Expand Down Expand Up @@ -534,7 +534,7 @@ describe("Allowance", async () => {
await roles.connect(owner).setAllowance(allowanceKey2, 100, 0, 0, 0, 0);

const conditionsFlat = toConditionsFlat({
paramType: ParameterType.AbiEncoded,
paramType: ParameterType.Calldata,
operator: Operator.Matches,
compValue: "0x",
children: [
Expand Down Expand Up @@ -694,7 +694,7 @@ describe("Allowance", async () => {
[
{
parent: 0,
paramType: ParameterType.AbiEncoded,
paramType: ParameterType.Calldata,
operator: Operator.Matches,
compValue: "0x",
},
Expand All @@ -717,7 +717,7 @@ describe("Allowance", async () => {
[
{
parent: 0,
paramType: ParameterType.AbiEncoded,
paramType: ParameterType.Calldata,
operator: Operator.Matches,
compValue: "0x",
},
Expand Down Expand Up @@ -818,7 +818,7 @@ describe("Allowance", async () => {
[
{
parent: 0,
paramType: ParameterType.AbiEncoded,
paramType: ParameterType.Calldata,
operator: Operator.Matches,
compValue: "0x",
},
Expand All @@ -841,7 +841,7 @@ describe("Allowance", async () => {
[
{
parent: 0,
paramType: ParameterType.AbiEncoded,
paramType: ParameterType.Calldata,
operator: Operator.Matches,
compValue: "0x",
},
Expand Down Expand Up @@ -930,7 +930,7 @@ describe("Allowance", async () => {
[
{
parent: 0,
paramType: ParameterType.AbiEncoded,
paramType: ParameterType.Calldata,
operator: Operator.Matches,
compValue: "0x",
},
Expand All @@ -953,7 +953,7 @@ describe("Allowance", async () => {
[
{
parent: 0,
paramType: ParameterType.AbiEncoded,
paramType: ParameterType.Calldata,
operator: Operator.Matches,
compValue: "0x",
},
Expand Down Expand Up @@ -1046,7 +1046,7 @@ describe("Allowance", async () => {
[
{
parent: 0,
paramType: ParameterType.AbiEncoded,
paramType: ParameterType.Calldata,
operator: Operator.Matches,
compValue: "0x",
},
Expand Down Expand Up @@ -1080,7 +1080,7 @@ describe("Allowance", async () => {
[
{
parent: 0,
paramType: ParameterType.AbiEncoded,
paramType: ParameterType.Calldata,
operator: Operator.Matches,
compValue: "0x",
},
Expand Down Expand Up @@ -1190,7 +1190,7 @@ describe("Allowance", async () => {
[
{
parent: 0,
paramType: ParameterType.AbiEncoded,
paramType: ParameterType.Calldata,
operator: Operator.Matches,
compValue: "0x",
},
Expand All @@ -1213,7 +1213,7 @@ describe("Allowance", async () => {
[
{
parent: 0,
paramType: ParameterType.AbiEncoded,
paramType: ParameterType.Calldata,
operator: Operator.Pass,
compValue: "0x",
},
Expand All @@ -1236,7 +1236,7 @@ describe("Allowance", async () => {
[
{
parent: 0,
paramType: ParameterType.AbiEncoded,
paramType: ParameterType.Calldata,
operator: Operator.Matches,
compValue: "0x",
},
Expand Down
2 changes: 1 addition & 1 deletion packages/evm/test/EmitsEvent.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ describe("EmitsEvent", async () => {
[
{
parent: 0,
paramType: ParameterType.AbiEncoded,
paramType: ParameterType.Calldata,
operator: Operator.Matches,
compValue: "0x",
},
Expand Down
Loading