Skip to content

Commit

Permalink
Merge pull request #39 from diadata-org/updaterandomness
Browse files Browse the repository at this point in the history
remove signature and previous signature onchain
  • Loading branch information
kaythxbye committed Oct 30, 2023
2 parents f10c03f + acb2d06 commit 69be154
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 86 deletions.
36 changes: 4 additions & 32 deletions bot/config/contracts/randomness.oracle.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const RANDOM_ORACLE_ANCHOR_ABI = {
source: {
hash: '0x8fb2ec74c5e5eb76b8070ff12ac0c20924a7c63cabf509b4b4f67f7b90882309',
hash: '0x33f08384805b1bc8adb805b5fe77b64567c6917a3454763b7060cd67a7f9fe0a',
language: 'ink! 4.3.0',
compiler: 'rustc 1.71.1',
build_info: {
Expand All @@ -14,7 +14,7 @@ export const RANDOM_ORACLE_ANCHOR_ABI = {
}
},
contract: {
name: 'dia-random-oracle',
name: 'dia-randomness-oracle',
version: '0.1.0',
authors: ['nnn-gif nitin.gurbani@diadata.org']
},
Expand Down Expand Up @@ -378,24 +378,6 @@ export const RANDOM_ORACLE_ANCHOR_ABI = {
}
},
name: 'randomness'
},
{
layout: {
leaf: {
key: '0xb1895189',
ty: 3
}
},
name: 'signature'
},
{
layout: {
leaf: {
key: '0xb1895189',
ty: 3
}
},
name: 'previous_signature'
}
],
name: 'RandomData'
Expand Down Expand Up @@ -425,7 +407,7 @@ export const RANDOM_ORACLE_ANCHOR_ABI = {
name: 'data'
}
],
name: 'RandomDataStorage'
name: 'RandomnessOracle'
}
},
root_key: '0x00000000'
Expand Down Expand Up @@ -615,21 +597,11 @@ export const RANDOM_ORACLE_ANCHOR_ABI = {
name: 'randomness',
type: 3,
typeName: 'Vec<u8>'
},
{
name: 'signature',
type: 3,
typeName: 'Vec<u8>'
},
{
name: 'previous_signature',
type: 3,
typeName: 'Vec<u8>'
}
]
}
},
path: ['dia_oracle_random_type', 'RandomData']
path: ['dia_oracle_randomness_type', 'RandomData']
}
},
{
Expand Down
6 changes: 2 additions & 4 deletions bot/modules/oracle/oracle.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import AlephZeroProvider from '@providers/blockchain/aleph'
import ExternalProvider from '@providers/external'
import NotificationProvider from '@providers/notification'
import { inject, injectable } from 'inversify'
import { hexToU8a } from '@polkadot/util'
import moment from 'moment'
import OracleRepository from './oracle.repository'
import { PRECISION_DECIMALS, TransactionEvent, RandomOracleEvent } from '@config/constants'
Expand Down Expand Up @@ -244,10 +245,7 @@ export default class OracleService {

if (!error) {
roundsArr.push(Number(randomResult.round))

params.randomness = randomResult.randomness
params.previousSignature = randomResult.previous_signature
params.signature = randomResult.signature
params.randomness = Array.from(hexToU8a(randomResult.randomness))
args.push(roundsArr)
args.push(params)
req.push(args)
Expand Down
6 changes: 0 additions & 6 deletions contracts/oracle-randomness-type/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,4 @@ use ink::prelude::vec::Vec;
pub struct RandomData {
/// A vector of bytes representing the randomness data.
pub randomness: Vec<u8>,

/// A vector of bytes representing the signature data.
pub signature: Vec<u8>,

/// A vector of bytes representing the previous round's signature data.
pub previous_signature: Vec<u8>,
}
51 changes: 11 additions & 40 deletions contracts/oracle-randomness/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,13 +230,9 @@ pub mod oracle_anchor {
let mut contract = RandomnessOracle::new();

let randomness = vec![1, 2, 3];
let signature = vec![4, 5, 6];
let previous_signature = vec![4, 5, 6];

let data = RandomData {
randomness,
signature,
previous_signature,
randomness
};

contract.set_random_value(1, data.clone());
Expand All @@ -258,12 +254,8 @@ pub mod oracle_anchor {
let mut contract = RandomnessOracle::new();

let randomness = vec![1, 2, 3];
let signature = vec![4, 5, 6];
let previous_signature = vec![4, 5, 6];
let data = RandomData {
randomness,
signature,
previous_signature,
randomness
};

contract.set_random_value(1, data.clone());
Expand All @@ -281,33 +273,25 @@ pub mod oracle_anchor {
(
1,
RandomData {
randomness: vec![2, 2, 3],
signature: vec![1, 2, 3],
previous_signature: vec![1, 2, 3],
randomness: vec![2, 2, 3]
},
),
(
2,
RandomData {
randomness: vec![1, 2, 3],
signature: vec![4, 5, 6],
previous_signature: vec![1, 2, 3],
randomness: vec![1, 2, 3]
},
),
(
4,
RandomData {
randomness: vec![1, 2, 3],
signature: vec![4, 5, 6],
previous_signature: vec![1, 2, 3],
randomness: vec![1, 2, 3]
},
),
(
3,
RandomData {
randomness: vec![1, 2, 3],
signature: vec![4, 5, 6],
previous_signature: vec![1, 2, 3],
randomness: vec![1, 2, 3]
},
),
];
Expand All @@ -321,9 +305,7 @@ pub mod oracle_anchor {
assert_eq!(
result,
Some(RandomData {
randomness: vec![1, 2, 3],
signature: vec![4, 5, 6],
previous_signature: vec![1, 2, 3]
randomness: vec![1, 2, 3]
})
);
}
Expand All @@ -335,12 +317,8 @@ pub mod oracle_anchor {
contract.set_updater(caller);

let randomness = vec![1, 2, 3];
let signature = vec![4, 5, 6];
let previous_signature = vec![4, 5, 6];
let data = RandomData {
randomness,
signature,
previous_signature,
randomness
};

contract.set_random_value(1, data);
Expand All @@ -354,12 +332,9 @@ pub mod oracle_anchor {
let account: AccountId = AccountId::from([0x2; 32]);
ink::env::test::set_caller::<ink::env::DefaultEnvironment>(account);
let randomness = vec![1, 2, 3];
let signature = vec![4, 5, 6];
let previous_signature = vec![4, 5, 6];

let data = RandomData {
randomness,
signature,
previous_signature,
randomness
};

random_data_storage.set_random_value(1, data);
Expand Down Expand Up @@ -620,8 +595,6 @@ pub mod oracle_anchor {
let constructor = RandomnessOracleRef::new();

let randomness = vec![1, 2, 3];
let signature = vec![4, 5, 6];
let previous_signature = vec![4, 5, 6];

let contract_acc_id = client
.instantiate(
Expand All @@ -635,9 +608,7 @@ pub mod oracle_anchor {
.expect("instantiate failed")
.account_id;
let r_data = RandomData {
randomness,
signature,
previous_signature,
randomness
};

let set_random_value = build_message::<RandomnessOracleRef>(contract_acc_id)
Expand Down
5 changes: 1 addition & 4 deletions example-randomness-oracle/example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,10 @@ mod randomoracleexample {
async fn default_works(mut client: ink_e2e::Client<C, E>) -> E2EResult<()> {
//init Oracle contract
let randomness = vec![1, 2, 3];
let signature = vec![4, 5, 6];
let previous_signature = vec![4, 5, 6];


let r_data = RandomData {
randomness,
signature,
previous_signature,
};


Expand Down

0 comments on commit 69be154

Please sign in to comment.