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

Sc delegation integration #1730

Merged
merged 48 commits into from
May 17, 2020
Merged

Conversation

iulianpascalau
Copy link
Contributor

@iulianpascalau iulianpascalau commented May 13, 2020

  • Reference latest version of Arwen.
  • Reference latest version of delegation contract.
  • Adjust gas metering for deployments (less gas used now).
  • Fix long tests.

void bigIntGetCallValue(bigInt destination);
void bigIntGetExternalBalance(byte *address, bigInt result);
void bigIntgetExternalBalance(byte *address, bigInt result);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Get instead get ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked in Arwen and it is indeed with a capital G

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

void bigIntGetCallValue(bigInt destination);
void bigIntGetExternalBalance(byte *address, bigInt result);
void bigIntgetExternalBalance(byte *address, bigInt result);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Get instead get ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

}

func (dp *delegationProcessor) sameElements(slice1 [][]byte, slice2 [][]byte) error {
for _, elem1 := range slice1 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you have sorted here slice1 and slice2 you could have only one for for this check. And also I would add a check for len before any computation if len(slice1) != len(slice2) return err

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the len check was done on lines L429:L432. Refactoring...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, refactored and added unit tests for that area

release string
}

// NewVersionComparator return a new version comparator instance
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

returns

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@@ -130,3 +130,6 @@ var ErrNilQueryService = errors.New("nil query service")

// ErrMissingElement signals a missing element event
var ErrMissingElement = errors.New("missing element")

// ErrGetVersionFromSC signals that a coll to "version" function on a contract resulted in an unexpected result
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"call" instead "coll" and "on a smart contract" instead "on a contract"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@@ -1,49 +1,517 @@
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to change the default values in this file ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, the node, at the current moment can not be started directly (to check the binary works) due to the fact that there is a mismatch between the staked value per node in genesis files (500k) and the economics.toml (2.5 mil)

@@ -1,122 +1,1322 @@
[
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to change the default values in this file ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, the node, at the current moment can not be started directly (to check the binary works) due to the fact that there is a mismatch between the staked value per node in genesis files (500k) and the economics.toml (2.5 mil)

}
]
]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add empty line to end of file

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

"metaChainConsensusGroupSize": 3,
"metaChainMinNodes": 3,
"hysteresis": 0.2,
"hysteresis": 0,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe leave it to 0.2 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reverted

@@ -1,49 +1,49 @@
{
"startTime": 0,
"roundDuration": 6000,
"roundDuration": 4000,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why to 6seconds ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reverted

}
]
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add empty line to end of file

Copy link
Contributor Author

@iulianpascalau iulianpascalau May 15, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

ChainID string
SystemSCConfig config.SystemSmartContractsConfig

//TODO remove this: at genesis time the genesis block creator should not write other shard's data in the same storage manager
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May delete the TODO - this is a must for hardFork when importing your own trie and accounts. As you have to import to the same storage the node will work after hardfork.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved TODO

"github.com/ElrondNetwork/elrond-go/core"
)

const numComponents = 3
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

numComponents maybe removed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will have a magic number as 3

return err
}

err = dp.executeSetNodePrice(sc)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe rename to something more specific as this works only with Elrond stlye delegation contract - maybe standardDelegationProcess ? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean the whole file? like standardDelegationProcessor?

}

func (dp *delegationProcessor) executeSetNumNodes(numNodes int, sc genesis.InitialSmartContractHandler) error {
setNumNodesTxData := fmt.Sprintf("%s@%x", setNumNodesFunction, numNodes)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe use strings and plus, instead of fmt.sprintf.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to use fmt.Sprintf where I have more than one addition. I also have a %x and this should get uglier

return hex.EncodeToString(node.PubKeyBytes())
}

func (dp *delegationProcessor) activate(_ sharding.GenesisNodeInfoHandler) string {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe rename the function name.

Copy link
Contributor Author

@iulianpascalau iulianpascalau May 15, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getBlsKeySig

}

return totalDelegated, nil
}

func (dp *delegationProcessor) setBlsKey(node sharding.GenesisNodeInfoHandler) string {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getBlsKey

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

sasurobert
sasurobert previously approved these changes May 15, 2020
Copy link
Collaborator

@andreibancioiu andreibancioiu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Green to merge & release.

Copy link
Contributor

@LucianMincu LucianMincu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

System tests passed.

@iulianpascalau iulianpascalau merged commit 2ef180f into development May 17, 2020
@iulianpascalau iulianpascalau deleted the sc-delegation-integration branch May 17, 2020 20:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants