KeyError:在合约上滑行时出现“值”

问题描述

Python版本:3.8.5 Solc版本:0.7.0 + commit.9e61f92b.Linux.g ++ Slither版本:0.6.13

尝试在实体合同上运行slither .时,我得到以下堆栈跟踪:

Traceback (most recent call last):
  File "/home/wirel/.local/lib/python3.8/site-packages/slither/__main__.py",line 692,in main_impl
    ) = process_all(filename,args,detector_classes,printer_classes)
  File "/home/wirel/.local/lib/python3.8/site-packages/slither/__main__.py",line 79,in process_all
    ) = process_single(compilation,line 62,in process_single
    slither = Slither(target,ast_format=ast,**vars(args))
  File "/home/wirel/.local/lib/python3.8/site-packages/slither/slither.py",line 100,in __init__
    self._parser.analyze_contracts()
  File "/home/wirel/.local/lib/python3.8/site-packages/slither/solc_parsing/slitherSolc.py",line 338,in analyze_contracts
    self._analyze_first_part(contracts_to_be_analyzed,libraries)
  File "/home/wirel/.local/lib/python3.8/site-packages/slither/solc_parsing/slitherSolc.py",line 395,in _analyze_first_part
    self._parse_struct_var_modifiers_functions(contract)
  File "/home/wirel/.local/lib/python3.8/site-packages/slither/solc_parsing/slitherSolc.py",line 461,in _parse_struct_var_modifiers_functions
    contract.parse_state_variables()
  File "/home/wirel/.local/lib/python3.8/site-packages/slither/solc_parsing/declarations/contract.py",line 303,in parse_state_variables
    var_parser = StateVariableSolc(var,varNotParsed)
  File "/home/wirel/.local/lib/python3.8/site-packages/slither/solc_parsing/variables/state_variable.py",line 9,in __init__
    super().__init__(variable,variable_data)
  File "/home/wirel/.local/lib/python3.8/site-packages/slither/solc_parsing/variables/variable_declaration.py",line 65,in __init__
    self._init_from_declaration(variable_data,variable_data["value"])
KeyError: 'value'
ERROR:root:None
ERROR:root:Error in .
ERROR:root:Traceback (most recent call last):
  File "/home/wirel/.local/lib/python3.8/site-packages/slither/__main__.py",variable_data["value"])
KeyError: 'value'

以下是合同:

// SPDX-License-Identifier: UNLICENSED
//     _____          __         .____           __    __                       
//    /  _  \  __ ___/  |_  ____ |    |    _____/  |__/  |_  ___________ ___.__.
//   /  /_\  \|  |  \   __\/  _ \|    |   /  _ \   __\   __\/ __ \_  __ <   |  |
//  /    |    \  |  /|  | (  <_> )    |__(  <_> )  |  |  | \  ___/|  | \/\___  |
//  \____|__  /____/ |__|  \____/|_______ \____/|__|  |__|  \___  >__|   / ____|
//         \/                           \/                     \/       \/     
// Automatically draws a winner once the payout threshold is met

pragma solidity ^0.7.0;

contract AutoLottery {
    address[] public players;
    uint256 public totalPayoutValue;
    uint256 public currentPrizePool;
    address public lastWinner;
    uint256 public lastPayout;
    address public owner;

    constructor() {
        totalPayoutValue = 0 ether;
        currentPrizePool = 0 ether;
        lastPayout = 0 ether;
        owner = msg.sender;
    }
    
    // Allow a player to enter,value entered must be 0.01 or greater
    function enter() public payable {
        require(msg.value >= 0.01 ether,"You must enter 0.01 or more Ether!");
        players.push(msg.sender);
        currentPrizePool += msg.value;
        if (address(this).balance >= 1.00 ether) {
            winner();
        }
    }

    // Choose a winner at random
    function winner() internal {
        require(address(this).balance >= 1.00 ether,"Not enough eth in prize pool!");

        uint index = random() % players.length;
        
        totalPayoutValue += address(this).balance;
        lastWinner = players[index];
        lastPayout = address(this).balance;
        
        payable(players[index]).transfer(address(this).balance);
        
        delete players;
    }

    // Creates a random number
    function random() private view returns (uint) {
        return uint(keccak256(abi.encode(block.difficulty,block.timestamp,players)));
    }

    // Returns a list of all currently entered players
    function getPlayers() public view returns (address[] memory) {
        return players;
    }
    
    // The owner of the contract can force a draw if its been too long since the last draw
    function emergencyDraw() public {
        require(msg.sender == owner,"Only the owner can call this method!");
        
        uint index = random() % players.length;
        
        totalPayoutValue += address(this).balance;
        lastWinner = players[index];
        lastPayout = address(this).balance;
        
        payable(players[index]).transfer(address(this).balance);
        
        delete players;
    }

}

关于如何解决此问题的任何想法?到目前为止,我已经尝试过重新安装python,slother和solc,甚至尝试从docker安装slider,但得到的结果相同。

解决方法

这是Slither内部的错误,应该在新的更新中修复。