-
Notifications
You must be signed in to change notification settings - Fork 7
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
Update node contract #106
Update node contract #106
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
6044dc8
to
31b5549
Compare
87eaedc
to
c4246b6
Compare
5d7b02f
to
0efeea1
Compare
0efeea1
to
894e74b
Compare
node.httpAddress | ||
); | ||
|
||
vm.prank(operator); |
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.
vm.prank
is cool. It just lets you change the msg.sender
value to any other address for a test, so you can impersonate someone and see how the contract behaves.
NodeId int | ||
SigningKey []byte | ||
HttpAddress string | ||
MtlsCert []byte |
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.
This field goes away in the next PR
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.
Using ERC721 is a smart idea. Will ecosystem tools break if we don't specify base/token URI? I suppose we could also generate some fun images too. Also do we need to block safeTransferFrom
?
bytes calldata signingKeyPub, | ||
string calldata httpAddress | ||
) public onlyOwner returns (uint16) { | ||
uint16 nodeId = _nodeIdCounter; |
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.
We should not allow a node to have node ID 0, because an originator SID of 0 means that the originator is the blockchain. Wondering if we should pre-increment _nodeIdCounter rather than post-incrementing it?
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 have a comment somewhere about this. I kinda think we should start at 1000 just to be safe. Would let us partition the smart contracts later if we wanted to.
require( | ||
_msgSender() == owner(), | ||
"Only the contract owner can transfer Node ownership" | ||
); |
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.
Small nit, any reason this one uses a require statement, but updateHealth
uses public onlyOwner
?
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.
Only that I wanted a better error message, but agree the inconsistency feels weird
require( | ||
bytes(nodes[publicKey].httpAddress).length == 0, | ||
"Node already exists" | ||
_msgSender() == ownerOf(tokenId), |
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 wonder if there are tradeoffs to allowing/encouraging nodes to update the HTTP address at any point, rather than going through a more heavyweight process via the DAO? For example, ensuring there is a graceful failover etc. Don't have a super strong opinion here
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 don't really know. Wondering the same thing. Worth a discussion.
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.
Will ecosystem tools break if we don't specify base/token URI?
The OpenZeppelin default just sets it to "". I would expect tools to handle that, since some generative NFTs are on-chain only. But I'm with you that at some point we'll do an extra-credit project and make a URI that has JSON metadata with a fun image and more info. Then it fully looks like a normal NFT.
Also do we need to block safeTransferFrom?
safeTransferFrom
calls transferFrom
internally, so we get them both with this override.
TL;DR
Why ERC721
AI Assisted Changelog
Smart Contract Changes:
Nodes
contract.addNode
,removeNode
,updateHttpAddress
,updateMtlsCert
, andupdateHealth
.NodeUpdated
andNodeRemoved
for better tracking of node changes.Go Bindings Update:
Nodes
contract.NodesNode
andNodesNodeWithId
to handle the new Node data.Testing:
CounterTest
toGroupMessagesTest
and addedNodesTest
for comprehensive testing of node functionalities.