Skip to content

Commit

Permalink
feat: rln-v2 (#35)
Browse files Browse the repository at this point in the history
* feat: init rln-v2 changes

* chore: remove poseidont3, dont calculate rate commitments

* fix: deploy script

* feat: add g16 verifier

* chore: deploy to sepolia and polygon-zkevm-testnet

* chore: snapshot

* fix(rln): reuse getDepositAmount func
  • Loading branch information
rymnc authored Jan 23, 2024
1 parent 9ee3217 commit 5d9108a
Show file tree
Hide file tree
Showing 9 changed files with 351 additions and 370 deletions.
32 changes: 17 additions & 15 deletions .gas-snapshot
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
RlnTest:test__Constants() (gas: 7921)
RlnTest:test__InvalidRegistration__DuplicateCommitment(uint256) (runs: 1000, μ: 120248, ~: 120248)
RlnTest:test__InvalidRegistration__FullSet() (gas: 1242442)
RlnTest:test__InvalidRegistration__InsufficientDeposit(uint256) (runs: 1000, μ: 17189, ~: 17189)
RlnTest:test__InvalidRegistration__InvalidIdCommitment(uint256) (runs: 1000, μ: 16963, ~: 16968)
RlnTest:test__InvalidSlash__InvalidProof() (gas: 958986)
RlnTest:test__InvalidSlash__MemberNotRegistered(uint256) (runs: 1000, μ: 30287, ~: 30287)
RlnTest:test__InvalidSlash__NoStake(uint256,address) (runs: 1000, μ: 301136, ~: 301143)
RlnTest:test__InvalidSlash__ToRlnAddress() (gas: 128396)
RlnTest:test__InvalidSlash__ToZeroAddress() (gas: 128301)
RlnTest:test__InvalidWithdraw__InsufficientContractBalance() (gas: 126872)
RlnTest:test__InvalidWithdraw__InsufficientWithdrawalBalance() (gas: 10494)
RlnTest:test__ValidRegistration(uint256) (runs: 1000, μ: 112053, ~: 112053)
RlnTest:test__ValidSlash(uint256,address) (runs: 1000, μ: 184955, ~: 184966)
RlnTest:test__ValidWithdraw(address) (runs: 1000, μ: 183699, ~: 183687)
RlnTest:test__Constants() (gas: 8619)
RlnTest:test__InvalidRegistration__DuplicateCommitment(uint256) (runs: 1000, μ: 144113, ~: 144113)
RlnTest:test__InvalidRegistration__FullSet() (gas: 1433224)
RlnTest:test__InvalidRegistration__InsufficientDeposit(uint256) (runs: 1000, μ: 17440, ~: 17440)
RlnTest:test__InvalidRegistration__InvalidIdCommitment(uint256) (runs: 1000, μ: 17053, ~: 17058)
RlnTest:test__InvalidRegistration__InvalidUserMessageLimit() (gas: 17055)
RlnTest:test__InvalidRegistration__MaxUserMessageLimit() (gas: 17203)
RlnTest:test__InvalidSlash__InvalidProof() (gas: 1081919)
RlnTest:test__InvalidSlash__MemberNotRegistered(uint256) (runs: 1000, μ: 32521, ~: 32521)
RlnTest:test__InvalidSlash__NoStake(uint256,address) (runs: 1000, μ: 319630, ~: 319682)
RlnTest:test__InvalidSlash__ToRlnAddress() (gas: 151034)
RlnTest:test__InvalidSlash__ToZeroAddress() (gas: 150939)
RlnTest:test__InvalidWithdraw__InsufficientContractBalance() (gas: 145224)
RlnTest:test__InvalidWithdraw__InsufficientWithdrawalBalance() (gas: 10538)
RlnTest:test__ValidRegistration(uint256) (runs: 1000, μ: 135760, ~: 135760)
RlnTest:test__ValidSlash(uint256,address) (runs: 1000, μ: 203402, ~: 203412)
RlnTest:test__ValidWithdraw(address) (runs: 1000, μ: 202120, ~: 202108)
45 changes: 45 additions & 0 deletions deployments/11155111/latest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
[
{
"hash": "0x5a916693fe596872c5ca5eebf14ae7cc027aa8b245c0ba7c5a7ba0c6cc6bdde8",
"transactionType": "CREATE",
"contractName": "Verifier",
"contractAddress": "0xEba4B7e7825D5Ed7A6A28b19200cc5382dC2F90E",
"function": null,
"arguments": null,
"transaction": {
"type": "0x02",
"from": "0x3f47b2a1df96de2e198d646b598c37251ccc3b98",
"gas": "0x723d7",
"value": "0x0",
"data": "0x608060405234801561001057600080fd5b5061058c806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063f5c9d69e14610030575b600080fd5b61004361003e36600461052c565b610057565b604051901515815260200160405180910390f35b60006104ca565b7f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47811061008f576000805260206000f35b50565b600060405183815284602082015285604082015260408160608360076107d05a03fa9150816100c5576000805260206000f35b825160408201526020830151606082015260408360808360066107d05a03fa915050806100f6576000805260206000f35b5050505050565b7f2b16fd00bd26d674287cfc25d02abf18b00fbc4964bb5b16b0f1077fec8f39be85527f22850edba988daec117b0bdae2ad24e5b5ac47186b0397c99905f7cfbcb3afff60208601526000608086018661019a87357f01e613151d854b94b0d8cd139333354f7394bf9582b47ee7fb125fd2f34a835f7f0374ef1ee7d1e0fbb80784c7b9a42a4c181413be097b9d64ca73417eec0c015384610092565b6101ea60208801357f1d63f0593a87129a1382a9c2be5e2c6d3ff6bc0ee6368ef2718dda96d0e054207f086bc14fda17a135507164dfcce27b710fcb5668dee2505acbeecb8fad6500f884610092565b50823581527f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd4760208401357f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd4703066020820152833560408201526020840135606082015260408401356080820152606084013560a08201527f2d4d9aa7e302d9df41749d5507949d05dbea33fbb16c643b22f599a2be6df2e260c08201527f14bedd503c37ceb061d8ec60209fe345ce89830a19230301f076caff004d192660e08201527f0967032fcbf776d1afc985f88877f182d38480a653f2decaa9794cbc3bf3060c6101008201527f0e187847ad4c798374d0d6732bf501847dd68bc0e071241e0213bc7fc13db7ab6101208201527f304cfbd1e08a704a99f5e847d93f8c3caafddec46b7a0d379da69a4d112346a76101408201527f1739c1b1a457a8c7313123d24d2f9192f896b7c63eea05a9d57f06547ad0cec8610160820152600087015161018082015260206000018701516101a08201527f198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c26101c08201527f1800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed6101e08201527f090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b6102008201527f12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa610220820152843561024082015260208501356102608201527f1989a57421455a443e8ab54b97c7cb0dc8d29a27dd2707383b5ce30e0937f1516102808201527f2458e5e27fc38dd430c6d5645a9845c35ecdaaaa777a29a9f79d04da627816d06102a08201527f25713f6db21b3ec0da75d5469790fad53d92bd7071d63c6fb6a138cad97585dc6102c08201527f225c87839a50bfa218107b5904aa7829ed709137673fc6bfcce156f52dd462476102e08201526020816103008360086107d05a03fa9051169695505050505050565b60405161038081016040526104e2600084013561005e565b6104ef602084013561005e565b6104fc604084013561005e565b610509818486888a6100fd565b90508060005260206000f35b806040810183101561052657600080fd5b92915050565b600080600080610140858703121561054357600080fd5b61054d8686610515565b935060c085018681111561056057600080fd5b6040860193506105708782610515565b925050610581866101008701610515565b90509295919450925056",
"nonce": "0x991",
"accessList": []
},
"additionalContracts": [],
"isFixedGasLimit": false
},
{
"hash": "0x449b676fdf6d2d897198c18007017f0b0d10a06153017ecf42aa5dad987bf71e",
"transactionType": "CREATE",
"contractName": "Rln",
"contractAddress": "0xb40d380FCbfCcb600da20FE0fF1908578355510d",
"function": null,
"arguments": [
"0",
"20",
"20",
"0xEba4B7e7825D5Ed7A6A28b19200cc5382dC2F90E"
],
"transaction": {
"type": "0x02",
"from": "0x3f47b2a1df96de2e198d646b598c37251ccc3b98",
"gas": "0x141c41",
"value": "0x0",
"data": "0x6101406040526000805534801561001557600080fd5b5060405161129b38038061129b83398101604081905261003491610066565b60a09390935260805260c08190526001901b60e0526001600160a01b03166101005263ffffffff4316610120526100b5565b6000806000806080858703121561007c57600080fd5b845160208601516040870151606088015192965090945092506001600160a01b03811681146100aa57600080fd5b939692955090935050565b60805160a05160c05160e051610100516101205161116d61012e600039600061027d0152600081816101ed0152610d0101526000818161046e0152610bdf015260006103ca0152600081816104e901528181610548015281816108a201526108f80152600081816101760152610803015261116d6000f3fe60806040526004361061015f5760003560e01c80639056a9bf116100c0578063c5b208ff11610074578063d66d6c1011610059578063d66d6c1014610490578063e493ef8c146104a3578063f220b9ec146104d757600080fd5b8063c5b208ff1461042f578063d0383d681461045c57600080fd5b806398366e35116100a557806398366e35146103b8578063ae74552a146103ec578063bc4991281461040257600080fd5b80639056a9bf1461035e578063933ebfdd1461038b57600080fd5b80634add651e116101175780636bdcc8ab116100fc5780636bdcc8ab146102e15780637671ac05146103115780638be9b1191461033e57600080fd5b80634add651e1461026b5780635daf08ca146102b457600080fd5b80632b7ac3f3116101485780632b7ac3f3146101db578063378de45b146102345780633ccfd60b1461025457600080fd5b806309aeb04c1461016457806322d9730c146101ab575b600080fd5b34801561017057600080fd5b506101987f000000000000000000000000000000000000000000000000000000000000000081565b6040519081526020015b60405180910390f35b3480156101b757600080fd5b506101cb6101c6366004610eb2565b61050b565b60405190151581526020016101a2565b3480156101e757600080fd5b5061020f7f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016101a2565b34801561024057600080fd5b5061019861024f366004610eb2565b610541565b34801561026057600080fd5b5061026961056d565b005b34801561027757600080fd5b5061029f7f000000000000000000000000000000000000000000000000000000000000000081565b60405163ffffffff90911681526020016101a2565b3480156102c057600080fd5b506101986102cf366004610eb2565b60026020526000908152604090205481565b3480156102ed57600080fd5b506101cb6102fc366004610eb2565b60056020526000908152604090205460ff1681565b34801561031d57600080fd5b5061019861032c366004610eb2565b60046020526000908152604090205481565b34801561034a57600080fd5b50610269610359366004610eed565b610630565b34801561036a57600080fd5b50610198610379366004610eb2565b60036020526000908152604090205481565b34801561039757600080fd5b506103ab6103a6366004610f35565b610689565b6040516101a29190610f57565b3480156103c457600080fd5b506101987f000000000000000000000000000000000000000000000000000000000000000081565b3480156103f857600080fd5b5061019860005481565b34801561040e57600080fd5b5061019861041d366004610eb2565b60016020526000908152604090205481565b34801561043b57600080fd5b5061019861044a366004610f9b565b60066020526000908152604090205481565b34801561046857600080fd5b506101987f000000000000000000000000000000000000000000000000000000000000000081565b61026961049e366004610f35565b6107bd565b3480156104af57600080fd5b506101987f30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000181565b3480156104e357600080fd5b506101987f000000000000000000000000000000000000000000000000000000000000000081565b6000811580159061053b57507f30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000182105b92915050565b600061053b7f000000000000000000000000000000000000000000000000000000000000000083610fee565b33600090815260066020526040812054908190036105b7576040517f6f50367a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b478111156105f1576040517f786e0a9900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b336000818152600660205260408082208290555183156108fc0291849190818181858888f1935050505015801561062c573d6000803e3d6000fd5b5050565b8261063a8161050b565b610678576040517f7f3e75af000000000000000000000000000000000000000000000000000000008152600481018290526024015b60405180910390fd5b61068384848461093c565b50505050565b60608183106106ce576040517f9ffcd53d000000000000000000000000000000000000000000000000000000008152600481018490526024810183905260440161066f565b600054821115610714576040517f9ffcd53d000000000000000000000000000000000000000000000000000000008152600481018490526024810183905260440161066f565b60006107208484611005565b67ffffffffffffffff81111561073857610738611018565b604051908082528060200260200182016040528015610761578160200160208202803683370190505b509050835b838110156107b557600081815260046020526040902054826107888784611005565b8151811061079857610798611047565b6020908102919091010152806107ad81611076565b915050610766565b509392505050565b816107c78161050b565b610800576040517f7f3e75af0000000000000000000000000000000000000000000000000000000081526004810182905260240161066f565b817f000000000000000000000000000000000000000000000000000000000000000081111561085e576040517f13a5e2ee0000000000000000000000000000000000000000000000000000000081526004810182905260240161066f565b8060000361089b576040517f13a5e2ee0000000000000000000000000000000000000000000000000000000081526004810182905260240161066f565b60006108c77f000000000000000000000000000000000000000000000000000000000000000085610fee565b905080341461092a576040517f25c3f46e0000000000000000000000000000000000000000000000000000000081527f0000000000000000000000000000000000000000000000000000000000000000600482015234602482015260440161066f565b610935858534610b95565b5050505050565b73ffffffffffffffffffffffffffffffffffffffff8216301480610974575073ffffffffffffffffffffffffffffffffffffffff8216155b156109c3576040517f4a149d0800000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8316600482015260240161066f565b6000838152600360209081526040808320546005909252822054909160ff90911615159003610a21576040517f5a971ebb0000000000000000000000000000000000000000000000000000000081526004810185905260240161066f565b6000848152600160205260408120549003610a6b576040517faabeeba50000000000000000000000000000000000000000000000000000000081526004810185905260240161066f565b610a76848484610cfd565b610aac576040517f09bde33900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000848152600160209081526040808320805460028452828520805490869055808652600485528386208690558986526005855283862080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169055918590556003845282852085905573ffffffffffffffffffffffffffffffffffffffff881685526006909352908320805492939192849290610b4c9084906110ae565b909155505060408051878152602081018390527f62ec3a516d22a993ce5cb4e7593e878c74f4d799dde522a88dc27a994fd5a943910160405180910390a1505050505050565b50565b60008381526005602052604090205460ff1615610bdd576040517e0a60f700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000060005410610c38576040517f57f6953100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008054848252600260209081526040808420839055918352600481528183208690558583526005815281832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600190811790915581528183208490556003815281832085905591548151868152928301859052908201527fff42916a89d1f5125f7f47168ee59c2b3fc9246ad1b229082ee85b69d001b5d79060600160405180910390a16001600080828254610cf391906110ae565b9091555050505050565b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663f5c9d69e604051806040016040528085600060088110610d5957610d59611047565b6020020135815260200185600160088110610d7657610d76611047565b6020020135905260408051608081018252868201359181019182529081906060820188600360200201358152508152602001604051806040016040528088600460088110610dc657610dc6611047565b6020020135815260200188600560088110610de357610de3611047565b60200201359052905260408051808201909152808760066020020135815260200187600760088110610e1757610e17611047565b602002013581525060405180604001604052808a81526020018973ffffffffffffffffffffffffffffffffffffffff168152506040518563ffffffff1660e01b8152600401610e6994939291906110e4565b602060405180830381865afa158015610e86573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610eaa919061114b565b949350505050565b600060208284031215610ec457600080fd5b5035919050565b73ffffffffffffffffffffffffffffffffffffffff81168114610b9257600080fd5b6000806000610140808587031215610f0457600080fd5b843593506020850135610f1681610ecb565b9250848101861015610f2757600080fd5b506040840190509250925092565b60008060408385031215610f4857600080fd5b50508035926020909101359150565b6020808252825182820181905260009190848201906040850190845b81811015610f8f57835183529284019291840191600101610f73565b50909695505050505050565b600060208284031215610fad57600080fd5b8135610fb881610ecb565b9392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b808202811582820484141761053b5761053b610fbf565b8181038181111561053b5761053b610fbf565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82036110a7576110a7610fbf565b5060010190565b8082018082111561053b5761053b610fbf565b8060005b60028110156106835781518452602093840193909101906001016110c5565b61014081016110f382876110c1565b60408083018660005b6002811015611123576111108383516110c1565b91830191602091909101906001016110fc565b5050505061113460c08301856110c1565b6111426101008301846110c1565b95945050505050565b60006020828403121561115d57600080fd5b81518015158114610fb857600080fd000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000014000000000000000000000000eba4b7e7825d5ed7a6a28b19200cc5382dc2f90e",
"nonce": "0x992",
"accessList": []
},
"additionalContracts": [],
"isFixedGasLimit": false
}
]
Loading

0 comments on commit 5d9108a

Please sign in to comment.