I have uploaded a couple of websites with `awe` v0.10.0 to test the autonomi API… v0.2.2 (stable-2024.10.4.6). To do so I used a local copy of safe_network in order to gain access to the MerkleRegister, using the same modification which is pending in PR https://github.com/maidsafe/safe_network/pull/2426
This report shows two examples of registers used to store metadata for two different websites. One for the **autonomi-demo** website register has been successfully updated, and another which repeatedly fails to update, for the **awe-some-sites** website.
### Creating/publishing a website
When a website is first published I create the register and immediately add two entries (merging each time). The result is that I have one value, and can examine the first and second entries (the history of root values) via the MerkleRegister. You can see this using `awe inspect-register -rak ef727106393e4ce36190827082e0421c99b2fd408a4fd79af7bafee7e1ac1850a4b2491a32ecdf948caa7480cb5f3308c7756ed71f46fbe5d55ac4f2545867ab89afc5c6ce2ec6effc16ed1dfa6b059b`
The output shows a single 'root' (1d2d.. which is the second value added) and that the register has two entries: one for the first value added (5ebb.. which is used as a type) and one for the second (1d2d.. which points to the website metatdata for the first version of the website.
```
Autonomi client initialising...
🔗 Connected to the Network register : ef727106393e4ce36190827082e0421c99b2fd408a4fd79af7bafee7e1ac1850a4b2491a32ecdf948caa7480cb5f3308c7756ed71f46fbe5d55ac4f2545867ab89afc5c6ce2ec6effc16ed1dfa6b059b
owner : PublicKey(04b2..de6d)
permissions : Writers({PublicKey(04b2..de6d)})
num roots : 1
app reg type: 5ebbbc..
size : 2
audit :
current state is merged, 1 value:
1d2d67a710b9d1656f802982857bf4492465431c14a122f2a3da8b7a24ddd1e5
======================
Root (Latest) Node(s):
[ 0] Node("0"..) Entry(1d2d67a710b9d1656f802982857bf4492465431c14a122f2a3da8b7a24ddd1e5)
======================
Register Structure:
(In general, earlier nodes are more indented)
[ 0] Node("0"..) Entry(1d2d67a710b9d1656f802982857bf4492465431c14a122f2a3da8b7a24ddd1e5)
[ 1] Node("1"..) Entry(5ebbbc4f061702c875b6cacb76e537eb482713c458b9d83c2f1e86ea9e0d0d0f)
======================
MerkleReg { roots: {[238, 69, 159, 118, 89, 244, 215, 129, 6, 190, 250, 38, 75, 196, 30, 104, 76, 143, 165, 210, 135, 111, 110, 186, 76, 250, 115, 190, 37, 179, 181, 185]}, dag: {[145, 184, 88, 172, 235, 64, 88, 207, 188, 242, 228, 102, 81, 154, 196, 17, 4, 101, 222, 223, 204, 70, 164, 82, 192, 87, 235, 3, 136, 52, 236, 122]: Node { children: {}, value: [94, 187, 188, 79, 6, 23, 2, 200, 117, 182, 202, 203, 118, 229, 55, 235, 72, 39, 19, 196, 88, 185, 216, 60, 47, 30, 134, 234, 158, 13, 13, 15] }, [238, 69, 159, 118, 89, 244, 215, 129, 6, 190, 250, 38, 75, 196, 30, 104, 76, 143, 165, 210, 135, 111, 110, 186, 76, 250, 115, 190, 37, 179, 181, 185]: Node { children: {[145, 184, 88, 172, 235, 64, 88, 207, 188, 242, 228, 102, 81, 154, 196, 17, 4, 101, 222, 223, 204, 70, 164, 82, 192, 87, 235, 3, 136, 52, 236, 122]}, value: [29, 45, 103, 167, 16, 185, 209, 101, 111, 128, 41, 130, 133, 123, 244, 73, 36, 101, 67, 28, 20, 161, 34, 242, 163, 218, 139, 122, 36, 221, 209, 229] }}, orphans: {} }
```
The above output is for the website **awe-some-sites**.
### Updating a website
When I do an update to the website I expect the result to be that we still have one root, which will be the most recent website metadata, and three entries. Below you can see the state after publishing and then updating the website **autonomi-demo** once. Using the command: `awe inspect-register -rak awv://9fc38253483e92cc6c506b62dead383a228a3508ec14fa0b7c05a56ea21fd692a4b2491a32ecdf948caa7480cb5f3308c7756ed71f46fbe5d55ac4f2545867ab89afc5c6ce2ec6effc16ed1dfa6b059b`
The output shows that this register has one root (eff7..) and three entries which shows that the subsequent call to `register_update()` has added an entry to the register and updated the root value:
```
Autonomi client initialising...
🔗 Connected to the Network register : 9fc38253483e92cc6c506b62dead383a228a3508ec14fa0b7c05a56ea21fd692a4b2491a32ecdf948caa7480cb5f3308c7756ed71f46fbe5d55ac4f2545867ab89afc5c6ce2ec6effc16ed1dfa6b059b
owner : PublicKey(04b2..de6d)
permissions : Writers({PublicKey(04b2..de6d)})
num roots : 1
app reg type: 5ebbbc..
size : 3
audit :
current state is merged, 1 value:
eff720e379a85e06ebb32cd1f53de8f99077246c1af5e9b324c2c53426660fd3
======================
Root (Latest) Node(s):
[ 0] Node("0"..) Entry(eff720e379a85e06ebb32cd1f53de8f99077246c1af5e9b324c2c53426660fd3)
======================
Register Structure:
(In general, earlier nodes are more indented)
[ 0] Node("0"..) Entry(eff720e379a85e06ebb32cd1f53de8f99077246c1af5e9b324c2c53426660fd3)
[ 1] Node("1"..) Entry(aaa2df9ecef3b9ba1d0062af6283f3d7be5e21c85d008d329ccac2202a32a167)
[ 2] Node("2"..) Entry(5ebbbc4f061702c875b6cacb76e537eb482713c458b9d83c2f1e86ea9e0d0d0f)
======================
MerkleReg { roots: {[60, 125, 59, 208, 8, 233, 109, 23, 223, 25, 160, 43, 211, 52, 72, 47, 250, 177, 246, 135, 69, 162, 104, 102, 148, 29, 243, 211, 176, 53, 112, 49]}, dag: {[11, 29, 154, 183, 238, 109, 39, 118, 160, 225, 140, 162, 241, 251, 49, 25, 184, 23, 182, 222, 227, 163, 28, 140, 154, 5, 162, 101, 158, 211, 237, 53]: Node { children: {[145, 184, 88, 172, 235, 64, 88, 207, 188, 242, 228, 102, 81, 154, 196, 17, 4, 101, 222, 223, 204, 70, 164, 82, 192, 87, 235, 3, 136, 52, 236, 122]}, value: [170, 162, 223, 158, 206, 243, 185, 186, 29, 0, 98, 175, 98, 131, 243, 215, 190, 94, 33, 200, 93, 0, 141, 50, 156, 202, 194, 32, 42, 50, 161, 103] }, [60, 125, 59, 208, 8, 233, 109, 23, 223, 25, 160, 43, 211, 52, 72, 47, 250, 177, 246, 135, 69, 162, 104, 102, 148, 29, 243, 211, 176, 53, 112, 49]: Node { children: {[11, 29, 154, 183, 238, 109, 39, 118, 160, 225, 140, 162, 241, 251, 49, 25, 184, 23, 182, 222, 227, 163, 28, 140, 154, 5, 162, 101, 158, 211, 237, 53]}, value: [239, 247, 32, 227, 121, 168, 94, 6, 235, 179, 44, 209, 245, 61, 232, 249, 144, 119, 36, 108, 26, 245, 233, 179, 36, 194, 197, 52, 38, 102, 15, 211] }, [145, 184, 88, 172, 235, 64, 88, 207, 188, 242, 228, 102, 81, 154, 196, 17, 4, 101, 222, 223, 204, 70, 164, 82, 192, 87, 235, 3, 136, 52, 236, 122]: Node { children: {}, value: [94, 187, 188, 79, 6, 23, 2, 200, 117, 182, 202, 203, 118, 229, 55, 235, 72, 39, 19, 196, 88, 185, 216, 60, 47, 30, 134, 234, 158, 13, 13, 15] }}, orphans: {} }
```
### The bug
In contrast, every time I try updating the **awe-some-sites** register, the register remains unchanged. For example, here's the output of a command to do and update for the third time which shows the register (and MerkleRegister) state before the register_update(), after the update, and after a subsequent register_get():
```
WEBSITE CONTENT UPLOADED:
397d9b636284df5ab0abcec8e0fc8080fb7fb65e183d520c8e95246acc276463 "/home/safe/src/safe-browser/awe-sites/awe-some-sites/content/index.html"
DEBUG publish_website_metadata() website_root '/home/safe/src/safe-browser/awe-sites/awe-some-sites/content/'
Adding '/home/safe/src/safe-browser/awe-sites/awe-some-sites/content/index.html' as '/index.html'
WEBSITE METADATA UPLOADED:
awm://d568c7835298f6c8706aeaf1dec3d14a6500b7841077f155e6a2e245822edeac
Updating versions register ef727106393e4ce36190827082e0421c99b2fd408a4fd79af7bafee7e1ac1850a4b2491a32ecdf948caa7480cb5f3308c7756ed71f46fbe5d55ac4f2545867ab89afc5c6ce2ec6effc16ed1dfa6b059b
Updating register : ef727106393e4ce36190827082e0421c99b2fd408a4fd79af7bafee7e1ac1850a4b2491a32ecdf948caa7480cb5f3308c7756ed71f46fbe5d55ac4f2545867ab89afc5c6ce2ec6effc16ed1dfa6b059b
Register get returned: ef727106393e4ce36190827082e0421c99b2fd408a4fd79af7bafee7e1ac1850a4b2491a32ecdf948caa7480cb5f3308c7756ed71f46fbe5d55ac4f2545867ab89afc5c6ce2ec6effc16ed1dfa6b059b
Before register_update()...do client.register_get()...
Register has 1 values
Register has 2 entries
Register MerkleReg { roots: {[238, 69, 159, 118, 89, 244, 215, 129, 6, 190, 250, 38, 75, 196, 30, 104, 76, 143, 165, 210, 135, 111, 110, 186, 76, 250, 115, 190, 37, 179, 181, 185]}, dag: {[145
, 184, 88, 172, 235, 64, 88, 207, 188, 242, 228, 102, 81, 154, 196, 17, 4, 101, 222, 223, 204, 70, 164, 82, 192, 87, 235, 3, 136, 52, 236, 122]: Node { children: {}, value: [94, 187, 188, 79, 6, 23,
2, 200, 117, 182, 202, 203, 118, 229, 55, 235, 72, 39, 19, 196, 88, 185, 216, 60, 47, 30, 134, 234, 158, 13, 13, 15] }, [238, 69, 159, 118, 89, 244, 215, 129, 6, 190, 250, 38, 75, 196, 30, 104, 76,
143, 165, 210, 135, 111, 110, 186, 76, 250, 115, 190, 37, 179, 181, 185]: Node { children: {[145, 184, 88, 172, 235, 64, 88, 207, 188, 242, 228, 102, 81, 154, 196, 17, 4, 101, 222, 223, 204, 70, 16
4, 82, 192, 87, 235, 3, 136, 52, 236, 122]}, value: [29, 45, 103, 167, 16, 185, 209, 101, 111, 128, 41, 130, 133, 123, 244, 73, 36, 101, 67, 28, 20, 161, 34, 242, 163, 218, 139, 122, 36, 221, 209, 2
29] }}, orphans: {} }
Calling register_update() with value: d568c7..
After update...
Register has 1 values
Register has 2 entries
Register MerkleReg { roots: {[238, 69, 159, 118, 89, 244, 215, 129, 6, 190, 250, 38, 75, 196, 30, 104, 76, 143, 165, 210, 135, 111, 110, 186, 76, 250, 115, 190, 37, 179, 181, 185]}, dag: {[145
, 184, 88, 172, 235, 64, 88, 207, 188, 242, 228, 102, 81, 154, 196, 17, 4, 101, 222, 223, 204, 70, 164, 82, 192, 87, 235, 3, 136, 52, 236, 122]: Node { children: {}, value: [94, 187, 188, 79, 6, 23,
2, 200, 117, 182, 202, 203, 118, 229, 55, 235, 72, 39, 19, 196, 88, 185, 216, 60, 47, 30, 134, 234, 158, 13, 13, 15] }, [238, 69, 159, 118, 89, 244, 215, 129, 6, 190, 250, 38, 75, 196, 30, 104, 76,
143, 165, 210, 135, 111, 110, 186, 76, 250, 115, 190, 37, 179, 181, 185]: Node { children: {[145, 184, 88, 172, 235, 64, 88, 207, 188, 242, 228, 102, 81, 154, 196, 17, 4, 101, 222, 223, 204, 70, 16
4, 82, 192, 87, 235, 3, 136, 52, 236, 122]}, value: [29, 45, 103, 167, 16, 185, 209, 101, 111, 128, 41, 130, 133, 123, 244, 73, 36, 101, 67, 28, 20, 161, 34, 242, 163, 218, 139, 122, 36, 221, 209, 2
29] }}, orphans: {} }
After update...and get...
Register has 1 values
Register has 2 entries
Register MerkleReg { roots: {[238, 69, 159, 118, 89, 244, 215, 129, 6, 190, 250, 38, 75, 196, 30, 104, 76, 143, 165, 210, 135, 111, 110, 186, 76, 250, 115, 190, 37, 179, 181, 185]}, dag: {[145
, 184, 88, 172, 235, 64, 88, 207, 188, 242, 228, 102, 81, 154, 196, 17, 4, 101, 222, 223, 204, 70, 164, 82, 192, 87, 235, 3, 136, 52, 236, 122]: Node { children: {}, value: [94, 187, 188, 79, 6, 23,
2, 200, 117, 182, 202, 203, 118, 229, 55, 235, 72, 39, 19, 196, 88, 185, 216, 60, 47, 30, 134, 234, 158, 13, 13, 15] }, [238, 69, 159, 118, 89, 244, 215, 129, 6, 190, 250, 38, 75, 196, 30, 104, 76,
143, 165, 210, 135, 111, 110, 186, 76, 250, 115, 190, 37, 179, 181, 185]: Node { children: {[145, 184, 88, 172, 235, 64, 88, 207, 188, 242, 228, 102, 81, 154, 196, 17, 4, 101, 222, 223, 204, 70, 16
4, 82, 192, 87, 235, 3, 136, 52, 236, 122]}, value: [29, 45, 103, 167, 16, 185, 209, 101, 111, 128, 41, 130, 133, 123, 244, 73, 36, 101, 67, 28, 20, 161, 34, 242, 163, 218, 139, 122, 36, 221, 209, 2
29] }}, orphans: {} }
client.register_update() added entry to register: ef727106393e4ce36190827082e0421c99b2fd408a4fd79af7bafee7e1ac1850a4b2491a32ecdf948caa7480cb5f3308c7756ed71f46fbe5d55ac4f2545867ab89afc5c6ce2ec6effc16
ed1dfa6b059b
DEBUG client.register_update() added entry to register: ef727106393e4ce36190827082e0421c99b2fd408a4fd79af7bafee7e1ac1850a4b2491a32ecdf948caa7480cb5f3308c7756ed71f46fbe5d55ac4f2545867ab89afc5c6ce2ec6
effc16ed1dfa6b059b
DEBUG register.inner_merkle_reg():
MerkleReg { roots: {[238, 69, 159, 118, 89, 244, 215, 129, 6, 190, 250, 38, 75, 196, 30, 104, 76, 143, 165, 210, 135, 111, 110, 186, 76, 250, 115, 190, 37, 179, 181, 185]}, dag: {[145, 184, 88, 172,
235, 64, 88, 207, 188, 242, 228, 102, 81, 154, 196, 17, 4, 101, 222, 223, 204, 70, 164, 82, 192, 87, 235, 3, 136, 52, 236, 122]: Node { children: {}, value: [94, 187, 188, 79, 6, 23, 2, 200, 117, 1
82, 202, 203, 118, 229, 55, 235, 72, 39, 19, 196, 88, 185, 216, 60, 47, 30, 134, 234, 158, 13, 13, 15] }, [238, 69, 159, 118, 89, 244, 215, 129, 6, 190, 250, 38, 75, 196, 30, 104, 76, 143, 165, 210,
135, 111, 110, 186, 76, 250, 115, 190, 37, 179, 181, 185]: Node { children: {[145, 184, 88, 172, 235, 64, 88, 207, 188, 242, 228, 102, 81, 154, 196, 17, 4, 101, 222, 223, 204, 70, 164, 82, 192, 87,
235, 3, 136, 52, 236, 122]}, value: [29, 45, 103, 167, 16, 185, 209, 101, 111, 128, 41, 130, 133, 123, 244, 73, 36, 101, 67, 28, 20, 161, 34, 242, 163, 218, 139, 122, 36, 221, 209, 229] }}, orphans
: {} }
website_metadata added to register: d568c7835298f6c8706aeaf1dec3d14a6500b7841077f155e6a2e245822edeac
WEBSITE UPDATED (version 1). All versions available at XOR-URL:
awv://ef727106393e4ce36190827082e0421c99b2fd408a4fd79af7bafee7e1ac1850a4b2491a32ecdf948caa7480cb5f3308c7756ed71f46fbe5d55ac4f2545867ab89afc5c6ce2ec6effc16ed1dfa6b059b
```
The full log output for the above is in the attached file.
Note: the output of awe register-inspect` for this register always remains the same, as shown under the first heading above, "Creating a website".
### Code
The Rust method which produces the above output is in [awe_website_versions.rs](https://github.com/happybeing/awe/blob/main/src-tauri/src/awe_website_versions.rs#L453) and is as follows:
```rust
/// Adds an XorName to the register, merging any branches
pub async fn add_xor_name(
&mut self,
client: &Client,
xor_value: &XorName,
owner_secret: &RegisterSecretKey,
_wallet: &Wallet, // Include for when updates are charged for
) -> Result<()> {
let register_xor_address = self.register.address().to_hex();
println!("Updating register : {register_xor_address}");
// The first register_get() has been added for testing (as reg_update() isn't always changing some registers)
match client.register_get(self.register.address().clone()).await {
Ok(register) => {
let register_xor_address = register.address().to_hex();
println!("Register get returned: {register_xor_address}");
let values = self.register.values();
println!("Before register_update()...do client.register_get()...");
println!(" Register has {} values", values.len());
println!(" Register has {} entries", self.num_entries());
let merkle_reg = self.register.inner_merkle_reg();
println!(" Register {merkle_reg:?}");
println!("Calling register_update() with value: {xor_value}");
match client
.register_update(
self.register.clone(),
Bytes::from(xor_value.to_vec()),
owner_secret.clone(),
)
.await
{
Ok(_) => {
let values = self.register.values();
println!("After update...");
println!(" Register has {} values", values.len());
println!(" Register has {} entries", self.num_entries());
let merkle_reg = self.register.inner_merkle_reg();
println!(" Register {merkle_reg:?}");
// It is necessary to get the register from the network to have it's entries accessible
self.register = match client
.register_get(self.register.address().clone())
.await
{
Ok(register) => {
let values = self.register.values();
println!("After update...and get...");
println!(" Register has {} values", values.len());
println!(" Register has {} entries", self.num_entries());
let merkle_reg = self.register.inner_merkle_reg();
println!(" Register {merkle_reg:?}");
let register_xor_address = self.register.address().to_hex();
println!("client.register_update() added entry to register: {register_xor_address}");
register
}
Err(e) => {
return Err(eyre!(
"DEBUG failed to get register that was just updated!\n{e}"
))
}
};
let register_xor_address = self.register.address().to_hex();
println!(
"DEBUG client.register_update() added entry to register: {register_xor_address}"
);
let merkle_reg = self.register.inner_merkle_reg();
println!("DEBUG register.inner_merkle_reg():\n{merkle_reg:?}");
}
Err(e) => {
return Err(eyre!("Failed to add XorName to register: {e:?}"));
}
}
}
Err(e) => return Err(eyre!("DEBUG failed to get register prior to update!\n{e}")),
};
Ok(())
}
```
The above has some extra debugging statements that are not part of `awe` v0.10.0 and have not been pushed to github.com/happybeing/awe.
#### Full debug output for the failing `register_update()`:
[testing-awe-some-sites-update-3.txt](https://github.com/user-attachments/files/17791083/testing-awe-some-sites-update-3.txt)