Skip to content

Commit

Permalink
v1.0.5 update
Browse files Browse the repository at this point in the history
  • Loading branch information
glitch003 committed Nov 12, 2024
1 parent 6bda7ce commit 22d76a2
Show file tree
Hide file tree
Showing 229 changed files with 61,809 additions and 13,034 deletions.
Binary file removed Archive/Habanero.zip
Binary file not shown.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<div align="center">
<h1>Lit Protocol Node and Contracts Snapshot Repo</h1>
<h1>Lit Protocol Node and Contracts</h1>
<img src="https://i.ibb.co/p2xfzK1/Screenshot-2022-11-15-at-09-56-57.png">
<br/>
<a href="https://twitter.com/LitProtocol"><img src="https://img.shields.io/twitter/follow/litprotocol?label=Follow&style=social"/></a>
<br/>
<br/>
This is a snapshot repo of the Lit Protocol Node and Contracts. It contains the code that is currently running on the "Datil" network. You can find previous network releases in the Archive folder.
The Lit Protocol Node is the core software that runs the Lit Protocol. It is a Rust application that node operators run to provide service to Lit Protocol.
<br/>
<br/>

Expand All @@ -16,7 +16,7 @@ https://developer.litprotocol.com/v3/sdk/installation
</a>

<br/><br/>
This is a snapshot of the monorepo that holds everything needed to run a Lit Node on the "Datil" network. Check out the readme in each folder for more information.
This is a monorepo that holds everything needed to run a Lit Node. Check out the readme in each folder for more information.

</div>

Expand Down
24 changes: 24 additions & 0 deletions blockchain/contracts/abis/PKPPermissions.abi
Original file line number Diff line number Diff line change
Expand Up @@ -751,6 +751,30 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "authMethodType",
"type": "uint256"
},
{
"internalType": "bytes",
"name": "id",
"type": "bytes"
}
],
"name": "getPKPPubKeysByAuthMethod",
"outputs": [
{
"internalType": "bytes[]",
"name": "",
"type": "bytes[]"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
Expand Down
7 changes: 7 additions & 0 deletions blockchain/contracts/abis/PaymentDelegation.abi
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,13 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "setDefaultRestriction",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
Expand Down
13 changes: 13 additions & 0 deletions blockchain/contracts/abis/RateLimitNFT.abi
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,19 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "owner",
"type": "address"
}
],
"name": "pruneExpired",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
Expand Down
150 changes: 150 additions & 0 deletions blockchain/contracts/abis/Staking.abi
Original file line number Diff line number Diff line change
Expand Up @@ -1886,6 +1886,156 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getActiveUnkickedValidatorStructs",
"outputs": [
{
"components": [
{
"internalType": "uint32",
"name": "ip",
"type": "uint32"
},
{
"internalType": "uint128",
"name": "ipv6",
"type": "uint128"
},
{
"internalType": "uint32",
"name": "port",
"type": "uint32"
},
{
"internalType": "address",
"name": "nodeAddress",
"type": "address"
},
{
"internalType": "uint256",
"name": "reward",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "senderPubKey",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "receiverPubKey",
"type": "uint256"
}
],
"internalType": "struct LibStakingStorage.Validator[]",
"name": "",
"type": "tuple[]"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getActiveUnkickedValidatorStructsAndCounts",
"outputs": [
{
"components": [
{
"internalType": "uint256",
"name": "epochLength",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "number",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "endTime",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "retries",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "timeout",
"type": "uint256"
}
],
"internalType": "struct LibStakingStorage.Epoch",
"name": "",
"type": "tuple"
},
{
"internalType": "uint256",
"name": "",
"type": "uint256"
},
{
"components": [
{
"internalType": "uint32",
"name": "ip",
"type": "uint32"
},
{
"internalType": "uint128",
"name": "ipv6",
"type": "uint128"
},
{
"internalType": "uint32",
"name": "port",
"type": "uint32"
},
{
"internalType": "address",
"name": "nodeAddress",
"type": "address"
},
{
"internalType": "uint256",
"name": "reward",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "senderPubKey",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "receiverPubKey",
"type": "uint256"
}
],
"internalType": "struct LibStakingStorage.Validator[]",
"name": "",
"type": "tuple[]"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getActiveUnkickedValidators",
"outputs": [
{
"internalType": "address[]",
"name": "",
"type": "address[]"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getKeyTypes",
Expand Down
8 changes: 4 additions & 4 deletions blockchain/contracts/contracts/lit-core/ReleaseRegister.sol
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,11 @@ contract ReleaseRegister is AccessControl {
revert InvalidEnv();
}

if (env != Env.Dev && env != Env.Staging) {
require(!creatorInit, "initCreator() may only be called once");
}
// if (env != Env.Dev && env != Env.Staging) {
// require(!creatorInit, "initCreator() may only be called once");
// }

creatorInit = true;
// creatorInit = true;
creatorDomain = domain;

allowedSubnets[subnetId] = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,23 @@ contract PKPPermissionsFacet {
return allPermittedAddresses;
}

function getPKPPubKeysByAuthMethod(
uint256 authMethodType,
bytes memory id
) external view returns (bytes[] memory) {
uint256 authMethodId = getAuthMethodId(authMethodType, id);

uint256 pkpIdsLength = s().authMethodToPkpIds[authMethodId].length();
bytes[] memory allPkpPubkeys = new bytes[](pkpIdsLength);

for (uint256 i = 0; i < pkpIdsLength; i++) {
allPkpPubkeys[i] = getPubkey(
s().authMethodToPkpIds[authMethodId].at(i)
);
}

return allPkpPubkeys;
}
/// get if a user is permitted to use a given pubkey. returns true if it is permitted to use the pubkey in the permittedAuthMethods[tokenId] struct.
function isPermittedAuthMethod(
uint256 tokenId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ contract PaymentDelegationFacet {
function delegatePayments(address user) public {
s().payers[user].add(msg.sender); // this guarantees the auth - that the payer made this txn, because msg.sender is authed.
s().users[msg.sender].add(user);
setDefaultRestriction();
}

function undelegatePayments(address user) public {
Expand All @@ -84,6 +85,7 @@ contract PaymentDelegationFacet {
s().payers[users[i]].add(msg.sender);
s().users[msg.sender].add(users[i]);
}
setDefaultRestriction();
}

function undelegatePaymentsBatch(address[] memory users) public {
Expand All @@ -100,9 +102,26 @@ contract PaymentDelegationFacet {
function setRestriction(
LibPaymentDelegationStorage.Restriction memory r
) public {
// due to a divide by zero bug in Datil v0.2.16,
// we need to prevent the period from being set to 0
// so we set the default period of 1 day if the period is 0
if (r.periodSeconds == 0) {
r.periodSeconds = 86400;
}
s().restrictions[msg.sender] = r;
}

function setDefaultRestriction() public {
LibPaymentDelegationStorage.Restriction memory r = s().restrictions[
msg.sender
];
if (r.requestsPerPeriod == 0 && r.periodSeconds == 0) {
r.requestsPerPeriod = 1000000000;
r.periodSeconds = 86400;
s().restrictions[msg.sender] = r;
}
}

/* ========== EVENTS ========== */

event RestrictionSet(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,24 @@ contract RateLimitNFTFacet is
s().maxExpirationSeconds = newMaxExpirationSeconds;
}

function pruneExpired(address owner) public {
uint256 balance = balanceOf(owner);
uint256[] memory tokenIds = new uint256[](balance);
for (uint256 i = 0; i < balance; i++) {
uint256 tokenId = tokenOfOwnerByIndex(owner, i);
if (s().capacity[tokenId].expiresAt < block.timestamp) {
tokenIds[i] = tokenId;
}
}

// burn the expired ones
for (uint256 i = 0; i < balance; i++) {
if (tokenIds[i] != 0) {
_burn(tokenIds[i]);
}
}
}

/* ========== EVENTS ========== */

event AdditionalRequestsPerKilosecondCostSet(
Expand Down
Loading

0 comments on commit 22d76a2

Please sign in to comment.