From 0224f177331ff5558cea2d6988578dbd989dd864 Mon Sep 17 00:00:00 2001 From: benbierens Date: Tue, 9 Apr 2024 13:24:30 +0200 Subject: [PATCH 1/4] fixes serialization of request state --- ProjectPlugins/CodexContractsPlugin/CodexContractsAccess.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ProjectPlugins/CodexContractsPlugin/CodexContractsAccess.cs b/ProjectPlugins/CodexContractsPlugin/CodexContractsAccess.cs index 4279347..c539af6 100644 --- a/ProjectPlugins/CodexContractsPlugin/CodexContractsAccess.cs +++ b/ProjectPlugins/CodexContractsPlugin/CodexContractsAccess.cs @@ -5,6 +5,8 @@ using Nethereum.ABI; using Nethereum.Hex.HexTypes; using Nethereum.Util; using NethereumWorkflow; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; using Utils; namespace CodexContractsPlugin @@ -28,6 +30,7 @@ namespace CodexContractsPlugin SlotFreedEventDTO[] GetSlotFreedEvents(BlockInterval blockRange); } + [JsonConverter(typeof(StringEnumConverter))] public enum RequestState { New, From 4a0885cf2d77b6ff7b21422f0009177a495f56e6 Mon Sep 17 00:00:00 2001 From: benbierens Date: Thu, 11 Apr 2024 07:46:00 +0200 Subject: [PATCH 2/4] Check for marketplace contract up-to-date --- .../ContractsContainerInfoExtractor.cs | 16 +++- .../Marketplace/Marketplace.cs | 80 ++++++++++++++++--- Tools/TestNetRewarder/ChainState.cs | 3 +- 3 files changed, 86 insertions(+), 13 deletions(-) diff --git a/ProjectPlugins/CodexContractsPlugin/ContractsContainerInfoExtractor.cs b/ProjectPlugins/CodexContractsPlugin/ContractsContainerInfoExtractor.cs index 94cf4e6..752192c 100644 --- a/ProjectPlugins/CodexContractsPlugin/ContractsContainerInfoExtractor.cs +++ b/ProjectPlugins/CodexContractsPlugin/ContractsContainerInfoExtractor.cs @@ -1,4 +1,5 @@ -using KubernetesWorkflow; +using CodexContractsPlugin.Marketplace; +using KubernetesWorkflow; using KubernetesWorkflow.Types; using Logging; using Newtonsoft.Json; @@ -53,7 +54,18 @@ namespace CodexContractsPlugin var artifact = JObject.Parse(json); var abi = artifact["abi"]; - return abi!.ToString(Formatting.None); + var byteCode = artifact["bytecode"]; + var abiResult = abi!.ToString(Formatting.None); + var byteCodeResult = byteCode!.ToString(Formatting.None); + + if (byteCodeResult + .ToLowerInvariant() + .Replace("\"", "") != MarketplaceDeploymentBase.BYTECODE.ToLowerInvariant()) + { + throw new Exception("BYTECODE in CodexContractsPlugin does not match BYTECODE deployed by container. Update Marketplace.cs generated code?"); + } + + return abiResult; } private static string Retry(Func fetch) diff --git a/ProjectPlugins/CodexContractsPlugin/Marketplace/Marketplace.cs b/ProjectPlugins/CodexContractsPlugin/Marketplace/Marketplace.cs index 507334a..a9ae4ba 100644 --- a/ProjectPlugins/CodexContractsPlugin/Marketplace/Marketplace.cs +++ b/ProjectPlugins/CodexContractsPlugin/Marketplace/Marketplace.cs @@ -7,6 +7,25 @@ using System.Numerics; #pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. namespace CodexContractsPlugin.Marketplace { + public partial class MarketplaceDeployment : MarketplaceDeploymentBase + { + public MarketplaceDeployment() : base(BYTECODE) { } + public MarketplaceDeployment(string byteCode) : base(byteCode) { } + } + + public class MarketplaceDeploymentBase : ContractDeploymentMessage + { + public static string BYTECODE = "0x60c06040523480156200001157600080fd5b5060405162003c1038038062003c10833981016040819052620000349162000487565b60208301518051608052816101004311620000965760405162461bcd60e51b815260206004820152601960248201527f496e73756666696369656e7420626c6f636b206865696768740000000000000060448201526064015b60405180910390fd5b81516000908155602083015160015560408301516002805460ff191660ff9092169190911790556060830151839190600390620000d4908262000627565b5050600480546001600160a01b0319166001600160a01b0393841617905550831660a05250825151606460ff9091161115620001535760405162461bcd60e51b815260206004820152601560248201527f4d757374206265206c657373207468616e20313030000000000000000000000060448201526064016200008d565b606483600001516060015160ff161115620001b15760405162461bcd60e51b815260206004820152601560248201527f4d757374206265206c657373207468616e20313030000000000000000000000060448201526064016200008d565b82516060810151602090910151606491620001cc91620006f3565b60ff1611156200021f5760405162461bcd60e51b815260206004820152601d60248201527f4d6178696d756d20736c617368696e672065786365656473203130302500000060448201526064016200008d565b82518051600c805460208085015160408087015160609788015160ff9081166401000000000260ff60201b1961ffff90931662010000029290921664ffffff0000199482166101000261ffff1990971698821698909817959095179290921695909517178355808801518051600d90815591810151600e5593840151600f80549190931660ff19919091161790915592820151869391929190601090620002c7908262000627565b50505090505050505062000725565b634e487b7160e01b600052604160045260246000fd5b604051608081016001600160401b0381118282101715620003115762000311620002d6565b60405290565b604080519081016001600160401b0381118282101715620003115762000311620002d6565b604051601f8201601f191681016001600160401b0381118282101715620003675762000367620002d6565b604052919050565b805160ff811681146200038157600080fd5b919050565b6000608082840312156200039957600080fd5b620003a3620002ec565b90508151815260208083015181830152620003c1604084016200036f565b604083015260608301516001600160401b0380821115620003e157600080fd5b818501915085601f830112620003f657600080fd5b8151818111156200040b576200040b620002d6565b6200041f601f8201601f191685016200033c565b915080825286848285010111156200043657600080fd5b60005b818110156200045657838101850151838201860152840162000439565b5060008482840101525080606085015250505092915050565b80516001600160a01b03811681146200038157600080fd5b6000806000606084860312156200049d57600080fd5b83516001600160401b0380821115620004b557600080fd5b9085019081870360a0811215620004cb57600080fd5b620004d562000317565b6080821215620004e457600080fd5b620004ee620002ec565b9150620004fb846200036f565b82526200050b602085016200036f565b6020830152604084015161ffff811681146200052657600080fd5b604083015262000539606085016200036f565b6060830152908152608083015190828211156200055557600080fd5b620005638983860162000386565b6020820152809650505050506200057d602085016200046f565b91506200058d604085016200046f565b90509250925092565b600181811c90821680620005ab57607f821691505b602082108103620005cc57634e487b7160e01b600052602260045260246000fd5b50919050565b601f82111562000622576000816000526020600020601f850160051c81016020861015620005fd5750805b601f850160051c820191505b818110156200061e5782815560010162000609565b5050505b505050565b81516001600160401b03811115620006435762000643620002d6565b6200065b8162000654845462000596565b84620005d2565b602080601f8311600181146200069357600084156200067a5750858301515b600019600386901b1c1916600185901b1785556200061e565b600085815260208120601f198616915b82811015620006c457888601518255948401946001909101908401620006a3565b5085821015620006e35787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60ff81811683821602908116908181146200071e57634e487b7160e01b600052601160045260246000fd5b5092915050565b60805160a0516134a26200076e6000396000818161039c01528181610b8801528181611cc10152818161204601526121b20152600081816125dc015261277b01526134a26000f3fe608060405234801561001057600080fd5b50600436106101775760003560e01c80639777b72c116100d8578063be5cdc481161008c578063f752196b11610066578063f752196b1461035a578063fb1e61ca1461037a578063fc0c546a1461039a57600080fd5b8063be5cdc4814610314578063c0cc4add14610334578063e8aa0a071461034757600080fd5b8063a3a0807e116100bd578063a3a0807e146102be578063a6af384b146102e1578063b396dc79146102f457600080fd5b80639777b72c146102a3578063a29c29a4146102ab57600080fd5b806359cc89ed1161012f5780636b00c8cf116101145780636b00c8cf146102375780636e2b54ee1461027b57806379502c551461028e57600080fd5b806359cc89ed1461020f5780635da738351461022257600080fd5b806308695fcd1161016057806308695fcd146101c2578063458d2bf1146101d75780634641dce6146101ea57600080fd5b806302fa8e651461017c57806305b90773146101a2575b600080fd5b61018f61018a3660046129b1565b6103c0565b6040519081526020015b60405180910390f35b6101b56101b03660046129b1565b610437565b60405161019991906129e0565b6101d56101d03660046129fa565b610529565b005b61018f6101e53660046129b1565b61067f565b6101fd6101f83660046129b1565b610698565b60405160ff9091168152602001610199565b6101d561021d366004612a2f565b6106ab565b61022a6109af565b6040516101999190612a66565b6102636102453660046129b1565b6000908152601360205260409020600501546001600160a01b031690565b6040516001600160a01b039091168152602001610199565b6101d56102893660046129b1565b6109d6565b610296610c09565b6040516101999190612af0565b61022a610d7a565b6101d56102b93660046129b1565b610d99565b6102d16102cc3660046129b1565b610f6a565b6040519015158152602001610199565b6101d56102ef366004612b72565b610f9f565b6103076103023660046129b1565b6111c5565b6040516101999190612c7b565b6103276103223660046129b1565b6113ae565b6040516101999190612cad565b6102d16103423660046129b1565b61147c565b6101d5610355366004612cc1565b61148f565b61018f6103683660046129b1565b60009081526007602052604090205490565b61038d6103883660046129b1565b6115cc565b6040516101999190612cef565b7f0000000000000000000000000000000000000000000000000000000000000000610263565b600081815260126020526040812060040154816103dc84610437565b905060008160048111156103f2576103f26129ca565b148061040f5750600181600481111561040d5761040d6129ca565b145b1561041b575092915050565b61042f8261042a600142612d18565b611783565b949350505050565b60008181526011602052604081205482906001600160a01b03166104945760405162461bcd60e51b815260206004820152600f60248201526e155b9adb9bdddb881c995c5d595cdd608a1b60448201526064015b60405180910390fd5b600083815260126020526040812090815460ff1660048111156104b9576104b96129ca565b1480156104d657506000848152601160205260409020600a015442115b156104e5576002925050610523565b6001815460ff1660048111156104fd576104fd6129ca565b14801561050d5750806004015442115b1561051c576003925050610523565b5460ff1691505b50919050565b6001610534836113ae565b6005811115610545576105456129ca565b146105925760405162461bcd60e51b815260206004820152601960248201527f536c6f74206e6f7420616363657074696e672070726f6f667300000000000000604482015260640161048b565b61059c828261179b565b6000828152601360209081526040808320600181015484526011909252909120600c5461ffff62010000909104166105e08560009081526007602052604090205490565b6105ea9190612d41565b60000361067957600c54600682015460009160649161061491640100000000900460ff1690612d55565b61061e9190612d6c565b9050808360040160008282546106349190612d18565b9091555050600c54600086815260076020526040902054610100820460ff169162010000900461ffff16906106699190612d6c565b1061067757610677856119c8565b505b50505050565b60006106928261068d611b6e565b611b79565b92915050565b6000610692826106a6611b6e565b611b8d565b60008381526011602052604090205483906001600160a01b03166107035760405162461bcd60e51b815260206004820152600f60248201526e155b9adb9bdddb881c995c5d595cdd608a1b604482015260640161048b565b6000848152601160205260409020600181015467ffffffffffffffff16841061076e5760405162461bcd60e51b815260206004820152600c60248201527f496e76616c696420736c6f740000000000000000000000000000000000000000604482015260640161048b565b60408051602080820188905281830187905282518083038401815260609092019092528051910120600090600081815260136020526040812060018101899055600381018890559192506107c1836113ae565b60058111156107d2576107d26129ca565b1461081f5760405162461bcd60e51b815260206004820152601060248201527f536c6f74206973206e6f74206672656500000000000000000000000000000000604482015260640161048b565b60048301546000838152600560209081526040808320429055600690915290205561084a828661148f565b60058101805473ffffffffffffffffffffffffffffffffffffffff191633179055805460ff1916600190811782554260028301556000888152601260205260408120808301805491939290916108a1908490612d80565b909155506108b190508842611bf9565b8160020160008282546108c49190612d18565b909155505060068401546108d83382611c79565b80601460000160008282546108ed9190612d80565b9091555050600483018190556005830154610911906001600160a01b031685611d81565b887ff530852268993f91008f1a1e0b09b5c813acd4188481f1fa83c33c7182e814b48960405161094391815260200190565b60405180910390a26001808601549083015467ffffffffffffffff90911690036109a457815460ff1916600117825542600383015560405189907f85e1543bf2f84fe80c6badbce3648c8539ad1df4d2b3d822938ca0538be727e690600090a25b505050505050505050565b336000908152600b602052604090206060906109d1906109ce90611da3565b90565b905090565b6000818152601160205260409020600a8101544211610a375760405162461bcd60e51b815260206004820152601960248201527f52657175657374206e6f74207965742074696d6564206f757400000000000000604482015260640161048b565b80546001600160a01b03163314610a905760405162461bcd60e51b815260206004820152601660248201527f496e76616c696420636c69656e74206164647265737300000000000000000000604482015260640161048b565b600082815260126020526040812090815460ff166004811115610ab557610ab56129ca565b14610b025760405162461bcd60e51b815260206004820152600d60248201527f496e76616c696420737461746500000000000000000000000000000000000000604482015260640161048b565b805460ff191660021781558154610b22906001600160a01b031684611db0565b60405183907ff903f4774c7bd27355f9d7fcbc382b079b164a697a44ac5d95267a4c3cb3bb2290600090a2600281015460158054829190600090610b67908490612d80565b909155505060405163a9059cbb60e01b8152336004820152602481018290527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063a9059cbb906044016020604051808303816000875af1158015610bd9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bfd9190612d93565b61067957610679612db5565b610c606040805160c0810182526000918101828152606082018390526080820183905260a0820192909252908190815260408051608081018252600080825260208281018290529282015260608082015291015290565b6040805160c081018252600c805460ff8082168486019081526101008304821660608087019190915261ffff62010000850416608080880191909152640100000000909404831660a087015290855285519283018652600d80548452600e54602085810191909152600f54909316968401969096526010805495969495928701949291840191610cef90612dcb565b80601f0160208091040260200160405190810160405280929190818152602001828054610d1b90612dcb565b8015610d685780601f10610d3d57610100808354040283529160200191610d68565b820191906000526020600020905b815481529060010190602001808311610d4b57829003601f168201915b50505050508152505081525050905090565b336000908152600a602052604090206060906109d1906109ce90611da3565b806000808281526013602052604090205460ff166005811115610dbe57610dbe6129ca565b03610dfa5760405162461bcd60e51b815260206004820152600c60248201526b536c6f74206973206672656560a01b604482015260640161048b565b600082815260136020526040902060058101546001600160a01b03163314610e645760405162461bcd60e51b815260206004820152601960248201527f536c6f742066696c6c6564206279206f7468657220686f737400000000000000604482015260640161048b565b6000610e6f846113ae565b90506004816005811115610e8557610e856129ca565b03610ed25760405162461bcd60e51b815260206004820152600c60248201527f416c726561647920706169640000000000000000000000000000000000000000604482015260640161048b565b6002816005811115610ee657610ee66129ca565b03610efe57610ef9826001015485611dd2565b610679565b6005816005811115610f1257610f126129ca565b03610f2557610ef98260010154856120bf565b6003816005811115610f3957610f396129ca565b03610f4857610ef9338561222b565b6001816005811115610f5c57610f5c6129ca565b0361067957610679846119c8565b6000806000610f8084610f7b611b6e565b61224d565b909250905081801561042f575060025460ff9081169116109392505050565b33610fad6020830183612e17565b6001600160a01b0316146110035760405162461bcd60e51b815260206004820152601660248201527f496e76616c696420636c69656e74206164647265737300000000000000000000604482015260640161048b565b600061101661101183612fa9565b612330565b6000818152601160205260409020549091506001600160a01b03161561107e5760405162461bcd60e51b815260206004820152601660248201527f5265717565737420616c72656164792065786973747300000000000000000000604482015260640161048b565b600081815260116020526040902082906110988282613206565b50600090506110ab606084013542612d80565b905082610120013581116111015760405162461bcd60e51b815260206004820152601960248201527f5265717565737420656e64206265666f72652065787069727900000000000000604482015260640161048b565b600082815260126020908152604090912060040182905561112e9061112890850185612e17565b83612360565b600061114161113c85612fa9565b612382565b600084815260126020526040812060020182905560148054929350839290919061116c908490612d80565b9091555061117c90503382611c79565b7f5fdb86c365a247a4d97dcbcc5c3abde9d6e3e2de26273f3fda8eef5073b9a96c83856020018661012001356040516111b7939291906132fe565b60405180910390a150505050565b6111cd6128e9565b816000808281526013602052604090205460ff1660058111156111f2576111f26129ca565b0361122e5760405162461bcd60e51b815260206004820152600c60248201526b536c6f74206973206672656560a01b604482015260640161048b565b60008381526013602052604090206112446128e9565b600180830154600090815260116020908152604091829020825160a0808201855282546001600160a01b03168252845160e0810186529583015467ffffffffffffffff9081168752600284015487860152600384015487870152600484015460608801526005840154608088015260068401549187019190915260078301541660c08601529182019390935281518083018352600884018054929493850192829082906112f090612dcb565b80601f016020809104026020016040519081016040528092919081815260200182805461131c90612dcb565b80156113695780601f1061133e57610100808354040283529160200191611369565b820191906000526020600020905b81548152906001019060200180831161134c57829003601f168201915b505050918352505060019190910154602091820152908252600a83015482820152600b9092015460409091015290825260039092015491810191909152915050919050565b6000818152601360205260408120600181015482036113d05750600092915050565b60006113df8260010154610437565b90506004825460ff1660058111156113f9576113f96129ca565b03611408575060049392505050565b600281600481111561141c5761141c6129ca565b0361142b575060059392505050565b600381600481111561143f5761143f6129ca565b0361144e575060029392505050565b6004816004811115611462576114626129ca565b03611471575060039392505050565b505460ff1692915050565b60006106928261148a611b6e565b6123a7565b6000828152601360209081526040808320600101548084526011909252909120546001600160a01b03166114f75760405162461bcd60e51b815260206004820152600f60248201526e155b9adb9bdddb881c995c5d595cdd608a1b604482015260640161048b565b60008381526013602090815260408083206001810154845260118352818420825160038082526080820190945291949093909290820160608036833701905050905061154a6115458761067f565b6123da565b8160008151811061155d5761155d61337a565b60209081029190910101526009820154611576906123eb565b816001815181106115895761158961337a565b6020026020010181815250508260030154816002815181106115ad576115ad61337a565b6020026020010181815250506115c48686836123f7565b505050505050565b6115d4612909565b60008281526011602052604090205482906001600160a01b031661162c5760405162461bcd60e51b815260206004820152600f60248201526e155b9adb9bdddb881c995c5d595cdd608a1b604482015260640161048b565b600083815260116020908152604091829020825160a0808201855282546001600160a01b03168252845160e081018652600184015467ffffffffffffffff90811682526002850154828701526003850154828801526004850154606083015260058501546080830152600685015492820192909252600784015490911660c082015292810192909252825180840184526008820180549394929392850192829082906116d790612dcb565b80601f016020809104026020016040519081016040528092919081815260200182805461170390612dcb565b80156117505780601f1061172557610100808354040283529160200191611750565b820191906000526020600020905b81548152906001019060200180831161173357829003601f168201915b505050505081526020016001820154815250508152602001600a8201548152602001600b82015481525050915050919050565b60008183106117925781611794565b825b9392505050565b60006117a6826125c2565b90504281106117f75760405162461bcd60e51b815260206004820152601860248201527f506572696f6420686173206e6f7420656e646564207965740000000000000000604482015260640161048b565b6001546118049082612d80565b42106118525760405162461bcd60e51b815260206004820152601460248201527f56616c69646174696f6e2074696d6564206f7574000000000000000000000000604482015260640161048b565b600083815260086020908152604080832085845290915290205460ff16156118bc5760405162461bcd60e51b815260206004820181905260248201527f50726f6f6620776173207375626d69747465642c206e6f74206d697373696e67604482015260640161048b565b6118c683836123a7565b6119125760405162461bcd60e51b815260206004820152601660248201527f50726f6f6620776173206e6f7420726571756972656400000000000000000000604482015260640161048b565b600083815260096020908152604080832085845290915290205460ff161561197c5760405162461bcd60e51b815260206004820152601f60248201527f50726f6f6620616c7265616479206d61726b6564206173206d697373696e6700604482015260640161048b565b60008381526009602090815260408083208584528252808320805460ff19166001908117909155868452600790925282208054919290916119be908490612d80565b9091555050505050565b60008181526013602090815260408083206001810154808552601290935292206005830154611a00906001600160a01b03168561222b565b6003808401546000868152601360205260408120805460ff1916815560018082018390556002820183905593810182905560048101829055600501805473ffffffffffffffffffffffffffffffffffffffff191690558383018054929392909190611a6c908490612d18565b909155505060405181815283907f1d31c9f8dea6e179f6a050db117595feea8937029ea51f5168a4780be7e8f5529060200160405180910390a2600085815260076020526040812055600083815260116020526040812060018085015490820154919291611ae4919067ffffffffffffffff16612d18565b600783015490915067ffffffffffffffff1681118015611b1957506001845460ff166004811115611b1757611b176129ca565b145b15611b6557835460ff19166004178455611b34600142612d18565b600485015560405185907f4769361a442504ecaf038f35e119bcccdd5e42096b24c09e3c17fd17c6684c0290600090a25b50505050505050565b60006109d1426125d5565b6000611794611b888484611b8d565b612601565b600080611b9c61010043612d41565b90506000610100611bae856043612d55565b611bb89190612d41565b90506000611bc861010087612d41565b9050600061010082611bda8587612d80565b611be49190612d80565b611bee9190612d41565b979650505050505050565b6000828152601160205260408120600a8101548310611c5a5760405162461bcd60e51b815260206004820152601760248201527f5374617274206e6f74206265666f726520657870697279000000000000000000604482015260640161048b565b6005810154600a820154611c6f908590612d18565b61042f9190612d55565b6040517f23b872dd0000000000000000000000000000000000000000000000000000000081526001600160a01b038381166004830152306024830181905260448301849052917f0000000000000000000000000000000000000000000000000000000000000000909116906323b872dd906064016020604051808303816000875af1158015611d0c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d309190612d93565b611d7c5760405162461bcd60e51b815260206004820152600f60248201527f5472616e73666572206661696c65640000000000000000000000000000000000604482015260640161048b565b505050565b6001600160a01b0382166000908152600b60205260409020611d7c908261265b565b6060600061179483612667565b6001600160a01b0382166000908152600a60205260409020611d7c90826126c3565b60008281526011602052604090205482906001600160a01b0316611e2a5760405162461bcd60e51b815260206004820152600f60248201526e155b9adb9bdddb881c995c5d595cdd608a1b604482015260640161048b565b60008381526012602090815260408083206011909252909120815460ff191660031782558054611e63906001600160a01b031686611db0565b60008481526013602052604090206005810154611e89906001600160a01b03168661222b565b6004808201546000888152601160209081526040808320815160a0808201845282546001600160a01b03168252835160e081018552600184015467ffffffffffffffff908116825260028501548288015260038501548287015298840154606082015260058401546080820152600684015491810191909152600783015490971660c088015292830195909552805180820182526008860180549496611fe6959093850192919082908290611f3d90612dcb565b80601f0160208091040260200160405190810160405280929190818152602001828054611f6990612dcb565b8015611fb65780601f10611f8b57610100808354040283529160200191611fb6565b820191906000526020600020905b815481529060010190602001808311611f9957829003601f168201915b505050505081526020016001820154815250508152602001600a8201548152602001600b820154815250506126cf565b611ff09190612d80565b905080601460010160008282546120079190612d80565b9091555050815460ff191660049081178355600583015460405163a9059cbb60e01b81526001600160a01b0391821692810192909252602482018390527f0000000000000000000000000000000000000000000000000000000000000000169063a9059cbb906044016020604051808303816000875af115801561208f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120b39190612d93565b611b6557611b65612db5565b60008281526011602052604090205482906001600160a01b03166121175760405162461bcd60e51b815260206004820152600f60248201526e155b9adb9bdddb881c995c5d595cdd608a1b604482015260640161048b565b6000828152601360205260409020600581015461213d906001600160a01b03168461222b565b60008160040154612152868460020154611bf9565b61215c9190612d80565b905080601460010160008282546121739190612d80565b9091555050815460ff191660049081178355600583015460405163a9059cbb60e01b81526001600160a01b0391821692810192909252602482018390527f0000000000000000000000000000000000000000000000000000000000000000169063a9059cbb906044016020604051808303816000875af11580156121fb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061221f9190612d93565b61067757610677612db5565b6001600160a01b0382166000908152600b60205260409020611d7c90826126c3565b600080600061225b856113ae565b60008681526005602052604081205491925090612277906125d5565b9050600182600581111561228d5761228d6129ca565b1415806122a1575061229f85826126eb565b155b156122b457600080935093505050612329565b6122be8686611b8d565b925060006122cb84612601565b600254909150600090610100906122e59060ff1682613390565b60008a8152600660205260409020546123029161ffff1690612d55565b61230c9190612d6c565b905080158061232257506123208183612d41565b155b9550505050505b9250929050565b6000816040516020016123439190612cef565b604051602081830303815290604052805190602001209050919050565b6001600160a01b0382166000908152600a60205260409020611d7c908261265b565b600061238d826126cf565b602083015151610692919067ffffffffffffffff16612d55565b60008060006123b6858561224d565b90925090508180156123d1575060025460ff90811690821610155b95945050505050565b600060ff1982168161042f826126f5565b600080611794836126f5565b60008381526008602052604081209061240e611b6e565b815260208101919091526040016000205460ff161561246f5760405162461bcd60e51b815260206004820152601760248201527f50726f6f6620616c7265616479207375626d6974746564000000000000000000604482015260640161048b565b600480546040517f94c8919d0000000000000000000000000000000000000000000000000000000081526001600160a01b03909116916394c8919d916124b99186918691016133ab565b602060405180830381865afa1580156124d6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124fa9190612d93565b6125465760405162461bcd60e51b815260206004820152600d60248201527f496e76616c69642070726f6f6600000000000000000000000000000000000000604482015260640161048b565b600083815260086020526040812060019161255f611b6e565b815260200190815260200160002060006101000a81548160ff0219169083151502179055507f3b989d183b84b02259d7c14b34a9c9eb0fccb4c355a920d25e581e25aef4993d836040516125b591815260200190565b60405180910390a1505050565b60006106926125d083612767565b612774565b60006106927f000000000000000000000000000000000000000000000000000000000000000083612d6c565b60008060ff8316612613600143612d18565b61261d9190612d18565b409050600081900361263157612631612db5565b60408051602081018390520160405160208183030381529060405280519060200120915050919050565b600061179483836127a0565b6060816000018054806020026020016040519081016040528092919081815260200182805480156126b757602002820191906000526020600020905b8154815260200190600101908083116126a3575b50505050509050919050565b600061179483836127ef565b6020810151608081015160409091015160009161069291612d55565b6000818311611794565b7fff00000000000000000000000000000000000000000000000000000000000000811660015b602081101561052357600891821c91612735908290612d55565b83901b7fff0000000000000000000000000000000000000000000000000000000000000016919091179060010161271b565b6000610692826001612d80565b60006106927f000000000000000000000000000000000000000000000000000000000000000083612d55565b60008181526001830160205260408120546127e757508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610692565b506000610692565b600081815260018301602052604081205480156128d8576000612813600183612d18565b855490915060009061282790600190612d18565b905081811461288c5760008660000182815481106128475761284761337a565b906000526020600020015490508087600001848154811061286a5761286a61337a565b6000918252602080832090910192909255918252600188019052604090208390555b855486908061289d5761289d613456565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610692565b6000915050610692565b5092915050565b60405180604001604052806128fc612909565b8152602001600081525090565b6040518060a0016040528060006001600160a01b031681526020016129786040518060e00160405280600067ffffffffffffffff1681526020016000815260200160008152602001600081526020016000815260200160008152602001600067ffffffffffffffff1681525090565b815260200161299d604051806040016040528060608152602001600080191681525090565b815260006020820181905260409091015290565b6000602082840312156129c357600080fd5b5035919050565b634e487b7160e01b600052602160045260246000fd5b60208101600583106129f4576129f46129ca565b91905290565b60008060408385031215612a0d57600080fd5b50508035926020909101359150565b6000610100828403121561052357600080fd5b60008060006101408486031215612a4557600080fd5b8335925060208401359150612a5d8560408601612a1c565b90509250925092565b6020808252825182820181905260009190848201906040850190845b81811015612a9e57835183529284019291840191600101612a82565b50909695505050505050565b6000815180845260005b81811015612ad057602081850181015186830182015201612ab4565b506000602082860101526020601f19601f83011685010191505092915050565b602081526000825160ff815116602084015260ff602082015116604084015261ffff604082015116606084015260ff606082015116608084015250602083015160a080840152805160c0840152602081015160e084015260ff60408201511661010084015260608101519050608061012084015261042f610140840182612aaa565b600060208284031215612b8457600080fd5b813567ffffffffffffffff811115612b9b57600080fd5b8201610160818503121561179457600080fd5b6000815160408452612bc36040850182612aaa565b602093840151949093019390935250919050565b60006101606001600160a01b038351168452602083015167ffffffffffffffff808251166020870152602082015160408701526040820151606087015260608201516080870152608082015160a087015260a082015160c08701528060c08301511660e08701525050604083015181610100860152612c5882860182612bae565b915050606083015161012085015260808301516101408501528091505092915050565b602081526000825160406020840152612c976060840182612bd7565b9050602084015160408401528091505092915050565b60208101600683106129f4576129f46129ca565b6000806101208385031215612cd557600080fd5b82359150612ce68460208501612a1c565b90509250929050565b6020815260006117946020830184612bd7565b634e487b7160e01b600052601160045260246000fd5b8181038181111561069257610692612d02565b634e487b7160e01b600052601260045260246000fd5b600082612d5057612d50612d2b565b500690565b808202811582820484141761069257610692612d02565b600082612d7b57612d7b612d2b565b500490565b8082018082111561069257610692612d02565b600060208284031215612da557600080fd5b8151801515811461179457600080fd5b634e487b7160e01b600052600160045260246000fd5b600181811c90821680612ddf57607f821691505b60208210810361052357634e487b7160e01b600052602260045260246000fd5b6001600160a01b0381168114612e1457600080fd5b50565b600060208284031215612e2957600080fd5b813561179481612dff565b634e487b7160e01b600052604160045260246000fd5b6040805190810167ffffffffffffffff81118282101715612e6d57612e6d612e34565b60405290565b60405160a0810167ffffffffffffffff81118282101715612e6d57612e6d612e34565b60405160e0810167ffffffffffffffff81118282101715612e6d57612e6d612e34565b604051601f8201601f1916810167ffffffffffffffff81118282101715612ee257612ee2612e34565b604052919050565b67ffffffffffffffff81168114612e1457600080fd5b600060408284031215612f1257600080fd5b612f1a612e4a565b9050813567ffffffffffffffff80821115612f3457600080fd5b818401915084601f830112612f4857600080fd5b8135602082821115612f5c57612f5c612e34565b612f6e601f8301601f19168201612eb9565b92508183528681838601011115612f8457600080fd5b8181850182850137600081838501015282855280860135818601525050505092915050565b6000813603610160811215612fbd57600080fd5b612fc5612e73565b8335612fd081612dff565b815260e0601f1983011215612fe457600080fd5b612fec612e96565b91506020840135612ffc81612eea565b8083525060408401356020830152606084013560408301526080840135606083015260a0840135608083015260c084013560a083015260e084013561304081612eea565b60c083015260208101919091526101008301359067ffffffffffffffff82111561306957600080fd5b61307536838601612f00565b604082015261012084013560608201526101409093013560808401525090919050565b6000813561069281612eea565b60008235603e198336030181126130bb57600080fd5b9190910192915050565b601f821115611d7c576000816000526020600020601f850160051c810160208610156130ee5750805b601f850160051c820191505b818110156115c4578281556001016130fa565b8135601e1983360301811261312157600080fd5b8201803567ffffffffffffffff81111561313a57600080fd5b6020813603818401131561314d57600080fd5b6131618261315b8654612dcb565b866130c5565b6000601f831160018114613197576000841561317f57508482018301355b600019600386901b1c1916600185901b1786556131f4565b600086815260209020601f19851690835b828110156131c95787850186013582559385019360019091019085016131a8565b50858210156131e85760001960f88760031b161c198585890101351681555b505060018460011b0186555b50508085013560018501555050505050565b813561321181612dff565b6001600160a01b03811673ffffffffffffffffffffffffffffffffffffffff1983541617825550602082013561324681612eea565b60018201805467ffffffffffffffff191667ffffffffffffffff83161790555060408201356002820155606082013560038201556080820135600482015560a0820135600582015560c082013560068201556132ca6132a760e08401613098565b6007830167ffffffffffffffff821667ffffffffffffffff198254161781555050565b6132e46132db6101008401846130a5565b6008830161310d565b610120820135600a820155610140820135600b8201555050565b8381526101208101833561331181612eea565b67ffffffffffffffff8082166020850152602086013560408501526040860135606085015260608601356080850152608086013560a085015260a086013560c085015260c0860135915061336482612eea565b1660e08301526101009091019190915292915050565b634e487b7160e01b600052603260045260246000fd5b61ffff8281168282160390808211156128e2576128e2612d02565b823581526020808401359082015260006101208281016133db604085016040880180358252602090810135910152565b6133f5608085016080880180358252602090810135910152565b61340f60c0850160c0880180358252602090810135910152565b61010084019190915283519081905261014083019060209081860160005b828110156134495781518552938301939083019060010161342d565b5092979650505050505050565b634e487b7160e01b600052603160045260246000fdfea26469706673582212201d12cd1bfef3b2ec5ee1f81d1ea21b12b2bb5ae8b67fb3ebaaeca5a194c2a0b564736f6c63430008170033"; + public MarketplaceDeploymentBase() : base(BYTECODE) { } + public MarketplaceDeploymentBase(string byteCode) : base(byteCode) { } + [Parameter("tuple", "configuration", 1)] + public virtual MarketplaceConfig Configuration { get; set; } + [Parameter("address", "token_", 2)] + public virtual string Token { get; set; } + [Parameter("address", "verifier", 3)] + public virtual string Verifier { get; set; } + } + public partial class ConfigFunction : ConfigFunctionBase { } [Function("config", typeof(ConfigOutputDTO))] @@ -24,8 +43,8 @@ namespace CodexContractsPlugin.Marketplace public virtual byte[] RequestId { get; set; } [Parameter("uint256", "slotIndex", 2)] public virtual BigInteger SlotIndex { get; set; } - [Parameter("bytes", "proof", 3)] - public virtual byte[] Proof { get; set; } + [Parameter("tuple", "proof", 3)] + public virtual Groth16Proof Proof { get; set; } } public partial class FreeSlotFunction : FreeSlotFunctionBase { } @@ -170,8 +189,8 @@ namespace CodexContractsPlugin.Marketplace { [Parameter("bytes32", "id", 1)] public virtual byte[] Id { get; set; } - [Parameter("bytes", "proof", 2)] - public virtual byte[] Proof { get; set; } + [Parameter("tuple", "proof", 2)] + public virtual Groth16Proof Proof { get; set; } } public partial class TokenFunction : TokenFunctionBase { } @@ -207,8 +226,6 @@ namespace CodexContractsPlugin.Marketplace { [Parameter("bytes32", "id", 1, false)] public virtual byte[] Id { get; set; } - [Parameter("bytes", "proof", 2, false)] - public virtual byte[] Proof { get; set; } } public partial class RequestCancelledEventDTO : RequestCancelledEventDTOBase { } @@ -278,10 +295,8 @@ namespace CodexContractsPlugin.Marketplace [FunctionOutput] public class ConfigOutputDTOBase : IFunctionOutputDTO { - [Parameter("tuple", "collateral", 1)] - public virtual CollateralConfig Collateral { get; set; } - [Parameter("tuple", "proofs", 2)] - public virtual ProofConfig Proofs { get; set; } + [Parameter("tuple", "", 1)] + public virtual MarketplaceConfig ReturnValue1 { get; set; } } @@ -446,6 +461,8 @@ namespace CodexContractsPlugin.Marketplace public virtual BigInteger Timeout { get; set; } [Parameter("uint8", "downtime", 3)] public virtual byte Downtime { get; set; } + [Parameter("string", "zkeyHash", 4)] + public virtual string ZkeyHash { get; set; } } public partial class MarketplaceConfig : MarketplaceConfigBase { } @@ -478,6 +495,48 @@ namespace CodexContractsPlugin.Marketplace public virtual ulong MaxSlotLoss { get; set; } } + public partial class G1Point : G1PointBase { } + + public class G1PointBase + { + [Parameter("uint256", "x", 1)] + public virtual BigInteger X { get; set; } + [Parameter("uint256", "y", 2)] + public virtual BigInteger Y { get; set; } + } + + public partial class Fp2Element : Fp2ElementBase { } + + public class Fp2ElementBase + { + [Parameter("uint256", "real", 1)] + public virtual BigInteger Real { get; set; } + [Parameter("uint256", "imag", 2)] + public virtual BigInteger Imag { get; set; } + } + + public partial class G2Point : G2PointBase { } + + public class G2PointBase + { + [Parameter("tuple", "x", 1)] + public virtual Fp2Element X { get; set; } + [Parameter("tuple", "y", 2)] + public virtual Fp2Element Y { get; set; } + } + + public partial class Groth16Proof : Groth16ProofBase { } + + public class Groth16ProofBase + { + [Parameter("tuple", "a", 1)] + public virtual G1Point A { get; set; } + [Parameter("tuple", "b", 2)] + public virtual G2Point B { get; set; } + [Parameter("tuple", "c", 3)] + public virtual G1Point C { get; set; } + } + public partial class Content : ContentBase { } public class ContentBase @@ -514,4 +573,5 @@ namespace CodexContractsPlugin.Marketplace public virtual BigInteger SlotIndex { get; set; } } } + #pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. diff --git a/Tools/TestNetRewarder/ChainState.cs b/Tools/TestNetRewarder/ChainState.cs index ce7f850..9c93f87 100644 --- a/Tools/TestNetRewarder/ChainState.cs +++ b/Tools/TestNetRewarder/ChainState.cs @@ -11,6 +11,8 @@ namespace TestNetRewarder public ChainState(HistoricState historicState, ICodexContracts contracts, BlockInterval blockRange) { + this.historicState = historicState; + NewRequests = contracts.GetStorageRequests(blockRange); historicState.CleanUpOldRequests(); historicState.ProcessNewRequests(NewRequests); @@ -23,7 +25,6 @@ namespace TestNetRewarder RequestCancelledEvents = contracts.GetRequestCancelledEvents(blockRange); SlotFilledEvents = contracts.GetSlotFilledEvents(blockRange); SlotFreedEvents = contracts.GetSlotFreedEvents(blockRange); - this.historicState = historicState; } public Request[] NewRequests { get; } From 1dbb749732c89a5f1b754a97f7e72eca2fdcad9e Mon Sep 17 00:00:00 2001 From: benbierens Date: Thu, 11 Apr 2024 08:50:03 +0200 Subject: [PATCH 3/4] Removes ChangedEvents field from chain-state, not necessary --- Tools/TestNetRewarder/ChainState.cs | 22 +++++++++++----------- Tools/TestNetRewarder/HistoricState.cs | 24 ------------------------ 2 files changed, 11 insertions(+), 35 deletions(-) diff --git a/Tools/TestNetRewarder/ChainState.cs b/Tools/TestNetRewarder/ChainState.cs index 9c93f87..b290e78 100644 --- a/Tools/TestNetRewarder/ChainState.cs +++ b/Tools/TestNetRewarder/ChainState.cs @@ -20,7 +20,6 @@ namespace TestNetRewarder StartedRequests = historicState.StorageRequests.Where(r => r.RecentlyStarted).ToArray(); FinishedRequests = historicState.StorageRequests.Where(r => r.RecentlyFinished).ToArray(); - ChangedRequests = historicState.StorageRequests.Where(r => r.RecentlyChanged).ToArray(); RequestFulfilledEvents = contracts.GetRequestFulfilledEvents(blockRange); RequestCancelledEvents = contracts.GetRequestCancelledEvents(blockRange); SlotFilledEvents = contracts.GetSlotFilledEvents(blockRange); @@ -31,7 +30,6 @@ namespace TestNetRewarder public StorageRequest[] AllRequests => historicState.StorageRequests; public StorageRequest[] StartedRequests { get; private set; } public StorageRequest[] FinishedRequests { get; private set; } - public StorageRequest[] ChangedRequests { get; private set; } public RequestFulfilledEventDTO[] RequestFulfilledEvents { get; } public RequestCancelledEventDTO[] RequestCancelledEvents { get; } public SlotFilledEventDTO[] SlotFilledEvents { get; } @@ -41,7 +39,7 @@ namespace TestNetRewarder { var entries = new List(); - entries.AddRange(ChangedRequests.Select(ToPair)); + entries.AddRange(NewRequests.Select(ToPair)); entries.AddRange(RequestFulfilledEvents.Select(ToPair)); entries.AddRange(RequestCancelledEvents.Select(ToPair)); entries.AddRange(SlotFilledEvents.Select(ToPair)); @@ -52,44 +50,46 @@ namespace TestNetRewarder return entries.Select(ToLine).ToArray(); } - private StringBlockNumberPair ToPair(StorageRequest r) + private StringBlockNumberPair ToPair(Request r) { - return new StringBlockNumberPair(JsonConvert.SerializeObject(r), r.Request.BlockNumber); + return new StringBlockNumberPair("NewRequest", JsonConvert.SerializeObject(r), r.BlockNumber); } private StringBlockNumberPair ToPair(RequestFulfilledEventDTO r) { - return new StringBlockNumberPair(JsonConvert.SerializeObject(r), r.BlockNumber); + return new StringBlockNumberPair("Fulfilled", JsonConvert.SerializeObject(r), r.BlockNumber); } private StringBlockNumberPair ToPair(RequestCancelledEventDTO r) { - return new StringBlockNumberPair(JsonConvert.SerializeObject(r), r.BlockNumber); + return new StringBlockNumberPair("Cancelled", JsonConvert.SerializeObject(r), r.BlockNumber); } private StringBlockNumberPair ToPair(SlotFilledEventDTO r) { - return new StringBlockNumberPair(JsonConvert.SerializeObject(r), r.BlockNumber); + return new StringBlockNumberPair("SlotFilled", JsonConvert.SerializeObject(r), r.BlockNumber); } private StringBlockNumberPair ToPair(SlotFreedEventDTO r) { - return new StringBlockNumberPair(JsonConvert.SerializeObject(r), r.BlockNumber); + return new StringBlockNumberPair("SlotFreed", JsonConvert.SerializeObject(r), r.BlockNumber); } private string ToLine(StringBlockNumberPair pair) { - return $"[{pair.Number}] {pair.Str}"; + return $"[{pair.Number}]({pair.Name}) {pair.Str}"; } public class StringBlockNumberPair { - public StringBlockNumberPair(string str, ulong number) + public StringBlockNumberPair(string name, string str, ulong number) { + Name = name; Str = str; Number = number; } + public string Name { get; } public string Str { get; } public ulong Number { get; } } diff --git a/Tools/TestNetRewarder/HistoricState.cs b/Tools/TestNetRewarder/HistoricState.cs index 316a80e..36d335d 100644 --- a/Tools/TestNetRewarder/HistoricState.cs +++ b/Tools/TestNetRewarder/HistoricState.cs @@ -28,8 +28,6 @@ namespace TestNetRewarder r.State == RequestState.Finished || r.State == RequestState.Failed ); - - foreach (var r in storageRequests) r.IsNew = false; } } @@ -39,13 +37,11 @@ namespace TestNetRewarder { Request = request; Hosts = Array.Empty(); - IsNew = true; } public Request Request { get; } public EthAddress[] Hosts { get; private set; } public RequestState State { get; private set; } - public bool IsNew { get; set; } [JsonIgnore] public bool RecentlyStarted { get; private set; } @@ -53,9 +49,6 @@ namespace TestNetRewarder [JsonIgnore] public bool RecentlyFinished { get; private set; } - [JsonIgnore] - public bool RecentlyChanged { get; private set; } - public void Update(ICodexContracts contracts) { var newHosts = GetHosts(contracts); @@ -70,27 +63,10 @@ namespace TestNetRewarder State == RequestState.Started && newState == RequestState.Finished; - RecentlyChanged = - IsNew || - State != newState || - HostsChanged(newHosts); - State = newState; Hosts = newHosts; } - private bool HostsChanged(EthAddress[] newHosts) - { - if (newHosts.Length != Hosts.Length) return true; - - foreach (var newHost in newHosts) - { - if (!Hosts.Contains(newHost)) return true; - } - - return false; - } - private EthAddress[] GetHosts(ICodexContracts contracts) { var result = new List(); From ca7258ef286d492407f43535b6ae725b976118fb Mon Sep 17 00:00:00 2001 From: benbierens Date: Thu, 11 Apr 2024 13:14:21 +0200 Subject: [PATCH 4/4] async dispatches sending of event overview to discord channel --- Tools/BiblioTech/Rewards/RoleDriver.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Tools/BiblioTech/Rewards/RoleDriver.cs b/Tools/BiblioTech/Rewards/RoleDriver.cs index 2afff6e..303f069 100644 --- a/Tools/BiblioTech/Rewards/RoleDriver.cs +++ b/Tools/BiblioTech/Rewards/RoleDriver.cs @@ -45,10 +45,17 @@ namespace BiblioTech.Rewards private async Task ProcessChainEvents(string[] eventsOverview) { if (eventsChannel == null || eventsOverview == null || !eventsOverview.Any()) return; - foreach (var e in eventsOverview) + await Task.Run(async () => { - await eventsChannel.SendMessageAsync(e); - } + foreach (var e in eventsOverview) + { + if (!string.IsNullOrEmpty(e)) + { + await eventsChannel.SendMessageAsync(e); + await Task.Delay(3000); + } + } + }); } private async Task> LoadAllUsers(SocketGuild guild)