From 44de3e36e5d7e62c1c38f18055b27dcccd99eb0f Mon Sep 17 00:00:00 2001 From: ZelionD Date: Sun, 11 Aug 2024 12:21:12 -0400 Subject: [PATCH] update sno sbt tests --- user-verifier/tests/artifacts/SNOSBT.json | 2 +- user-verifier/tests/test_sbt.rs | 302 +++++++++++++++------- 2 files changed, 206 insertions(+), 98 deletions(-) diff --git a/user-verifier/tests/artifacts/SNOSBT.json b/user-verifier/tests/artifacts/SNOSBT.json index b9a30ea..4d81ced 100644 --- a/user-verifier/tests/artifacts/SNOSBT.json +++ b/user-verifier/tests/artifacts/SNOSBT.json @@ -555,7 +555,7 @@ "type": "function" } ], - "bytecode": "0x608060405234801561001057600080fd5b50610022640100000000610027810204565b61010c565b600061003a6401000000006100e8810204565b805490915068010000000000000000900460ff1615610085576040517ff92ee8a900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80546001604060020a03908116146100e557805467ffffffffffffffff19166001604060020a0390811782556040519081527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0090565b6119698061011b6000396000f3fe608060405234801561001057600080fd5b50600436106101b5576000357c010000000000000000000000000000000000000000000000000000000090048063788c4202116101005780639c8f1126116100a9578063d547741f11610083578063d547741f1461043f578063eac70dfc14610452578063ee6ff81a1461046557600080fd5b80639c8f112614610411578063a217fddf14610424578063ca15c8731461042c57600080fd5b80639010d07c116100da5780639010d07c1461036157806390fdd5891461039957806391d14854146103ac57600080fd5b8063788c42021461032a5780638129fc1c1461033257806382aefa241461033a57600080fd5b806336568abe116101625780636ee1cf061161013c5780636ee1cf06146102d85780636f3f323c1461030e5780637807518b1461032157600080fd5b806336568abe1461028b5780633fee7b0d1461029e5780636c69efc9146102c557600080fd5b8063248a9ca311610193578063248a9ca31461022c5780632f2ff15d1461026e57806332ce7c0a1461028357600080fd5b806301ffc9a7146101ba5780630f6d50dc146101e257806318160ddd1461021a575b600080fd5b6101cd6101c83660046115a3565b610478565b60405190151581526020015b60405180910390f35b6101cd6101f0366004611607565b73ffffffffffffffffffffffffffffffffffffffff16600090815260208190526040902054151590565b6002545b6040519081526020016101d9565b61021e61023a366004611624565b60009081527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800602052604090206001015490565b61028161027c36600461163d565b6104d4565b005b61021e61051e565b61028161029936600461163d565b610535565b61021e7fa2e8fe7c00f159dc6d97ca8f61c83aa484a94b4677735133e05a1d3cf58ac69181565b6102816102d336600461166d565b610593565b61021e6102e6366004611607565b73ffffffffffffffffffffffffffffffffffffffff1660009081526020819052604090205490565b61028161031c366004611624565b6107fe565b61021e60045481565b60035461021e565b61028161080f565b61021e7f114e74f6ea3bd819998f78687bfcb11b140da08e9b7d222fa9c1f1ba1f2aa12281565b61037461036f3660046116b8565b6109a3565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016101d9565b61021e6103a7366004611607565b6109e4565b6101cd6103ba36600461163d565b60009182527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020908152604080842073ffffffffffffffffffffffffffffffffffffffff93909316845291905290205460ff1690565b61028161041f366004611624565b610a1e565b61021e600081565b61021e61043a366004611624565b610af4565b61028161044d36600461163d565b610b33565b610281610460366004611607565b610b77565b61021e610473366004611607565b610d4a565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f5a05180f0000000000000000000000000000000000000000000000000000000014806104ce57506104ce82610ff7565b92915050565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800602052604090206001015461050e8161108e565b6105188383611098565b50505050565b60006002546003546105309190611709565b905090565b73ffffffffffffffffffffffffffffffffffffffff81163314610584576040517f6697b23200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61058e82826110ef565b505050565b7f114e74f6ea3bd819998f78687bfcb11b140da08e9b7d222fa9c1f1ba1f2aa1226105bd8161108e565b83836105ed8273ffffffffffffffffffffffffffffffffffffffff16600090815260208190526040902054151590565b15610659576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f54686973206b696e64206f662053425420616c7265616479206578697374000060448201526064015b60405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff818116600090815260016020526040902054161561070e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603560248201527f57616c6c657420686173206265656e20616c7265616479207573656420746f2060448201527f6d696e742074686973206b696e64206f662053425400000000000000000000006064820152608401610650565b6001600260008282546107219190611720565b909155505073ffffffffffffffffffffffffffffffffffffffff858116600081815260016020818152604080842080547fffffffffffffffffffffffff00000000000000000000000000000000000000009081168e891690811790925582516060810184524281528085018881528d8a1682860190815284895295889052848820915182555195810180548316968a169690961790955592516002909401805490931693909616929092179055519192917fec517472143379d88d10fcb50037af41e880677081d0b233149c3d70b9f5b9369190a3505050505050565b60006108098161108e565b50600455565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000810460ff16159067ffffffffffffffff1660008115801561085a5750825b905060008267ffffffffffffffff1660011480156108775750303b155b905081158015610885575080155b156108bc576040517ff92ee8a900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b84547fffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000166001178555831561091d5784547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff16680100000000000000001785555b60006002819055610834600355610e1060045561093a9033611098565b50831561099c5784547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b5050505050565b60008281527fc1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e823717059320006020819052604082206109dc908461113d565b949350505050565b73ffffffffffffffffffffffffffffffffffffffff8116600090815260208190526040812054610a1657506000919050565b6003546104ce565b3360009081527fd899505834629eb300e74c720bc2ccfa64c67750c977fb28a4698835213ef6c8602052604090205460ff1680610a8957503360009081527fb7db2dd08fcb62d0c9e08c51941cae53c267786a0b75803fb7960902fc8ef97d602052604090205460ff165b610aef576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f4e6f7420617574686f72697a65640000000000000000000000000000000000006044820152606401610650565b600355565b60008181527fc1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e82371705932000602081905260408220610b2c90611149565b9392505050565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020526040902060010154610b6d8161108e565b61051883836110ef565b3360009081527fecfb03a241cc67499591701273c9840824101e710aea92d3ca0339671f5c64c0602052604090205460ff1680610be257503360009081527fb7db2dd08fcb62d0c9e08c51941cae53c267786a0b75803fb7960902fc8ef97d602052604090205460ff165b610c48576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f4e6f7420617574686f72697a65640000000000000000000000000000000000006044820152606401610650565b73ffffffffffffffffffffffffffffffffffffffff811660009081526020819052604090205415610d475773ffffffffffffffffffffffffffffffffffffffff80821660008181526020818152604080832060018181018054909716855280845291842080547fffffffffffffffffffffffff00000000000000000000000000000000000000009081169091559484529183905282825584548416909455600290810180549093169092558154610d00908490611733565b909155505060405173ffffffffffffffffffffffffffffffffffffffff8216907fb37cf8eece8b5e64575d707079155f564741a1a9523c32d65196063452c4065b90600090a25b50565b73ffffffffffffffffffffffffffffffffffffffff811660009081526020819052604081205480600003610d815750600092915050565b73ffffffffffffffffffffffffffffffffffffffff8084166000908152602081815260408083206002015481517f9426e22600000000000000000000000000000000000000000000000000000000815291519416938492639426e22692600480820193918290030181865afa158015610dfe573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e229190611746565b6040517ff3c94aa800000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff878116600483015291925060009184169063f3c94aa890602401600060405180830381865afa158015610e94573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201604052610eda91908101906117a2565b905060005b8151811015610fea5760008373ffffffffffffffffffffffffffffffffffffffff16635ea21491848481518110610f1857610f18611884565b60200260200101516040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401610f74919073ffffffffffffffffffffffffffffffffffffffff91909116815260200190565b602060405180830381865afa158015610f91573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fb591906118b3565b90504260045482610fc69190611720565b10610fd75750939695505050505050565b5080610fe2816118cc565b915050610edf565b5060009695505050505050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b0000000000000000000000000000000000000000000000000000000014806104ce57507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316146104ce565b610d478133611153565b60007fc1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e82371705932000816110c685856111fe565b905080156109dc5760008581526020839052604090206110e6908561131f565b50949350505050565b60007fc1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e823717059320008161111d8585611341565b905080156109dc5760008581526020839052604090206110e6908561141f565b6000610b2c8383611441565b60006104ce825490565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff166111fa576040517fe2517d3f00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8216600482015260248101839052604401610650565b5050565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020818152604080842073ffffffffffffffffffffffffffffffffffffffff8616855290915282205460ff166113155760008481526020828152604080832073ffffffffffffffffffffffffffffffffffffffff87168452909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790556112b13390565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16857f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a460019150506104ce565b60009150506104ce565b6000610b2c8373ffffffffffffffffffffffffffffffffffffffff841661146b565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020818152604080842073ffffffffffffffffffffffffffffffffffffffff8616855290915282205460ff16156113155760008481526020828152604080832073ffffffffffffffffffffffffffffffffffffffff8716808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339287917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a460019150506104ce565b6000610b2c8373ffffffffffffffffffffffffffffffffffffffff84166114ba565b600082600001828154811061145857611458611884565b9060005260206000200154905092915050565b60008181526001830160205260408120546114b2575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556104ce565b5060006104ce565b600081815260018301602052604081205480156113155760006114de600183611733565b85549091506000906114f290600190611733565b905080821461155757600086600001828154811061151257611512611884565b906000526020600020015490508087600001848154811061153557611535611884565b6000918252602080832090910192909255918252600188019052604090208390555b855486908061156857611568611904565b6001900381819060005260206000200160009055905585600101600086815260200190815260200160002060009055600193505050506104ce565b6000602082840312156115b557600080fd5b81357fffffffff0000000000000000000000000000000000000000000000000000000081168114610b2c57600080fd5b73ffffffffffffffffffffffffffffffffffffffff81168114610d4757600080fd5b60006020828403121561161957600080fd5b8135610b2c816115e5565b60006020828403121561163657600080fd5b5035919050565b6000806040838503121561165057600080fd5b823591506020830135611662816115e5565b809150509250929050565b60008060006060848603121561168257600080fd5b833561168d816115e5565b9250602084013561169d816115e5565b915060408401356116ad816115e5565b809150509250925092565b600080604083850312156116cb57600080fd5b50508035926020909101359150565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b80820281158282048414176104ce576104ce6116da565b808201808211156104ce576104ce6116da565b818103818111156104ce576104ce6116da565b60006020828403121561175857600080fd5b8151610b2c816115e5565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b805161179d816115e5565b919050565b600060208083850312156117b557600080fd5b825167ffffffffffffffff808211156117cd57600080fd5b818501915085601f8301126117e157600080fd5b8151818111156117f3576117f3611763565b8381026040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0603f8301168101818110858211171561183557611835611763565b60405291825284820192508381018501918883111561185357600080fd5b938501935b828510156118785761186985611792565b84529385019392850192611858565b98975050505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6000602082840312156118c557600080fd5b5051919050565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82036118fd576118fd6116da565b5060010190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fdfea26469706673582212200b6b84703b77f327d1de74b650d63a615f6d5f4bf08374e18ca979da081b4bce64736f6c63430008140033", + "bytecode": "0x608060405234801561001057600080fd5b50610022640100000000610027810204565b61010c565b600061003a6401000000006100e8810204565b805490915068010000000000000000900460ff1615610085576040517ff92ee8a900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80546001604060020a03908116146100e557805467ffffffffffffffff19166001604060020a0390811782556040519081527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0090565b6119818061011b6000396000f3fe608060405234801561001057600080fd5b50600436106101b5576000357c010000000000000000000000000000000000000000000000000000000090048063788c4202116101005780639c8f1126116100a9578063d547741f11610083578063d547741f1461043f578063eac70dfc14610452578063ee6ff81a1461046557600080fd5b80639c8f112614610411578063a217fddf14610424578063ca15c8731461042c57600080fd5b80639010d07c116100da5780639010d07c1461036157806390fdd5891461039957806391d14854146103ac57600080fd5b8063788c42021461032a5780638129fc1c1461033257806382aefa241461033a57600080fd5b806336568abe116101625780636ee1cf061161013c5780636ee1cf06146102d85780636f3f323c1461030e5780637807518b1461032157600080fd5b806336568abe1461028b5780633fee7b0d1461029e5780636c69efc9146102c557600080fd5b8063248a9ca311610193578063248a9ca31461022c5780632f2ff15d1461026e57806332ce7c0a1461028357600080fd5b806301ffc9a7146101ba5780630f6d50dc146101e257806318160ddd1461021a575b600080fd5b6101cd6101c83660046115bb565b610478565b60405190151581526020015b60405180910390f35b6101cd6101f036600461161f565b73ffffffffffffffffffffffffffffffffffffffff16600090815260208190526040902054151590565b6002545b6040519081526020016101d9565b61021e61023a36600461163c565b60009081527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800602052604090206001015490565b61028161027c366004611655565b6104d4565b005b61021e61051e565b610281610299366004611655565b610535565b61021e7fa2e8fe7c00f159dc6d97ca8f61c83aa484a94b4677735133e05a1d3cf58ac69181565b6102816102d3366004611685565b610593565b61021e6102e636600461161f565b73ffffffffffffffffffffffffffffffffffffffff1660009081526020819052604090205490565b61028161031c36600461163c565b6107e2565b61021e60045481565b60035461021e565b6102816107f3565b61021e7f114e74f6ea3bd819998f78687bfcb11b140da08e9b7d222fa9c1f1ba1f2aa12281565b61037461036f3660046116d0565b610987565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016101d9565b61021e6103a736600461161f565b6109c8565b6101cd6103ba366004611655565b60009182527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020908152604080842073ffffffffffffffffffffffffffffffffffffffff93909316845291905290205460ff1690565b61028161041f36600461163c565b610a02565b61021e600081565b61021e61043a36600461163c565b610ad8565b61028161044d366004611655565b610b17565b61028161046036600461161f565b610b5b565b61021e61047336600461161f565b610c38565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f5a05180f0000000000000000000000000000000000000000000000000000000014806104ce57506104ce82610f0e565b92915050565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800602052604090206001015461050e81610fa5565b6105188383610faf565b50505050565b60006002546003546105309190611721565b905090565b73ffffffffffffffffffffffffffffffffffffffff81163314610584576040517f6697b23200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61058e8282611006565b505050565b7f114e74f6ea3bd819998f78687bfcb11b140da08e9b7d222fa9c1f1ba1f2aa1226105bd81610fa5565b83836105c882610c38565b15610634576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f54686973206b696e64206f662053425420616c7265616479206578697374000060448201526064015b60405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff81811660009081526001602052604090205416156106e9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603560248201527f57616c6c657420686173206265656e20616c7265616479207573656420746f2060448201527f6d696e742074686973206b696e64206f66205342540000000000000000000000606482015260840161062b565b6106f286611054565b6001600260008282546107059190611738565b909155505073ffffffffffffffffffffffffffffffffffffffff858116600081815260016020818152604080842080547fffffffffffffffffffffffff00000000000000000000000000000000000000009081168e891690811790925582516060810184524281528085018881528d8a1682860190815284895295889052848820915182555195810180548316968a169690961790955592516002909401805490931693909616929092179055519192917fec517472143379d88d10fcb50037af41e880677081d0b233149c3d70b9f5b9369190a3505050505050565b60006107ed81610fa5565b50600455565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000810460ff16159067ffffffffffffffff1660008115801561083e5750825b905060008267ffffffffffffffff16600114801561085b5750303b155b905081158015610869575080155b156108a0576040517ff92ee8a900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b84547fffffffffffffffffffffffffffffffffffffffffffffffff000000000000000016600117855583156109015784547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff16680100000000000000001785555b60006002819055610834600355610e1060045561091e9033610faf565b5083156109805784547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b5050505050565b60008281527fc1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e823717059320006020819052604082206109c09084611155565b949350505050565b73ffffffffffffffffffffffffffffffffffffffff81166000908152602081905260408120546109fa57506000919050565b6003546104ce565b3360009081527fd899505834629eb300e74c720bc2ccfa64c67750c977fb28a4698835213ef6c8602052604090205460ff1680610a6d57503360009081527fb7db2dd08fcb62d0c9e08c51941cae53c267786a0b75803fb7960902fc8ef97d602052604090205460ff165b610ad3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f4e6f7420617574686f72697a6564000000000000000000000000000000000000604482015260640161062b565b600355565b60008181527fc1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e82371705932000602081905260408220610b1090611161565b9392505050565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020526040902060010154610b5181610fa5565b6105188383611006565b3360009081527fecfb03a241cc67499591701273c9840824101e710aea92d3ca0339671f5c64c0602052604090205460ff1680610bc657503360009081527fb7db2dd08fcb62d0c9e08c51941cae53c267786a0b75803fb7960902fc8ef97d602052604090205460ff165b610c2c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f4e6f7420617574686f72697a6564000000000000000000000000000000000000604482015260640161062b565b610c3581611054565b50565b73ffffffffffffffffffffffffffffffffffffffff811660009081526020819052604081205480600003610c6f5750600092915050565b73ffffffffffffffffffffffffffffffffffffffff808416600090815260208181526040808320815160608101835281548152600182015486168185015260029091015490941684820181905281517f9426e22600000000000000000000000000000000000000000000000000000000815291519092639426e22692600480820193918290030181865afa158015610d0b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d2f919061174b565b604080840151602085015191517ff3c94aa800000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff928316600482015292935060009291169063f3c94aa890602401600060405180830381865afa158015610dab573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201604052610df191908101906117a7565b905060005b8151811015610f015760008373ffffffffffffffffffffffffffffffffffffffff16635ea21491848481518110610e2f57610e2f611889565b60200260200101516040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401610e8b919073ffffffffffffffffffffffffffffffffffffffff91909116815260200190565b602060405180830381865afa158015610ea8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ecc91906118b8565b90504260045482610edd9190611738565b10610eee5750939695505050505050565b5080610ef9816118d1565b915050610df6565b5060009695505050505050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b0000000000000000000000000000000000000000000000000000000014806104ce57507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316146104ce565b610c35813361116b565b60007fc1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e8237170593200081610fdd8585611216565b905080156109c0576000858152602083905260409020610ffd9085611337565b50949350505050565b60007fc1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e82371705932000816110348585611359565b905080156109c0576000858152602083905260409020610ffd9085611437565b73ffffffffffffffffffffffffffffffffffffffff811660009081526020819052604090205415610c355773ffffffffffffffffffffffffffffffffffffffff80821660008181526020818152604080832060018181018054909716855280845291842080547fffffffffffffffffffffffff0000000000000000000000000000000000000000908116909155948452918390528282558454841690945560029081018054909316909255815461110c908490611909565b909155505060405173ffffffffffffffffffffffffffffffffffffffff8216907fb37cf8eece8b5e64575d707079155f564741a1a9523c32d65196063452c4065b90600090a250565b6000610b108383611459565b60006104ce825490565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff16611212576040517fe2517d3f00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff821660048201526024810183905260440161062b565b5050565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020818152604080842073ffffffffffffffffffffffffffffffffffffffff8616855290915282205460ff1661132d5760008481526020828152604080832073ffffffffffffffffffffffffffffffffffffffff87168452909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790556112c93390565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16857f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a460019150506104ce565b60009150506104ce565b6000610b108373ffffffffffffffffffffffffffffffffffffffff8416611483565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020818152604080842073ffffffffffffffffffffffffffffffffffffffff8616855290915282205460ff161561132d5760008481526020828152604080832073ffffffffffffffffffffffffffffffffffffffff8716808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339287917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a460019150506104ce565b6000610b108373ffffffffffffffffffffffffffffffffffffffff84166114d2565b600082600001828154811061147057611470611889565b9060005260206000200154905092915050565b60008181526001830160205260408120546114ca575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556104ce565b5060006104ce565b6000818152600183016020526040812054801561132d5760006114f6600183611909565b855490915060009061150a90600190611909565b905080821461156f57600086600001828154811061152a5761152a611889565b906000526020600020015490508087600001848154811061154d5761154d611889565b6000918252602080832090910192909255918252600188019052604090208390555b85548690806115805761158061191c565b6001900381819060005260206000200160009055905585600101600086815260200190815260200160002060009055600193505050506104ce565b6000602082840312156115cd57600080fd5b81357fffffffff0000000000000000000000000000000000000000000000000000000081168114610b1057600080fd5b73ffffffffffffffffffffffffffffffffffffffff81168114610c3557600080fd5b60006020828403121561163157600080fd5b8135610b10816115fd565b60006020828403121561164e57600080fd5b5035919050565b6000806040838503121561166857600080fd5b82359150602083013561167a816115fd565b809150509250929050565b60008060006060848603121561169a57600080fd5b83356116a5816115fd565b925060208401356116b5816115fd565b915060408401356116c5816115fd565b809150509250925092565b600080604083850312156116e357600080fd5b50508035926020909101359150565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b80820281158282048414176104ce576104ce6116f2565b808201808211156104ce576104ce6116f2565b60006020828403121561175d57600080fd5b8151610b10816115fd565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b80516117a2816115fd565b919050565b600060208083850312156117ba57600080fd5b825167ffffffffffffffff808211156117d257600080fd5b818501915085601f8301126117e657600080fd5b8151818111156117f8576117f8611768565b8381026040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0603f8301168101818110858211171561183a5761183a611768565b60405291825284820192508381018501918883111561185857600080fd5b938501935b8285101561187d5761186e85611797565b8452938501939285019261185d565b98975050505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6000602082840312156118ca57600080fd5b5051919050565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203611902576119026116f2565b5060010190565b818103818111156104ce576104ce6116f2565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fdfea2646970667358221220bae52dab3927bae999878572bfd3a6fc6634de1f3ba8ceac43c6cb2ff3fd70f164736f6c63430008140033", "deployedBytecode": "", "linkReferences": {}, "deployedLinkReferences": {} diff --git a/user-verifier/tests/test_sbt.rs b/user-verifier/tests/test_sbt.rs index 2260c43..d726644 100644 --- a/user-verifier/tests/test_sbt.rs +++ b/user-verifier/tests/test_sbt.rs @@ -6,8 +6,8 @@ use jsonrpc_core::Error as RPCError; use std::str::FromStr; use uuid::Uuid; use web3::{ - contract::{self, Error::Api as ApiError}, - signing::Key, + contract::{self, Contract, Error::Api as ApiError}, + signing::{Key, SecretKey, SecretKeyRef}, types::TransactionRequest, }; @@ -401,29 +401,45 @@ async fn test_sno_sbt() -> Result<(), anyhow::Error> { let owner_secret = web3::signing::SecretKey::from_str( "ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80", )?; + // let owner = web3::signing::SecretKeyRef::from(&owner_secret); let signer_secret = web3::signing::SecretKey::from_slice(&hex::decode(SNO_SBT_SIGNER_PRIVATE_KEY)?)?; let signer = web3::signing::SecretKeyRef::from(&signer_secret); - // Account #18 private key from Hardhat local node - let node_wallet_secret = web3::signing::SecretKey::from_str( - "de9be858da4a475276426320d5e9262ecfc3ba460bfac56360bfa6c4c28b4ee0", - )?; - let node_wallet = web3::signing::SecretKeyRef::from(&node_wallet_secret); - - // Account #19 private key from Hardhat local node - let wallet_secret = web3::signing::SecretKey::from_str( - "df57089febbacf7ba0bc227dafbffa9fc08a93fdc68e1e42411a14efcf23656e", - )?; - let wallet = web3::signing::SecretKeyRef::from(&wallet_secret); + let node_wallets_secret = vec![ + // Account #18 private key from Hardhat local node + web3::signing::SecretKey::from_str( + "de9be858da4a475276426320d5e9262ecfc3ba460bfac56360bfa6c4c28b4ee0", + )?, + // Account #19 private key from Hardhat local node + web3::signing::SecretKey::from_str( + "df57089febbacf7ba0bc227dafbffa9fc08a93fdc68e1e42411a14efcf23656e", + )?, + ]; + let node_wallets = node_wallets_secret + .iter() + .map(web3::signing::SecretKeyRef::from) + .collect::>(); + + let wallets_secret = vec![ + // Account #16 private key from Hardhat local node + web3::signing::SecretKey::from_str( + "ea6c44ac03bff858b476bba40716402b03e41b8e97e276d1baec7c37d42484a0", + )?, + // Account #17 private key from Hardhat local node + web3::signing::SecretKey::from_str( + "689af8efa8c651a91ad287602527f3af2fe9f6501a7ac4b061667b5a93e037fd", + )?, + ]; + + let wallets = wallets_secret + .iter() + .map(web3::signing::SecretKeyRef::from) + .collect::>(); // Default http url for Hardhat local node let http = web3::transports::Http::new("http://127.0.0.1:8545")?; - - // Set miner address to be able to call `ValidatorSet::process()` method - let _ = hardhat_set_coinbase(&http, node_wallet.address()).await?; - let web3_client = web3::Web3::new(http); let validator_set_contract = deploy_upgradeable_contract( @@ -479,45 +495,54 @@ async fn test_sno_sbt() -> Result<(), anyhow::Error> { .await?; } - signed_call( - &server_nodes_manager_contract, - "newStake", - (node_wallet.address(), wallet.address()), - Some(U256::one()), - &wallet_secret, - ) - .await?; + for ((wallet, wallet_secret), (node_wallet, node_wallet_secret)) in wallets + .iter() + .zip(&wallets_secret) + .zip(node_wallets.iter().zip(&node_wallets_secret)) + { + signed_call( + &server_nodes_manager_contract, + "newStake", + (node_wallet.address(), wallet.address()), + Some(U256::one()), + wallet_secret, + ) + .await?; - signed_call( - &server_nodes_manager_contract, - "onBlock", - (), - None, - &node_wallet_secret, - ) - .await?; + signed_call( + &server_nodes_manager_contract, + "onBlock", + (), + None, + &owner_secret, + ) + .await?; - assert_matches!( - validator_set_contract - .query::<(U256, Address, bool), _, _, _>( - "stakes", - node_wallet.address(), - None, - contract::Options::default(), - None, - ) - .await, - Ok((staked, _, _)) if staked == U256::one() - ); + // Set miner address to be able to call `ValidatorSet::process()` method + let _ = hardhat_set_coinbase(web3_client.transport(), node_wallet.address()).await?; - signed_call( - &validator_set_contract, - "process", - (), - None, - &node_wallet_secret, - ) - .await?; + signed_call( + &validator_set_contract, + "process", + (), + None, + node_wallet_secret, + ) + .await?; + + assert_matches!( + validator_set_contract + .query::<(U256, Address, bool), _, _, _>( + "stakes", + node_wallet.address(), + None, + contract::Options::default(), + None, + ) + .await, + Ok((staked, _, _)) if staked == U256::one() + ); + } let issuer_contract = deploy_contract( web3_client.eth(), @@ -570,57 +595,75 @@ async fn test_sno_sbt() -> Result<(), anyhow::Error> { }; let req_signer = signer::SbtRequestSigner::new(signer_config); - let req = req_signer.build_signed_sno_sbt_request( - wallet.address(), - wallet.address(), - server_nodes_manager_contract.address(), - get_latest_block_timestamp(web3_client.eth()).await?, - )?; - - let signed_data = hex::decode(&req.data)?; - let sig_r: [u8; 32] = hex::decode(&req.r)?.try_into().map_err(|e| { - anyhow::Error::msg(format!( - "Signature R data is not 32 bytes length. Error: {e:?}" - )) - })?; - let sig_s: [u8; 32] = hex::decode(&req.s)?.try_into().map_err(|e| { - anyhow::Error::msg(format!( - "Signature S data is not 32 bytes length. Error: {e:?}" - )) - })?; // Try to mint SNO SBT - signed_call( + mint_sno_sbt( + &web3_client, + &req_signer, + &wallets[0], + &wallets_secret[0], + &wallets[0], + &sbt_contract, + &server_nodes_manager_contract, &issuer_contract, - "sbtMint", - ( - sbt_contract.address(), - signed_data.clone(), - req.v, - sig_r, - sig_s, - ), - None, - &wallet_secret, ) - .await - .unwrap(); + .await?; // Verify that SNO SBT can't be minted twice - let err_already_exist = signed_call( + let err_already_exist = mint_sno_sbt( + &web3_client, + &req_signer, + &wallets[0], + &wallets_secret[0], + &wallets[0], + &sbt_contract, + &server_nodes_manager_contract, &issuer_contract, - "sbtMint", - (sbt_contract.address(), signed_data, req.v, sig_r, sig_s), - None, - &wallet_secret, ) .await .unwrap_err(); - assert_matches!(err_already_exist, ApiError(web3::Error::Rpc(RPCError { message, .. })) if message.as_str() == ERR_SBT_ALREADY_EXIST); + assert!(err_already_exist + .to_string() + .contains(ERR_SBT_ALREADY_EXIST)); // Verify that SNO SBT is minted correctly assert_ne!( - sbt_verify(&sbt_contract, wallet.address()).await?, + sbt_verify(&sbt_contract, wallets[0].address()).await?, + DateTime::::from_timestamp(0, 0).unwrap() + ); + + // Unstake to remove node from validators list + signed_call( + &server_nodes_manager_contract, + "unstake", + (node_wallets[0].address(), U256::one()), + None, + &wallets_secret[0], + ) + .await?; + + // Verify that SNO SBT is not valid anymore + assert_eq!( + sbt_verify(&sbt_contract, wallets[0].address()).await?, + DateTime::::from_timestamp(0, 0).unwrap() + ); + + // Try to re-mint SNO SBT with different SNO wallet + mint_sno_sbt( + &web3_client, + &req_signer, + &wallets[0], + &wallets_secret[0], + &wallets[1], + &sbt_contract, + &server_nodes_manager_contract, + &issuer_contract, + ) + .await?; + + // Verify that SNO SBT is re-minted correctly + assert_ne!( + sbt_verify(&sbt_contract, wallets[0].address()).await?, DateTime::::from_timestamp(0, 0).unwrap() ); @@ -637,24 +680,26 @@ async fn test_sno_sbt() -> Result<(), anyhow::Error> { // Verify that SNO SBT is not valid anymore assert_eq!( - sbt_verify(&sbt_contract, wallet.address()).await?, + sbt_verify(&sbt_contract, wallets[0].address()).await?, DateTime::::from_timestamp(0, 0).unwrap() ); - // Try to burn OG SBT + // Try to burn SNO SBT signed_call( &issuer_contract, "sbtBurn", - (sbt_contract.address(), wallet.address()), + (sbt_contract.address(), wallets[0].address()), None, &owner_secret, ) .await .unwrap(); - // Verify that OG SBT doesn't exist anymore - let zero_date = sbt_verify(&sbt_contract, wallet.address()).await?; - assert_eq!(zero_date, DateTime::::from_timestamp(0, 0).unwrap()); + // Verify that SNO SBT doesn't exist anymore + assert_matches!( + sbt_exists(&sbt_contract, wallets[0].address()).await, + Ok(false) + ); Ok(()) } @@ -679,6 +724,21 @@ pub async fn gov_sbt_verify( )) } +pub async fn sbt_exists( + contract: &web3::contract::Contract, + wallet_addr: ethabi::Address, +) -> contract::Result { + contract + .query::( + "sbtExists", + wallet_addr, + wallet_addr, + contract::Options::default(), + None, + ) + .await +} + pub async fn sbt_verify( contract: &web3::contract::Contract, wallet_addr: ethabi::Address, @@ -696,3 +756,51 @@ pub async fn sbt_verify( DateTime::::from_timestamp(issued_at, 0) .ok_or_else(|| contract::Error::InvalidOutputType("Not a valid timestamp".to_owned())) } + +pub async fn mint_sno_sbt<'a, T: web3::Transport>( + web3_client: &'a web3::Web3, + req_signer: &'a signer::SbtRequestSigner, + wallet: &'a SecretKeyRef<'a>, + wallet_secret: &'a SecretKey, + sno_wallet: &'a SecretKeyRef<'a>, + sbt_contract: &'a Contract, + sno_contract: &'a Contract, + issuer_contract: &'a Contract, +) -> anyhow::Result<()> { + let req = req_signer.build_signed_sno_sbt_request( + wallet.address(), + sno_wallet.address(), + sno_contract.address(), + get_latest_block_timestamp(web3_client.eth()).await?, + )?; + + let signed_data = hex::decode(&req.data)?; + let sig_r: [u8; 32] = hex::decode(&req.r)?.try_into().map_err(|e| { + anyhow::Error::msg(format!( + "Signature R data is not 32 bytes length. Error: {e:?}" + )) + })?; + let sig_s: [u8; 32] = hex::decode(&req.s)?.try_into().map_err(|e| { + anyhow::Error::msg(format!( + "Signature S data is not 32 bytes length. Error: {e:?}" + )) + })?; + + // Try to mint SNO SBT + signed_call( + &issuer_contract, + "sbtMint", + ( + sbt_contract.address(), + signed_data.clone(), + req.v, + sig_r, + sig_s, + ), + None, + &wallet_secret, + ) + .await?; + + Ok(()) +}