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

feat: HIP-1028 Implement Create and Update calls with metadata #16135

Merged
merged 1 commit into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
feat: HIP-1028 Implement Create and Update calls with metadata (#15136)
Signed-off-by: Stanimir Stoyanov <stanimir.stoyanov@limechain.tech>
Signed-off-by: Valentin Valkanov <valentin.valkanov@limechain.tech>
Co-authored-by: Valentin Valkanov <valentin.valkanov@limechain.tech>
  • Loading branch information
stoyanov-st and Valentin Valkanov authored Oct 24, 2024
commit e1787150eb08150abe4908082ca995ffcf4a04d4
1 change: 1 addition & 0 deletions hedera-node/configuration/dev/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ contracts.systemContract.cancelAirdrops.enabled=true
contracts.systemContract.claimAirdrops.enabled=true
contracts.systemContract.rejectTokens.enabled=true
contracts.systemContract.setUnlimitedAutoAssociations.enabled=true
contracts.systemContract.metadataKeyAndFieldSupport.enabled=true
# Needed for end-end tests running on mod-service code
staking.periodMins=1
staking.fees.nodeRewardPercentage=10
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ contracts.systemContract.rejectTokens.enabled=true
contracts.systemContract.setUnlimitedAutoAssociations.enabled=true
ledger.id=0x02
entities.unlimitedAutoAssociationsEnabled=true
contracts.systemContract.metadataKeyAndFieldSupport.enabled=true
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ private ParsingConstants() {
"(" + "string,string,address,string,bool,int64,bool," + TOKEN_KEY + ARRAY_BRACKETS + "," + EXPIRY + ")";
public static final String HEDERA_TOKEN_V3 =
"(" + "string,string,address,string,bool,int64,bool," + TOKEN_KEY + ARRAY_BRACKETS + "," + EXPIRY_V2 + ")";
public static final String HEDERA_TOKEN_V4 = "(" + "string,string,address,string,bool,uint32,bool," + TOKEN_KEY
+ ARRAY_BRACKETS + "," + EXPIRY + ",bytes" + ")";
public static final String HEDERA_TOKEN_WITH_METADATA = "(" + "string,string,address,string,bool,int64,bool,"
+ TOKEN_KEY + ARRAY_BRACKETS + "," + EXPIRY_V2 + ",bytes)";

public static final String TOKEN_INFO = "("
+ HEDERA_TOKEN_V2
+ ",int64,bool,bool,bool,"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ public record ContractsConfig(
@ConfigProperty(value = "systemContract.accountService.isAuthorizedRawEnabled", defaultValue = "true")
@NetworkProperty
boolean systemContractAccountServiceIsAuthorizedRawEnabled,
@ConfigProperty(value = "systemContract.metadataKeyAndFieldSupport.enabled", defaultValue = "false")
@NetworkProperty
boolean metadataKeyAndFieldEnabled,
@ConfigProperty(value = "systemContract.updateCustomFees.enabled", defaultValue = "true") @NetworkProperty
boolean systemContractUpdateCustomFeesEnabled,
@ConfigProperty(value = "systemContract.tokenInfo.v2.enabled", defaultValue = "false") @NetworkProperty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import static com.hedera.node.app.service.contract.impl.exec.failure.CustomExceptionalHaltReason.INSUFFICIENT_CHILD_RECORDS;
import static com.hedera.node.app.service.contract.impl.exec.failure.CustomExceptionalHaltReason.INVALID_CONTRACT_ID;
import static com.hedera.node.app.service.contract.impl.exec.failure.CustomExceptionalHaltReason.INVALID_SIGNATURE;
import static com.hedera.node.app.service.contract.impl.exec.systemcontracts.hts.create.CreateTranslator.CREATE_FUNCTIONS;
import static com.hedera.node.app.service.contract.impl.exec.systemcontracts.hts.create.CreateTranslator.createSelectorsMap;
import static com.hedera.node.app.service.contract.impl.exec.utils.FrameUtils.acquiredSenderAuthorizationViaDelegateCall;
import static com.hedera.node.app.service.contract.impl.exec.utils.FrameUtils.alreadyHalted;
import static com.hedera.node.app.service.contract.impl.exec.utils.FrameUtils.isTopLevelTransaction;
Expand Down Expand Up @@ -187,7 +187,7 @@ private boolean isTokenCreation(MessageFrame frame) {
return false;
}
var selector = frame.getInputData().slice(0, 4).toArray();
return CREATE_FUNCTIONS.stream().anyMatch(s -> Arrays.equals(s.selector(), selector));
return createSelectorsMap.keySet().stream().anyMatch(s -> Arrays.equals(s.selector(), selector));
}

public boolean isImplicitCreationEnabled(@NonNull Configuration config) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ private ReturnTypes() {
protected static final String EXPIRY_FIELDS =
// second, autoRenewAccount, autoRenewPeriod
"(uint32,address,uint32)";
// TODO: consider this expiry type for TokenV3. Might need to add another function to handle this.
protected static final String EXPIRY_FIELDS_V2 =
// second, autoRenewAccount, autoRenewPeriod
"(int64,address,int64)";
protected static final String CUSTOM_FEES =
// FixedFee array
// amount, tokenId, useHbarsForPayment, useCurrentTokenForPayment, feeCollector
Expand Down Expand Up @@ -130,7 +134,7 @@ private ReturnTypes() {
+ "("
+ TOKEN_FIELDS
+ TOKEN_KEYS
+ EXPIRY_FIELDS
+ EXPIRY_FIELDS_V2
+ ",bytes" // metadata
+ ")"
+ STATUS_FIELDS // totalSupply, deleted, defaultKycStatus, pauseStatus
Expand Down Expand Up @@ -166,7 +170,7 @@ private ReturnTypes() {
+ "("
+ TOKEN_FIELDS
+ TOKEN_KEYS
+ EXPIRY_FIELDS
+ EXPIRY_FIELDS_V2
+ ",bytes" // metadata
+ ")"
+ STATUS_FIELDS
Expand Down Expand Up @@ -204,7 +208,7 @@ private ReturnTypes() {
+ "("
+ TOKEN_FIELDS
+ TOKEN_KEYS
+ EXPIRY_FIELDS
+ EXPIRY_FIELDS_V2
+ ",bytes" // metadata
+ ")"
+ STATUS_FIELDS // totalSupply, deleted, defaultKycStatus, pauseStatus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import static com.hedera.node.app.service.contract.impl.exec.utils.FrameUtils.contractsConfigOf;
import static com.hedera.node.app.service.contract.impl.exec.utils.FrameUtils.stackIncludesActiveAddress;
import static com.hedera.node.app.service.contract.impl.utils.ConversionUtils.asEvmAddress;
import static com.hedera.node.app.service.contract.impl.utils.ConversionUtils.asHeadlongAddress;
import static com.hedera.node.app.service.contract.impl.utils.ConversionUtils.headlongAddressOf;
import static com.hedera.node.app.service.contract.impl.utils.ConversionUtils.pbjToBesuAddress;
import static java.util.Objects.requireNonNull;
Expand All @@ -56,7 +55,6 @@
import com.hedera.node.app.service.contract.impl.exec.scope.SpecificCryptoVerificationStrategy;
import com.hedera.node.app.service.contract.impl.exec.scope.VerificationStrategy;
import com.hedera.node.app.service.contract.impl.exec.systemcontracts.common.AbstractCall;
import com.hedera.node.app.service.contract.impl.exec.systemcontracts.hts.AddressIdConverter;
import com.hedera.node.app.service.contract.impl.hevm.HederaWorldUpdater;
import com.hedera.node.app.service.contract.impl.records.ContractCallStreamBuilder;
import com.hedera.node.config.data.ContractsConfig;
Expand Down Expand Up @@ -85,11 +83,10 @@ public ClassicCreatesCall(
@NonNull final HederaWorldUpdater.Enhancement enhancement,
@Nullable final TransactionBody syntheticCreate,
@NonNull final VerificationStrategy verificationStrategy,
@NonNull final Address spender,
@NonNull final AddressIdConverter addressIdConverter) {
@NonNull final AccountID spender) {
super(systemContractGasCalculator, enhancement, false);
this.verificationStrategy = requireNonNull(verificationStrategy);
this.spenderId = addressIdConverter.convert(asHeadlongAddress(spender.toArrayUnsafe()));
this.spenderId = spender;
this.syntheticCreate = syntheticCreate;
}

Expand Down
Loading
Loading