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

Create ticker on metachain #3363

Merged
merged 11 commits into from Aug 25, 2021
Merged

Conversation

sasurobert
Copy link
Contributor

Add ticker on metachain
Add interface to process built in functions easily on metachain

@iulianpascalau iulianpascalau self-requested a review August 24, 2021 12:42
@@ -1816,12 +1824,30 @@ func (d *delegation) computeAndUpdateRewards(callerAddress []byte, delegator *De

isOwner := d.isOwner(callerAddress)

totalRewards, err := d.computeRewards(delegator.RewardsCheckpoint, isOwner, activeFund.Value)
Copy link
Contributor

Choose a reason for hiding this comment

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

The error returned here is not managed below in any way

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

d.eei.AddReturnMessage("not enough arguments")
return vmcommon.UserError
}
err := d.eei.UseGas(d.gasCost.MetaChainSystemSCsCost.DelegationOps)
Copy link
Contributor

Choose a reason for hiding this comment

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

DelegationOps is ok also for liquidStaking or we should define another special cost for it ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we also use liquid staking ops cost as well - from liquid staking manager contract.

Copy link
Contributor

Choose a reason for hiding this comment

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

ok

err := d.eei.UseGas(d.gasCost.MetaChainSystemSCsCost.DelegationOps)
if err != nil {
d.eei.AddReturnMessage(err.Error())
return vmcommon.UserError
Copy link
Contributor

Choose a reason for hiding this comment

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

OutOfGas ?

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

}

if len(args.Arguments) != 3 {
d.eei.AddReturnMessage("not enough arguments")
Copy link
Contributor

Choose a reason for hiding this comment

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

invalid number of arguments ?

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

return vmcommon.Ok
}

func (d *delegation) reDelegateRewardsViaLiquidStaking(args *vmcommon.ContractCallInput) vmcommon.ReturnCode {
Copy link
Contributor

Choose a reason for hiding this comment

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

These methods (reDelegateRewardsViaLiquidStaking, unDelegateViaLiquidStaking and returnViaLiquidStaking) will be implemented in this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

in the next PR

Copy link
Contributor

Choose a reason for hiding this comment

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

ok

return vmcommon.UserError
}
if args.CallValue.Cmp(zero) != 0 {
l.eei.AddReturnMessage("not a payable function")
Copy link
Contributor

Choose a reason for hiding this comment

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

"function is not payable in eGLD" to keep the same message format used in all the other methods from 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.

done

return vmcommon.UserError
}
if len(args.Arguments) == 0 {
l.eei.AddReturnMessage("not enough arguments")
Copy link
Contributor

Choose a reason for hiding this comment

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

"invalid number of arguments" ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this has concrete check on next PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

ok

return vmcommon.Ok
}

func (l *liquidStaking) claimRewardsFromDelegatedPosition(args *vmcommon.ContractCallInput) vmcommon.ReturnCode {
Copy link
Contributor

Choose a reason for hiding this comment

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

claimRewardsViaLiquidStaking is already implemented in delegation.go. This method shouldn't be also implemented?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

methods from delegation.go can be called by liquidStaking contract only

Copy link
Contributor

Choose a reason for hiding this comment

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

ok

return vmcommon.Ok
}

func (l *liquidStaking) reDelegateRewardsFromPosition(args *vmcommon.ContractCallInput) vmcommon.ReturnCode {
Copy link
Contributor

Choose a reason for hiding this comment

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

These next methods will be implemented in this PR ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

next PR

message LiquidStakingAttributes {
bytes ContractAddress = 1 [(gogoproto.jsontag) = "ContractAddress"];
uint32 RewardsCheckpoint = 2 [(gogoproto.jsontag) = "RewardsCheckpoint"];
}
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

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

Copy link
Contributor

@iulianpascalau iulianpascalau left a comment

Choose a reason for hiding this comment

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

minor stuff

vm/address.go Show resolved Hide resolved
vm/systemSmartContracts/eei.go Outdated Show resolved Hide resolved
vm/systemSmartContracts/eei.go Show resolved Hide resolved
vm/systemSmartContracts/delegation.go Show resolved Hide resolved
value := big.NewInt(0).SetBytes(args.Arguments[1])
checkPoint := uint32(big.NewInt(0).SetBytes(args.Arguments[2]).Uint64())

totalRewards, err := d.computeRewards(checkPoint, false, value)
Copy link
Contributor

Choose a reason for hiding this comment

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

so the claim operation via liquid staking will also take all unclaimed rewards (if existing) before creating the liquid position, right?

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

good

vm/systemSmartContracts/esdt.go Show resolved Hide resolved
}

// ArgsNewLiquidStaking defines the arguments to create the liquid staking smart contract
type ArgsNewLiquidStaking struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

according to our last talk about naming convention, this should be LiquidStakingArgs

return vmcommon.UserError
}
if !l.flagLiquidStaking.IsSet() {
l.eei.AddReturnMessage("liquid staking contract is not enabled")
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is not backwards compatible if we end up having a transaction towards the liquid staking contract before we have this code up and running.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We do have this backward compatible - it is resolved directly in systemVM. line 108-110. It was done for delegation contract first. And contract have activation. They implement CanUseContract()

Copy link
Contributor

Choose a reason for hiding this comment

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

ok

const tokenIDKey = "tokenID"
const noncePrefix = "n"

type liquidStaking struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

is this sc complete? What it does is that it just have some checks on some operations.
+ do not forget about tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No. this is incomplete.

Copy link
Contributor

Choose a reason for hiding this comment

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

ok

vm/systemSmartContracts/proto/liquidStaking.proto Outdated Show resolved Hide resolved
@sasurobert sasurobert merged commit 5aeffb0 into feat/liquid-staking Aug 25, 2021
@sasurobert sasurobert deleted the nft-on-meta-blockchainhook branch August 25, 2021 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants