Skip to content

Commit

Permalink
Removed unused parameter from Sharding Table getter
Browse files Browse the repository at this point in the history
  • Loading branch information
0xbraindevd committed Jan 30, 2024
1 parent 8821a17 commit 645e328
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 30 deletions.
14 changes: 2 additions & 12 deletions abi/ShardingTableV2.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,6 @@
"outputs": [
{
"components": [
{
"internalType": "uint256",
"name": "hashRingPosition",
"type": "uint256"
},
{
"internalType": "bytes",
"name": "nodeId",
Expand All @@ -134,7 +129,7 @@
"type": "uint96"
}
],
"internalType": "struct ShardingTableStructsV2.NodeInfo[]",
"internalType": "struct ShardingTableStructsV1.NodeInfo[]",
"name": "",
"type": "tuple[]"
}
Expand All @@ -159,11 +154,6 @@
"outputs": [
{
"components": [
{
"internalType": "uint256",
"name": "hashRingPosition",
"type": "uint256"
},
{
"internalType": "bytes",
"name": "nodeId",
Expand All @@ -185,7 +175,7 @@
"type": "uint96"
}
],
"internalType": "struct ShardingTableStructsV2.NodeInfo[]",
"internalType": "struct ShardingTableStructsV1.NodeInfo[]",
"name": "",
"type": "tuple[]"
}
Expand Down
14 changes: 7 additions & 7 deletions contracts/v2/ShardingTable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {ContractStatus} from "../v1/abstract/ContractStatus.sol";
import {Initializable} from "../v1/interface/Initializable.sol";
import {Named} from "../v1/interface/Named.sol";
import {Versioned} from "../v1/interface/Versioned.sol";
import {ShardingTableStructsV1} from "../v1/structs/ShardingTableStructsV1.sol";
import {ShardingTableStructsV2} from "./structs/ShardingTableStructsV2.sol";
import {ShardingTableErrors} from "./errors/ShardingTableErrors.sol";

Expand Down Expand Up @@ -45,11 +46,11 @@ contract ShardingTableV2 is Named, Versioned, ContractStatus, Initializable {
function getShardingTable(
uint72 startingIdentityId,
uint72 nodesNumber
) external view returns (ShardingTableStructsV2.NodeInfo[] memory) {
) external view returns (ShardingTableStructsV1.NodeInfo[] memory) {
return _getShardingTable(startingIdentityId, nodesNumber);
}

function getShardingTable() external view returns (ShardingTableStructsV2.NodeInfo[] memory) {
function getShardingTable() external view returns (ShardingTableStructsV1.NodeInfo[] memory) {
ShardingTableStorageV2 sts = shardingTableStorage;
return _getShardingTable(sts.indexToIdentityId(0), sts.nodesCount());
}
Expand Down Expand Up @@ -186,8 +187,8 @@ contract ShardingTableV2 is Named, Versioned, ContractStatus, Initializable {
function _getShardingTable(
uint72 startingIdentityId,
uint72 nodesNumber
) internal view virtual returns (ShardingTableStructsV2.NodeInfo[] memory) {
ShardingTableStructsV2.NodeInfo[] memory nodesPage;
) internal view virtual returns (ShardingTableStructsV1.NodeInfo[] memory) {
ShardingTableStructsV1.NodeInfo[] memory nodesPage;
ShardingTableStorageV2 sts = shardingTableStorage;

if ((sts.nodesCount() == 0) || (nodesNumber == 0)) return nodesPage;
Expand All @@ -196,16 +197,15 @@ contract ShardingTableV2 is Named, Versioned, ContractStatus, Initializable {

require((startingIdentityId == NULL) || (startingNode.identityId != NULL), "Wrong starting Identity ID");

nodesPage = new ShardingTableStructsV2.NodeInfo[](nodesNumber);
nodesPage = new ShardingTableStructsV1.NodeInfo[](nodesNumber);

ProfileStorage ps = profileStorage;
StakingStorage ss = stakingStorage;

uint72 nextIdentityId = startingIdentityId;
uint72 index;
while ((index < nodesNumber) && (nextIdentityId != NULL)) {
nodesPage[index] = ShardingTableStructsV2.NodeInfo({
hashRingPosition: uint256(ps.getNodeAddress(nextIdentityId, 1)),
nodesPage[index] = ShardingTableStructsV1.NodeInfo({
nodeId: ps.getNodeId(nextIdentityId),
identityId: nextIdentityId,
ask: ps.getAsk(nextIdentityId),
Expand Down
8 changes: 0 additions & 8 deletions contracts/v2/structs/ShardingTableStructsV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,6 @@
pragma solidity ^0.8.16;

library ShardingTableStructsV2 {
struct NodeInfo {
uint256 hashRingPosition;
bytes nodeId;
uint72 identityId;
uint96 ask;
uint96 stake;
}

struct Node {
uint256 hashRingPosition;
uint72 index;
Expand Down
3 changes: 2 additions & 1 deletion deploy/031_deploy_commit_manager_v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
export default func;
func.tags = ['CommitManagerV2', 'v2'];
func.dependencies = [
'Hub',
'HubV2',
'IdentityStorageV2',
'ProximityScoringProxy',
'Log2PLDSF',
'LinearSum',
'ParametersStorage',
'ProfileStorage',
'ServiceAgreementStorageProxy',
Expand Down
3 changes: 2 additions & 1 deletion deploy/033_deploy_commit_manager_v2_u1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
export default func;
func.tags = ['CommitManagerV2U1', 'v2'];
func.dependencies = [
'ContentAssetStorage',
'HubV2',
'IdentityStorageV2',
'ProximityScoringProxy',
'Log2PLDSF',
'LinearSum',
'ParametersStorage',
'ProfileStorage',
'ServiceAgreementStorageProxy',
'ContentAssetStorageV2',
'HashingProxy',
'SHA256',
'ShardingTableStorageV2',
Expand Down
2 changes: 1 addition & 1 deletion deploy/034_deploy_commit_manager_v1_u1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
export default func;
func.tags = ['CommitManagerV1U1', 'v1'];
func.dependencies = [
'ContentAssetStorage',
'Hub',
'IdentityStorage',
'ScoringProxy',
'Log2PLDSF',
'ParametersStorage',
'ProfileStorage',
'ServiceAgreementStorageProxy',
'ContentAssetStorage',
'HashingProxy',
'SHA256',
'ShardingTableStorage',
Expand Down

0 comments on commit 645e328

Please sign in to comment.