Skip to content

Commit

Permalink
Merge pull request #12 from ritual-net/dev
Browse files Browse the repository at this point in the history
aa/release: Cut Infernet `v1.0.0` release, merge `dev` into `main`
  • Loading branch information
anish-ritual authored Jun 5, 2024
2 parents 2d04a7f + d8ad8d8 commit 62955fe
Show file tree
Hide file tree
Showing 53 changed files with 5,219 additions and 1,680 deletions.
161 changes: 103 additions & 58 deletions .gas-snapshot
Original file line number Diff line number Diff line change
@@ -1,58 +1,103 @@
BalanceScaleTest:testE2E() (gas: 942571)
CoordinatorCallbackTest:testCallbackGasLimitIsApproximatelyCorrect() (gas: 301195)
CoordinatorCallbackTest:testCanCreateCallback() (gas: 142641)
CoordinatorCallbackTest:testCanDeliverCallbackResponse() (gas: 331677)
CoordinatorCallbackTest:testCanDeliverCallbackResponseOnceAcrossTwoNodes() (gas: 505224)
CoordinatorCallbackTest:testCannotDeliverCallbackMaxGasPriceTooLow() (gas: 139387)
CoordinatorCallbackTest:testCannotDeliverCallbackResponseFromSameNodeTwice() (gas: 312437)
CoordinatorCallbackTest:testCannotDeliverCallbackWithInsufficientGasLimit() (gas: 304859)
CoordinatorCallbackTest:testFuzzCannotDeliverCallbackIfIncorrectInterval(uint32) (runs: 256, μ: 139312, ~: 139312)
CoordinatorGeneralTest:testCannotBeReassignedSubscriptionID() (gas: 453861)
CoordinatorGeneralTest:testCannotReceiveResponseFromNonCoordinator() (gas: 11012)
CoordinatorSubscriptionTest:testCanCancelFulfilledSubscription() (gas: 230898)
CoordinatorSubscriptionTest:testCanCancelSubscription() (gas: 87979)
CoordinatorSubscriptionTest:testCanReadContainerInputs() (gas: 13394)
CoordinatorSubscriptionTest:testCannotCancelCancelledSubscription() (gas: 88548)
CoordinatorSubscriptionTest:testCannotCancelNonExistentSubscription() (gas: 14075)
CoordinatorSubscriptionTest:testCannotCancelUnownedSubscription() (gas: 135656)
CoordinatorSubscriptionTest:testCannotDeliverMaxRedundancyResponse() (gas: 452793)
CoordinatorSubscriptionTest:testCannotDeliverResponseDelayed() (gas: 121768)
CoordinatorSubscriptionTest:testCannotDeliverResponseEarly() (gas: 121613)
CoordinatorSubscriptionTest:testCannotDeliverResponseForCompletedSubscription() (gas: 468557)
CoordinatorSubscriptionTest:testCannotDeliverResponseForNonExistentSubscription() (gas: 22024)
CoordinatorSubscriptionTest:testCannotDeliverResponseFromNonNode() (gas: 111969)
CoordinatorSubscriptionTest:testCannotDeliverResponseIfAlreadyDeliveredInCurrentInterval() (gas: 290576)
CoordinatorSubscriptionTest:testCannotDeliverResponseIncorrectInterval() (gas: 289704)
CoordinatorSubscriptionTest:testCannotDeliverResponseNonActiveSubscription() (gas: 131838)
CoordinatorSubscriptionTest:testCannotDeliverSubscriptionWithInsufficientGasLimit() (gas: 282230)
CoordinatorSubscriptionTest:testFuzzSubscriptionIntervalsAreCorrect(uint32,uint32,uint32) (runs: 256, μ: 21641, ~: 14634)
CoordinatorSubscriptionTest:testSubscriptionGasLimitIsApproximatelyCorrect() (gas: 278328)
EIP712CoordinatorTest:testCanAtomicCreateSubscriptionAndDeliverOutput() (gas: 368256)
EIP712CoordinatorTest:testCanCancelSubscriptionCreatedViaDelegate() (gas: 149801)
EIP712CoordinatorTest:testCanCreateDelegatedSubscriptionWithUnorderedNonces() (gas: 336739)
EIP712CoordinatorTest:testCanCreateNewSubscriptionViaEIP712() (gas: 179021)
EIP712CoordinatorTest:testCanDelegatedDeliverComputeResponseForExistingSubscription() (gas: 509659)
EIP712CoordinatorTest:testCanGetExistingSubscriptionViaEIP712() (gas: 186650)
EIP712CoordinatorTest:testCanUseExistingDelegatedSubscriptionFromOldSigner() (gas: 170617)
EIP712CoordinatorTest:testCannotAtomicDeliverOutputForCompletedSubscription() (gas: 368987)
EIP712CoordinatorTest:testCannotCreateDelegatedSubscriptionWhereNonceReused() (gas: 207700)
EIP712CoordinatorTest:testCannotCreateDelegatedSubscriptionWhereSignatureExpired() (gas: 32448)
EIP712CoordinatorTest:testCannotDeliverEIP712SubscriptionWhereGasLimitTooLow() (gas: 338884)
EIP712CoordinatorTest:testCannotUseValidDelegatedSubscriptionFromOldSigner() (gas: 48168)
EIP712CoordinatorTest:testDeliverReducedGasCostSubscriptionCachedSubscription() (gas: 501991)
EIP712CoordinatorTest:testFuzzCannotCreateDelegatedSubscriptionWhereSignatureMismatch(uint256) (runs: 256, μ: 43249, ~: 43249)
ManagerTest:testActivateNode() (gas: 54843)
ManagerTest:testActivateNodeMustReadministerCooldownIfReactivating() (gas: 86779)
ManagerTest:testCanCallOnlyActiveNodeFnAsActiveNode() (gas: 48772)
ManagerTest:testCanDeactivateActiveNode() (gas: 40439)
ManagerTest:testCanDeactivateInactiveNode() (gas: 26121)
ManagerTest:testCanDeactivateRegisteredNode() (gas: 36586)
ManagerTest:testCanRegisterInactiveNode() (gas: 61447)
ManagerTest:testCanRegisterInactiveNodeViaProxy() (gas: 59598)
ManagerTest:testCannnotCallOnlyActiveNodeFnAsInactiveNode() (gas: 16139)
ManagerTest:testCannotActivateInactiveNode() (gas: 16594)
ManagerTest:testCannotCallOnlyActiveNodeFnAsRegisteredNode() (gas: 40810)
ManagerTest:testCannotReactivateNode() (gas: 49335)
ManagerTest:testCannotRegisterActiveNode() (gas: 49924)
ManagerTest:testCannotReregisterNode() (gas: 43382)
ManagerTest:testFuzzCannotActivateNodeBeforeCooldownElapsed(uint256) (runs: 256, μ: 45226, ~: 45226)
BalanceScaleTest:testFuzzE2E(bool) (runs: 256, μ: 1809689, ~: 861479)
CoordinatedTest:testFuzzCoordinatorCanCallPermissionedFunction(address) (runs: 256, μ: 260428, ~: 260428)
CoordinatedTest:testFuzzNonCoordinatorCannotCallPermissionedFunction(address) (runs: 256, μ: 6550614, ~: 6550614)
CoordinatorAllowlistSubscriptionTest:testCanDeliverResponseFromAllowedNode() (gas: 306231)
CoordinatorAllowlistSubscriptionTest:testCanDeliverResponseFromAllowedNodeAcrossIntervals() (gas: 480610)
CoordinatorAllowlistSubscriptionTest:testCanDeliverResponseFromNodeInAllowedIntervalsOnly() (gas: 1345112)
CoordinatorAllowlistSubscriptionTest:testFuzzAllowlistCanBeUpdated(address[],bool[]) (runs: 256, μ: 2505856, ~: 1646814)
CoordinatorAllowlistSubscriptionTest:testFuzzCannotDeliverResponseFromUnallowedNode(address) (runs: 256, μ: 186266, ~: 186266)
CoordinatorAllowlistSubscriptionTest:testInboxIsNotUpdatedOnUnallowedNodeFailedResponseDelivery() (gas: 360661)
CoordinatorAllowlistSubscriptionTest:testInitialAllowlistCorrectlySet() (gas: 20433)
CoordinatorCallbackTest:testCallbackDeliveryDoesNotStoreDataInInbox() (gas: 340392)
CoordinatorCallbackTest:testCanCreateCallback() (gas: 142471)
CoordinatorCallbackTest:testCanDeliverCallbackResponse() (gas: 352552)
CoordinatorCallbackTest:testCanDeliverCallbackResponseOnceAcrossTwoNodes() (gas: 521754)
CoordinatorCallbackTest:testCannotDeliverCallbackResponseFromSameNodeTwice() (gas: 337156)
CoordinatorCallbackTest:testFuzzCannotDeliverCallbackIfIncorrectInterval(uint32) (runs: 256, μ: 160915, ~: 160915)
CoordinatorEagerPaymentNoProofTest:testSubscriptionCanBeFulfilledAcrossIntervalsWithERC20Payment() (gas: 2173404)
CoordinatorEagerPaymentNoProofTest:testSubscriptionCanBeFulfilledWithERC20() (gas: 2035968)
CoordinatorEagerPaymentNoProofTest:testSubscriptionCanBeFulfilledWithETHPayment() (gas: 1904869)
CoordinatorEagerPaymentNoProofTest:testSubscriptionCannotBeFulfilledIfSpenderNoAllowance() (gas: 1759984)
CoordinatorEagerPaymentNoProofTest:testSubscriptionCannotBeFulfilledIfSpenderPartialAllowance() (gas: 1791785)
CoordinatorEagerPaymentNoProofTest:testSubscriptionCannotBeFulfilledWithInvalidWalletProvenance() (gas: 1749770)
CoordinatorEagerPaymentProofTest:testSubscriptionCannotBeFulfilledIfNodeNotApprovedToSpendFromWallet() (gas: 2041768)
CoordinatorEagerPaymentProofTest:testSubscriptionCannotBeFulfilledIfNodeWalletHasInsufficientFundsForEscrow() (gas: 2035849)
CoordinatorEagerPaymentProofTest:testSubscriptionFulfillmentWithEagerProofValidatingFalse() (gas: 2043859)
CoordinatorEagerPaymentProofTest:testSubscriptionFulfillmentWithEagerProofValidatingTrue() (gas: 2216007)
CoordinatorEagerSubscriptionTest:testEagerSubscriptionDeliveryDoesNotStoreOutputsInInbox() (gas: 335343)
CoordinatorGeneralTest:testCannotBeReassignedSubscriptionID() (gas: 593510)
CoordinatorGeneralTest:testCannotReceiveResponseFromNonCoordinator() (gas: 11090)
CoordinatorLazyPaymentNoProofTest:testLazySubscriptionCanBeFulfilledWithPayment() (gas: 2080866)
CoordinatorLazyPaymentProofTest:testLazySubscriptionCanBeFulfilledWhenProofWindowExpires() (gas: 2048061)
CoordinatorLazyPaymentProofTest:testLazySubscriptionWithProofCanBeFulfilledWhenNodeIsSlashedInTime() (gas: 2046492)
CoordinatorLazyPaymentProofTest:testLazySubscriptionWithProofCanBeFulfilledWhenProofValidatesCorrectlyInTime() (gas: 2046768)
CoordinatorLazyPaymentProofTest:testMultipleSubscriptionsCanBeFullfilledInParallelToLazyProof() (gas: 2395441)
CoordinatorLazyPaymentProofTest:testPaymentCanBeFulfilledEvenWhenSubscriptionIsCancelled() (gas: 2050985)
CoordinatorLazyPaymentProofTest:testSubscriptionCannotBeFinalizedWithIncorrectProofValidation() (gas: 2085727)
CoordinatorLazySubscriptionTest:testCanDeliverLazyAndEagerSubscriptionToSameContract() (gas: 713794)
CoordinatorLazySubscriptionTest:testCanDeliverLazySubscriptionsMoreThanOnce() (gas: 1141898)
CoordinatorLazySubscriptionTest:testLazySubscriptionDeliveryStoresOutputsInInbox() (gas: 432129)
CoordinatorSubscriptionTest:testCanCancelCancelledSubscription() (gas: 114223)
CoordinatorSubscriptionTest:testCanCancelFulfilledSubscription() (gas: 310625)
CoordinatorSubscriptionTest:testCanCancelSubscription() (gas: 113364)
CoordinatorSubscriptionTest:testCanReadContainerInputs() (gas: 12991)
CoordinatorSubscriptionTest:testCannotCancelNonExistentSubscription() (gas: 14036)
CoordinatorSubscriptionTest:testCannotCancelUnownedSubscription() (gas: 135118)
CoordinatorSubscriptionTest:testCannotDeliverMaxRedundancyResponse() (gas: 472903)
CoordinatorSubscriptionTest:testCannotDeliverResponseDelayed() (gas: 138023)
CoordinatorSubscriptionTest:testCannotDeliverResponseEarly() (gas: 137868)
CoordinatorSubscriptionTest:testCannotDeliverResponseForCompletedSubscription() (gas: 515868)
CoordinatorSubscriptionTest:testCannotDeliverResponseForNonExistentSubscription() (gas: 53098)
CoordinatorSubscriptionTest:testCannotDeliverResponseIfAlreadyDeliveredInCurrentInterval() (gas: 312824)
CoordinatorSubscriptionTest:testCannotDeliverResponseIncorrectInterval() (gas: 311936)
CoordinatorSubscriptionTest:testCannotDeliverResponseNonActiveSubscription() (gas: 333058)
CoordinatorSubscriptionTest:testFuzzSubscriptionIntervalsAreCorrect(uint32,uint32,uint32) (runs: 256, μ: 20750, ~: 14427)
EIP712CoordinatorTest:testCanAtomicCreateLazySubscriptionAndDeliverOutput() (gas: 477085)
EIP712CoordinatorTest:testCanAtomicCreateSubscriptionAndDeliverOutput() (gas: 364781)
EIP712CoordinatorTest:testCanCancelSubscriptionCreatedViaDelegate() (gas: 158728)
EIP712CoordinatorTest:testCanCreateDelegatedSubscriptionWithUnorderedNonces() (gas: 294026)
EIP712CoordinatorTest:testCanCreateNewSubscriptionViaEIP712() (gas: 150149)
EIP712CoordinatorTest:testCanDelegatedDeliverComputeResponseForExistingSubscription() (gas: 513265)
EIP712CoordinatorTest:testCanDeliverDelegatedResponseAsAllowedNode() (gas: 388533)
EIP712CoordinatorTest:testCanGetExistingSubscriptionViaEIP712() (gas: 155309)
EIP712CoordinatorTest:testCanUseExistingDelegatedSubscriptionFromOldSigner() (gas: 151693)
EIP712CoordinatorTest:testCannotAtomicDeliverOutputForCompletedSubscription() (gas: 365133)
EIP712CoordinatorTest:testCannotCreateDelegatedSubscriptionWhereNonceReused() (gas: 173593)
EIP712CoordinatorTest:testCannotCreateDelegatedSubscriptionWhereSignatureExpired() (gas: 29062)
EIP712CoordinatorTest:testCannotCreateNewDelegatedSubscriptionAtomicallyAsUnallowedNode() (gas: 230091)
EIP712CoordinatorTest:testCannotUseValidDelegatedSubscriptionFromOldSigner() (gas: 44779)
EIP712CoordinatorTest:testFuzzCannotCreateDelegatedSubscriptionWhereSignatureMismatch(uint256) (runs: 256, μ: 38869, ~: 38869)
FeeTest:testFuzzNonOwnerCannotUpdateFee(address) (runs: 256, μ: 336914, ~: 336914)
FeeTest:testFuzzOwnerCanUpdateFee(address,uint16) (runs: 256, μ: 357038, ~: 359293)
FeeTest:testOwnerCanTransferOwnership() (gas: 339108)
InboxTest:testFuzzCorrectImmutableTimestampStored(uint32) (runs: 256, μ: 160790, ~: 161957)
InboxTest:testFuzzInboxItemsAreOrderedSeriallyByTime(uint32) (runs: 256, μ: 1318543, ~: 1319837)
InboxTest:testFuzzNodesCanStoreDataToInbox(address,uint32,bytes32,bytes,bytes,bytes) (runs: 256, μ: 318590, ~: 279369)
InboxTest:testFuzzNonCoordinatorAddressCannotCallAuthenticatedWrite(address) (runs: 256, μ: 14631, ~: 14631)
InboxTest:testFuzzOnlyCoordinatorCanCallAuthenticatedWrite(uint32,bytes32,address,uint32,uint32,bytes,bytes,bytes) (runs: 256, μ: 332087, ~: 290162)
InboxTest:testMultipleNodesCanStoreDataToInbox() (gas: 309017)
InboxTest:testNodeCannotCallAuthenticatedWrite() (gas: 14349)
InboxTest:testNodesCanDeliverDataViaCoordinatorAndDirectSamePath() (gas: 566823)
InboxTest:testNodesCanDeliverLazySubscription() (gas: 436476)
InboxTest:testNodesCanStoreDataMultipleTimesDifferentPath() (gas: 302138)
InboxTest:testNodesCanStoreDataMultipleTimesSamePath() (gas: 282890)
ReaderTest:testBatchSubscriptionsAreEmptyWhereEndAndStartIdEqual() (gas: 6799)
ReaderTest:testCanReadRedundancyCountPostSubscriptionDeletion() (gas: 320189)
ReaderTest:testCanReadRedundancyCounts() (gas: 916576)
ReaderTest:testCanReadSingleSubscription() (gas: 202816)
ReaderTest:testCanReadSubscriptions() (gas: 757617)
ReaderTest:testCannotReadBatchSubscriptionsWhereIdOverOrUnderflow() (gas: 10948)
ReaderTest:testCannotReadRedundancyCountWhenInputArrayLengthsMismatch() (gas: 18479)
ReaderTest:testFuzzNonExistentSubscriptionIntervalReturns0RedundancyCount(uint32,uint32) (runs: 256, μ: 14492, ~: 14492)
ReaderTest:testReadCancelledOrNonExistentSubscription() (gas: 224830)
RegistryTest:testRegistryAddresses() (gas: 19433)
RegistryTest:testRegistryViaLibDeploy() (gas: 6508079)
WalletFactoryTest:testFuzzWalletsAreCreatedCorrectly(address) (runs: 256, μ: 748538, ~: 748694)
WalletFactoryTest:testFuzzWalletsCreatedDirectlyAreNotValid(address) (runs: 256, μ: 722443, ~: 722754)
WalletTest:testFuzzCanApproveSpenderToSpendEther(address,uint256,uint256) (runs: 256, μ: 811262, ~: 812377)
WalletTest:testFuzzCanApproveSpenderToSpendToken(address,uint256,uint256) (runs: 256, μ: 824673, ~: 825451)
WalletTest:testFuzzCanCreateWalletWithCorrectOwner(address) (runs: 256, μ: 712767, ~: 712845)
WalletTest:testFuzzCanTransferERC20ToWallet(uint256) (runs: 256, μ: 776172, ~: 778349)
WalletTest:testFuzzCanTransferEtherToWallet(uint256) (runs: 256, μ: 756160, ~: 758260)
WalletTest:testFuzzCanTransferWalletOwnership(address) (runs: 256, μ: 720253, ~: 720253)
WalletTest:testMultipleSpendersUtilizingFunds() (gas: 1013813)
2 changes: 1 addition & 1 deletion .github/workflows/test_contracts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
version: nightly-2cb875799419c907cc3709e586ece2559e6b340e

- name: Install contract deps
run: forge --version && forge install
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,8 @@ docs/
# VSCode workspace config
.vscode/

# IntelliJ IDEA workspace config
.idea

# OS cache
.DS_Store
75 changes: 48 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,52 +78,73 @@ contract MyContract is SubscriptionConsumer {
}
```

## Repository structure
## Pruned repository structure

Ignores self-explanatory files:

```bash
.
├── .env.sample # Sample env variables
├── .gas-snapshot # Function execution gas snapshot
├── Makefile
├── README.md
├── STYLE.md
├── compiled # Pre-compiled artifacts (via solc)
├── .env.sample # Sample env file (used for deploy scripts)
├── compiled # Seperately compiled contracts (via solc)
│   └── Verifier.sol
│   ├── Halo2Verifier.json
│   └── Verifier.sol
├── foundry.toml # Foundry setup
├── remappings.txt
├── scripts
│   └── Deploy.sol # EIP712Coordinator deploy script
├── src # Contracts
│   └── Deploy.sol # Deploy contracts via LibDeploy
├── src
│   ├── Coordinator.sol # Base coordinator
│   ├── EIP712Coordinator.sol # EIP-712 typed message supporting coordinator
│   ├── Manager.sol # Node manager
│   ├── consumer # Consumers inherited by developers
│   ├── EIP712Coordinator.sol # Coordinator w/ EIP-712 delegation support
│   ├── Inbox.sol # Message inbox
│   ├── Registry.sol # Root registry
│   ├── consumer
│   │   ├── Base.sol
│   │   ├── Callback.sol # CallbackConsumer
│   │   └── Subscription.sol # SubscriptionConsumer
│   └── pattern # Useful developer patterns
│   └── Delegator.sol # EIP-712 delegator
└── test # Tests
│   ├── pattern
│   │   ├── Allowlist.sol # Responding node allowlist pattern
│   │   └── Delegator.sol # Delegated compute pattern (w/ EIP712Coordinator)
│   ├── payments
│   │   ├── Fee.sol # Protocol fee registry
│   │   ├── IVerifier.sol # Verifier interface (implemented downstream)
│   │   ├── Wallet.sol # Escrow wallet
│   │   └── WalletFactory.sol # Wallet factory
│   └── utility
│   ├── Coordinated.sol # Utility restriction for Coordinator-permissioned fns
│   └── Reader.sol # Off-chain reader
└── test
├── Coordinated.t.sol
├── Coordinator.t.sol
├── E2E.t.sol
├── EIP712Coordinator.t.sol
├── Manager.t.sol
├── Fee.t.sol
├── Inbox.t.sol
├── Reader.t.sol
├── Registry.t.sol
├── Wallet.t.sol
├── WalletFactory.t.sol
├── ezkl # E2E tests w/ EZKL-generated proofs
│   ├── BalanceScale.sol
│   └── DataAttestor.sol
├── lib # Useful libraries
│   ├── LibSign.sol # EIP-712 signing
│   └── LibStruct.sol # Struct parsing
├── lib
│   ├── LibDeploy.sol # Useful deployment library
│   └── LibSign.sol # Useful EIP-712 signing library
└── mocks
├── MockManager.sol
├── MockNode.sol # Mock Infernet node
└── consumer
├── MockCoordinated.sol
├── MockNode.sol
├── MockProtocol.sol
├── MockToken.sol
├── consumer
│   ├── AllowlistDelegatorSubscription.sol
│   ├── AllowlistSubscription.sol
│   ├── Base.sol
│   ├── Callback.sol
│   ├── DelegatorCallback.sol
│   ├── DelegatorSubscription.sol
│   └── Subscription.sol
└── verifier
├── Atomic.sol
├── Base.sol
├── Callback.sol
├── DelegatorCallback.sol
└── Subscription.sol
└── Optimistic.sol
```

## License
Expand Down
Loading

0 comments on commit 62955fe

Please sign in to comment.