diff --git a/blockindex/contractstaking/event_handler.go b/blockindex/contractstaking/event_handler.go index daecaf9a30..dd95f9ba20 100644 --- a/blockindex/contractstaking/event_handler.go +++ b/blockindex/contractstaking/event_handler.go @@ -23,25 +23,6 @@ import ( const ( // StakingContractABI is the ABI of system staking contract StakingContractABI = `[ - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "uint256", - "name": "tokenId", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "AmountIncreased", - "type": "event" - }, { "anonymous": false, "inputs": [ @@ -149,25 +130,6 @@ const ( "name": "DelegateChanged", "type": "event" }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "uint256", - "name": "tokenId", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "duration", - "type": "uint256" - } - ], - "name": "DurationExtended", - "type": "event" - }, { "anonymous": false, "inputs": [ @@ -357,6 +319,31 @@ const ( ], "name": "Withdrawal", "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "duration", + "type": "uint256" + } + ], + "name": "BucketExpanded", + "type": "event" } ]` ) @@ -417,10 +404,8 @@ func (eh *contractStakingEventHandler) HandleEvent(ctx context.Context, blk *blo return eh.handleUnstakedEvent(event, blk.Height()) case "Merged": return eh.handleMergedEvent(event) - case "DurationExtended": - return eh.handleDurationExtendedEvent(event) - case "AmountIncreased": - return eh.handleAmountIncreasedEvent(event) + case "BucketExpanded": + return eh.handleBucketExpandedEvent(event) case "DelegateChanged": return eh.handleDelegateChangedEvent(event) case "Withdrawal": @@ -614,38 +599,16 @@ func (eh *contractStakingEventHandler) handleMergedEvent(event eventParam) error return eh.dirty.updateBucketInfo(tokenIDsParam[0].Uint64(), b) } -func (eh *contractStakingEventHandler) handleDurationExtendedEvent(event eventParam) error { +func (eh *contractStakingEventHandler) handleBucketExpandedEvent(event eventParam) error { tokenIDParam, err := event.IndexedFieldUint256("tokenId") if err != nil { return err } - durationParam, err := event.FieldUint256("duration") - if err != nil { - return err - } - - b, ok := eh.dirty.getBucketInfo(tokenIDParam.Uint64()) - if !ok { - return errors.Wrapf(ErrBucketNotExist, "token id %d", tokenIDParam.Uint64()) - } - bt, ok := eh.dirty.getBucketType(b.TypeIndex) - if !ok { - return errors.Wrapf(errBucketTypeNotExist, "id %d", b.TypeIndex) - } - newBtIdx, _, ok := eh.dirty.matchBucketType(bt.Amount, durationParam.Uint64()) - if !ok { - return errors.Wrapf(errBucketTypeNotExist, "amount %d, duration %d", bt.Amount.Int64(), durationParam.Uint64()) - } - b.TypeIndex = newBtIdx - return eh.dirty.updateBucketInfo(tokenIDParam.Uint64(), b) -} - -func (eh *contractStakingEventHandler) handleAmountIncreasedEvent(event eventParam) error { - tokenIDParam, err := event.IndexedFieldUint256("tokenId") + amountParam, err := event.FieldUint256("amount") if err != nil { return err } - amountParam, err := event.FieldUint256("amount") + durationParam, err := event.FieldUint256("duration") if err != nil { return err } @@ -654,13 +617,9 @@ func (eh *contractStakingEventHandler) handleAmountIncreasedEvent(event eventPar if !ok { return errors.Wrapf(ErrBucketNotExist, "token id %d", tokenIDParam.Uint64()) } - bt, ok := eh.dirty.getBucketType(b.TypeIndex) + newBtIdx, _, ok := eh.dirty.matchBucketType(amountParam, durationParam.Uint64()) if !ok { - return errors.Wrapf(errBucketTypeNotExist, "id %d", b.TypeIndex) - } - newBtIdx, _, ok := eh.dirty.matchBucketType(amountParam, bt.Duration) - if !ok { - return errors.Wrapf(errBucketTypeNotExist, "amount %d, duration %d", amountParam.Int64(), bt.Duration) + return errors.Wrapf(errBucketTypeNotExist, "amount %d, duration %d", amountParam.Int64(), durationParam.Uint64()) } b.TypeIndex = newBtIdx return eh.dirty.updateBucketInfo(tokenIDParam.Uint64(), b) diff --git a/blockindex/contractstaking/indexer_test.go b/blockindex/contractstaking/indexer_test.go index 772a34b3a6..e580a4d9d1 100644 --- a/blockindex/contractstaking/indexer_test.go +++ b/blockindex/contractstaking/indexer_test.go @@ -382,6 +382,53 @@ func TestContractStakingIndexerBucketInfo(t *testing.T) { r.EqualValues(1, indexer.TotalBucketCount()) } +func TestContractStakingIndexerChangeBucketType(t *testing.T) { + r := require.New(t) + testDBPath, err := testutil.PathOfTempFile("staking.db") + r.NoError(err) + defer testutil.CleanupPath(testDBPath) + cfg := db.DefaultConfig + cfg.DbPath = testDBPath + kvStore := db.NewBoltDB(cfg) + indexer, err := NewContractStakingIndexer(kvStore, _testStakingContractAddress, 0) + r.NoError(err) + r.NoError(indexer.Start(context.Background())) + + // init bucket type + bucketTypeData := [][2]int64{ + {10, 10}, + {20, 10}, + {10, 100}, + {20, 100}, + } + height := uint64(1) + handler := newContractStakingEventHandler(indexer.cache, height) + for _, data := range bucketTypeData { + activateBucketType(r, handler, data[0], data[1], height) + } + err = indexer.commit(handler) + r.NoError(err) + + t.Run("expand bucket type", func(t *testing.T) { + owner := identityset.Address(0) + delegate := identityset.Address(1) + height++ + handler = newContractStakingEventHandler(indexer.cache, height) + stake(r, handler, owner, delegate, 1, 10, 100, height) + r.NoError(err) + r.NoError(indexer.commit(handler)) + bucket, ok := indexer.Bucket(1) + r.True(ok) + + expandBucketType(r, handler, int64(bucket.Index), 20, 100) + r.NoError(indexer.commit(handler)) + bucket, ok = indexer.Bucket(bucket.Index) + r.True(ok) + r.EqualValues(20, bucket.StakedAmount.Int64()) + r.EqualValues(100, bucket.StakedDurationBlockNumber) + }) +} + func BenchmarkIndexer_PutBlockBeforeContractHeight(b *testing.B) { // Create a new Indexer with a contract height of 100 indexer := &Indexer{contractDeployHeight: 100} @@ -458,3 +505,12 @@ func withdraw(r *require.Assertions, handler *contractStakingEventHandler, token }) r.NoError(err) } + +func expandBucketType(r *require.Assertions, handler *contractStakingEventHandler, token, amount, duration int64) { + err := handler.handleBucketExpandedEvent(eventParam{ + "tokenId": big.NewInt(token), + "amount": big.NewInt(amount), + "duration": big.NewInt(duration), + }) + r.NoError(err) +} diff --git a/e2etest/contract_staking_test.go b/e2etest/contract_staking_test.go index e5ca295c0d..4d7e296986 100644 --- a/e2etest/contract_staking_test.go +++ b/e2etest/contract_staking_test.go @@ -39,32 +39,13 @@ import ( const ( // _stakingContractByteCode is the byte code of the contract staking contract for testing, which changes the freeze blocks to 10 - _stakingContractByteCode = `60806040523480156200001157600080fd5b5060405180604001604052806009815260200168109d58dad95d13919560ba1b815250604051806040016040528060038152602001621092d560ea1b81525081600090816200006191906200019b565b5060016200007082826200019b565b5050506200008d62000087620000a060201b60201c565b620000a4565b6006805460ff60a01b1916905562000267565b3390565b600680546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b634e487b7160e01b600052604160045260246000fd5b600181811c908216806200012157607f821691505b6020821081036200014257634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200019657600081815260208120601f850160051c81016020861015620001715750805b601f850160051c820191505b8181101562000192578281556001016200017d565b5050505b505050565b81516001600160401b03811115620001b757620001b7620000f6565b620001cf81620001c884546200010c565b8462000148565b602080601f831160018114620002075760008415620001ee5750858301515b600019600386901b1c1916600185901b17855562000192565b600085815260208120601f198616915b82811015620002385788860151825594840194600190910190840162000217565b5085821015620002575787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b613dbf80620002776000396000f3fe6080604052600436106102925760003560e01c80637acb77571161015a578063bbe33ea5116100c1578063e449f3411161007a578063e449f341146107e9578063e985e9c514610809578063eb0ffb2e14610852578063eec7ee7314610872578063f0b56b5d14610885578063f2fde38b1461089a57600080fd5b8063bbe33ea514610740578063c87b56dd14610753578063c8e7792314610773578063d0949f9914610793578063d6605fd8146107a9578063e0028ecf146107c957600080fd5b806398ca3b761161011357806398ca3b76146106985780639f7d5b00146106b8578063a22cb465146106cd578063b2383e55146106ed578063b88d4fde14610700578063b8f4bd7b1461072057600080fd5b80637acb7757146105fd5780638456cb59146106105780638da5cb5b1461062557806393b6ef591461064357806395d89b4114610663578063960014bd1461067857600080fd5b806342842e0e116101fe5780636198e339116101b75780636198e339146105485780636352211e1461056857806370a0823114610588578063711563d4146105a8578063715018a6146105bb57806378bfca10146105d057600080fd5b806342842e0e14610458578063431cd92a1461047857806343e06c59146104c95780635c975abb146104e95780635ceb8b5b146105085780635d36598f1461052857600080fd5b80630f5b2ca5116102505780630f5b2ca5146103965780631338736f146103b657806323b872dd146103d65780632e17de78146103f65780633f4ba83a146104165780633fd140df1461042b57600080fd5b8062f714ce1461029757806301ffc9a7146102b957806303459b16146102ee57806306fdde031461031c578063081812fc1461033e578063095ea7b314610376575b600080fd5b3480156102a357600080fd5b506102b76102b23660046134d2565b6108ba565b005b3480156102c557600080fd5b506102d96102d4366004613518565b610981565b60405190151581526020015b60405180910390f35b3480156102fa57600080fd5b5061030e610309366004613535565b6109d3565b6040519081526020016102e5565b34801561032857600080fd5b506103316109f9565b6040516102e5919061359e565b34801561034a57600080fd5b5061035e610359366004613535565b610a8b565b6040516001600160a01b0390911681526020016102e5565b34801561038257600080fd5b506102b76103913660046135b1565b610ab2565b3480156103a257600080fd5b506102b76103b13660046134d2565b610bc7565b3480156103c257600080fd5b506102b76103d13660046135dd565b610c34565b3480156103e257600080fd5b506102b76103f13660046135ff565b610ca7565b34801561040257600080fd5b506102b7610411366004613535565b610cd8565b34801561042257600080fd5b506102b7610d87565b34801561043757600080fd5b5061044b61044636600461368b565b610d99565b6040516102e591906136cc565b34801561046457600080fd5b506102b76104733660046135ff565b610f1b565b34801561048457600080fd5b50610498610493366004613535565b610f36565b6040805195865260208601949094529284019190915260608301526001600160a01b0316608082015260a0016102e5565b3480156104d557600080fd5b506102d96104e43660046135dd565b610fb2565b3480156104f557600080fd5b50600654600160a01b900460ff166102d9565b34801561051457600080fd5b506102b7610523366004613756565b610fcd565b34801561053457600080fd5b506102b761054336600461368b565b611074565b34801561055457600080fd5b506102b7610563366004613535565b61110a565b34801561057457600080fd5b5061035e610583366004613535565b61116c565b34801561059457600080fd5b5061030e6105a33660046137a1565b6111cc565b61030e6105b63660046137be565b611252565b3480156105c757600080fd5b506102b761132b565b3480156105dc57600080fd5b506105f06105eb3660046135dd565b61133d565b6040516102e591906137fd565b61030e61060b3660046134d2565b611472565b34801561061c57600080fd5b506102b76114f6565b34801561063157600080fd5b506006546001600160a01b031661035e565b34801561064f57600080fd5b5061030e61065e366004613535565b611506565b34801561066f57600080fd5b50610331611531565b34801561068457600080fd5b5061044b61069336600461368b565b611540565b3480156106a457600080fd5b506102b76106b3366004613856565b6116ba565b3480156106c457600080fd5b50600b5461030e565b3480156106d957600080fd5b506102b76106e83660046138ac565b611750565b6102b76106fb3660046135dd565b61175f565b34801561070c57600080fd5b506102b761071b366004613925565b611863565b34801561072c57600080fd5b506102b761073b366004613856565b61189b565b6102b761074e366004613756565b61198a565b34801561075f57600080fd5b5061033161076e366004613535565b611b94565b34801561077f57600080fd5b506102b761078e3660046135dd565b611c07565b34801561079f57600080fd5b5061030e60001981565b3480156107b557600080fd5b506102b76107c43660046135dd565b611dac565b3480156107d557600080fd5b506102b76107e43660046135dd565b611e91565b3480156107f557600080fd5b506102b761080436600461368b565b611f05565b34801561081557600080fd5b506102d96108243660046139e8565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b34801561085e57600080fd5b506102b761086d3660046135dd565b611fe1565b61030e610880366004613a16565b612057565b34801561089157600080fd5b5061030e600a81565b3480156108a657600080fd5b506102b76108b53660046137a1565b61215c565b6108c26121d5565b816108cc81612222565b600083815260086020526040902060028101546108e890612277565b156109325760405162461bcd60e51b81526020600482015260156024820152746e6f7420726561647920746f20776974686472617760581b60448201526064015b60405180910390fd5b61093b846122eb565b610945818461238e565b6040516001600160a01b0384169085907fd964a27d45f595739c13d8b1160b57491050cacf3a2e5602207277d6228f64ee90600090a350505050565b60006001600160e01b031982166380ac58cd60e01b14806109b257506001600160e01b03198216635b5e139f60e01b145b806109cd57506301ffc9a760e01b6001600160e01b03198316145b92915050565b60006109de8261244d565b6000828152600860205260409020600201546109cd90612277565b606060008054610a0890613adc565b80601f0160208091040260200160405190810160405280929190818152602001828054610a3490613adc565b8015610a815780601f10610a5657610100808354040283529160200191610a81565b820191906000526020600020905b815481529060010190602001808311610a6457829003601f168201915b5050505050905090565b6000610a968261244d565b506000908152600460205260409020546001600160a01b031690565b6000610abd8261116c565b9050806001600160a01b0316836001600160a01b031603610b2a5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b6064820152608401610929565b336001600160a01b0382161480610b465750610b468133610824565b610bb85760405162461bcd60e51b815260206004820152603d60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206f7220617070726f76656420666f7220616c6c0000006064820152608401610929565b610bc283836124ac565b505050565b610bcf6121d5565b81610bd981612222565b6000838152600860205260409020610bf1908361251a565b6040516001600160a01b038316815283907f6f08c7e76d830d5f3d0a18fd27f4d8c0049b24a8689ddb39625e0864d894a9c19060200160405180910390a2505050565b610c3c6121d5565b81610c4681612222565b6000838152600860205260409020610c5d81612618565b610c678184612662565b837f907fece23ce39fbcbceb71e515043fe29408353fbb393b25b35eb8a70a4bad0b84604051610c9991815260200190565b60405180910390a250505050565b610cb1338261274f565b610ccd5760405162461bcd60e51b815260040161092990613b16565b610bc28383836127cd565b610ce06121d5565b80610cea81612222565b6000828152600860205260409020610d0181612618565b610d0a8161293e565b15610d4e5760405162461bcd60e51b81526020600482015260146024820152736e6f7420726561647920746f20756e7374616b6560601b6044820152606401610929565b610d57816129e3565b60405183907f11725367022c3ff288940f4b5473aa61c2da6a24af7363a1128ee2401e8983b290600090a2505050565b610d8f612a1a565b610d97612a74565b565b6060816001600160401b03811115610db357610db36138df565b604051908082528060200260200182016040528015610de657816020015b6060815260200190600190039081610dd15790505b5090506000610df4600b5490565b905060005b83811015610f1357816001600160401b03811115610e1957610e196138df565b604051908082528060200260200182016040528015610e42578160200160208202803683370190505b50838281518110610e5557610e55613b63565b60200260200101819052506000600a6000878785818110610e7857610e78613b63565b9050602002016020810190610e8d91906137a1565b6001600160a01b03166001600160a01b03168152602001908152602001600020905060005b83811015610f09576000818152602083905260409020548551869085908110610edd57610edd613b63565b60200260200101518281518110610ef657610ef6613b63565b6020908102919091010152600101610eb2565b5050600101610df9565b505092915050565b610bc283838360405180602001604052806000815250611863565b6000806000806000610f478661244d565b60008681526008602052604081208054600b80549293929091908110610f6f57610f6f613b63565b6000918252602090912060039182020180546001918201549185015460028601549590930154909b919a509198509296506001600160a01b031694509092505050565b6000610fc6610fc18484612ac9565b612b30565b9392505050565b610fd56121d5565b60008060005b8481101561106c57858582818110610ff557610ff5613b63565b90506020020135925061100783612222565b6000838152600860205260409020915061102082612618565b61102a8285612662565b827f907fece23ce39fbcbceb71e515043fe29408353fbb393b25b35eb8a70a4bad0b8560405161105c91815260200190565b60405180910390a2600101610fdb565b505050505050565b61107c6121d5565b60008060005b838110156111035784848281811061109c5761109c613b63565b9050602002013592506110ae83612222565b600083815260086020526040902091506110c782612b61565b6110d082612bab565b60405183907ff27b6ce5b2f5e68ddb2fd95a8a909d4ecf1daaac270935fff052feacb24f184290600090a2600101611082565b5050505050565b6111126121d5565b8061111c81612222565b600082815260086020526040902061113381612b61565b61113c81612bab565b60405183907ff27b6ce5b2f5e68ddb2fd95a8a909d4ecf1daaac270935fff052feacb24f184290600090a2505050565b6000818152600260205260408120546001600160a01b0316806109cd5760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b6044820152606401610929565b60006001600160a01b0382166112365760405162461bcd60e51b815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f7420612076616044820152683634b21037bbb732b960b91b6064820152608401610929565b506001600160a01b031660009081526003602052604090205490565b600061125c6121d5565b6000821180156112745750346112728387613b8f565b145b6112905760405162461bcd60e51b815260040161092990613ba6565b600061129c8686612ac9565b90506112a781612bff565b600754600101915060005b83811015611320576112c48286612c4b565b6112ce8184613bd2565b604080516001600160a01b0388168152602081018a90529081018890527f17700ceb1658b18206f427c1578048e87504106b14ec69e9b4586d9a95174a329060600160405180910390a26001016112b2565b50505b949350505050565b611333612a1a565b610d976000612ce5565b606060008211801561135a5750600b546113578385613bd2565b11155b6113765760405162461bcd60e51b815260040161092990613ba6565b816001600160401b0381111561138e5761138e6138df565b6040519080825280602002602001820160405280156113e357816020015b6113d060405180606001604052806000815260200160008152602001600081525090565b8152602001906001900390816113ac5790505b50905060005b8281101561146b57600b8185018154811061140657611406613b63565b9060005260206000209060030201604051806060016040529081600082015481526020016001820154815260200160028201548152505082828151811061144f5761144f613b63565b60200260200101819052506114648160010190565b90506113e9565b5092915050565b600061147c6121d5565b3460006114898286612ac9565b905061149481612bff565b61149e8185612c4b565b600754604080516001600160a01b03871681526020810185905290810187905281907f17700ceb1658b18206f427c1578048e87504106b14ec69e9b4586d9a95174a329060600160405180910390a295945050505050565b6114fe612a1a565b610d97612d37565b60006115118261244d565b600082815260086020526040902061152881612618565b610fc68161293e565b606060018054610a0890613adc565b6060816001600160401b0381111561155a5761155a6138df565b60405190808252806020026020018201604052801561158d57816020015b60608152602001906001900390816115785790505b509050600061159b600b5490565b905060005b83811015610f1357816001600160401b038111156115c0576115c06138df565b6040519080825280602002602001820160405280156115e9578160200160208202803683370190505b508382815181106115fc576115fc613b63565b602002602001018190525060006009600087878581811061161f5761161f613b63565b905060200201602081019061163491906137a1565b6001600160a01b03166001600160a01b03168152602001908152602001600020905060005b838110156116b057600081815260208390526040902054855186908590811061168457611684613b63565b6020026020010151828151811061169d5761169d613b63565b6020908102919091010152600101611659565b50506001016115a0565b6116c26121d5565b6000805b83811015611103578484828181106116e0576116e0613b63565b9050602002013591506116f282612222565b600082815260086020526040902061170a908461251a565b6040516001600160a01b038416815282907f6f08c7e76d830d5f3d0a18fd27f4d8c0049b24a8689ddb39625e0864d894a9c19060200160405180910390a26001016116c6565b61175b338383612d7a565b5050565b6117676121d5565b8161177181612222565b600083815260086020526040902061178881612b61565b8054600b805460009190839081106117a2576117a2613b63565b90600052602060002090600302019050848160000154346117c39190613bd2565b146117e05760405162461bcd60e51b815260040161092990613be5565b60038301546001600160a01b03166000908152600a602090815260408083208584529091529020805460001901905560018101546118219084908790612e48565b857f1d9c4d2b3e13eb9ac08a42625750ac17ec6ca94b4755c49285e9467b4e48c89d8660405161185391815260200190565b60405180910390a2505050505050565b61186d338361274f565b6118895760405162461bcd60e51b815260040161092990613b16565b61189584848484612e94565b50505050565b6118a36121d5565b60008060005b8481101561106c578585828181106118c3576118c3613b63565b9050602002013592506118d583612222565b600083815260086020526040902060028101549092506118f490612277565b156119395760405162461bcd60e51b81526020600482015260156024820152746e6f7420726561647920746f20776974686472617760581b6044820152606401610929565b611942836122eb565b61194c828561238e565b6040516001600160a01b0385169084907fd964a27d45f595739c13d8b1160b57491050cacf3a2e5602207277d6228f64ee90600090a36001016118a9565b6119926121d5565b600182116119d35760405162461bcd60e51b815260206004820152600e60248201526d0d2dcecc2d8d2c840d8cadccee8d60931b6044820152606401610929565b3460008080855b8015611b8a57600019018787828181106119f6576119f6613b63565b905060200201359350611a0884612222565b60008481526008602052604090209250611a2183612618565b82546003840154600b80546001600160a01b039092169183908110611a4857611a48613b63565b906000526020600020906003020193508360010154881015611a9f5760405162461bcd60e51b815260206004820152601060248201526f34b73b30b634b210323ab930ba34b7b760811b6044820152606401610929565b8354611aab9088613bd2565b9650611abd8560010154600019141590565b15611af2576001600160a01b038116600090815260096020908152604080832085845290915290208054600019019055611b1e565b6001600160a01b0381166000908152600a60209081526040808320858452909152902080546000190190555b8215611b3257611b2d866122eb565b611b83565b6000196001860155611b4585888a612e48565b7fb3f4c8ca702dbbd32d9a25ce17b1942a5060284d9d69fc4fcac8fb0397891b128a8a898b604051611b7a9493929190613c10565b60405180910390a15b50506119da565b5050505050505050565b6060611b9f8261244d565b6000611bb660408051602081019091526000815290565b90506000815111611bd65760405180602001604052806000815250610fc6565b80611be084612ec7565b604051602001611bf1929190613c56565b6040516020818303038152906040529392505050565b611c0f612a1a565b81600003611c535760405162461bcd60e51b8152602060048201526011602482015270185b5bdd5b9d081a5cc81a5b9d985b1a59607a1b6044820152606401610929565b6000828152600c6020908152604080832084845290915290205415611cb25760405162461bcd60e51b81526020600482015260156024820152746475706c6963617465206275636b6574207479706560581b6044820152606401610929565b60408051606081018252838152602080820184815243838501908152600b8054600181018255600082815295517f0175b7a638427703f0dbe7bb9bbf987a2551717b34e79f33b5b1008d1fa01db960039092029182015592517f0175b7a638427703f0dbe7bb9bbf987a2551717b34e79f33b5b1008d1fa01dba84015590517f0175b7a638427703f0dbe7bb9bbf987a2551717b34e79f33b5b1008d1fa01dbb9092019190915554858352600c82528383208584528252918390209190915581518481529081018390527f6b39e3267efcd6611c8d7d2534c4715dcb4824322b90d85540a3a82967b6e7b791015b60405180910390a15050565b611db46121d5565b81611dbe81612222565b6000838152600860205260409020611dd581612b61565b8054600b80546000919083908110611def57611def613b63565b9060005260206000209060030201905080600101548511611e225760405162461bcd60e51b815260040161092990613be5565b60038301546001600160a01b03166000908152600a60209081526040808320858452909152902080546000190190558054611e5f90849087612e48565b857fc599168ac63ff28ec278088a2c424383a36ca26c931eb41af05e014f19252ea48660405161185391815260200190565b611e99612a1a565b43600b611ea68484612ac9565b81548110611eb657611eb6613b63565b9060005260206000209060030201600201819055507f6b39e3267efcd6611c8d7d2534c4715dcb4824322b90d85540a3a82967b6e7b78282604051611da0929190918252602082015260400190565b611f0d6121d5565b60008060005b8381101561110357848482818110611f2d57611f2d613b63565b905060200201359250611f3f83612222565b60008381526008602052604090209150611f5882612618565b611f618261293e565b15611fa55760405162461bcd60e51b81526020600482015260146024820152736e6f7420726561647920746f20756e7374616b6560601b6044820152606401610929565b611fae826129e3565b60405183907f11725367022c3ff288940f4b5473aa61c2da6a24af7363a1128ee2401e8983b290600090a2600101611f13565b611fe9612a1a565b600019600b611ff88484612ac9565b8154811061200857612008613b63565b9060005260206000209060030201600201819055507f099df2bf9247b43481cf1b791a4dd5fa1220c40c62940da539082fbcb30241d68282604051611da0929190918252602082015260400190565b60006120616121d5565b3482518561206f9190613b8f565b1461208c5760405162461bcd60e51b815260040161092990613ba6565b60006120988585612ac9565b90506120a381612bff565b600754600101915060005b8351811015612153576120da828583815181106120cd576120cd613b63565b6020026020010151612c4b565b6120e48184613bd2565b7f17700ceb1658b18206f427c1578048e87504106b14ec69e9b4586d9a95174a3285838151811061211757612117613b63565b602090810291909101810151604080516001600160a01b0390921682529181018a905290810188905260600160405180910390a26001016120ae565b50509392505050565b612164612a1a565b6001600160a01b0381166121c95760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610929565b6121d281612ce5565b50565b600654600160a01b900460ff1615610d975760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610929565b61222b8161116c565b6001600160a01b0316336001600160a01b0316146121d25760405162461bcd60e51b81526020600482015260096024820152683737ba1037bbb732b960b91b6044820152606401610929565b600060001982036122c35760405162461bcd60e51b81526020600482015260166024820152751b9bdd08185b881d5b9cdd185ad95908189d58dad95d60521b6044820152606401610929565b60006122d0600a84613bd2565b90504381116122e25750600092915050565b43900392915050565b60006122f68261116c565b9050612306816000846001612f59565b61230f8261116c565b600083815260046020908152604080832080546001600160a01b03199081169091556001600160a01b0385168085526003845282852080546000190190558785526002909352818420805490911690555192935084927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b6000600b8360000154815481106123a7576123a7613b63565b600091825260208220600390910201546040519092506001600160a01b0384169083908381818185875af1925050503d8060008114612402576040519150601f19603f3d011682016040523d82523d6000602084013e612407565b606091505b50509050806118955760405162461bcd60e51b81526020600482015260126024820152713330b4b632b2103a37903a3930b739b332b960711b6044820152606401610929565b6000818152600260205260409020546001600160a01b03166121d25760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b6044820152606401610929565b600081815260046020526040902080546001600160a01b0319166001600160a01b03841690811790915581906124e18261116c565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b61252382612618565b815460038301546001600160a01b0390811690831681036125565760405162461bcd60e51b815260040161092990613be5565b6001840154600019146125ac576001600160a01b038181166000908152600960208181526040808420878552825280842080546000190190559387168352908152828220858352905220805460010190556125f1565b6001600160a01b038181166000908152600a60208181526040808420878552825280842080546000190190559387168352908152828220858352905220805460010190555b505060039190910180546001600160a01b0319166001600160a01b03909216919091179055565b6002810154600019146121d25760405162461bcd60e51b81526020600482015260126024820152713737ba10309039ba30b5b2b2103a37b5b2b760711b6044820152606401610929565b815460038301546001600160a01b031661267b8461293e565b8310156126bd5760405162461bcd60e51b815260206004820152601060248201526f34b73b30b634b210323ab930ba34b7b760811b6044820152606401610929565b60006126ed600b84815481106126d5576126d5613b63565b90600052602060002090600302016000015485612ac9565b90506126f881612bff565b60001960018681018290556001600160a01b039390931660008181526009602090815260408083209783529681528682208054909401909355968390558652600a8152838620918652529220805490920190915550565b60008061275b8361116c565b9050806001600160a01b0316846001600160a01b031614806127a257506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b806113235750836001600160a01b03166127bb84610a8b565b6001600160a01b031614949350505050565b826001600160a01b03166127e08261116c565b6001600160a01b0316146128065760405162461bcd60e51b815260040161092990613c85565b6001600160a01b0382166128685760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610929565b6128758383836001612f59565b826001600160a01b03166128888261116c565b6001600160a01b0316146128ae5760405162461bcd60e51b815260040161092990613c85565b600081815260046020908152604080832080546001600160a01b03199081169091556001600160a01b0387811680865260038552838620805460001901905590871680865283862080546001019055868652600290945282852080549092168417909155905184937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600181015460009060001981036129905760405162461bcd60e51b81526020600482015260166024820152751b9bdd08185b881d5b9b1bd8dad95908189d58dad95d60521b6044820152606401610929565b6000600b8460000154815481106129a9576129a9613b63565b906000526020600020906003020160010154826129c69190613bd2565b90504381116129d9575060009392505050565b4390039392505050565b43600282015560038101546001600160a01b0316600090815260096020908152604080832093548352929052208054600019019055565b6006546001600160a01b03163314610d975760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610929565b612a7c613029565b6006805460ff60a01b191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b6000828152600c6020908152604080832084845290915281205480612b265760405162461bcd60e51b8152602060048201526013602482015272696e76616c6964206275636b6574207479706560681b6044820152606401610929565b6000198101611323565b600043600b8381548110612b4657612b46613b63565b90600052602060002090600302016002015411159050919050565b6001810154600019146121d25760405162461bcd60e51b81526020600482015260126024820152713737ba1030903637b1b5b2b2103a37b5b2b760711b6044820152606401610929565b80546003820154436001938401556001600160a01b03166000818152600a60209081526040808320858452825280832080546000190190559282526009815282822093825292909252902080549091019055565b612c0881612b30565b6121d25760405162461bcd60e51b8152602060048201526014602482015273696e616374697665206275636b6574207479706560601b6044820152606401610929565b6007805460019081018083556040805160808101825286815260001960208083018281528385019283526001600160a01b0389811660608601818152600098895260088552878920965187559251868a0155935160028601559051600390940180546001600160a01b03191694909116939093179092558352600a815281832087845290529020805490910190555461175b903390613079565b600680546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b612d3f6121d5565b6006805460ff60a01b1916600160a01b1790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258612aac3390565b816001600160a01b0316836001600160a01b031603612ddb5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610929565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6000612e548383612ac9565b9050612e5f81612bff565b60038401546001600160a01b03166000908152600a602090815260408083208484529091529020805460010190559092555050565b612e9f8484846127cd565b612eab84848484613093565b6118955760405162461bcd60e51b815260040161092990613cca565b60606000612ed483613191565b60010190506000816001600160401b03811115612ef357612ef36138df565b6040519080825280601f01601f191660200182016040528015612f1d576020820181803683370190505b5090508181016020015b600019016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a8504945084612f2757509392505050565b80600114612fa95760405162461bcd60e51b815260206004820152601f60248201527f6261746368207472616e73666572206973206e6f7420737570706f72746564006044820152606401610929565b6001600160a01b0383161580612fd15750600082815260086020526040902060020154600019145b61301d5760405162461bcd60e51b815260206004820152601e60248201527f63616e6e6f74207472616e7366657220756e7374616b656420746f6b656e00006044820152606401610929565b61189584848484613269565b600654600160a01b900460ff16610d975760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610929565b61175b8282604051806020016040528060008152506132f1565b60006001600160a01b0384163b1561318957604051630a85bd0160e11b81526001600160a01b0385169063150b7a02906130d7903390899088908890600401613d1c565b6020604051808303816000875af1925050508015613112575060408051601f3d908101601f1916820190925261310f91810190613d59565b60015b61316f573d808015613140576040519150601f19603f3d011682016040523d82523d6000602084013e613145565b606091505b5080516000036131675760405162461bcd60e51b815260040161092990613cca565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611323565b506001611323565b60008072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b83106131d05772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef810000000083106131fc576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc10000831061321a57662386f26fc10000830492506010015b6305f5e1008310613232576305f5e100830492506008015b612710831061324657612710830492506004015b60648310613258576064830492506002015b600a83106109cd5760010192915050565b6001811115611895576001600160a01b038416156132af576001600160a01b038416600090815260036020526040812080548392906132a9908490613d76565b90915550505b6001600160a01b03831615611895576001600160a01b038316600090815260036020526040812080548392906132e6908490613bd2565b909155505050505050565b6132fb8383613324565b6133086000848484613093565b610bc25760405162461bcd60e51b815260040161092990613cca565b6001600160a01b03821661337a5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610929565b6000818152600260205260409020546001600160a01b0316156133df5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610929565b6133ed600083836001612f59565b6000818152600260205260409020546001600160a01b0316156134525760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610929565b6001600160a01b038216600081815260036020908152604080832080546001019055848352600290915280822080546001600160a01b0319168417905551839291907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b6001600160a01b03811681146121d257600080fd5b600080604083850312156134e557600080fd5b8235915060208301356134f7816134bd565b809150509250929050565b6001600160e01b0319811681146121d257600080fd5b60006020828403121561352a57600080fd5b8135610fc681613502565b60006020828403121561354757600080fd5b5035919050565b60005b83811015613569578181015183820152602001613551565b50506000910152565b6000815180845261358a81602086016020860161354e565b601f01601f19169290920160200192915050565b602081526000610fc66020830184613572565b600080604083850312156135c457600080fd5b82356135cf816134bd565b946020939093013593505050565b600080604083850312156135f057600080fd5b50508035926020909101359150565b60008060006060848603121561361457600080fd5b833561361f816134bd565b9250602084013561362f816134bd565b929592945050506040919091013590565b60008083601f84011261365257600080fd5b5081356001600160401b0381111561366957600080fd5b6020830191508360208260051b850101111561368457600080fd5b9250929050565b6000806020838503121561369e57600080fd5b82356001600160401b038111156136b457600080fd5b6136c085828601613640565b90969095509350505050565b6000602080830181845280855180835260408601915060408160051b87010192508387016000805b8381101561374857888603603f19018552825180518088529088019088880190845b818110156137325783518352928a0192918a0191600101613716565b50909750505093860193918601916001016136f4565b509398975050505050505050565b60008060006040848603121561376b57600080fd5b83356001600160401b0381111561378157600080fd5b61378d86828701613640565b909790965060209590950135949350505050565b6000602082840312156137b357600080fd5b8135610fc6816134bd565b600080600080608085870312156137d457600080fd5b843593506020850135925060408501356137ed816134bd565b9396929550929360600135925050565b602080825282518282018190526000919060409081850190868401855b82811015613849578151805185528681015187860152850151858501526060909301929085019060010161381a565b5091979650505050505050565b60008060006040848603121561386b57600080fd5b83356001600160401b0381111561388157600080fd5b61388d86828701613640565b90945092505060208401356138a1816134bd565b809150509250925092565b600080604083850312156138bf57600080fd5b82356138ca816134bd565b9150602083013580151581146134f757600080fd5b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b038111828210171561391d5761391d6138df565b604052919050565b6000806000806080858703121561393b57600080fd5b8435613946816134bd565b9350602085810135613957816134bd565b93506040860135925060608601356001600160401b038082111561397a57600080fd5b818801915088601f83011261398e57600080fd5b8135818111156139a0576139a06138df565b6139b2601f8201601f191685016138f5565b915080825289848285010111156139c857600080fd5b808484018584013760008482840101525080935050505092959194509250565b600080604083850312156139fb57600080fd5b8235613a06816134bd565b915060208301356134f7816134bd565b600080600060608486031215613a2b57600080fd5b83359250602080850135925060408501356001600160401b0380821115613a5157600080fd5b818701915087601f830112613a6557600080fd5b813581811115613a7757613a776138df565b8060051b9150613a888483016138f5565b818152918301840191848101908a841115613aa257600080fd5b938501935b83851015613acc5784359250613abc836134bd565b8282529385019390850190613aa7565b8096505050505050509250925092565b600181811c90821680613af057607f821691505b602082108103613b1057634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252602d908201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560408201526c1c881bdc88185c1c1c9bdd9959609a1b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b80820281158282048414176109cd576109cd613b79565b602080825260129082015271696e76616c696420706172616d657465727360701b604082015260600190565b808201808211156109cd576109cd613b79565b60208082526011908201527034b73b30b634b21037b832b930ba34b7b760791b604082015260600190565b6060808252810184905260006001600160fb1b03851115613c3057600080fd5b8460051b8087608085013760208301949094525060408101919091520160800192915050565b60008351613c6881846020880161354e565b835190830190613c7c81836020880161354e565b01949350505050565b60208082526025908201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060408201526437bbb732b960d91b606082015260800190565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090613d4f90830184613572565b9695505050505050565b600060208284031215613d6b57600080fd5b8151610fc681613502565b818103818111156109cd576109cd613b7956fea2646970667358221220be917767ef1b31d340fe6087913ba2e72285104d0b6c49192dabe393bb91652864736f6c63430008120033` + _stakingContractByteCode = `60806040523480156200001157600080fd5b5060405180604001604052806009815260200168109d58dad95d13919560ba1b815250604051806040016040528060038152602001621092d560ea1b81525081600090816200006191906200019b565b5060016200007082826200019b565b5050506200008d62000087620000a060201b60201c565b620000a4565b6006805460ff60a01b1916905562000267565b3390565b600680546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b634e487b7160e01b600052604160045260246000fd5b600181811c908216806200012157607f821691505b6020821081036200014257634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200019657600081815260208120601f850160051c81016020861015620001715750805b601f850160051c820191505b8181101562000192578281556001016200017d565b5050505b505050565b81516001600160401b03811115620001b757620001b7620000f6565b620001cf81620001c884546200010c565b8462000148565b602080601f831160018114620002075760008415620001ee5750858301515b600019600386901b1c1916600185901b17855562000192565b600085815260208120601f198616915b82811015620002385788860151825594840194600190910190840162000217565b5085821015620002575787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b613cf580620002776000396000f3fe6080604052600436106102875760003560e01c8063715018a61161015a578063b8f4bd7b116100c1578063e449f3411161007a578063e449f341146107be578063e985e9c5146107de578063eb0ffb2e14610827578063eec7ee7314610847578063f0b56b5d1461085a578063f2fde38b1461086f57600080fd5b8063b8f4bd7b14610715578063bbe33ea514610735578063c87b56dd14610748578063c8e7792314610768578063d0949f9914610788578063e0028ecf1461079e57600080fd5b806395d89b411161011357806395d89b411461066b578063960014bd1461068057806398ca3b76146106a05780639f7d5b00146106c0578063a22cb465146106d5578063b88d4fde146106f557600080fd5b8063715018a6146105c357806378bfca10146105d85780637acb7757146106055780638456cb59146106185780638da5cb5b1461062d57806393b6ef591461064b57600080fd5b80633f4ba83a116101fe5780635ceb8b5b116101b75780635ceb8b5b146105105780635d36598f146105305780636198e339146105505780636352211e1461057057806370a0823114610590578063711563d4146105b057600080fd5b80633f4ba83a1461041e5780633fd140df1461043357806342842e0e14610460578063431cd92a1461048057806343e06c59146104d15780635c975abb146104f157600080fd5b8063081812fc11610250578063081812fc14610346578063095ea7b31461037e5780630f5b2ca51461039e5780631338736f146103be57806323b872dd146103de5780632e17de78146103fe57600080fd5b8062f714ce1461028c57806301ffc9a7146102ae578063025008ed146102e357806303459b16146102f657806306fdde0314610324575b600080fd5b34801561029857600080fd5b506102ac6102a73660046133dd565b61088f565b005b3480156102ba57600080fd5b506102ce6102c9366004613423565b610956565b60405190151581526020015b60405180910390f35b6102ac6102f1366004613440565b6109a8565b34801561030257600080fd5b5061031661031136600461346c565b610ae9565b6040519081526020016102da565b34801561033057600080fd5b50610339610b0f565b6040516102da91906134d5565b34801561035257600080fd5b5061036661036136600461346c565b610ba1565b6040516001600160a01b0390911681526020016102da565b34801561038a57600080fd5b506102ac6103993660046134e8565b610bc8565b3480156103aa57600080fd5b506102ac6103b93660046133dd565b610cdd565b3480156103ca57600080fd5b506102ac6103d9366004613514565b610d4a565b3480156103ea57600080fd5b506102ac6103f9366004613536565b610dbd565b34801561040a57600080fd5b506102ac61041936600461346c565b610dee565b34801561042a57600080fd5b506102ac610e9d565b34801561043f57600080fd5b5061045361044e3660046135c2565b610eaf565b6040516102da9190613603565b34801561046c57600080fd5b506102ac61047b366004613536565b611031565b34801561048c57600080fd5b506104a061049b36600461346c565b61104c565b6040805195865260208601949094529284019190915260608301526001600160a01b0316608082015260a0016102da565b3480156104dd57600080fd5b506102ce6104ec366004613514565b6110c8565b3480156104fd57600080fd5b50600654600160a01b900460ff166102ce565b34801561051c57600080fd5b506102ac61052b36600461368d565b6110e3565b34801561053c57600080fd5b506102ac61054b3660046135c2565b61118a565b34801561055c57600080fd5b506102ac61056b36600461346c565b611220565b34801561057c57600080fd5b5061036661058b36600461346c565b611282565b34801561059c57600080fd5b506103166105ab3660046136d8565b6112e2565b6103166105be3660046136f5565b611368565b3480156105cf57600080fd5b506102ac611441565b3480156105e457600080fd5b506105f86105f3366004613514565b611453565b6040516102da9190613734565b6103166106133660046133dd565b611588565b34801561062457600080fd5b506102ac61160c565b34801561063957600080fd5b506006546001600160a01b0316610366565b34801561065757600080fd5b5061031661066636600461346c565b61161c565b34801561067757600080fd5b50610339611647565b34801561068c57600080fd5b5061045361069b3660046135c2565b611656565b3480156106ac57600080fd5b506102ac6106bb36600461378d565b6117d0565b3480156106cc57600080fd5b50600b54610316565b3480156106e157600080fd5b506102ac6106f03660046137e3565b611866565b34801561070157600080fd5b506102ac61071036600461385c565b611875565b34801561072157600080fd5b506102ac61073036600461378d565b6118ad565b6102ac61074336600461368d565b61199c565b34801561075457600080fd5b5061033961076336600461346c565b611b83565b34801561077457600080fd5b506102ac610783366004613514565b611bf6565b34801561079457600080fd5b5061031660001981565b3480156107aa57600080fd5b506102ac6107b9366004613514565b611d9b565b3480156107ca57600080fd5b506102ac6107d93660046135c2565b611e0f565b3480156107ea57600080fd5b506102ce6107f936600461391f565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b34801561083357600080fd5b506102ac610842366004613514565b611eeb565b61031661085536600461394d565b611f61565b34801561086657600080fd5b50610316600a81565b34801561087b57600080fd5b506102ac61088a3660046136d8565b612066565b6108976120df565b816108a18161212c565b600083815260086020526040902060028101546108bd90612181565b156109075760405162461bcd60e51b81526020600482015260156024820152746e6f7420726561647920746f20776974686472617760581b60448201526064015b60405180910390fd5b610910846121f5565b61091a8184612298565b6040516001600160a01b0384169085907fd964a27d45f595739c13d8b1160b57491050cacf3a2e5602207277d6228f64ee90600090a350505050565b60006001600160e01b031982166380ac58cd60e01b148061098757506001600160e01b03198216635b5e139f60e01b145b806109a257506301ffc9a760e01b6001600160e01b03198316145b92915050565b6109b06120df565b826109ba8161212c565b60008481526008602052604090206109d181612357565b8054600b805460009190839081106109eb576109eb613a13565b906000526020600020906003020190508060010154851015610a1f5760405162461bcd60e51b81526004016108fe90613a29565b80548690610a2d9034613a69565b14610a6b5760405162461bcd60e51b815260206004820152600e60248201526d1a5b9d985b1a5908185b5bdd5b9d60921b60448201526064016108fe565b60038301546001600160a01b03166000908152600a6020908152604080832085845290915290208054600019019055610aa58387876123a1565b604080518781526020810187905288917fd29e04160a74f0dbab5e7b82ef0392d86d11ac2939e5883eb3353be4cfedb83e910160405180910390a250505050505050565b6000610af4826123ed565b6000828152600860205260409020600201546109a290612181565b606060008054610b1e90613a7c565b80601f0160208091040260200160405190810160405280929190818152602001828054610b4a90613a7c565b8015610b975780601f10610b6c57610100808354040283529160200191610b97565b820191906000526020600020905b815481529060010190602001808311610b7a57829003601f168201915b5050505050905090565b6000610bac826123ed565b506000908152600460205260409020546001600160a01b031690565b6000610bd382611282565b9050806001600160a01b0316836001600160a01b031603610c405760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084016108fe565b336001600160a01b0382161480610c5c5750610c5c81336107f9565b610cce5760405162461bcd60e51b815260206004820152603d60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206f7220617070726f76656420666f7220616c6c00000060648201526084016108fe565b610cd8838361244c565b505050565b610ce56120df565b81610cef8161212c565b6000838152600860205260409020610d0790836124ba565b6040516001600160a01b038316815283907f6f08c7e76d830d5f3d0a18fd27f4d8c0049b24a8689ddb39625e0864d894a9c19060200160405180910390a2505050565b610d526120df565b81610d5c8161212c565b6000838152600860205260409020610d73816125dc565b610d7d8184612626565b837f907fece23ce39fbcbceb71e515043fe29408353fbb393b25b35eb8a70a4bad0b84604051610daf91815260200190565b60405180910390a250505050565b610dc733826126f0565b610de35760405162461bcd60e51b81526004016108fe90613ab6565b610cd883838361276e565b610df66120df565b80610e008161212c565b6000828152600860205260409020610e17816125dc565b610e20816128df565b15610e645760405162461bcd60e51b81526020600482015260146024820152736e6f7420726561647920746f20756e7374616b6560601b60448201526064016108fe565b610e6d81612984565b60405183907f11725367022c3ff288940f4b5473aa61c2da6a24af7363a1128ee2401e8983b290600090a2505050565b610ea56129bb565b610ead612a15565b565b6060816001600160401b03811115610ec957610ec9613816565b604051908082528060200260200182016040528015610efc57816020015b6060815260200190600190039081610ee75790505b5090506000610f0a600b5490565b905060005b8381101561102957816001600160401b03811115610f2f57610f2f613816565b604051908082528060200260200182016040528015610f58578160200160208202803683370190505b50838281518110610f6b57610f6b613a13565b60200260200101819052506000600a6000878785818110610f8e57610f8e613a13565b9050602002016020810190610fa391906136d8565b6001600160a01b03166001600160a01b03168152602001908152602001600020905060005b8381101561101f576000818152602083905260409020548551869085908110610ff357610ff3613a13565b6020026020010151828151811061100c5761100c613a13565b6020908102919091010152600101610fc8565b5050600101610f0f565b505092915050565b610cd883838360405180602001604052806000815250611875565b600080600080600061105d866123ed565b60008681526008602052604081208054600b8054929392909190811061108557611085613a13565b6000918252602090912060039182020180546001918201549185015460028601549590930154909b919a509198509296506001600160a01b031694509092505050565b60006110dc6110d78484612a6a565b612ad1565b9392505050565b6110eb6120df565b60008060005b848110156111825785858281811061110b5761110b613a13565b90506020020135925061111d8361212c565b60008381526008602052604090209150611136826125dc565b6111408285612626565b827f907fece23ce39fbcbceb71e515043fe29408353fbb393b25b35eb8a70a4bad0b8560405161117291815260200190565b60405180910390a26001016110f1565b505050505050565b6111926120df565b60008060005b83811015611219578484828181106111b2576111b2613a13565b9050602002013592506111c48361212c565b600083815260086020526040902091506111dd82612357565b6111e682612b02565b60405183907ff27b6ce5b2f5e68ddb2fd95a8a909d4ecf1daaac270935fff052feacb24f184290600090a2600101611198565b5050505050565b6112286120df565b806112328161212c565b600082815260086020526040902061124981612357565b61125281612b02565b60405183907ff27b6ce5b2f5e68ddb2fd95a8a909d4ecf1daaac270935fff052feacb24f184290600090a2505050565b6000818152600260205260408120546001600160a01b0316806109a25760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b60448201526064016108fe565b60006001600160a01b03821661134c5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f7420612076616044820152683634b21037bbb732b960b91b60648201526084016108fe565b506001600160a01b031660009081526003602052604090205490565b60006113726120df565b60008211801561138a5750346113888387613b03565b145b6113a65760405162461bcd60e51b81526004016108fe90613b1a565b60006113b28686612a6a565b90506113bd81612b56565b600754600101915060005b83811015611436576113da8286612ba2565b6113e48184613a69565b604080516001600160a01b0388168152602081018a90529081018890527f17700ceb1658b18206f427c1578048e87504106b14ec69e9b4586d9a95174a329060600160405180910390a26001016113c8565b50505b949350505050565b6114496129bb565b610ead6000612c3c565b60606000821180156114705750600b5461146d8385613a69565b11155b61148c5760405162461bcd60e51b81526004016108fe90613b1a565b816001600160401b038111156114a4576114a4613816565b6040519080825280602002602001820160405280156114f957816020015b6114e660405180606001604052806000815260200160008152602001600081525090565b8152602001906001900390816114c25790505b50905060005b8281101561158157600b8185018154811061151c5761151c613a13565b9060005260206000209060030201604051806060016040529081600082015481526020016001820154815260200160028201548152505082828151811061156557611565613a13565b602002602001018190525061157a8160010190565b90506114ff565b5092915050565b60006115926120df565b34600061159f8286612a6a565b90506115aa81612b56565b6115b48185612ba2565b600754604080516001600160a01b03871681526020810185905290810187905281907f17700ceb1658b18206f427c1578048e87504106b14ec69e9b4586d9a95174a329060600160405180910390a295945050505050565b6116146129bb565b610ead612c8e565b6000611627826123ed565b600082815260086020526040902061163e816125dc565b6110dc816128df565b606060018054610b1e90613a7c565b6060816001600160401b0381111561167057611670613816565b6040519080825280602002602001820160405280156116a357816020015b606081526020019060019003908161168e5790505b50905060006116b1600b5490565b905060005b8381101561102957816001600160401b038111156116d6576116d6613816565b6040519080825280602002602001820160405280156116ff578160200160208202803683370190505b5083828151811061171257611712613a13565b602002602001018190525060006009600087878581811061173557611735613a13565b905060200201602081019061174a91906136d8565b6001600160a01b03166001600160a01b03168152602001908152602001600020905060005b838110156117c657600081815260208390526040902054855186908590811061179a5761179a613a13565b602002602001015182815181106117b3576117b3613a13565b602090810291909101015260010161176f565b50506001016116b6565b6117d86120df565b6000805b83811015611219578484828181106117f6576117f6613a13565b9050602002013591506118088261212c565b600082815260086020526040902061182090846124ba565b6040516001600160a01b038416815282907f6f08c7e76d830d5f3d0a18fd27f4d8c0049b24a8689ddb39625e0864d894a9c19060200160405180910390a26001016117dc565b611871338383612cd1565b5050565b61187f33836126f0565b61189b5760405162461bcd60e51b81526004016108fe90613ab6565b6118a784848484612d9f565b50505050565b6118b56120df565b60008060005b84811015611182578585828181106118d5576118d5613a13565b9050602002013592506118e78361212c565b6000838152600860205260409020600281015490925061190690612181565b1561194b5760405162461bcd60e51b81526020600482015260156024820152746e6f7420726561647920746f20776974686472617760581b60448201526064016108fe565b611954836121f5565b61195e8285612298565b6040516001600160a01b0385169084907fd964a27d45f595739c13d8b1160b57491050cacf3a2e5602207277d6228f64ee90600090a36001016118bb565b6119a46120df565b600182116119e55760405162461bcd60e51b815260206004820152600e60248201526d0d2dcecc2d8d2c840d8cadccee8d60931b60448201526064016108fe565b3460008080855b8015611b795760001901878782818110611a0857611a08613a13565b905060200201359350611a1a8461212c565b60008481526008602052604090209250611a33836125dc565b82546003840154600b80546001600160a01b039092169183908110611a5a57611a5a613a13565b906000526020600020906003020193508360010154881015611a8e5760405162461bcd60e51b81526004016108fe90613a29565b8354611a9a9088613a69565b9650611aac8560010154600019141590565b15611ae1576001600160a01b038116600090815260096020908152604080832085845290915290208054600019019055611b0d565b6001600160a01b0381166000908152600a60209081526040808320858452909152902080546000190190555b8215611b2157611b1c866121f5565b611b72565b6000196001860155611b3485888a6123a1565b7fb3f4c8ca702dbbd32d9a25ce17b1942a5060284d9d69fc4fcac8fb0397891b128a8a898b604051611b699493929190613b46565b60405180910390a15b50506119ec565b5050505050505050565b6060611b8e826123ed565b6000611ba560408051602081019091526000815290565b90506000815111611bc557604051806020016040528060008152506110dc565b80611bcf84612dd2565b604051602001611be0929190613b8c565b6040516020818303038152906040529392505050565b611bfe6129bb565b81600003611c425760405162461bcd60e51b8152602060048201526011602482015270185b5bdd5b9d081a5cc81a5b9d985b1a59607a1b60448201526064016108fe565b6000828152600c6020908152604080832084845290915290205415611ca15760405162461bcd60e51b81526020600482015260156024820152746475706c6963617465206275636b6574207479706560581b60448201526064016108fe565b60408051606081018252838152602080820184815243838501908152600b8054600181018255600082815295517f0175b7a638427703f0dbe7bb9bbf987a2551717b34e79f33b5b1008d1fa01db960039092029182015592517f0175b7a638427703f0dbe7bb9bbf987a2551717b34e79f33b5b1008d1fa01dba84015590517f0175b7a638427703f0dbe7bb9bbf987a2551717b34e79f33b5b1008d1fa01dbb9092019190915554858352600c82528383208584528252918390209190915581518481529081018390527f6b39e3267efcd6611c8d7d2534c4715dcb4824322b90d85540a3a82967b6e7b791015b60405180910390a15050565b611da36129bb565b43600b611db08484612a6a565b81548110611dc057611dc0613a13565b9060005260206000209060030201600201819055507f6b39e3267efcd6611c8d7d2534c4715dcb4824322b90d85540a3a82967b6e7b78282604051611d8f929190918252602082015260400190565b611e176120df565b60008060005b8381101561121957848482818110611e3757611e37613a13565b905060200201359250611e498361212c565b60008381526008602052604090209150611e62826125dc565b611e6b826128df565b15611eaf5760405162461bcd60e51b81526020600482015260146024820152736e6f7420726561647920746f20756e7374616b6560601b60448201526064016108fe565b611eb882612984565b60405183907f11725367022c3ff288940f4b5473aa61c2da6a24af7363a1128ee2401e8983b290600090a2600101611e1d565b611ef36129bb565b600019600b611f028484612a6a565b81548110611f1257611f12613a13565b9060005260206000209060030201600201819055507f099df2bf9247b43481cf1b791a4dd5fa1220c40c62940da539082fbcb30241d68282604051611d8f929190918252602082015260400190565b6000611f6b6120df565b34825185611f799190613b03565b14611f965760405162461bcd60e51b81526004016108fe90613b1a565b6000611fa28585612a6a565b9050611fad81612b56565b600754600101915060005b835181101561205d57611fe482858381518110611fd757611fd7613a13565b6020026020010151612ba2565b611fee8184613a69565b7f17700ceb1658b18206f427c1578048e87504106b14ec69e9b4586d9a95174a3285838151811061202157612021613a13565b602090810291909101810151604080516001600160a01b0390921682529181018a905290810188905260600160405180910390a2600101611fb8565b50509392505050565b61206e6129bb565b6001600160a01b0381166120d35760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016108fe565b6120dc81612c3c565b50565b600654600160a01b900460ff1615610ead5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b60448201526064016108fe565b61213581611282565b6001600160a01b0316336001600160a01b0316146120dc5760405162461bcd60e51b81526020600482015260096024820152683737ba1037bbb732b960b91b60448201526064016108fe565b600060001982036121cd5760405162461bcd60e51b81526020600482015260166024820152751b9bdd08185b881d5b9cdd185ad95908189d58dad95d60521b60448201526064016108fe565b60006121da600a84613a69565b90504381116121ec5750600092915050565b43900392915050565b600061220082611282565b9050612210816000846001612e64565b61221982611282565b600083815260046020908152604080832080546001600160a01b03199081169091556001600160a01b0385168085526003845282852080546000190190558785526002909352818420805490911690555192935084927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b6000600b8360000154815481106122b1576122b1613a13565b600091825260208220600390910201546040519092506001600160a01b0384169083908381818185875af1925050503d806000811461230c576040519150601f19603f3d011682016040523d82523d6000602084013e612311565b606091505b50509050806118a75760405162461bcd60e51b81526020600482015260126024820152713330b4b632b2103a37903a3930b739b332b960711b60448201526064016108fe565b6001810154600019146120dc5760405162461bcd60e51b81526020600482015260126024820152713737ba1030903637b1b5b2b2103a37b5b2b760711b60448201526064016108fe565b60006123ad8383612a6a565b90506123b881612b56565b60038401546001600160a01b03166000908152600a602090815260408083208484529091529020805460010190559092555050565b6000818152600260205260409020546001600160a01b03166120dc5760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b60448201526064016108fe565b600081815260046020526040902080546001600160a01b0319166001600160a01b038416908117909155819061248182611282565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6124c3826125dc565b815460038301546001600160a01b03908116908316810361251a5760405162461bcd60e51b815260206004820152601160248201527034b73b30b634b21037b832b930ba34b7b760791b60448201526064016108fe565b600184015460001914612570576001600160a01b038181166000908152600960208181526040808420878552825280842080546000190190559387168352908152828220858352905220805460010190556125b5565b6001600160a01b038181166000908152600a60208181526040808420878552825280842080546000190190559387168352908152828220858352905220805460010190555b505060039190910180546001600160a01b0319166001600160a01b03909216919091179055565b6002810154600019146120dc5760405162461bcd60e51b81526020600482015260126024820152713737ba10309039ba30b5b2b2103a37b5b2b760711b60448201526064016108fe565b815460038301546001600160a01b031661263f846128df565b83101561265e5760405162461bcd60e51b81526004016108fe90613a29565b600061268e600b848154811061267657612676613a13565b90600052602060002090600302016000015485612a6a565b905061269981612b56565b60001960018681018290556001600160a01b039390931660008181526009602090815260408083209783529681528682208054909401909355968390558652600a8152838620918652529220805490920190915550565b6000806126fc83611282565b9050806001600160a01b0316846001600160a01b0316148061274357506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b806114395750836001600160a01b031661275c84610ba1565b6001600160a01b031614949350505050565b826001600160a01b031661278182611282565b6001600160a01b0316146127a75760405162461bcd60e51b81526004016108fe90613bbb565b6001600160a01b0382166128095760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b60648201526084016108fe565b6128168383836001612e64565b826001600160a01b031661282982611282565b6001600160a01b03161461284f5760405162461bcd60e51b81526004016108fe90613bbb565b600081815260046020908152604080832080546001600160a01b03199081169091556001600160a01b0387811680865260038552838620805460001901905590871680865283862080546001019055868652600290945282852080549092168417909155905184937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600181015460009060001981036129315760405162461bcd60e51b81526020600482015260166024820152751b9bdd08185b881d5b9b1bd8dad95908189d58dad95d60521b60448201526064016108fe565b6000600b84600001548154811061294a5761294a613a13565b906000526020600020906003020160010154826129679190613a69565b905043811161297a575060009392505050565b4390039392505050565b43600282015560038101546001600160a01b0316600090815260096020908152604080832093548352929052208054600019019055565b6006546001600160a01b03163314610ead5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016108fe565b612a1d612f34565b6006805460ff60a01b191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b6000828152600c6020908152604080832084845290915281205480612ac75760405162461bcd60e51b8152602060048201526013602482015272696e76616c6964206275636b6574207479706560681b60448201526064016108fe565b6000198101611439565b600043600b8381548110612ae757612ae7613a13565b90600052602060002090600302016002015411159050919050565b80546003820154436001938401556001600160a01b03166000818152600a60209081526040808320858452825280832080546000190190559282526009815282822093825292909252902080549091019055565b612b5f81612ad1565b6120dc5760405162461bcd60e51b8152602060048201526014602482015273696e616374697665206275636b6574207479706560601b60448201526064016108fe565b6007805460019081018083556040805160808101825286815260001960208083018281528385019283526001600160a01b0389811660608601818152600098895260088552878920965187559251868a0155935160028601559051600390940180546001600160a01b03191694909116939093179092558352600a8152818320878452905290208054909101905554611871903390612f84565b600680546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b612c966120df565b6006805460ff60a01b1916600160a01b1790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258612a4d3390565b816001600160a01b0316836001600160a01b031603612d325760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016108fe565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b612daa84848461276e565b612db684848484612f9e565b6118a75760405162461bcd60e51b81526004016108fe90613c00565b60606000612ddf8361309c565b60010190506000816001600160401b03811115612dfe57612dfe613816565b6040519080825280601f01601f191660200182016040528015612e28576020820181803683370190505b5090508181016020015b600019016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a8504945084612e3257509392505050565b80600114612eb45760405162461bcd60e51b815260206004820152601f60248201527f6261746368207472616e73666572206973206e6f7420737570706f727465640060448201526064016108fe565b6001600160a01b0383161580612edc5750600082815260086020526040902060020154600019145b612f285760405162461bcd60e51b815260206004820152601e60248201527f63616e6e6f74207472616e7366657220756e7374616b656420746f6b656e000060448201526064016108fe565b6118a784848484613174565b600654600160a01b900460ff16610ead5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b60448201526064016108fe565b6118718282604051806020016040528060008152506131fc565b60006001600160a01b0384163b1561309457604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290612fe2903390899088908890600401613c52565b6020604051808303816000875af192505050801561301d575060408051601f3d908101601f1916820190925261301a91810190613c8f565b60015b61307a573d80801561304b576040519150601f19603f3d011682016040523d82523d6000602084013e613050565b606091505b5080516000036130725760405162461bcd60e51b81526004016108fe90613c00565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611439565b506001611439565b60008072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b83106130db5772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef81000000008310613107576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc10000831061312557662386f26fc10000830492506010015b6305f5e100831061313d576305f5e100830492506008015b612710831061315157612710830492506004015b60648310613163576064830492506002015b600a83106109a25760010192915050565b60018111156118a7576001600160a01b038416156131ba576001600160a01b038416600090815260036020526040812080548392906131b4908490613cac565b90915550505b6001600160a01b038316156118a7576001600160a01b038316600090815260036020526040812080548392906131f1908490613a69565b909155505050505050565b613206838361322f565b6132136000848484612f9e565b610cd85760405162461bcd60e51b81526004016108fe90613c00565b6001600160a01b0382166132855760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016108fe565b6000818152600260205260409020546001600160a01b0316156132ea5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016108fe565b6132f8600083836001612e64565b6000818152600260205260409020546001600160a01b03161561335d5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016108fe565b6001600160a01b038216600081815260036020908152604080832080546001019055848352600290915280822080546001600160a01b0319168417905551839291907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b6001600160a01b03811681146120dc57600080fd5b600080604083850312156133f057600080fd5b823591506020830135613402816133c8565b809150509250929050565b6001600160e01b0319811681146120dc57600080fd5b60006020828403121561343557600080fd5b81356110dc8161340d565b60008060006060848603121561345557600080fd5b505081359360208301359350604090920135919050565b60006020828403121561347e57600080fd5b5035919050565b60005b838110156134a0578181015183820152602001613488565b50506000910152565b600081518084526134c1816020860160208601613485565b601f01601f19169290920160200192915050565b6020815260006110dc60208301846134a9565b600080604083850312156134fb57600080fd5b8235613506816133c8565b946020939093013593505050565b6000806040838503121561352757600080fd5b50508035926020909101359150565b60008060006060848603121561354b57600080fd5b8335613556816133c8565b92506020840135613566816133c8565b929592945050506040919091013590565b60008083601f84011261358957600080fd5b5081356001600160401b038111156135a057600080fd5b6020830191508360208260051b85010111156135bb57600080fd5b9250929050565b600080602083850312156135d557600080fd5b82356001600160401b038111156135eb57600080fd5b6135f785828601613577565b90969095509350505050565b6000602080830181845280855180835260408601915060408160051b87010192508387016000805b8381101561367f57888603603f19018552825180518088529088019088880190845b818110156136695783518352928a0192918a019160010161364d565b509097505050938601939186019160010161362b565b509398975050505050505050565b6000806000604084860312156136a257600080fd5b83356001600160401b038111156136b857600080fd5b6136c486828701613577565b909790965060209590950135949350505050565b6000602082840312156136ea57600080fd5b81356110dc816133c8565b6000806000806080858703121561370b57600080fd5b84359350602085013592506040850135613724816133c8565b9396929550929360600135925050565b602080825282518282018190526000919060409081850190868401855b828110156137805781518051855286810151878601528501518585015260609093019290850190600101613751565b5091979650505050505050565b6000806000604084860312156137a257600080fd5b83356001600160401b038111156137b857600080fd5b6137c486828701613577565b90945092505060208401356137d8816133c8565b809150509250925092565b600080604083850312156137f657600080fd5b8235613801816133c8565b91506020830135801515811461340257600080fd5b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b038111828210171561385457613854613816565b604052919050565b6000806000806080858703121561387257600080fd5b843561387d816133c8565b935060208581013561388e816133c8565b93506040860135925060608601356001600160401b03808211156138b157600080fd5b818801915088601f8301126138c557600080fd5b8135818111156138d7576138d7613816565b6138e9601f8201601f1916850161382c565b915080825289848285010111156138ff57600080fd5b808484018584013760008482840101525080935050505092959194509250565b6000806040838503121561393257600080fd5b823561393d816133c8565b91506020830135613402816133c8565b60008060006060848603121561396257600080fd5b83359250602080850135925060408501356001600160401b038082111561398857600080fd5b818701915087601f83011261399c57600080fd5b8135818111156139ae576139ae613816565b8060051b91506139bf84830161382c565b818152918301840191848101908a8411156139d957600080fd5b938501935b83851015613a0357843592506139f3836133c8565b82825293850193908501906139de565b8096505050505050509250925092565b634e487b7160e01b600052603260045260246000fd5b60208082526010908201526f34b73b30b634b210323ab930ba34b7b760811b604082015260600190565b634e487b7160e01b600052601160045260246000fd5b808201808211156109a2576109a2613a53565b600181811c90821680613a9057607f821691505b602082108103613ab057634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252602d908201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560408201526c1c881bdc88185c1c1c9bdd9959609a1b606082015260800190565b80820281158282048414176109a2576109a2613a53565b602080825260129082015271696e76616c696420706172616d657465727360701b604082015260600190565b6060808252810184905260006001600160fb1b03851115613b6657600080fd5b8460051b8087608085013760208301949094525060408101919091520160800192915050565b60008351613b9e818460208801613485565b835190830190613bb2818360208801613485565b01949350505050565b60208082526025908201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060408201526437bbb732b960d91b606082015260800190565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090613c85908301846134a9565b9695505050505050565b600060208284031215613ca157600080fd5b81516110dc8161340d565b818103818111156109a2576109a2613a5356fea2646970667358221220c678b66ffcd38f880d3bf9e74ca21c7c767e50fbfef0c4a68283be493d360a3364736f6c63430008120033` _stakingContractABI = `[ { "inputs": [], "stateMutability": "nonpayable", "type": "constructor" }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "uint256", - "name": "tokenId", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "AmountIncreased", - "type": "event" - }, { "anonymous": false, "inputs": [ @@ -118,6 +99,12 @@ const ( { "anonymous": false, "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, { "indexed": false, "internalType": "uint256", @@ -131,7 +118,7 @@ const ( "type": "uint256" } ], - "name": "BucketTypeActivated", + "name": "BucketExpanded", "type": "event" }, { @@ -150,26 +137,26 @@ const ( "type": "uint256" } ], - "name": "BucketTypeDeactivated", + "name": "BucketTypeActivated", "type": "event" }, { "anonymous": false, "inputs": [ { - "indexed": true, + "indexed": false, "internalType": "uint256", - "name": "tokenId", + "name": "amount", "type": "uint256" }, { "indexed": false, - "internalType": "address", - "name": "newDelegate", - "type": "address" + "internalType": "uint256", + "name": "duration", + "type": "uint256" } ], - "name": "DelegateChanged", + "name": "BucketTypeDeactivated", "type": "event" }, { @@ -183,12 +170,12 @@ const ( }, { "indexed": false, - "internalType": "uint256", - "name": "duration", - "type": "uint256" + "internalType": "address", + "name": "newDelegate", + "type": "address" } ], - "name": "DurationExtended", + "name": "DelegateChanged", "type": "event" }, { @@ -659,15 +646,20 @@ const ( "name": "_tokenId", "type": "uint256" }, + { + "internalType": "uint256", + "name": "_newAmount", + "type": "uint256" + }, { "internalType": "uint256", "name": "_newDuration", "type": "uint256" } ], - "name": "extendDuration", + "name": "expandBucket", "outputs": [], - "stateMutability": "nonpayable", + "stateMutability": "payable", "type": "function" }, { @@ -689,24 +681,6 @@ const ( "stateMutability": "view", "type": "function" }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_tokenId", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "_newAmount", - "type": "uint256" - } - ], - "name": "increaseAmount", - "outputs": [], - "stateMutability": "payable", - "type": "function" - }, { "inputs": [ { @@ -1568,7 +1542,7 @@ func TestContractStaking(t *testing.T) { tokenID := bt.Index r.EqualValues(10, bt.StakedDurationBlockNumber) // extend duration - data, err := lsdABI.Pack("extendDuration", big.NewInt(int64(tokenID)), big.NewInt(100)) + data, err := lsdABI.Pack("expandBucket", big.NewInt(int64(tokenID)), big.NewInt(10), big.NewInt(100)) r.NoError(err) param = callParam{ contractAddr: contractAddresses, @@ -1590,7 +1564,7 @@ func TestContractStaking(t *testing.T) { bt := simpleStake(_delegates[4], big.NewInt(10), big.NewInt(10)) tokenID := bt.Index - data, err := lsdABI.Pack("increaseAmount", big.NewInt(int64(tokenID)), big.NewInt(100)) + data, err := lsdABI.Pack("expandBucket", big.NewInt(int64(tokenID)), big.NewInt(100), big.NewInt(10)) r.NoError(err) param = callParam{ contractAddr: contractAddresses, @@ -1609,6 +1583,112 @@ func TestContractStaking(t *testing.T) { r.EqualValues(100, bt.StakedAmount.Int64()) }) + t.Run("expand bucket type", func(t *testing.T) { + + t.Run("invalid bucket type", func(t *testing.T) { + bt := simpleStake(_delegates[4], big.NewInt(10), big.NewInt(10)) + tokenID := bt.Index + data, err := lsdABI.Pack("expandBucket", big.NewInt(int64(tokenID)), big.NewInt(100), big.NewInt(1000)) + r.NoError(err) + param = callParam{ + contractAddr: contractAddresses, + bytecode: hex.EncodeToString(data), + amount: big.NewInt(90), + gasLimit: 1000000, + gasPrice: big.NewInt(0), + sk: identityset.PrivateKey(adminID), + } + receipts, _ = writeContract(bc, sf, dao, ap, []*callParam{¶m}, r) + r.Len(receipts, 1) + r.EqualValues("invalid bucket type", receipts[0].ExecutionRevertMsg()) + r.EqualValues(iotextypes.ReceiptStatus_ErrExecutionReverted, receipts[0].Status) + }) + + t.Run("shorter duration", func(t *testing.T) { + bt := simpleStake(_delegates[4], big.NewInt(10), big.NewInt(100)) + tokenID := bt.Index + data, err := lsdABI.Pack("expandBucket", big.NewInt(int64(tokenID)), big.NewInt(10), big.NewInt(10)) + r.NoError(err) + param = callParam{ + contractAddr: contractAddresses, + bytecode: hex.EncodeToString(data), + amount: big.NewInt(0), + gasLimit: 1000000, + gasPrice: big.NewInt(0), + sk: identityset.PrivateKey(adminID), + } + receipts, _ = writeContract(bc, sf, dao, ap, []*callParam{¶m}, r) + r.Len(receipts, 1) + r.EqualValues("invalid duration", receipts[0].ExecutionRevertMsg()) + r.EqualValues(iotextypes.ReceiptStatus_ErrExecutionReverted, receipts[0].Status) + }) + + t.Run("not enough pay", func(t *testing.T) { + bt := simpleStake(_delegates[4], big.NewInt(10), big.NewInt(100)) + tokenID := bt.Index + data, err := lsdABI.Pack("expandBucket", big.NewInt(int64(tokenID)), big.NewInt(100), big.NewInt(100)) + r.NoError(err) + param = callParam{ + contractAddr: contractAddresses, + bytecode: hex.EncodeToString(data), + amount: big.NewInt(0), + gasLimit: 1000000, + gasPrice: big.NewInt(0), + sk: identityset.PrivateKey(adminID), + } + receipts, _ = writeContract(bc, sf, dao, ap, []*callParam{¶m}, r) + r.Len(receipts, 1) + r.EqualValues("invalid amount", receipts[0].ExecutionRevertMsg()) + r.EqualValues(iotextypes.ReceiptStatus_ErrExecutionReverted, receipts[0].Status) + }) + + t.Run("success", func(t *testing.T) { + bt := simpleStake(_delegates[4], big.NewInt(10), big.NewInt(10)) + tokenID := bt.Index + data, err := lsdABI.Pack("expandBucket", big.NewInt(int64(tokenID)), big.NewInt(100), big.NewInt(100)) + r.NoError(err) + param = callParam{ + contractAddr: contractAddresses, + bytecode: hex.EncodeToString(data), + amount: big.NewInt(90), + gasLimit: 1000000, + gasPrice: big.NewInt(0), + sk: identityset.PrivateKey(adminID), + } + receipts, _ = writeContract(bc, sf, dao, ap, []*callParam{¶m}, r) + r.Len(receipts, 1) + r.EqualValues("", receipts[0].ExecutionRevertMsg()) + r.EqualValues(iotextypes.ReceiptStatus_Success, receipts[0].Status) + bt, ok := indexer.Bucket(uint64(tokenID)) + r.True(ok) + r.EqualValues(100, bt.StakedAmount.Int64()) + r.EqualValues(100, bt.StakedDurationBlockNumber) + }) + + t.Run("unchange", func(t *testing.T) { + bt := simpleStake(_delegates[4], big.NewInt(10), big.NewInt(10)) + tokenID := bt.Index + data, err := lsdABI.Pack("expandBucket", big.NewInt(int64(tokenID)), big.NewInt(10), big.NewInt(10)) + r.NoError(err) + param = callParam{ + contractAddr: contractAddresses, + bytecode: hex.EncodeToString(data), + amount: big.NewInt(0), + gasLimit: 1000000, + gasPrice: big.NewInt(0), + sk: identityset.PrivateKey(adminID), + } + receipts, _ = writeContract(bc, sf, dao, ap, []*callParam{¶m}, r) + r.Len(receipts, 1) + r.EqualValues("", receipts[0].ExecutionRevertMsg()) + r.EqualValues(iotextypes.ReceiptStatus_Success, receipts[0].Status) + bt, ok := indexer.Bucket(uint64(tokenID)) + r.True(ok) + r.EqualValues(10, bt.StakedAmount.Int64()) + r.EqualValues(10, bt.StakedDurationBlockNumber) + }) + }) + t.Run("change delegate", func(t *testing.T) { delegateIdx := 5 bt := simpleStake(_delegates[delegateIdx], big.NewInt(10), big.NewInt(10)) @@ -1635,7 +1715,6 @@ func TestContractStaking(t *testing.T) { r.True(ok) r.EqualValues(identityset.Address(delegateIdx).String(), bt.Candidate.String()) }) - } func prepareContractStakingBlockchain(ctx context.Context, cfg config.Config, r *require.Assertions) (blockchain.Blockchain, factory.Factory, blockdao.BlockDAO, actpool.ActPool, *contractstaking.Indexer) {