Skip to content

Commit c789fc2

Browse files
committed
Use bytes for schnorr sig in stake table contract
Using current jellyfish APIs it's not possible to construct the type currently used. Since the contract doesn't need it we can send a bytes type instead.
1 parent db1ed76 commit c789fc2

File tree

13 files changed

+271
-248
lines changed

13 files changed

+271
-248
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

contracts/rust/adapter/src/bindings/staketablev2.rs

Lines changed: 115 additions & 163 deletions
Large diffs are not rendered by default.

contracts/rust/adapter/src/sol_types.rs

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,10 @@ pub use crate::bindings::{
3939
lightclientv2mock::{self, LightClientV2Mock},
4040
plonkverifier::PlonkVerifier,
4141
plonkverifierv2::PlonkVerifierV2,
42-
staketablev2 as staketable,
42+
staketable::StakeTable,
4343
staketablev2::{
44-
EdOnBN254::EdOnBN254Point as EdOnBN254PointSol, StakeTable, BN254::G2Point as G2PointSol,
44+
self, EdOnBN254::EdOnBN254Point as EdOnBN254PointSol, StakeTableV2,
45+
BN254::G2Point as G2PointSol,
4546
},
4647
timelock::Timelock,
4748
};
@@ -173,7 +174,7 @@ impl From<LightClientV2Mock::votingStakeTableStateReturn> for StakeTableStateSol
173174
}
174175
}
175176

176-
impl From<G1PointSol> for staketable::BN254::G1Point {
177+
impl From<G1PointSol> for staketablev2::BN254::G1Point {
177178
fn from(v: G1PointSol) -> Self {
178179
unsafe { std::mem::transmute(v) }
179180
}
@@ -182,13 +183,14 @@ impl From<G1PointSol> for staketable::BN254::G1Point {
182183
use serde::{Deserialize, Deserializer, Serialize, Serializer};
183184

184185
use self::{
185-
staketable::{EdOnBN254::EdOnBN254Point, BN254::G2Point},
186+
staketablev2::{EdOnBN254::EdOnBN254Point, BN254::G2Point},
186187
StakeTableV2::{
187-
ConsensusKeysUpdated, Delegated, Undelegated, ValidatorExit, ValidatorRegistered,
188+
ConsensusKeysUpdated, ConsensusKeysUpdatedV2, Delegated, Undelegated, ValidatorExit,
189+
ValidatorRegistered, ValidatorRegisteredV2,
188190
},
189191
};
190192

191-
impl PartialEq for staketable {
193+
impl PartialEq for ValidatorRegistered {
192194
fn eq(&self, other: &Self) -> bool {
193195
self.account == other.account
194196
&& self.blsVk == other.blsVk
@@ -197,6 +199,17 @@ impl PartialEq for staketable {
197199
}
198200
}
199201

202+
impl PartialEq for ValidatorRegisteredV2 {
203+
fn eq(&self, other: &Self) -> bool {
204+
self.account == other.account
205+
&& self.blsVk == other.blsVk
206+
&& self.schnorrVk == other.schnorrVk
207+
&& self.commission == other.commission
208+
&& self.blsSig == other.blsSig
209+
&& self.schnorrSig == other.schnorrSig
210+
}
211+
}
212+
200213
impl PartialEq for ConsensusKeysUpdated {
201214
fn eq(&self, other: &Self) -> bool {
202215
self.account == other.account
@@ -205,6 +218,16 @@ impl PartialEq for ConsensusKeysUpdated {
205218
}
206219
}
207220

221+
impl PartialEq for ConsensusKeysUpdatedV2 {
222+
fn eq(&self, other: &Self) -> bool {
223+
self.account == other.account
224+
&& self.blsVK == other.blsVK
225+
&& self.schnorrVK == other.schnorrVK
226+
&& self.blsSig == other.blsSig
227+
&& self.schnorrSig == other.schnorrSig
228+
}
229+
}
230+
208231
impl Serialize for ValidatorRegistered {
209232
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
210233
where

contracts/src/StakeTableV2.sol

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ contract StakeTableV2 is StakeTable {
2020
EdOnBN254.EdOnBN254Point schnorrVk,
2121
uint16 commission,
2222
BN254.G1Point blsSig,
23-
EdOnBN254.EdOnBN254Point schnorrSig
23+
bytes schnorrSig
2424
);
2525

2626
/// @notice A validator updates their consensus keys
@@ -30,7 +30,7 @@ contract StakeTableV2 is StakeTable {
3030
BN254.G2Point blsVK,
3131
EdOnBN254.EdOnBN254Point schnorrVK,
3232
BN254.G1Point blsSig,
33-
EdOnBN254.EdOnBN254Point schnorrSig
33+
bytes schnorrSig
3434
);
3535

3636
/// @notice The exit escrow period is updated
@@ -66,7 +66,7 @@ contract StakeTableV2 is StakeTable {
6666
BN254.G2Point memory blsVK,
6767
EdOnBN254.EdOnBN254Point memory schnorrVK,
6868
BN254.G1Point memory blsSig,
69-
EdOnBN254.EdOnBN254Point memory schnorrSig,
69+
bytes memory schnorrSig,
7070
uint16 commission
7171
) external virtual {
7272
address validator = msg.sender;
@@ -100,7 +100,7 @@ contract StakeTableV2 is StakeTable {
100100
BN254.G2Point memory blsVK,
101101
EdOnBN254.EdOnBN254Point memory schnorrVK,
102102
BN254.G1Point memory blsSig,
103-
EdOnBN254.EdOnBN254Point memory schnorrSig
103+
bytes memory schnorrSig
104104
) external virtual {
105105
address validator = msg.sender;
106106

sequencer-sqlite/Cargo.lock

Lines changed: 1 addition & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

staking-cli/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ alloy = { workspace = true }
1010
anyhow = { workspace = true }
1111
ark-ec = { workspace = true }
1212
ark-ed-on-bn254 = { workspace = true }
13+
ark-serialize = { workspace = true }
1314
clap = { workspace = true }
1415
clap-serde = "0.5.1"
1516
clap-serde-derive = "0.2.1"

staking-cli/src/demo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ pub async fn setup_stake_table_contract_for_test(
143143
commission,
144144
validator_address,
145145
bls_key_pair,
146-
state_key_pair.ver_key(),
146+
state_key_pair,
147147
)
148148
.await?;
149149
assert!(receipt.status());

staking-cli/src/deploy.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ impl TestSystem {
136136
self.commission,
137137
self.deployer_address,
138138
self.bls_key_pair.clone(),
139-
self.state_key_pair.ver_key(),
139+
self.state_key_pair.clone(),
140140
)
141141
.await?;
142142
assert!(receipt.status());

staking-cli/src/lib.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@ use anyhow::{bail, Result};
1111
use clap::{Parser, Subcommand};
1212
use clap_serde_derive::ClapSerde;
1313
use demo::DelegationConfig;
14-
pub(crate) use hotshot_types::{
15-
light_client::{StateSignKey, StateVerKey},
16-
signature_key::BLSPrivKey,
17-
};
14+
pub(crate) use hotshot_types::{light_client::StateSignKey, signature_key::BLSPrivKey};
1815
pub(crate) use jf_signature::bls_over_bn254::KeyPair as BLSKeyPair;
1916
use parse::Commission;
2017
use sequencer_utils::logging;

staking-cli/src/main.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use hotshot_contract_adapter::{
1414
evm::DecodeRevert as _,
1515
sol_types::EspToken::{self, EspTokenErrors},
1616
};
17+
use hotshot_types::light_client::StateKeyPair;
1718
use staking_cli::{
1819
claim::{claim_validator_exit, claim_withdrawal},
1920
delegation::{approve, delegate, undelegate},
@@ -252,7 +253,7 @@ pub async fn main() -> Result<()> {
252253
commission,
253254
account,
254255
(consensus_private_key).into(),
255-
(&state_private_key).into(),
256+
StateKeyPair::from_sign_key(state_private_key),
256257
)
257258
.await
258259
},
@@ -266,7 +267,7 @@ pub async fn main() -> Result<()> {
266267
stake_table_addr,
267268
account,
268269
(consensus_private_key).into(),
269-
(&state_private_key).into(),
270+
StateKeyPair::from_sign_key(state_private_key),
270271
)
271272
.await
272273
},

0 commit comments

Comments
 (0)