Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feat: add Stake Table contract API #748

Merged
merged 43 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
3eb78b7
move over PlonkVerifier and fix solhint
alxiong Oct 24, 2023
66966f2
fix: flake.nix for solhint dep
alxiong Oct 26, 2023
1e09fb3
add ffi & fuzz test example for polyeval
alxiong Oct 27, 2023
4546436
wip: test evalDataGen
alxiong Oct 31, 2023
271d019
wip: put aside evalDataEval failed test
alxiong Oct 31, 2023
296af4e
pass Transcript's appendMessage fuzz test
alxiong Nov 1, 2023
71dce98
more tests, and fix prior failure
alxiong Nov 2, 2023
69079d9
bugfix: fix type inconsistency leading to diff transcript
alxiong Nov 3, 2023
2887bba
finish tests for Transcript.sol
alxiong Nov 3, 2023
6807ac8
vm.assume -> bound when possible
alxiong Nov 3, 2023
e0a3e31
add extra fuzzy input constraint on zeta value
alxiong Nov 4, 2023
6bc9d0b
wip: two more plonkverifier test
alxiong Nov 6, 2023
566ee05
wip: add most verifier tests
alxiong Nov 8, 2023
1dd6540
Merge remote-tracking branch 'origin/main' into plonk-verifier
alxiong Nov 8, 2023
f5d1b37
add eval domain support for size=32 for testing
alxiong Nov 9, 2023
388ddd1
test: finish all tests
alxiong Nov 9, 2023
1d7c6c6
bugfix: add missing check, improving test to catch similar mistakes
alxiong Nov 9, 2023
2951431
fortify the precondition of genEvalData test
alxiong Nov 10, 2023
af7266c
fix inf point conversion and alpha_2 comp
alxiong Nov 10, 2023
79f7c0f
directly use diff-test binary
alxiong Nov 10, 2023
73c9a6f
Merge remote-tracking branch 'origin/main' into plonk-verifier
alxiong Nov 10, 2023
c226f87
remove done TODO
alxiong Nov 10, 2023
9775bd1
avoid burden shellHook to build diff-test, use just command instead
alxiong Nov 10, 2023
1ba425a
ci: fix ci error
alxiong Nov 10, 2023
343b953
address comments
alxiong Nov 10, 2023
bdf18ac
fix bad path test for batchVerify
alxiong Nov 13, 2023
1039690
add stake table interfaces
alxiong Nov 11, 2023
90bf8d1
fix: allow empty public input, remove default.fuzz.runs, increase ci.…
alxiong Nov 14, 2023
b914f77
address comments
alxiong Nov 14, 2023
fc1484e
improve diff-test
alxiong Nov 14, 2023
9268423
Revert "add stake table interfaces"
alxiong Nov 14, 2023
8bded3e
add stake table interfaces
alxiong Nov 11, 2023
47aa781
address comments
alxiong Nov 14, 2023
8e857eb
update totalStake() return types
alxiong Nov 15, 2023
479c976
Merge branch 'main' into stake-table-api
alxiong Nov 16, 2023
36fb30e
update contract-bindings
alxiong Nov 16, 2023
cfb6471
address comments
alxiong Nov 16, 2023
78949dc
Merge remote-tracking branch 'origin/main' into stake-table-api
alxiong Nov 17, 2023
65a87d0
more comments
alxiong Nov 17, 2023
8ff8e8d
withdraw->withdrawFunds more explicit name
alxiong Nov 17, 2023
c83ebbe
revert flake.nix formatting
alxiong Nov 17, 2023
612a578
more explict fn names
alxiong Nov 17, 2023
3225774
Merge remote-tracking branch 'origin/main' into stake-table-api
alxiong Nov 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
171 changes: 171 additions & 0 deletions contract-bindings/src/ed_on_bn254.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
pub use ed_on_bn254::*;
/// This module was auto-generated with ethers-rs Abigen.
/// More information at: <https://github.com/gakonst/ethers-rs>
#[allow(
clippy::enum_variant_names,
clippy::too_many_arguments,
clippy::upper_case_acronyms,
clippy::type_complexity,
dead_code,
non_camel_case_types
)]
pub mod ed_on_bn254 {
#[allow(deprecated)]
fn __abi() -> ::ethers::core::abi::Abi {
::ethers::core::abi::ethabi::Contract {
constructor: ::core::option::Option::None,
functions: ::core::convert::From::from([(
::std::borrow::ToOwned::to_owned("P_MOD"),
::std::vec![::ethers::core::abi::ethabi::Function {
name: ::std::borrow::ToOwned::to_owned("P_MOD"),
inputs: ::std::vec![],
outputs: ::std::vec![::ethers::core::abi::ethabi::Param {
name: ::std::string::String::new(),
kind: ::ethers::core::abi::ethabi::ParamType::Uint(256usize,),
internal_type: ::core::option::Option::Some(
::std::borrow::ToOwned::to_owned("uint256"),
),
},],
constant: ::core::option::Option::None,
state_mutability: ::ethers::core::abi::ethabi::StateMutability::View,
},],
)]),
events: ::std::collections::BTreeMap::new(),
errors: ::std::collections::BTreeMap::new(),
receive: false,
fallback: false,
}
}
///The parsed JSON ABI of the contract.
pub static EDONBN254_ABI: ::ethers::contract::Lazy<::ethers::core::abi::Abi> =
::ethers::contract::Lazy::new(__abi);
#[rustfmt::skip]
const __BYTECODE: &[u8] = b"`\xA6a\08`\x0B\x82\x82\x829\x80Q`\0\x1A`s\x14`+WcNH{q`\xE0\x1B`\0R`\0`\x04R`$`\0\xFD[0`\0R`s\x81S\x82\x81\xF3\xFEs\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x000\x14`\x80`@R`\x046\x10`3W`\x005`\xE0\x1C\x80c\x1Dq.'\x14`8W[`\0\x80\xFD[`^\x7F0dNr\xE11\xA0)\xB8PE\xB6\x81\x81X](3\xE8Hy\xB9p\x91C\xE1\xF5\x93\xF0\0\0\x01\x81V[`@Q\x90\x81R` \x01`@Q\x80\x91\x03\x90\xF3\xFE\xA2dipfsX\"\x12 \xCA\xEC>\x0F\xDD\xCC\x97\x7F\xE8\xF8\xD5hZ\x98\xCA\x8A#{1\xFA\xF2V\x98\xAB\xD5\xD1e\x16l\x83Y\xF3dsolcC\0\x08\x14\x003";
/// The bytecode of the contract.
pub static EDONBN254_BYTECODE: ::ethers::core::types::Bytes =
::ethers::core::types::Bytes::from_static(__BYTECODE);
#[rustfmt::skip]
const __DEPLOYED_BYTECODE: &[u8] = b"s\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x000\x14`\x80`@R`\x046\x10`3W`\x005`\xE0\x1C\x80c\x1Dq.'\x14`8W[`\0\x80\xFD[`^\x7F0dNr\xE11\xA0)\xB8PE\xB6\x81\x81X](3\xE8Hy\xB9p\x91C\xE1\xF5\x93\xF0\0\0\x01\x81V[`@Q\x90\x81R` \x01`@Q\x80\x91\x03\x90\xF3\xFE\xA2dipfsX\"\x12 \xCA\xEC>\x0F\xDD\xCC\x97\x7F\xE8\xF8\xD5hZ\x98\xCA\x8A#{1\xFA\xF2V\x98\xAB\xD5\xD1e\x16l\x83Y\xF3dsolcC\0\x08\x14\x003";
/// The deployed bytecode of the contract.
pub static EDONBN254_DEPLOYED_BYTECODE: ::ethers::core::types::Bytes =
::ethers::core::types::Bytes::from_static(__DEPLOYED_BYTECODE);
pub struct EdOnBN254<M>(::ethers::contract::Contract<M>);
impl<M> ::core::clone::Clone for EdOnBN254<M> {
fn clone(&self) -> Self {
Self(::core::clone::Clone::clone(&self.0))
}
}
impl<M> ::core::ops::Deref for EdOnBN254<M> {
type Target = ::ethers::contract::Contract<M>;
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl<M> ::core::ops::DerefMut for EdOnBN254<M> {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.0
}
}
impl<M> ::core::fmt::Debug for EdOnBN254<M> {
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
f.debug_tuple(::core::stringify!(EdOnBN254))
.field(&self.address())
.finish()
}
}
impl<M: ::ethers::providers::Middleware> EdOnBN254<M> {
/// Creates a new contract instance with the specified `ethers` client at
/// `address`. The contract derefs to a `ethers::Contract` object.
pub fn new<T: Into<::ethers::core::types::Address>>(
address: T,
client: ::std::sync::Arc<M>,
) -> Self {
Self(::ethers::contract::Contract::new(
address.into(),
EDONBN254_ABI.clone(),
client,
))
}
/// Constructs the general purpose `Deployer` instance based on the provided constructor arguments and sends it.
/// Returns a new instance of a deployer that returns an instance of this contract after sending the transaction
///
/// Notes:
/// - If there are no constructor arguments, you should pass `()` as the argument.
/// - The default poll duration is 7 seconds.
/// - The default number of confirmations is 1 block.
///
///
/// # Example
///
/// Generate contract bindings with `abigen!` and deploy a new contract instance.
///
/// *Note*: this requires a `bytecode` and `abi` object in the `greeter.json` artifact.
///
/// ```ignore
/// # async fn deploy<M: ethers::providers::Middleware>(client: ::std::sync::Arc<M>) {
/// abigen!(Greeter, "../greeter.json");
///
/// let greeter_contract = Greeter::deploy(client, "Hello world!".to_string()).unwrap().send().await.unwrap();
/// let msg = greeter_contract.greet().call().await.unwrap();
/// # }
/// ```
pub fn deploy<T: ::ethers::core::abi::Tokenize>(
client: ::std::sync::Arc<M>,
constructor_args: T,
) -> ::core::result::Result<
::ethers::contract::builders::ContractDeployer<M, Self>,
::ethers::contract::ContractError<M>,
> {
let factory = ::ethers::contract::ContractFactory::new(
EDONBN254_ABI.clone(),
EDONBN254_BYTECODE.clone().into(),
client,
);
let deployer = factory.deploy(constructor_args)?;
let deployer = ::ethers::contract::ContractDeployer::new(deployer);
Ok(deployer)
}
///Calls the contract's `P_MOD` (0x1d712e27) function
pub fn p_mod(
&self,
) -> ::ethers::contract::builders::ContractCall<M, ::ethers::core::types::U256> {
self.0
.method_hash([29, 113, 46, 39], ())
.expect("method not found (this should never happen)")
}
}
impl<M: ::ethers::providers::Middleware> From<::ethers::contract::Contract<M>> for EdOnBN254<M> {
fn from(contract: ::ethers::contract::Contract<M>) -> Self {
Self::new(contract.address(), contract.client())
}
}
///Container type for all input parameters for the `P_MOD` function with signature `P_MOD()` and selector `0x1d712e27`
#[derive(
Clone,
::ethers::contract::EthCall,
::ethers::contract::EthDisplay,
serde::Serialize,
serde::Deserialize,
Default,
Debug,
PartialEq,
Eq,
Hash,
)]
#[ethcall(name = "P_MOD", abi = "P_MOD()")]
pub struct PModCall;
///Container type for all return fields from the `P_MOD` function with signature `P_MOD()` and selector `0x1d712e27`
#[derive(
Clone,
::ethers::contract::EthAbiType,
::ethers::contract::EthAbiCodec,
serde::Serialize,
serde::Deserialize,
Default,
Debug,
PartialEq,
Eq,
Hash,
)]
pub struct PModReturn(pub ::ethers::core::types::U256);
}
Loading