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

ESDT system SC correct initialization at end-of-epoch #2986

Merged
merged 3 commits into from
Apr 11, 2021

Conversation

iulianpascalau
Copy link
Contributor

@iulianpascalau iulianpascalau commented Apr 10, 2021

  • Fixed the ESDT bad initialization of the owner address. At the end of epoch, when the ESDT will be activated, the ESDT owner will be re-rewritten in the contract in the correct form. After that, some contract APIs like configChange will work as expected.

Testing scenario: launch a testnet, wait until ESDT feature becomes active (epoch 4) and try issue an ESDT with a base issuing value less than 5 eGLD. The transaction should fail. When trying to issue an ESDT with 5 eGLD, it should work. Use the erd1fpkcgel4gcmh8zqqdt043yfcn5tyx8373kg6q2qmkxzu4dqamc0swts65c address (pem file is located in elrond-go/cmd/node/testKeys/esdtWalletKey.pem) to send a transaction with the following parameters:

- sender: erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqzllls8a5w6u
- value: 0 eGLD
- gas limit: 51000000
- data: configChange@486d8467f546377388006adf5891389d16431e3e8d91a0281bb185cab41dde1f@b1a2bc2ec50000@0a@14

Meaning: "change the ESDT configuration: set the owner to 486d8467f546377388006adf5891389d16431e3e8d91a0281bb185cab41dde1f which is erd1fpkcgel4gcmh8zqqdt043yfcn5tyx8373kg6q2qmkxzu4dqamc0swts65c, set the base issuing cost to 0.05 eGLD and set the minimum and maximum name lengths to 10 and 20 respectively"
The transaction should succeed.
Now, try issuing a new ESDT token with 0.05eGLD. The token should be issued (transaction succeeded).

@@ -762,7 +769,8 @@ func (e *esdt) togglePause(args *vmcommon.ContractCallInput, builtInFunc string)
}

func (e *esdt) configChange(args *vmcommon.ContractCallInput) vmcommon.ReturnCode {
if !bytes.Equal(args.CallerAddr, e.ownerAddress) {
icCorrectCaller := bytes.Equal(args.CallerAddr, e.ownerAddress) || bytes.Equal(args.CallerAddr, e.endOfEpochSCAddress)
Copy link
Contributor

Choose a reason for hiding this comment

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

isCorrectCaller

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

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 Apr 10, 2021
vm/errors.go Outdated
@@ -83,12 +83,12 @@ var ErrNilMessageSignVerifier = errors.New("nil message sign verifier")
// ErrNilStakingSmartContractAddress signals that staking smart contract address is nil
var ErrNilStakingSmartContractAddress = errors.New("nil staking smart contract address")

// ErrNilEndOfEpochSmartContractAddress signals that the end of epoch smart contract address is nil
var ErrNilEndOfEpochSmartContractAddress = errors.New("nil end of epoch contract address")
Copy link
Contributor

Choose a reason for hiding this comment

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

nil end of epoch smart contract address

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 merged commit 57ffae2 into feat/eip-esdt-local-mint Apr 11, 2021
@sasurobert sasurobert deleted the re-init-esdt-system-sc branch April 11, 2021 20:35
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