Skip to content

Commit 89d6b43

Browse files
authored
feat: smart contract updates (#279)
* chore: added transfer in case 2 spend * feat: added waiting for 24 to withdraw for provider * chore: send funds directly to bidder instead of map * fix: added check for storing commitment * chore: added tests for edge cases * chore: generated abi * docs(infra): update README.md (#281) * fix: fixed pr comments * fix: fixed abi * fix: changed compare * fix: fixed order * chore: added protocol fee amount * fix: added comma * fix: updated abi * fix: fixed withdrawal delay * fix: returned comment * fix: returned back the comment * fix: updated comment * fix: updated comment * fix: optimized require * fix: changed comment * fix: comment * fix: fixed another comment * fix: fixed seconds to milliseconds * fix: fixed test
1 parent be0e7d9 commit 89d6b43

16 files changed

Lines changed: 1125 additions & 299 deletions

File tree

contracts-abi/abi/ProviderRegistry.abi

Lines changed: 164 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -58,51 +58,6 @@
5858
"outputs": [],
5959
"stateMutability": "nonpayable"
6060
},
61-
{
62-
"type": "function",
63-
"name": "bidderAmount",
64-
"inputs": [
65-
{
66-
"name": "",
67-
"type": "address",
68-
"internalType": "address"
69-
}
70-
],
71-
"outputs": [
72-
{
73-
"name": "",
74-
"type": "uint256",
75-
"internalType": "uint256"
76-
}
77-
],
78-
"stateMutability": "view"
79-
},
80-
{
81-
"type": "function",
82-
"name": "checkStake",
83-
"inputs": [
84-
{
85-
"name": "provider",
86-
"type": "address",
87-
"internalType": "address"
88-
}
89-
],
90-
"outputs": [
91-
{
92-
"name": "",
93-
"type": "uint256",
94-
"internalType": "uint256"
95-
}
96-
],
97-
"stateMutability": "view"
98-
},
99-
{
100-
"type": "function",
101-
"name": "depositFunds",
102-
"inputs": [],
103-
"outputs": [],
104-
"stateMutability": "payable"
105-
},
10661
{
10762
"type": "function",
10863
"name": "eoaToBlsPubkey",
@@ -180,6 +135,25 @@
180135
],
181136
"stateMutability": "view"
182137
},
138+
{
139+
"type": "function",
140+
"name": "getProviderStake",
141+
"inputs": [
142+
{
143+
"name": "provider",
144+
"type": "address",
145+
"internalType": "address"
146+
}
147+
],
148+
"outputs": [
149+
{
150+
"name": "",
151+
"type": "uint256",
152+
"internalType": "uint256"
153+
}
154+
],
155+
"stateMutability": "view"
156+
},
183157
{
184158
"type": "function",
185159
"name": "initialize",
@@ -203,11 +177,29 @@
203177
"name": "_owner",
204178
"type": "address",
205179
"internalType": "address"
180+
},
181+
{
182+
"name": "_withdrawalDelay",
183+
"type": "uint256",
184+
"internalType": "uint256"
206185
}
207186
],
208187
"outputs": [],
209188
"stateMutability": "nonpayable"
210189
},
190+
{
191+
"type": "function",
192+
"name": "isProviderValid",
193+
"inputs": [
194+
{
195+
"name": "provider",
196+
"type": "address",
197+
"internalType": "address"
198+
}
199+
],
200+
"outputs": [],
201+
"stateMutability": "view"
202+
},
211203
{
212204
"type": "function",
213205
"name": "minStake",
@@ -260,6 +252,19 @@
260252
],
261253
"stateMutability": "view"
262254
},
255+
{
256+
"type": "function",
257+
"name": "protocolFeeAmount",
258+
"inputs": [],
259+
"outputs": [
260+
{
261+
"name": "",
262+
"type": "uint256",
263+
"internalType": "uint256"
264+
}
265+
],
266+
"stateMutability": "view"
267+
},
263268
{
264269
"type": "function",
265270
"name": "providerRegistered",
@@ -370,6 +375,19 @@
370375
"outputs": [],
371376
"stateMutability": "nonpayable"
372377
},
378+
{
379+
"type": "function",
380+
"name": "setWithdrawalDelay",
381+
"inputs": [
382+
{
383+
"name": "_withdrawalDelay",
384+
"type": "uint256",
385+
"internalType": "uint256"
386+
}
387+
],
388+
"outputs": [],
389+
"stateMutability": "nonpayable"
390+
},
373391
{
374392
"type": "function",
375393
"name": "slash",
@@ -398,6 +416,13 @@
398416
"outputs": [],
399417
"stateMutability": "nonpayable"
400418
},
419+
{
420+
"type": "function",
421+
"name": "stake",
422+
"inputs": [],
423+
"outputs": [],
424+
"stateMutability": "payable"
425+
},
401426
{
402427
"type": "function",
403428
"name": "transferOwnership",
@@ -411,6 +436,13 @@
411436
"outputs": [],
412437
"stateMutability": "nonpayable"
413438
},
439+
{
440+
"type": "function",
441+
"name": "unstake",
442+
"inputs": [],
443+
"outputs": [],
444+
"stateMutability": "nonpayable"
445+
},
414446
{
415447
"type": "function",
416448
"name": "upgradeToAndCall",
@@ -431,14 +463,8 @@
431463
},
432464
{
433465
"type": "function",
434-
"name": "withdrawBidderAmount",
435-
"inputs": [
436-
{
437-
"name": "bidder",
438-
"type": "address",
439-
"internalType": "address"
440-
}
441-
],
466+
"name": "withdraw",
467+
"inputs": [],
442468
"outputs": [],
443469
"stateMutability": "nonpayable"
444470
},
@@ -451,17 +477,49 @@
451477
},
452478
{
453479
"type": "function",
454-
"name": "withdrawStakedAmount",
480+
"name": "withdrawProtocolFee",
455481
"inputs": [
456482
{
457-
"name": "provider",
483+
"name": "treasuryAddress",
458484
"type": "address",
459485
"internalType": "address payable"
460486
}
461487
],
462488
"outputs": [],
463489
"stateMutability": "nonpayable"
464490
},
491+
{
492+
"type": "function",
493+
"name": "withdrawalDelay",
494+
"inputs": [],
495+
"outputs": [
496+
{
497+
"name": "",
498+
"type": "uint256",
499+
"internalType": "uint256"
500+
}
501+
],
502+
"stateMutability": "view"
503+
},
504+
{
505+
"type": "function",
506+
"name": "withdrawalRequests",
507+
"inputs": [
508+
{
509+
"name": "",
510+
"type": "address",
511+
"internalType": "address"
512+
}
513+
],
514+
"outputs": [
515+
{
516+
"name": "",
517+
"type": "uint256",
518+
"internalType": "uint256"
519+
}
520+
],
521+
"stateMutability": "view"
522+
},
465523
{
466524
"type": "event",
467525
"name": "FundsDeposited",
@@ -576,6 +634,25 @@
576634
],
577635
"anonymous": false
578636
},
637+
{
638+
"type": "event",
639+
"name": "Unstake",
640+
"inputs": [
641+
{
642+
"name": "provider",
643+
"type": "address",
644+
"indexed": true,
645+
"internalType": "address"
646+
},
647+
{
648+
"name": "timestamp",
649+
"type": "uint256",
650+
"indexed": false,
651+
"internalType": "uint256"
652+
}
653+
],
654+
"anonymous": false
655+
},
579656
{
580657
"type": "event",
581658
"name": "Upgraded",
@@ -589,6 +666,38 @@
589666
],
590667
"anonymous": false
591668
},
669+
{
670+
"type": "event",
671+
"name": "Withdraw",
672+
"inputs": [
673+
{
674+
"name": "provider",
675+
"type": "address",
676+
"indexed": true,
677+
"internalType": "address"
678+
},
679+
{
680+
"name": "amount",
681+
"type": "uint256",
682+
"indexed": false,
683+
"internalType": "uint256"
684+
}
685+
],
686+
"anonymous": false
687+
},
688+
{
689+
"type": "event",
690+
"name": "WithdrawalDelayUpdated",
691+
"inputs": [
692+
{
693+
"name": "newWithdrawalDelay",
694+
"type": "uint256",
695+
"indexed": false,
696+
"internalType": "uint256"
697+
}
698+
],
699+
"anonymous": false
700+
},
592701
{
593702
"type": "error",
594703
"name": "AddressEmptyCode",

contracts-abi/clients/ProviderRegistry/ProviderRegistry.go

Lines changed: 677 additions & 120 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

contracts/contracts/BidderRegistry.sol

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,9 @@ contract BidderRegistry is
356356

357357
// Check if bid exceeds the available amount for the block
358358
if (availableAmount < bid) {
359-
// todo: burn it, until oracle will do the calculation and transfers
359+
(bool success, ) = payable(bidder).call{value: bid - availableAmount}("");
360+
require(success, "couldn't transfer to bidder");
361+
360362
bid = uint64(availableAmount);
361363
}
362364

contracts/contracts/PreConfCommitmentStore.sol

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,9 @@ contract PreConfCommitmentStore is IPreConfCommitmentStore, Ownable2StepUpgradea
326326
"sender is not commiter"
327327
);
328328

329+
// Ensure the provider's balance is greater than minStake and no pending withdrawal
330+
providerRegistry.isProviderValid(commiterAddress);
331+
329332
EncrPreConfCommitment memory newCommitment = EncrPreConfCommitment(
330333
false,
331334
commiterAddress,

0 commit comments

Comments
 (0)