Code
I defined a field in my contract like this
messages: Mapping<String, Vec<Message>>
Message is struct
pub struct Message {
pub id: u128,
pub key: String,
pub p: String,
pub b: String,
pub s: Vec<String>,
pub addr: AccountId,
pub sel: [u8;4],
pub data: Vec<u8>,
}
This is a method with pseudo-code
fn push_message(&mut self, message: Message) -> Result<(), Error> {
let mut c_message = self.messages.get(&message.key).unwrap_or(Vec::<Message>::new());
c_message.push(message);
self.received_message_table.insert(message.key, &c_message);
Ok(())
}
Operation
Repeatedly call push_message
with the same key
value to test the upper limit of Vec size.
Expectation
I can call push_message
successfully every time until the weight exceeds the maxExtrinsic weight.
Result
I only pushed 67 message into the Vec, then I got the error contracts.ContractTraped
.
In the node terminal, I saw the output "range end index 16388 out of range for slice of length 16384".
What does this mean? I think the transaction fail is because of the storage limit, instead of gas limit, is it?
Compact<u32>
at the start... if the len were really small it would take 1 byte. docs.rs/parity-scale-codec/3.1.5/src/parity_scale_codec/…