-
Notifications
You must be signed in to change notification settings - Fork 632
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: enforce that account_ids are valid in FunctionCallPermission #7139
Conversation
64d0bfe
to
2396089
Compare
Note to self: after this is merged, look into using |
@@ -417,6 +430,30 @@ fn validate_add_key_action( | |||
Ok(()) | |||
} | |||
|
|||
fn truncate_string(s: &str, limit: usize) -> String { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm surprised that something like this is not present in default Rust string library..
(or is it there, but we need a custom method for a reason ?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not surprised -- doing this properly is a hard and domain-specific: you probably don't want to truncate 🏳️🌈 to 🏳️ and for that you need to pull substantial amount of unicode in. And then you can truncate to the number of visual characters, or to the number of fixed-width symbols, or to the number of bytes.
let got = truncate_string(input, limit); | ||
assert_eq!(got, want) | ||
} | ||
check("hello", 0, ""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you also check:
check("", 10, "")
block_hash: CryptoHash::default(), | ||
}; | ||
|
||
// Run the transaction & collect the logs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd also mention -- that we expect this transaction to pass, as this is before the account id enforcement.
} | ||
} | ||
|
||
// Re-run the transaction. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and comment that we expect this transaction to fail, as this is the protocol version that enforces the account ids.
2396089
to
7e91585
Compare
…re (#7569) # account_id_in_function_call_permission This feature controls [the check](https://github.com/near/nearcore/blob/b315192e84d388671316deaa3a17ece9d0565fd1/runtime/runtime/src/verifier.rs#L400-L405) which enforces that account id in function call permission is indeed a valid account id. Before, any string could have been used there. The primary motivation is robustness -- by restricting permissions to only valid account ids, we don't have to deal with potentially arbitrary long strings in storage. # Context - Implementation: #7139 # Testing and QA We have basic and upgradability test [here](https://github.com/near/nearcore/blob/master/integration-tests/src/tests/client/features/account_id_in_function_call_permission.rs#L18). This PR also adds a test for an extra edge case with overly long account id. This feature have been running on betanet for couple of months without problems. # Checklist - [x] Link to nightly nayduck run: https://nayduck.near.org/#/run/2667 - [x] Update CHANGELOG.md to include this protocol feature in the `Unreleased` section.
…re (#7569) # account_id_in_function_call_permission This feature controls [the check](https://github.com/near/nearcore/blob/b315192e84d388671316deaa3a17ece9d0565fd1/runtime/runtime/src/verifier.rs#L400-L405) which enforces that account id in function call permission is indeed a valid account id. Before, any string could have been used there. The primary motivation is robustness -- by restricting permissions to only valid account ids, we don't have to deal with potentially arbitrary long strings in storage. # Context - Implementation: #7139 # Testing and QA We have basic and upgradability test [here](https://github.com/near/nearcore/blob/master/integration-tests/src/tests/client/features/account_id_in_function_call_permission.rs#L18). This PR also adds a test for an extra edge case with overly long account id. This feature have been running on betanet for couple of months without problems. # Checklist - [x] Link to nightly nayduck run: https://nayduck.near.org/#/run/2667 - [x] Update CHANGELOG.md to include this protocol feature in the `Unreleased` section.
…re (#7569) # account_id_in_function_call_permission This feature controls [the check](https://github.com/near/nearcore/blob/b315192e84d388671316deaa3a17ece9d0565fd1/runtime/runtime/src/verifier.rs#L400-L405) which enforces that account id in function call permission is indeed a valid account id. Before, any string could have been used there. The primary motivation is robustness -- by restricting permissions to only valid account ids, we don't have to deal with potentially arbitrary long strings in storage. # Context - Implementation: #7139 # Testing and QA We have basic and upgradability test [here](https://github.com/near/nearcore/blob/master/integration-tests/src/tests/client/features/account_id_in_function_call_permission.rs#L18). This PR also adds a test for an extra edge case with overly long account id. This feature have been running on betanet for couple of months without problems. # Checklist - [x] Link to nightly nayduck run: https://nayduck.near.org/#/run/2667 - [x] Update CHANGELOG.md to include this protocol feature in the `Unreleased` section.
closes https://nearinc.atlassian.net/browse/CPR-135