You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

997 lines
36 KiB

4 years ago
Fix eth events query and sync inconsistent state - kvdb - Fix path in Last when doing `setNew` - Only close if db != nil, and after closing, always set db to nil - This will avoid a panic in the case where the db is closed but there's an error soon after, and a future call tries to close again. This is because pebble.Close() will panic if the db is already closed. - Avoid calling pebble methods when a the Storage interface already implements that method (like Close). - statedb - In test, avoid calling KVDB method if the same method is available for the StateDB (like MakeCheckpoint, CurrentBatch). - eth - In *EventByBlock methods, take blockHash as input argument and use it when querying the event logs. Previously the blockHash was only taken from the logs results *only if* there was any log. This caused the following issue: if there was no logs, it was not possible to know if the result was from the expected block or an uncle block! By querying logs by blockHash we make sure that even if there are no logs, they are from the right block. - Note that now the function can either be called with a blockNum or blockHash, but not both at the same time. - sync - If there's an error during call to Sync call resetState, which internally resets the stateDB to avoid stale checkpoints (and a corresponding invalid increase in the StateDB batchNum). - During a Sync, after very batch processed, make sure that the StateDB currentBatch corresponds to the batchNum in the smart contract log/event.
3 years ago
Fix eth events query and sync inconsistent state - kvdb - Fix path in Last when doing `setNew` - Only close if db != nil, and after closing, always set db to nil - This will avoid a panic in the case where the db is closed but there's an error soon after, and a future call tries to close again. This is because pebble.Close() will panic if the db is already closed. - Avoid calling pebble methods when a the Storage interface already implements that method (like Close). - statedb - In test, avoid calling KVDB method if the same method is available for the StateDB (like MakeCheckpoint, CurrentBatch). - eth - In *EventByBlock methods, take blockHash as input argument and use it when querying the event logs. Previously the blockHash was only taken from the logs results *only if* there was any log. This caused the following issue: if there was no logs, it was not possible to know if the result was from the expected block or an uncle block! By querying logs by blockHash we make sure that even if there are no logs, they are from the right block. - Note that now the function can either be called with a blockNum or blockHash, but not both at the same time. - sync - If there's an error during call to Sync call resetState, which internally resets the stateDB to avoid stale checkpoints (and a corresponding invalid increase in the StateDB batchNum). - During a Sync, after very batch processed, make sure that the StateDB currentBatch corresponds to the batchNum in the smart contract log/event.
3 years ago
Fix eth events query and sync inconsistent state - kvdb - Fix path in Last when doing `setNew` - Only close if db != nil, and after closing, always set db to nil - This will avoid a panic in the case where the db is closed but there's an error soon after, and a future call tries to close again. This is because pebble.Close() will panic if the db is already closed. - Avoid calling pebble methods when a the Storage interface already implements that method (like Close). - statedb - In test, avoid calling KVDB method if the same method is available for the StateDB (like MakeCheckpoint, CurrentBatch). - eth - In *EventByBlock methods, take blockHash as input argument and use it when querying the event logs. Previously the blockHash was only taken from the logs results *only if* there was any log. This caused the following issue: if there was no logs, it was not possible to know if the result was from the expected block or an uncle block! By querying logs by blockHash we make sure that even if there are no logs, they are from the right block. - Note that now the function can either be called with a blockNum or blockHash, but not both at the same time. - sync - If there's an error during call to Sync call resetState, which internally resets the stateDB to avoid stale checkpoints (and a corresponding invalid increase in the StateDB batchNum). - During a Sync, after very batch processed, make sure that the StateDB currentBatch corresponds to the batchNum in the smart contract log/event.
3 years ago
Fix eth events query and sync inconsistent state - kvdb - Fix path in Last when doing `setNew` - Only close if db != nil, and after closing, always set db to nil - This will avoid a panic in the case where the db is closed but there's an error soon after, and a future call tries to close again. This is because pebble.Close() will panic if the db is already closed. - Avoid calling pebble methods when a the Storage interface already implements that method (like Close). - statedb - In test, avoid calling KVDB method if the same method is available for the StateDB (like MakeCheckpoint, CurrentBatch). - eth - In *EventByBlock methods, take blockHash as input argument and use it when querying the event logs. Previously the blockHash was only taken from the logs results *only if* there was any log. This caused the following issue: if there was no logs, it was not possible to know if the result was from the expected block or an uncle block! By querying logs by blockHash we make sure that even if there are no logs, they are from the right block. - Note that now the function can either be called with a blockNum or blockHash, but not both at the same time. - sync - If there's an error during call to Sync call resetState, which internally resets the stateDB to avoid stale checkpoints (and a corresponding invalid increase in the StateDB batchNum). - During a Sync, after very batch processed, make sure that the StateDB currentBatch corresponds to the batchNum in the smart contract log/event.
3 years ago
Fix eth events query and sync inconsistent state - kvdb - Fix path in Last when doing `setNew` - Only close if db != nil, and after closing, always set db to nil - This will avoid a panic in the case where the db is closed but there's an error soon after, and a future call tries to close again. This is because pebble.Close() will panic if the db is already closed. - Avoid calling pebble methods when a the Storage interface already implements that method (like Close). - statedb - In test, avoid calling KVDB method if the same method is available for the StateDB (like MakeCheckpoint, CurrentBatch). - eth - In *EventByBlock methods, take blockHash as input argument and use it when querying the event logs. Previously the blockHash was only taken from the logs results *only if* there was any log. This caused the following issue: if there was no logs, it was not possible to know if the result was from the expected block or an uncle block! By querying logs by blockHash we make sure that even if there are no logs, they are from the right block. - Note that now the function can either be called with a blockNum or blockHash, but not both at the same time. - sync - If there's an error during call to Sync call resetState, which internally resets the stateDB to avoid stale checkpoints (and a corresponding invalid increase in the StateDB batchNum). - During a Sync, after very batch processed, make sure that the StateDB currentBatch corresponds to the batchNum in the smart contract log/event.
3 years ago
Fix eth events query and sync inconsistent state - kvdb - Fix path in Last when doing `setNew` - Only close if db != nil, and after closing, always set db to nil - This will avoid a panic in the case where the db is closed but there's an error soon after, and a future call tries to close again. This is because pebble.Close() will panic if the db is already closed. - Avoid calling pebble methods when a the Storage interface already implements that method (like Close). - statedb - In test, avoid calling KVDB method if the same method is available for the StateDB (like MakeCheckpoint, CurrentBatch). - eth - In *EventByBlock methods, take blockHash as input argument and use it when querying the event logs. Previously the blockHash was only taken from the logs results *only if* there was any log. This caused the following issue: if there was no logs, it was not possible to know if the result was from the expected block or an uncle block! By querying logs by blockHash we make sure that even if there are no logs, they are from the right block. - Note that now the function can either be called with a blockNum or blockHash, but not both at the same time. - sync - If there's an error during call to Sync call resetState, which internally resets the stateDB to avoid stale checkpoints (and a corresponding invalid increase in the StateDB batchNum). - During a Sync, after very batch processed, make sure that the StateDB currentBatch corresponds to the batchNum in the smart contract log/event.
3 years ago
Fix eth events query and sync inconsistent state - kvdb - Fix path in Last when doing `setNew` - Only close if db != nil, and after closing, always set db to nil - This will avoid a panic in the case where the db is closed but there's an error soon after, and a future call tries to close again. This is because pebble.Close() will panic if the db is already closed. - Avoid calling pebble methods when a the Storage interface already implements that method (like Close). - statedb - In test, avoid calling KVDB method if the same method is available for the StateDB (like MakeCheckpoint, CurrentBatch). - eth - In *EventByBlock methods, take blockHash as input argument and use it when querying the event logs. Previously the blockHash was only taken from the logs results *only if* there was any log. This caused the following issue: if there was no logs, it was not possible to know if the result was from the expected block or an uncle block! By querying logs by blockHash we make sure that even if there are no logs, they are from the right block. - Note that now the function can either be called with a blockNum or blockHash, but not both at the same time. - sync - If there's an error during call to Sync call resetState, which internally resets the stateDB to avoid stale checkpoints (and a corresponding invalid increase in the StateDB batchNum). - During a Sync, after very batch processed, make sure that the StateDB currentBatch corresponds to the batchNum in the smart contract log/event.
3 years ago
Fix eth events query and sync inconsistent state - kvdb - Fix path in Last when doing `setNew` - Only close if db != nil, and after closing, always set db to nil - This will avoid a panic in the case where the db is closed but there's an error soon after, and a future call tries to close again. This is because pebble.Close() will panic if the db is already closed. - Avoid calling pebble methods when a the Storage interface already implements that method (like Close). - statedb - In test, avoid calling KVDB method if the same method is available for the StateDB (like MakeCheckpoint, CurrentBatch). - eth - In *EventByBlock methods, take blockHash as input argument and use it when querying the event logs. Previously the blockHash was only taken from the logs results *only if* there was any log. This caused the following issue: if there was no logs, it was not possible to know if the result was from the expected block or an uncle block! By querying logs by blockHash we make sure that even if there are no logs, they are from the right block. - Note that now the function can either be called with a blockNum or blockHash, but not both at the same time. - sync - If there's an error during call to Sync call resetState, which internally resets the stateDB to avoid stale checkpoints (and a corresponding invalid increase in the StateDB batchNum). - During a Sync, after very batch processed, make sure that the StateDB currentBatch corresponds to the batchNum in the smart contract log/event.
3 years ago
Fix eth events query and sync inconsistent state - kvdb - Fix path in Last when doing `setNew` - Only close if db != nil, and after closing, always set db to nil - This will avoid a panic in the case where the db is closed but there's an error soon after, and a future call tries to close again. This is because pebble.Close() will panic if the db is already closed. - Avoid calling pebble methods when a the Storage interface already implements that method (like Close). - statedb - In test, avoid calling KVDB method if the same method is available for the StateDB (like MakeCheckpoint, CurrentBatch). - eth - In *EventByBlock methods, take blockHash as input argument and use it when querying the event logs. Previously the blockHash was only taken from the logs results *only if* there was any log. This caused the following issue: if there was no logs, it was not possible to know if the result was from the expected block or an uncle block! By querying logs by blockHash we make sure that even if there are no logs, they are from the right block. - Note that now the function can either be called with a blockNum or blockHash, but not both at the same time. - sync - If there's an error during call to Sync call resetState, which internally resets the stateDB to avoid stale checkpoints (and a corresponding invalid increase in the StateDB batchNum). - During a Sync, after very batch processed, make sure that the StateDB currentBatch corresponds to the batchNum in the smart contract log/event.
3 years ago
Fix eth events query and sync inconsistent state - kvdb - Fix path in Last when doing `setNew` - Only close if db != nil, and after closing, always set db to nil - This will avoid a panic in the case where the db is closed but there's an error soon after, and a future call tries to close again. This is because pebble.Close() will panic if the db is already closed. - Avoid calling pebble methods when a the Storage interface already implements that method (like Close). - statedb - In test, avoid calling KVDB method if the same method is available for the StateDB (like MakeCheckpoint, CurrentBatch). - eth - In *EventByBlock methods, take blockHash as input argument and use it when querying the event logs. Previously the blockHash was only taken from the logs results *only if* there was any log. This caused the following issue: if there was no logs, it was not possible to know if the result was from the expected block or an uncle block! By querying logs by blockHash we make sure that even if there are no logs, they are from the right block. - Note that now the function can either be called with a blockNum or blockHash, but not both at the same time. - sync - If there's an error during call to Sync call resetState, which internally resets the stateDB to avoid stale checkpoints (and a corresponding invalid increase in the StateDB batchNum). - During a Sync, after very batch processed, make sure that the StateDB currentBatch corresponds to the batchNum in the smart contract log/event.
3 years ago
Fix eth events query and sync inconsistent state - kvdb - Fix path in Last when doing `setNew` - Only close if db != nil, and after closing, always set db to nil - This will avoid a panic in the case where the db is closed but there's an error soon after, and a future call tries to close again. This is because pebble.Close() will panic if the db is already closed. - Avoid calling pebble methods when a the Storage interface already implements that method (like Close). - statedb - In test, avoid calling KVDB method if the same method is available for the StateDB (like MakeCheckpoint, CurrentBatch). - eth - In *EventByBlock methods, take blockHash as input argument and use it when querying the event logs. Previously the blockHash was only taken from the logs results *only if* there was any log. This caused the following issue: if there was no logs, it was not possible to know if the result was from the expected block or an uncle block! By querying logs by blockHash we make sure that even if there are no logs, they are from the right block. - Note that now the function can either be called with a blockNum or blockHash, but not both at the same time. - sync - If there's an error during call to Sync call resetState, which internally resets the stateDB to avoid stale checkpoints (and a corresponding invalid increase in the StateDB batchNum). - During a Sync, after very batch processed, make sure that the StateDB currentBatch corresponds to the batchNum in the smart contract log/event.
3 years ago
Fix eth events query and sync inconsistent state - kvdb - Fix path in Last when doing `setNew` - Only close if db != nil, and after closing, always set db to nil - This will avoid a panic in the case where the db is closed but there's an error soon after, and a future call tries to close again. This is because pebble.Close() will panic if the db is already closed. - Avoid calling pebble methods when a the Storage interface already implements that method (like Close). - statedb - In test, avoid calling KVDB method if the same method is available for the StateDB (like MakeCheckpoint, CurrentBatch). - eth - In *EventByBlock methods, take blockHash as input argument and use it when querying the event logs. Previously the blockHash was only taken from the logs results *only if* there was any log. This caused the following issue: if there was no logs, it was not possible to know if the result was from the expected block or an uncle block! By querying logs by blockHash we make sure that even if there are no logs, they are from the right block. - Note that now the function can either be called with a blockNum or blockHash, but not both at the same time. - sync - If there's an error during call to Sync call resetState, which internally resets the stateDB to avoid stale checkpoints (and a corresponding invalid increase in the StateDB batchNum). - During a Sync, after very batch processed, make sure that the StateDB currentBatch corresponds to the batchNum in the smart contract log/event.
3 years ago
Fix eth events query and sync inconsistent state - kvdb - Fix path in Last when doing `setNew` - Only close if db != nil, and after closing, always set db to nil - This will avoid a panic in the case where the db is closed but there's an error soon after, and a future call tries to close again. This is because pebble.Close() will panic if the db is already closed. - Avoid calling pebble methods when a the Storage interface already implements that method (like Close). - statedb - In test, avoid calling KVDB method if the same method is available for the StateDB (like MakeCheckpoint, CurrentBatch). - eth - In *EventByBlock methods, take blockHash as input argument and use it when querying the event logs. Previously the blockHash was only taken from the logs results *only if* there was any log. This caused the following issue: if there was no logs, it was not possible to know if the result was from the expected block or an uncle block! By querying logs by blockHash we make sure that even if there are no logs, they are from the right block. - Note that now the function can either be called with a blockNum or blockHash, but not both at the same time. - sync - If there's an error during call to Sync call resetState, which internally resets the stateDB to avoid stale checkpoints (and a corresponding invalid increase in the StateDB batchNum). - During a Sync, after very batch processed, make sure that the StateDB currentBatch corresponds to the batchNum in the smart contract log/event.
3 years ago
Fix eth events query and sync inconsistent state - kvdb - Fix path in Last when doing `setNew` - Only close if db != nil, and after closing, always set db to nil - This will avoid a panic in the case where the db is closed but there's an error soon after, and a future call tries to close again. This is because pebble.Close() will panic if the db is already closed. - Avoid calling pebble methods when a the Storage interface already implements that method (like Close). - statedb - In test, avoid calling KVDB method if the same method is available for the StateDB (like MakeCheckpoint, CurrentBatch). - eth - In *EventByBlock methods, take blockHash as input argument and use it when querying the event logs. Previously the blockHash was only taken from the logs results *only if* there was any log. This caused the following issue: if there was no logs, it was not possible to know if the result was from the expected block or an uncle block! By querying logs by blockHash we make sure that even if there are no logs, they are from the right block. - Note that now the function can either be called with a blockNum or blockHash, but not both at the same time. - sync - If there's an error during call to Sync call resetState, which internally resets the stateDB to avoid stale checkpoints (and a corresponding invalid increase in the StateDB batchNum). - During a Sync, after very batch processed, make sure that the StateDB currentBatch corresponds to the batchNum in the smart contract log/event.
3 years ago
Fix eth events query and sync inconsistent state - kvdb - Fix path in Last when doing `setNew` - Only close if db != nil, and after closing, always set db to nil - This will avoid a panic in the case where the db is closed but there's an error soon after, and a future call tries to close again. This is because pebble.Close() will panic if the db is already closed. - Avoid calling pebble methods when a the Storage interface already implements that method (like Close). - statedb - In test, avoid calling KVDB method if the same method is available for the StateDB (like MakeCheckpoint, CurrentBatch). - eth - In *EventByBlock methods, take blockHash as input argument and use it when querying the event logs. Previously the blockHash was only taken from the logs results *only if* there was any log. This caused the following issue: if there was no logs, it was not possible to know if the result was from the expected block or an uncle block! By querying logs by blockHash we make sure that even if there are no logs, they are from the right block. - Note that now the function can either be called with a blockNum or blockHash, but not both at the same time. - sync - If there's an error during call to Sync call resetState, which internally resets the stateDB to avoid stale checkpoints (and a corresponding invalid increase in the StateDB batchNum). - During a Sync, after very batch processed, make sure that the StateDB currentBatch corresponds to the batchNum in the smart contract log/event.
3 years ago
Fix eth events query and sync inconsistent state - kvdb - Fix path in Last when doing `setNew` - Only close if db != nil, and after closing, always set db to nil - This will avoid a panic in the case where the db is closed but there's an error soon after, and a future call tries to close again. This is because pebble.Close() will panic if the db is already closed. - Avoid calling pebble methods when a the Storage interface already implements that method (like Close). - statedb - In test, avoid calling KVDB method if the same method is available for the StateDB (like MakeCheckpoint, CurrentBatch). - eth - In *EventByBlock methods, take blockHash as input argument and use it when querying the event logs. Previously the blockHash was only taken from the logs results *only if* there was any log. This caused the following issue: if there was no logs, it was not possible to know if the result was from the expected block or an uncle block! By querying logs by blockHash we make sure that even if there are no logs, they are from the right block. - Note that now the function can either be called with a blockNum or blockHash, but not both at the same time. - sync - If there's an error during call to Sync call resetState, which internally resets the stateDB to avoid stale checkpoints (and a corresponding invalid increase in the StateDB batchNum). - During a Sync, after very batch processed, make sure that the StateDB currentBatch corresponds to the batchNum in the smart contract log/event.
3 years ago
Fix eth events query and sync inconsistent state - kvdb - Fix path in Last when doing `setNew` - Only close if db != nil, and after closing, always set db to nil - This will avoid a panic in the case where the db is closed but there's an error soon after, and a future call tries to close again. This is because pebble.Close() will panic if the db is already closed. - Avoid calling pebble methods when a the Storage interface already implements that method (like Close). - statedb - In test, avoid calling KVDB method if the same method is available for the StateDB (like MakeCheckpoint, CurrentBatch). - eth - In *EventByBlock methods, take blockHash as input argument and use it when querying the event logs. Previously the blockHash was only taken from the logs results *only if* there was any log. This caused the following issue: if there was no logs, it was not possible to know if the result was from the expected block or an uncle block! By querying logs by blockHash we make sure that even if there are no logs, they are from the right block. - Note that now the function can either be called with a blockNum or blockHash, but not both at the same time. - sync - If there's an error during call to Sync call resetState, which internally resets the stateDB to avoid stale checkpoints (and a corresponding invalid increase in the StateDB batchNum). - During a Sync, after very batch processed, make sure that the StateDB currentBatch corresponds to the batchNum in the smart contract log/event.
3 years ago
Fix eth events query and sync inconsistent state - kvdb - Fix path in Last when doing `setNew` - Only close if db != nil, and after closing, always set db to nil - This will avoid a panic in the case where the db is closed but there's an error soon after, and a future call tries to close again. This is because pebble.Close() will panic if the db is already closed. - Avoid calling pebble methods when a the Storage interface already implements that method (like Close). - statedb - In test, avoid calling KVDB method if the same method is available for the StateDB (like MakeCheckpoint, CurrentBatch). - eth - In *EventByBlock methods, take blockHash as input argument and use it when querying the event logs. Previously the blockHash was only taken from the logs results *only if* there was any log. This caused the following issue: if there was no logs, it was not possible to know if the result was from the expected block or an uncle block! By querying logs by blockHash we make sure that even if there are no logs, they are from the right block. - Note that now the function can either be called with a blockNum or blockHash, but not both at the same time. - sync - If there's an error during call to Sync call resetState, which internally resets the stateDB to avoid stale checkpoints (and a corresponding invalid increase in the StateDB batchNum). - During a Sync, after very batch processed, make sure that the StateDB currentBatch corresponds to the batchNum in the smart contract log/event.
3 years ago
Fix eth events query and sync inconsistent state - kvdb - Fix path in Last when doing `setNew` - Only close if db != nil, and after closing, always set db to nil - This will avoid a panic in the case where the db is closed but there's an error soon after, and a future call tries to close again. This is because pebble.Close() will panic if the db is already closed. - Avoid calling pebble methods when a the Storage interface already implements that method (like Close). - statedb - In test, avoid calling KVDB method if the same method is available for the StateDB (like MakeCheckpoint, CurrentBatch). - eth - In *EventByBlock methods, take blockHash as input argument and use it when querying the event logs. Previously the blockHash was only taken from the logs results *only if* there was any log. This caused the following issue: if there was no logs, it was not possible to know if the result was from the expected block or an uncle block! By querying logs by blockHash we make sure that even if there are no logs, they are from the right block. - Note that now the function can either be called with a blockNum or blockHash, but not both at the same time. - sync - If there's an error during call to Sync call resetState, which internally resets the stateDB to avoid stale checkpoints (and a corresponding invalid increase in the StateDB batchNum). - During a Sync, after very batch processed, make sure that the StateDB currentBatch corresponds to the batchNum in the smart contract log/event.
3 years ago
Fix eth events query and sync inconsistent state - kvdb - Fix path in Last when doing `setNew` - Only close if db != nil, and after closing, always set db to nil - This will avoid a panic in the case where the db is closed but there's an error soon after, and a future call tries to close again. This is because pebble.Close() will panic if the db is already closed. - Avoid calling pebble methods when a the Storage interface already implements that method (like Close). - statedb - In test, avoid calling KVDB method if the same method is available for the StateDB (like MakeCheckpoint, CurrentBatch). - eth - In *EventByBlock methods, take blockHash as input argument and use it when querying the event logs. Previously the blockHash was only taken from the logs results *only if* there was any log. This caused the following issue: if there was no logs, it was not possible to know if the result was from the expected block or an uncle block! By querying logs by blockHash we make sure that even if there are no logs, they are from the right block. - Note that now the function can either be called with a blockNum or blockHash, but not both at the same time. - sync - If there's an error during call to Sync call resetState, which internally resets the stateDB to avoid stale checkpoints (and a corresponding invalid increase in the StateDB batchNum). - During a Sync, after very batch processed, make sure that the StateDB currentBatch corresponds to the batchNum in the smart contract log/event.
3 years ago
Fix eth events query and sync inconsistent state - kvdb - Fix path in Last when doing `setNew` - Only close if db != nil, and after closing, always set db to nil - This will avoid a panic in the case where the db is closed but there's an error soon after, and a future call tries to close again. This is because pebble.Close() will panic if the db is already closed. - Avoid calling pebble methods when a the Storage interface already implements that method (like Close). - statedb - In test, avoid calling KVDB method if the same method is available for the StateDB (like MakeCheckpoint, CurrentBatch). - eth - In *EventByBlock methods, take blockHash as input argument and use it when querying the event logs. Previously the blockHash was only taken from the logs results *only if* there was any log. This caused the following issue: if there was no logs, it was not possible to know if the result was from the expected block or an uncle block! By querying logs by blockHash we make sure that even if there are no logs, they are from the right block. - Note that now the function can either be called with a blockNum or blockHash, but not both at the same time. - sync - If there's an error during call to Sync call resetState, which internally resets the stateDB to avoid stale checkpoints (and a corresponding invalid increase in the StateDB batchNum). - During a Sync, after very batch processed, make sure that the StateDB currentBatch corresponds to the batchNum in the smart contract log/event.
3 years ago
Fix eth events query and sync inconsistent state - kvdb - Fix path in Last when doing `setNew` - Only close if db != nil, and after closing, always set db to nil - This will avoid a panic in the case where the db is closed but there's an error soon after, and a future call tries to close again. This is because pebble.Close() will panic if the db is already closed. - Avoid calling pebble methods when a the Storage interface already implements that method (like Close). - statedb - In test, avoid calling KVDB method if the same method is available for the StateDB (like MakeCheckpoint, CurrentBatch). - eth - In *EventByBlock methods, take blockHash as input argument and use it when querying the event logs. Previously the blockHash was only taken from the logs results *only if* there was any log. This caused the following issue: if there was no logs, it was not possible to know if the result was from the expected block or an uncle block! By querying logs by blockHash we make sure that even if there are no logs, they are from the right block. - Note that now the function can either be called with a blockNum or blockHash, but not both at the same time. - sync - If there's an error during call to Sync call resetState, which internally resets the stateDB to avoid stale checkpoints (and a corresponding invalid increase in the StateDB batchNum). - During a Sync, after very batch processed, make sure that the StateDB currentBatch corresponds to the batchNum in the smart contract log/event.
3 years ago
Fix eth events query and sync inconsistent state - kvdb - Fix path in Last when doing `setNew` - Only close if db != nil, and after closing, always set db to nil - This will avoid a panic in the case where the db is closed but there's an error soon after, and a future call tries to close again. This is because pebble.Close() will panic if the db is already closed. - Avoid calling pebble methods when a the Storage interface already implements that method (like Close). - statedb - In test, avoid calling KVDB method if the same method is available for the StateDB (like MakeCheckpoint, CurrentBatch). - eth - In *EventByBlock methods, take blockHash as input argument and use it when querying the event logs. Previously the blockHash was only taken from the logs results *only if* there was any log. This caused the following issue: if there was no logs, it was not possible to know if the result was from the expected block or an uncle block! By querying logs by blockHash we make sure that even if there are no logs, they are from the right block. - Note that now the function can either be called with a blockNum or blockHash, but not both at the same time. - sync - If there's an error during call to Sync call resetState, which internally resets the stateDB to avoid stale checkpoints (and a corresponding invalid increase in the StateDB batchNum). - During a Sync, after very batch processed, make sure that the StateDB currentBatch corresponds to the batchNum in the smart contract log/event.
3 years ago
  1. package eth
  2. import (
  3. "context"
  4. "fmt"
  5. "math/big"
  6. "strings"
  7. "github.com/ethereum/go-ethereum"
  8. "github.com/ethereum/go-ethereum/accounts/abi"
  9. "github.com/ethereum/go-ethereum/accounts/abi/bind"
  10. ethCommon "github.com/ethereum/go-ethereum/common"
  11. "github.com/ethereum/go-ethereum/core/types"
  12. "github.com/ethereum/go-ethereum/crypto"
  13. "github.com/ethereum/go-ethereum/ethclient"
  14. "github.com/hermeznetwork/hermez-node/common"
  15. HermezAuctionProtocol "github.com/hermeznetwork/hermez-node/eth/contracts/auction"
  16. HEZ "github.com/hermeznetwork/hermez-node/eth/contracts/tokenHEZ"
  17. "github.com/hermeznetwork/hermez-node/log"
  18. "github.com/hermeznetwork/tracerr"
  19. )
  20. // SlotState is the state of a slot
  21. type SlotState struct {
  22. Bidder ethCommon.Address
  23. ForgerCommitment bool
  24. Fulfilled bool
  25. BidAmount *big.Int
  26. ClosedMinBid *big.Int
  27. }
  28. // NewSlotState returns an empty SlotState
  29. func NewSlotState() *SlotState {
  30. return &SlotState{
  31. Bidder: ethCommon.Address{},
  32. Fulfilled: false,
  33. ForgerCommitment: false,
  34. BidAmount: big.NewInt(0),
  35. ClosedMinBid: big.NewInt(0),
  36. }
  37. }
  38. // Coordinator is the details of the Coordinator identified by the forger address
  39. type Coordinator struct {
  40. Forger ethCommon.Address
  41. URL string
  42. }
  43. // AuctionState represents the state of the Rollup in the Smart Contract
  44. type AuctionState struct {
  45. // Mapping to control slot state
  46. Slots map[int64]*SlotState
  47. // Mapping to control balances pending to claim
  48. PendingBalances map[ethCommon.Address]*big.Int
  49. // Mapping to register all the coordinators. The address used for the mapping is the forger address
  50. Coordinators map[ethCommon.Address]*Coordinator
  51. }
  52. // AuctionEventInitialize is the InitializeHermezAuctionProtocolEvent event of
  53. // the Smart Contract
  54. type AuctionEventInitialize struct {
  55. DonationAddress ethCommon.Address
  56. BootCoordinatorAddress ethCommon.Address
  57. BootCoordinatorURL string
  58. Outbidding uint16
  59. SlotDeadline uint8
  60. ClosedAuctionSlots uint16
  61. OpenAuctionSlots uint16
  62. AllocationRatio [3]uint16
  63. }
  64. // AuctionVariables returns the AuctionVariables from the initialize event
  65. func (ei *AuctionEventInitialize) AuctionVariables(
  66. InitialMinimalBidding *big.Int) *common.AuctionVariables {
  67. return &common.AuctionVariables{
  68. EthBlockNum: 0,
  69. DonationAddress: ei.DonationAddress,
  70. BootCoordinator: ei.BootCoordinatorAddress,
  71. BootCoordinatorURL: ei.BootCoordinatorURL,
  72. DefaultSlotSetBid: [6]*big.Int{
  73. InitialMinimalBidding, InitialMinimalBidding, InitialMinimalBidding,
  74. InitialMinimalBidding, InitialMinimalBidding, InitialMinimalBidding,
  75. },
  76. DefaultSlotSetBidSlotNum: 0,
  77. ClosedAuctionSlots: ei.ClosedAuctionSlots,
  78. OpenAuctionSlots: ei.OpenAuctionSlots,
  79. AllocationRatio: ei.AllocationRatio,
  80. Outbidding: ei.Outbidding,
  81. SlotDeadline: ei.SlotDeadline,
  82. }
  83. }
  84. // AuctionEventNewBid is an event of the Auction Smart Contract
  85. type AuctionEventNewBid struct {
  86. Slot int64
  87. BidAmount *big.Int
  88. Bidder ethCommon.Address
  89. }
  90. // AuctionEventNewSlotDeadline is an event of the Auction Smart Contract
  91. type AuctionEventNewSlotDeadline struct {
  92. NewSlotDeadline uint8
  93. }
  94. // AuctionEventNewClosedAuctionSlots is an event of the Auction Smart Contract
  95. type AuctionEventNewClosedAuctionSlots struct {
  96. NewClosedAuctionSlots uint16
  97. }
  98. // AuctionEventNewOutbidding is an event of the Auction Smart Contract
  99. type AuctionEventNewOutbidding struct {
  100. NewOutbidding uint16
  101. }
  102. // AuctionEventNewDonationAddress is an event of the Auction Smart Contract
  103. type AuctionEventNewDonationAddress struct {
  104. NewDonationAddress ethCommon.Address
  105. }
  106. // AuctionEventNewBootCoordinator is an event of the Auction Smart Contract
  107. type AuctionEventNewBootCoordinator struct {
  108. NewBootCoordinator ethCommon.Address
  109. NewBootCoordinatorURL string
  110. }
  111. // AuctionEventNewOpenAuctionSlots is an event of the Auction Smart Contract
  112. type AuctionEventNewOpenAuctionSlots struct {
  113. NewOpenAuctionSlots uint16
  114. }
  115. // AuctionEventNewAllocationRatio is an event of the Auction Smart Contract
  116. type AuctionEventNewAllocationRatio struct {
  117. NewAllocationRatio [3]uint16
  118. }
  119. // AuctionEventSetCoordinator is an event of the Auction Smart Contract
  120. type AuctionEventSetCoordinator struct {
  121. BidderAddress ethCommon.Address
  122. ForgerAddress ethCommon.Address
  123. CoordinatorURL string
  124. }
  125. // AuctionEventNewForgeAllocated is an event of the Auction Smart Contract
  126. type AuctionEventNewForgeAllocated struct {
  127. Bidder ethCommon.Address
  128. Forger ethCommon.Address
  129. SlotToForge int64
  130. BurnAmount *big.Int
  131. DonationAmount *big.Int
  132. GovernanceAmount *big.Int
  133. }
  134. // AuctionEventNewDefaultSlotSetBid is an event of the Auction Smart Contract
  135. type AuctionEventNewDefaultSlotSetBid struct {
  136. SlotSet int64
  137. NewInitialMinBid *big.Int
  138. }
  139. // AuctionEventNewForge is an event of the Auction Smart Contract
  140. type AuctionEventNewForge struct {
  141. Forger ethCommon.Address
  142. SlotToForge int64
  143. }
  144. // AuctionEventHEZClaimed is an event of the Auction Smart Contract
  145. type AuctionEventHEZClaimed struct {
  146. Owner ethCommon.Address
  147. Amount *big.Int
  148. }
  149. // AuctionEvents is the list of events in a block of the Auction Smart Contract
  150. type AuctionEvents struct {
  151. NewBid []AuctionEventNewBid
  152. NewSlotDeadline []AuctionEventNewSlotDeadline
  153. NewClosedAuctionSlots []AuctionEventNewClosedAuctionSlots
  154. NewOutbidding []AuctionEventNewOutbidding
  155. NewDonationAddress []AuctionEventNewDonationAddress
  156. NewBootCoordinator []AuctionEventNewBootCoordinator
  157. NewOpenAuctionSlots []AuctionEventNewOpenAuctionSlots
  158. NewAllocationRatio []AuctionEventNewAllocationRatio
  159. SetCoordinator []AuctionEventSetCoordinator
  160. NewForgeAllocated []AuctionEventNewForgeAllocated
  161. NewDefaultSlotSetBid []AuctionEventNewDefaultSlotSetBid
  162. NewForge []AuctionEventNewForge
  163. HEZClaimed []AuctionEventHEZClaimed
  164. }
  165. // NewAuctionEvents creates an empty AuctionEvents with the slices initialized.
  166. func NewAuctionEvents() AuctionEvents {
  167. return AuctionEvents{
  168. NewBid: make([]AuctionEventNewBid, 0),
  169. NewSlotDeadline: make([]AuctionEventNewSlotDeadline, 0),
  170. NewClosedAuctionSlots: make([]AuctionEventNewClosedAuctionSlots, 0),
  171. NewOutbidding: make([]AuctionEventNewOutbidding, 0),
  172. NewDonationAddress: make([]AuctionEventNewDonationAddress, 0),
  173. NewBootCoordinator: make([]AuctionEventNewBootCoordinator, 0),
  174. NewOpenAuctionSlots: make([]AuctionEventNewOpenAuctionSlots, 0),
  175. NewAllocationRatio: make([]AuctionEventNewAllocationRatio, 0),
  176. SetCoordinator: make([]AuctionEventSetCoordinator, 0),
  177. NewForgeAllocated: make([]AuctionEventNewForgeAllocated, 0),
  178. NewDefaultSlotSetBid: make([]AuctionEventNewDefaultSlotSetBid, 0),
  179. NewForge: make([]AuctionEventNewForge, 0),
  180. HEZClaimed: make([]AuctionEventHEZClaimed, 0),
  181. }
  182. }
  183. // AuctionInterface is the inteface to to Auction Smart Contract
  184. type AuctionInterface interface {
  185. //
  186. // Smart Contract Methods
  187. //
  188. // Getter/Setter, where Setter is onlyOwner
  189. AuctionSetSlotDeadline(newDeadline uint8) (*types.Transaction, error)
  190. AuctionGetSlotDeadline() (uint8, error)
  191. AuctionSetOpenAuctionSlots(newOpenAuctionSlots uint16) (*types.Transaction, error)
  192. AuctionGetOpenAuctionSlots() (uint16, error)
  193. AuctionSetClosedAuctionSlots(newClosedAuctionSlots uint16) (*types.Transaction, error)
  194. AuctionGetClosedAuctionSlots() (uint16, error)
  195. AuctionSetOutbidding(newOutbidding uint16) (*types.Transaction, error)
  196. AuctionGetOutbidding() (uint16, error)
  197. AuctionSetAllocationRatio(newAllocationRatio [3]uint16) (*types.Transaction, error)
  198. AuctionGetAllocationRatio() ([3]uint16, error)
  199. AuctionSetDonationAddress(newDonationAddress ethCommon.Address) (*types.Transaction, error)
  200. AuctionGetDonationAddress() (*ethCommon.Address, error)
  201. AuctionSetBootCoordinator(newBootCoordinator ethCommon.Address,
  202. newBootCoordinatorURL string) (*types.Transaction, error)
  203. AuctionGetBootCoordinator() (*ethCommon.Address, error)
  204. AuctionChangeDefaultSlotSetBid(slotSet int64,
  205. newInitialMinBid *big.Int) (*types.Transaction, error)
  206. // Coordinator Management
  207. AuctionSetCoordinator(forger ethCommon.Address, coordinatorURL string) (*types.Transaction,
  208. error)
  209. // Slot Info
  210. AuctionGetSlotNumber(blockNum int64) (int64, error)
  211. AuctionGetCurrentSlotNumber() (int64, error)
  212. AuctionGetMinBidBySlot(slot int64) (*big.Int, error)
  213. AuctionGetDefaultSlotSetBid(slotSet uint8) (*big.Int, error)
  214. AuctionGetSlotSet(slot int64) (*big.Int, error)
  215. // Bidding
  216. AuctionBid(amount *big.Int, slot int64, bidAmount *big.Int, deadline *big.Int) (
  217. tx *types.Transaction, err error)
  218. AuctionMultiBid(amount *big.Int, startingSlot, endingSlot int64, slotSets [6]bool,
  219. maxBid, minBid, deadline *big.Int) (tx *types.Transaction, err error)
  220. // Forge
  221. AuctionCanForge(forger ethCommon.Address, blockNum int64) (bool, error)
  222. AuctionForge(forger ethCommon.Address) (*types.Transaction, error)
  223. // Fees
  224. AuctionClaimHEZ() (*types.Transaction, error)
  225. AuctionGetClaimableHEZ(bidder ethCommon.Address) (*big.Int, error)
  226. //
  227. // Smart Contract Status
  228. //
  229. AuctionConstants() (*common.AuctionConstants, error)
  230. AuctionEventsByBlock(blockNum int64, blockHash *ethCommon.Hash) (*AuctionEvents, error)
  231. AuctionEventInit(genesisBlockNum int64) (*AuctionEventInitialize, int64, error)
  232. }
  233. //
  234. // Implementation
  235. //
  236. // AuctionClient is the implementation of the interface to the Auction Smart Contract in ethereum.
  237. type AuctionClient struct {
  238. client *EthereumClient
  239. chainID *big.Int
  240. address ethCommon.Address
  241. tokenHEZCfg TokenConfig
  242. auction *HermezAuctionProtocol.HermezAuctionProtocol
  243. tokenHEZ *HEZ.HEZ
  244. contractAbi abi.ABI
  245. opts *bind.CallOpts
  246. }
  247. // NewAuctionClient creates a new AuctionClient. `tokenAddress` is the address of the HEZ tokens.
  248. func NewAuctionClient(client *EthereumClient, address ethCommon.Address,
  249. tokenHEZCfg TokenConfig) (*AuctionClient, error) {
  250. contractAbi, err :=
  251. abi.JSON(strings.NewReader(string(HermezAuctionProtocol.HermezAuctionProtocolABI)))
  252. if err != nil {
  253. return nil, tracerr.Wrap(err)
  254. }
  255. auction, err := HermezAuctionProtocol.NewHermezAuctionProtocol(address, client.Client())
  256. if err != nil {
  257. return nil, tracerr.Wrap(err)
  258. }
  259. tokenHEZ, err := HEZ.NewHEZ(tokenHEZCfg.Address, client.Client())
  260. if err != nil {
  261. return nil, tracerr.Wrap(err)
  262. }
  263. chainID, err := client.EthChainID()
  264. if err != nil {
  265. return nil, tracerr.Wrap(err)
  266. }
  267. return &AuctionClient{
  268. client: client,
  269. chainID: chainID,
  270. address: address,
  271. tokenHEZCfg: tokenHEZCfg,
  272. auction: auction,
  273. tokenHEZ: tokenHEZ,
  274. contractAbi: contractAbi,
  275. opts: newCallOpts(),
  276. }, nil
  277. }
  278. // AuctionSetSlotDeadline is the interface to call the smart contract function
  279. func (c *AuctionClient) AuctionSetSlotDeadline(newDeadline uint8) (*types.Transaction, error) {
  280. var tx *types.Transaction
  281. var err error
  282. if tx, err = c.client.CallAuth(
  283. 0,
  284. func(ec *ethclient.Client, auth *bind.TransactOpts) (*types.Transaction, error) {
  285. return c.auction.SetSlotDeadline(auth, newDeadline)
  286. },
  287. ); err != nil {
  288. return nil, tracerr.Wrap(fmt.Errorf("Failed setting slotDeadline: %w", err))
  289. }
  290. return tx, nil
  291. }
  292. // AuctionGetSlotDeadline is the interface to call the smart contract function
  293. func (c *AuctionClient) AuctionGetSlotDeadline() (slotDeadline uint8, err error) {
  294. if err := c.client.Call(func(ec *ethclient.Client) error {
  295. slotDeadline, err = c.auction.GetSlotDeadline(c.opts)
  296. return tracerr.Wrap(err)
  297. }); err != nil {
  298. return 0, tracerr.Wrap(err)
  299. }
  300. return slotDeadline, nil
  301. }
  302. // AuctionSetOpenAuctionSlots is the interface to call the smart contract function
  303. func (c *AuctionClient) AuctionSetOpenAuctionSlots(
  304. newOpenAuctionSlots uint16) (tx *types.Transaction, err error) {
  305. if tx, err = c.client.CallAuth(
  306. 0,
  307. func(ec *ethclient.Client, auth *bind.TransactOpts) (*types.Transaction, error) {
  308. return c.auction.SetOpenAuctionSlots(auth, newOpenAuctionSlots)
  309. },
  310. ); err != nil {
  311. return nil, tracerr.Wrap(fmt.Errorf("Failed setting openAuctionSlots: %w", err))
  312. }
  313. return tx, nil
  314. }
  315. // AuctionGetOpenAuctionSlots is the interface to call the smart contract function
  316. func (c *AuctionClient) AuctionGetOpenAuctionSlots() (openAuctionSlots uint16, err error) {
  317. if err := c.client.Call(func(ec *ethclient.Client) error {
  318. openAuctionSlots, err = c.auction.GetOpenAuctionSlots(c.opts)
  319. return tracerr.Wrap(err)
  320. }); err != nil {
  321. return 0, tracerr.Wrap(err)
  322. }
  323. return openAuctionSlots, nil
  324. }
  325. // AuctionSetClosedAuctionSlots is the interface to call the smart contract function
  326. func (c *AuctionClient) AuctionSetClosedAuctionSlots(
  327. newClosedAuctionSlots uint16) (tx *types.Transaction, err error) {
  328. if tx, err = c.client.CallAuth(
  329. 0,
  330. func(ec *ethclient.Client, auth *bind.TransactOpts) (*types.Transaction, error) {
  331. return c.auction.SetClosedAuctionSlots(auth, newClosedAuctionSlots)
  332. },
  333. ); err != nil {
  334. return nil, tracerr.Wrap(fmt.Errorf("Failed setting closedAuctionSlots: %w", err))
  335. }
  336. return tx, nil
  337. }
  338. // AuctionGetClosedAuctionSlots is the interface to call the smart contract function
  339. func (c *AuctionClient) AuctionGetClosedAuctionSlots() (closedAuctionSlots uint16, err error) {
  340. if err := c.client.Call(func(ec *ethclient.Client) error {
  341. closedAuctionSlots, err = c.auction.GetClosedAuctionSlots(c.opts)
  342. return tracerr.Wrap(err)
  343. }); err != nil {
  344. return 0, tracerr.Wrap(err)
  345. }
  346. return closedAuctionSlots, nil
  347. }
  348. // AuctionSetOutbidding is the interface to call the smart contract function
  349. func (c *AuctionClient) AuctionSetOutbidding(newOutbidding uint16) (tx *types.Transaction,
  350. err error) {
  351. if tx, err = c.client.CallAuth(
  352. 12500000, //nolint:gomnd
  353. func(ec *ethclient.Client, auth *bind.TransactOpts) (*types.Transaction, error) {
  354. return c.auction.SetOutbidding(auth, newOutbidding)
  355. },
  356. ); err != nil {
  357. return nil, tracerr.Wrap(fmt.Errorf("Failed setting setOutbidding: %w", err))
  358. }
  359. return tx, nil
  360. }
  361. // AuctionGetOutbidding is the interface to call the smart contract function
  362. func (c *AuctionClient) AuctionGetOutbidding() (outbidding uint16, err error) {
  363. if err := c.client.Call(func(ec *ethclient.Client) error {
  364. outbidding, err = c.auction.GetOutbidding(c.opts)
  365. return tracerr.Wrap(err)
  366. }); err != nil {
  367. return 0, tracerr.Wrap(err)
  368. }
  369. return outbidding, nil
  370. }
  371. // AuctionSetAllocationRatio is the interface to call the smart contract function
  372. func (c *AuctionClient) AuctionSetAllocationRatio(
  373. newAllocationRatio [3]uint16) (tx *types.Transaction, err error) {
  374. if tx, err = c.client.CallAuth(
  375. 0,
  376. func(ec *ethclient.Client, auth *bind.TransactOpts) (*types.Transaction, error) {
  377. return c.auction.SetAllocationRatio(auth, newAllocationRatio)
  378. },
  379. ); err != nil {
  380. return nil, tracerr.Wrap(fmt.Errorf("Failed setting allocationRatio: %w", err))
  381. }
  382. return tx, nil
  383. }
  384. // AuctionGetAllocationRatio is the interface to call the smart contract function
  385. func (c *AuctionClient) AuctionGetAllocationRatio() (allocationRation [3]uint16, err error) {
  386. if err := c.client.Call(func(ec *ethclient.Client) error {
  387. allocationRation, err = c.auction.GetAllocationRatio(c.opts)
  388. return tracerr.Wrap(err)
  389. }); err != nil {
  390. return [3]uint16{}, tracerr.Wrap(err)
  391. }
  392. return allocationRation, nil
  393. }
  394. // AuctionSetDonationAddress is the interface to call the smart contract function
  395. func (c *AuctionClient) AuctionSetDonationAddress(
  396. newDonationAddress ethCommon.Address) (tx *types.Transaction, err error) {
  397. if tx, err = c.client.CallAuth(
  398. 0,
  399. func(ec *ethclient.Client, auth *bind.TransactOpts) (*types.Transaction, error) {
  400. return c.auction.SetDonationAddress(auth, newDonationAddress)
  401. },
  402. ); err != nil {
  403. return nil, tracerr.Wrap(fmt.Errorf("Failed setting donationAddress: %w", err))
  404. }
  405. return tx, nil
  406. }
  407. // AuctionGetDonationAddress is the interface to call the smart contract function
  408. func (c *AuctionClient) AuctionGetDonationAddress() (donationAddress *ethCommon.Address,
  409. err error) {
  410. var _donationAddress ethCommon.Address
  411. if err := c.client.Call(func(ec *ethclient.Client) error {
  412. _donationAddress, err = c.auction.GetDonationAddress(c.opts)
  413. return tracerr.Wrap(err)
  414. }); err != nil {
  415. return nil, tracerr.Wrap(err)
  416. }
  417. return &_donationAddress, nil
  418. }
  419. // AuctionSetBootCoordinator is the interface to call the smart contract function
  420. func (c *AuctionClient) AuctionSetBootCoordinator(newBootCoordinator ethCommon.Address,
  421. newBootCoordinatorURL string) (tx *types.Transaction, err error) {
  422. if tx, err = c.client.CallAuth(
  423. 0,
  424. func(ec *ethclient.Client, auth *bind.TransactOpts) (*types.Transaction, error) {
  425. return c.auction.SetBootCoordinator(auth, newBootCoordinator,
  426. newBootCoordinatorURL)
  427. },
  428. ); err != nil {
  429. return nil, tracerr.Wrap(fmt.Errorf("Failed setting bootCoordinator: %w", err))
  430. }
  431. return tx, nil
  432. }
  433. // AuctionGetBootCoordinator is the interface to call the smart contract function
  434. func (c *AuctionClient) AuctionGetBootCoordinator() (bootCoordinator *ethCommon.Address,
  435. err error) {
  436. var _bootCoordinator ethCommon.Address
  437. if err := c.client.Call(func(ec *ethclient.Client) error {
  438. _bootCoordinator, err = c.auction.GetBootCoordinator(c.opts)
  439. return tracerr.Wrap(err)
  440. }); err != nil {
  441. return nil, tracerr.Wrap(err)
  442. }
  443. return &_bootCoordinator, nil
  444. }
  445. // AuctionChangeDefaultSlotSetBid is the interface to call the smart contract function
  446. func (c *AuctionClient) AuctionChangeDefaultSlotSetBid(slotSet int64,
  447. newInitialMinBid *big.Int) (tx *types.Transaction, err error) {
  448. if tx, err = c.client.CallAuth(
  449. 0,
  450. func(ec *ethclient.Client, auth *bind.TransactOpts) (*types.Transaction, error) {
  451. slotSetToSend := big.NewInt(slotSet)
  452. return c.auction.ChangeDefaultSlotSetBid(auth, slotSetToSend, newInitialMinBid)
  453. },
  454. ); err != nil {
  455. return nil, tracerr.Wrap(fmt.Errorf("Failed changing slotSet Bid: %w", err))
  456. }
  457. return tx, nil
  458. }
  459. // AuctionGetClaimableHEZ is the interface to call the smart contract function
  460. func (c *AuctionClient) AuctionGetClaimableHEZ(
  461. claimAddress ethCommon.Address) (claimableHEZ *big.Int, err error) {
  462. if err := c.client.Call(func(ec *ethclient.Client) error {
  463. claimableHEZ, err = c.auction.GetClaimableHEZ(c.opts, claimAddress)
  464. return tracerr.Wrap(err)
  465. }); err != nil {
  466. return nil, tracerr.Wrap(err)
  467. }
  468. return claimableHEZ, nil
  469. }
  470. // AuctionSetCoordinator is the interface to call the smart contract function
  471. func (c *AuctionClient) AuctionSetCoordinator(forger ethCommon.Address,
  472. coordinatorURL string) (tx *types.Transaction, err error) {
  473. if tx, err = c.client.CallAuth(
  474. 0,
  475. func(ec *ethclient.Client, auth *bind.TransactOpts) (*types.Transaction, error) {
  476. return c.auction.SetCoordinator(auth, forger, coordinatorURL)
  477. },
  478. ); err != nil {
  479. return nil, tracerr.Wrap(fmt.Errorf("Failed set coordinator: %w", err))
  480. }
  481. return tx, nil
  482. }
  483. // AuctionGetCurrentSlotNumber is the interface to call the smart contract function
  484. func (c *AuctionClient) AuctionGetCurrentSlotNumber() (currentSlotNumber int64, err error) {
  485. var _currentSlotNumber *big.Int
  486. if err := c.client.Call(func(ec *ethclient.Client) error {
  487. _currentSlotNumber, err = c.auction.GetCurrentSlotNumber(c.opts)
  488. return tracerr.Wrap(err)
  489. }); err != nil {
  490. return 0, tracerr.Wrap(err)
  491. }
  492. return _currentSlotNumber.Int64(), nil
  493. }
  494. // AuctionGetMinBidBySlot is the interface to call the smart contract function
  495. func (c *AuctionClient) AuctionGetMinBidBySlot(slot int64) (minBid *big.Int, err error) {
  496. if err := c.client.Call(func(ec *ethclient.Client) error {
  497. slotToSend := big.NewInt(slot)
  498. minBid, err = c.auction.GetMinBidBySlot(c.opts, slotToSend)
  499. return tracerr.Wrap(err)
  500. }); err != nil {
  501. return big.NewInt(0), tracerr.Wrap(err)
  502. }
  503. return minBid, nil
  504. }
  505. // AuctionGetSlotSet is the interface to call the smart contract function
  506. func (c *AuctionClient) AuctionGetSlotSet(slot int64) (slotSet *big.Int, err error) {
  507. if err := c.client.Call(func(ec *ethclient.Client) error {
  508. slotToSend := big.NewInt(slot)
  509. slotSet, err = c.auction.GetSlotSet(c.opts, slotToSend)
  510. return tracerr.Wrap(err)
  511. }); err != nil {
  512. return big.NewInt(0), tracerr.Wrap(err)
  513. }
  514. return slotSet, nil
  515. }
  516. // AuctionGetDefaultSlotSetBid is the interface to call the smart contract function
  517. func (c *AuctionClient) AuctionGetDefaultSlotSetBid(slotSet uint8) (minBidSlotSet *big.Int,
  518. err error) {
  519. if err := c.client.Call(func(ec *ethclient.Client) error {
  520. minBidSlotSet, err = c.auction.GetDefaultSlotSetBid(c.opts, slotSet)
  521. return tracerr.Wrap(err)
  522. }); err != nil {
  523. return big.NewInt(0), tracerr.Wrap(err)
  524. }
  525. return minBidSlotSet, nil
  526. }
  527. // AuctionGetSlotNumber is the interface to call the smart contract function
  528. func (c *AuctionClient) AuctionGetSlotNumber(blockNum int64) (slot int64, err error) {
  529. var _slot *big.Int
  530. if err := c.client.Call(func(ec *ethclient.Client) error {
  531. _slot, err = c.auction.GetSlotNumber(c.opts, big.NewInt(blockNum))
  532. return tracerr.Wrap(err)
  533. }); err != nil {
  534. return 0, tracerr.Wrap(err)
  535. }
  536. return _slot.Int64(), nil
  537. }
  538. // AuctionBid is the interface to call the smart contract function
  539. func (c *AuctionClient) AuctionBid(amount *big.Int, slot int64, bidAmount *big.Int,
  540. deadline *big.Int) (tx *types.Transaction, err error) {
  541. if tx, err = c.client.CallAuth(
  542. 0,
  543. func(ec *ethclient.Client, auth *bind.TransactOpts) (*types.Transaction, error) {
  544. owner := c.client.account.Address
  545. spender := c.address
  546. nonce, err := c.tokenHEZ.Nonces(c.opts, owner)
  547. if err != nil {
  548. return nil, tracerr.Wrap(err)
  549. }
  550. tokenName := c.tokenHEZCfg.Name
  551. tokenAddr := c.tokenHEZCfg.Address
  552. digest, _ := createPermitDigest(tokenAddr, owner, spender, c.chainID,
  553. amount, nonce, deadline, tokenName)
  554. signature, _ := c.client.ks.SignHash(*c.client.account, digest)
  555. permit := createPermit(owner, spender, amount, deadline, digest, signature)
  556. _slot := big.NewInt(slot)
  557. return c.auction.ProcessBid(auth, amount, _slot, bidAmount, permit)
  558. },
  559. ); err != nil {
  560. return nil, tracerr.Wrap(fmt.Errorf("Failed bid: %w", err))
  561. }
  562. return tx, nil
  563. }
  564. // AuctionMultiBid is the interface to call the smart contract function
  565. func (c *AuctionClient) AuctionMultiBid(amount *big.Int, startingSlot, endingSlot int64,
  566. slotSets [6]bool, maxBid, minBid, deadline *big.Int) (tx *types.Transaction, err error) {
  567. if tx, err = c.client.CallAuth(
  568. 1000000, //nolint:gomnd
  569. func(ec *ethclient.Client, auth *bind.TransactOpts) (*types.Transaction, error) {
  570. owner := c.client.account.Address
  571. spender := c.address
  572. nonce, err := c.tokenHEZ.Nonces(c.opts, owner)
  573. if err != nil {
  574. return nil, tracerr.Wrap(err)
  575. }
  576. tokenName := c.tokenHEZCfg.Name
  577. tokenAddr := c.tokenHEZCfg.Address
  578. digest, _ := createPermitDigest(tokenAddr, owner, spender, c.chainID,
  579. amount, nonce, deadline, tokenName)
  580. signature, _ := c.client.ks.SignHash(*c.client.account, digest)
  581. permit := createPermit(owner, spender, amount, deadline, digest, signature)
  582. _startingSlot := big.NewInt(startingSlot)
  583. _endingSlot := big.NewInt(endingSlot)
  584. return c.auction.ProcessMultiBid(auth, amount, _startingSlot, _endingSlot,
  585. slotSets, maxBid, minBid, permit)
  586. },
  587. ); err != nil {
  588. return nil, tracerr.Wrap(fmt.Errorf("Failed multibid: %w", err))
  589. }
  590. return tx, nil
  591. }
  592. // AuctionCanForge is the interface to call the smart contract function
  593. func (c *AuctionClient) AuctionCanForge(forger ethCommon.Address, blockNum int64) (canForge bool,
  594. err error) {
  595. if err := c.client.Call(func(ec *ethclient.Client) error {
  596. canForge, err = c.auction.CanForge(c.opts, forger, big.NewInt(blockNum))
  597. return tracerr.Wrap(err)
  598. }); err != nil {
  599. return false, tracerr.Wrap(err)
  600. }
  601. return canForge, nil
  602. }
  603. // AuctionClaimHEZ is the interface to call the smart contract function
  604. func (c *AuctionClient) AuctionClaimHEZ() (tx *types.Transaction, err error) {
  605. if tx, err = c.client.CallAuth(
  606. 0,
  607. func(ec *ethclient.Client, auth *bind.TransactOpts) (*types.Transaction, error) {
  608. return c.auction.ClaimHEZ(auth)
  609. },
  610. ); err != nil {
  611. return nil, tracerr.Wrap(fmt.Errorf("Failed claim HEZ: %w", err))
  612. }
  613. return tx, nil
  614. }
  615. // AuctionForge is the interface to call the smart contract function
  616. func (c *AuctionClient) AuctionForge(forger ethCommon.Address) (tx *types.Transaction, err error) {
  617. if tx, err = c.client.CallAuth(
  618. 0,
  619. func(ec *ethclient.Client, auth *bind.TransactOpts) (*types.Transaction, error) {
  620. return c.auction.Forge(auth, forger)
  621. },
  622. ); err != nil {
  623. return nil, tracerr.Wrap(fmt.Errorf("Failed forge: %w", err))
  624. }
  625. return tx, nil
  626. }
  627. // AuctionConstants returns the Constants of the Auction Smart Contract
  628. func (c *AuctionClient) AuctionConstants() (auctionConstants *common.AuctionConstants, err error) {
  629. auctionConstants = new(common.AuctionConstants)
  630. if err := c.client.Call(func(ec *ethclient.Client) error {
  631. auctionConstants.BlocksPerSlot, err = c.auction.BLOCKSPERSLOT(c.opts)
  632. if err != nil {
  633. return tracerr.Wrap(err)
  634. }
  635. genesisBlock, err := c.auction.GenesisBlock(c.opts)
  636. if err != nil {
  637. return tracerr.Wrap(err)
  638. }
  639. auctionConstants.GenesisBlockNum = genesisBlock.Int64()
  640. auctionConstants.HermezRollup, err = c.auction.HermezRollup(c.opts)
  641. if err != nil {
  642. return tracerr.Wrap(err)
  643. }
  644. auctionConstants.InitialMinimalBidding, err =
  645. c.auction.INITIALMINIMALBIDDING(c.opts)
  646. if err != nil {
  647. return tracerr.Wrap(err)
  648. }
  649. auctionConstants.GovernanceAddress, err = c.auction.GovernanceAddress(c.opts)
  650. if err != nil {
  651. return tracerr.Wrap(err)
  652. }
  653. auctionConstants.TokenHEZ, err = c.auction.TokenHEZ(c.opts)
  654. if err != nil {
  655. return tracerr.Wrap(err)
  656. }
  657. return nil
  658. }); err != nil {
  659. return nil, tracerr.Wrap(err)
  660. }
  661. return auctionConstants, nil
  662. }
  663. // AuctionVariables returns the variables of the Auction Smart Contract
  664. func (c *AuctionClient) AuctionVariables() (auctionVariables *common.AuctionVariables, err error) {
  665. auctionVariables = new(common.AuctionVariables)
  666. if err := c.client.Call(func(ec *ethclient.Client) error {
  667. auctionVariables.AllocationRatio, err = c.AuctionGetAllocationRatio()
  668. if err != nil {
  669. return tracerr.Wrap(err)
  670. }
  671. bootCoordinator, err := c.AuctionGetBootCoordinator()
  672. if err != nil {
  673. return tracerr.Wrap(err)
  674. }
  675. auctionVariables.BootCoordinator = *bootCoordinator
  676. auctionVariables.BootCoordinatorURL, err = c.auction.BootCoordinatorURL(c.opts)
  677. if err != nil {
  678. return tracerr.Wrap(err)
  679. }
  680. auctionVariables.ClosedAuctionSlots, err = c.AuctionGetClosedAuctionSlots()
  681. if err != nil {
  682. return tracerr.Wrap(err)
  683. }
  684. var defaultSlotSetBid [6]*big.Int
  685. for i := uint8(0); i < 6; i++ {
  686. bid, err := c.AuctionGetDefaultSlotSetBid(i)
  687. if err != nil {
  688. return tracerr.Wrap(err)
  689. }
  690. defaultSlotSetBid[i] = bid
  691. }
  692. auctionVariables.DefaultSlotSetBid = defaultSlotSetBid
  693. donationAddress, err := c.AuctionGetDonationAddress()
  694. if err != nil {
  695. return tracerr.Wrap(err)
  696. }
  697. auctionVariables.DonationAddress = *donationAddress
  698. auctionVariables.OpenAuctionSlots, err = c.AuctionGetOpenAuctionSlots()
  699. if err != nil {
  700. return tracerr.Wrap(err)
  701. }
  702. auctionVariables.Outbidding, err = c.AuctionGetOutbidding()
  703. if err != nil {
  704. return tracerr.Wrap(err)
  705. }
  706. auctionVariables.SlotDeadline, err = c.AuctionGetSlotDeadline()
  707. return tracerr.Wrap(err)
  708. }); err != nil {
  709. return nil, tracerr.Wrap(err)
  710. }
  711. return auctionVariables, nil
  712. }
  713. var (
  714. logAuctionNewBid = crypto.Keccak256Hash([]byte(
  715. "NewBid(uint128,uint128,address)"))
  716. logAuctionNewSlotDeadline = crypto.Keccak256Hash([]byte(
  717. "NewSlotDeadline(uint8)"))
  718. logAuctionNewClosedAuctionSlots = crypto.Keccak256Hash([]byte(
  719. "NewClosedAuctionSlots(uint16)"))
  720. logAuctionNewOutbidding = crypto.Keccak256Hash([]byte(
  721. "NewOutbidding(uint16)"))
  722. logAuctionNewDonationAddress = crypto.Keccak256Hash([]byte(
  723. "NewDonationAddress(address)"))
  724. logAuctionNewBootCoordinator = crypto.Keccak256Hash([]byte(
  725. "NewBootCoordinator(address,string)"))
  726. logAuctionNewOpenAuctionSlots = crypto.Keccak256Hash([]byte(
  727. "NewOpenAuctionSlots(uint16)"))
  728. logAuctionNewAllocationRatio = crypto.Keccak256Hash([]byte(
  729. "NewAllocationRatio(uint16[3])"))
  730. logAuctionSetCoordinator = crypto.Keccak256Hash([]byte(
  731. "SetCoordinator(address,address,string)"))
  732. logAuctionNewForgeAllocated = crypto.Keccak256Hash([]byte(
  733. "NewForgeAllocated(address,address,uint128,uint128,uint128,uint128)"))
  734. logAuctionNewDefaultSlotSetBid = crypto.Keccak256Hash([]byte(
  735. "NewDefaultSlotSetBid(uint128,uint128)"))
  736. logAuctionNewForge = crypto.Keccak256Hash([]byte(
  737. "NewForge(address,uint128)"))
  738. logAuctionHEZClaimed = crypto.Keccak256Hash([]byte(
  739. "HEZClaimed(address,uint128)"))
  740. logAuctionInitialize = crypto.Keccak256Hash([]byte(
  741. "InitializeHermezAuctionProtocolEvent(address,address,string," +
  742. "uint16,uint8,uint16,uint16,uint16[3])"))
  743. )
  744. // AuctionEventInit returns the initialize event with its corresponding block number
  745. func (c *AuctionClient) AuctionEventInit(genesisBlockNum int64) (*AuctionEventInitialize, int64, error) {
  746. query := ethereum.FilterQuery{
  747. Addresses: []ethCommon.Address{
  748. c.address,
  749. },
  750. FromBlock: big.NewInt(max(0, genesisBlockNum-blocksPerDay)),
  751. ToBlock: big.NewInt(genesisBlockNum),
  752. Topics: [][]ethCommon.Hash{{logAuctionInitialize}},
  753. }
  754. logs, err := c.client.client.FilterLogs(context.Background(), query)
  755. if err != nil {
  756. return nil, 0, tracerr.Wrap(err)
  757. }
  758. if len(logs) != 1 {
  759. return nil, 0,
  760. tracerr.Wrap(fmt.Errorf("no event of type InitializeHermezAuctionProtocolEvent found"))
  761. }
  762. vLog := logs[0]
  763. if vLog.Topics[0] != logAuctionInitialize {
  764. return nil, 0, tracerr.Wrap(fmt.Errorf("event is not InitializeHermezAuctionProtocolEvent"))
  765. }
  766. var auctionInit AuctionEventInitialize
  767. if err := c.contractAbi.UnpackIntoInterface(&auctionInit,
  768. "InitializeHermezAuctionProtocolEvent", vLog.Data); err != nil {
  769. return nil, 0, tracerr.Wrap(err)
  770. }
  771. return &auctionInit, int64(vLog.BlockNumber), tracerr.Wrap(err)
  772. }
  773. // AuctionEventsByBlock returns the events in a block that happened in the
  774. // Auction Smart Contract.
  775. // To query by blockNum, set blockNum >= 0 and blockHash == nil.
  776. // To query by blockHash set blockHash != nil, and blockNum will be ignored.
  777. // If there are no events in that block the result is nil.
  778. func (c *AuctionClient) AuctionEventsByBlock(blockNum int64,
  779. blockHash *ethCommon.Hash) (*AuctionEvents, error) {
  780. var auctionEvents AuctionEvents
  781. var blockNumBigInt *big.Int
  782. if blockHash == nil {
  783. blockNumBigInt = big.NewInt(blockNum)
  784. }
  785. query := ethereum.FilterQuery{
  786. BlockHash: blockHash,
  787. FromBlock: blockNumBigInt,
  788. ToBlock: blockNumBigInt,
  789. Addresses: []ethCommon.Address{
  790. c.address,
  791. },
  792. Topics: [][]ethCommon.Hash{},
  793. }
  794. logs, err := c.client.client.FilterLogs(context.TODO(), query)
  795. if err != nil {
  796. return nil, tracerr.Wrap(err)
  797. }
  798. if len(logs) == 0 {
  799. return nil, nil
  800. }
  801. for _, vLog := range logs {
  802. if blockHash != nil && vLog.BlockHash != *blockHash {
  803. log.Errorw("Block hash mismatch", "expected", blockHash.String(), "got",
  804. vLog.BlockHash.String())
  805. return nil, tracerr.Wrap(ErrBlockHashMismatchEvent)
  806. }
  807. switch vLog.Topics[0] {
  808. case logAuctionNewBid:
  809. var auxNewBid struct {
  810. Slot *big.Int
  811. BidAmount *big.Int
  812. Address ethCommon.Address
  813. }
  814. var newBid AuctionEventNewBid
  815. if err := c.contractAbi.UnpackIntoInterface(&auxNewBid, "NewBid",
  816. vLog.Data); err != nil {
  817. return nil, tracerr.Wrap(err)
  818. }
  819. newBid.BidAmount = auxNewBid.BidAmount
  820. newBid.Slot = new(big.Int).SetBytes(vLog.Topics[1][:]).Int64()
  821. newBid.Bidder = ethCommon.BytesToAddress(vLog.Topics[2].Bytes())
  822. auctionEvents.NewBid = append(auctionEvents.NewBid, newBid)
  823. case logAuctionNewSlotDeadline:
  824. var newSlotDeadline AuctionEventNewSlotDeadline
  825. if err := c.contractAbi.UnpackIntoInterface(&newSlotDeadline,
  826. "NewSlotDeadline", vLog.Data); err != nil {
  827. return nil, tracerr.Wrap(err)
  828. }
  829. auctionEvents.NewSlotDeadline = append(auctionEvents.NewSlotDeadline, newSlotDeadline)
  830. case logAuctionNewClosedAuctionSlots:
  831. var newClosedAuctionSlots AuctionEventNewClosedAuctionSlots
  832. if err := c.contractAbi.UnpackIntoInterface(&newClosedAuctionSlots,
  833. "NewClosedAuctionSlots", vLog.Data); err != nil {
  834. return nil, tracerr.Wrap(err)
  835. }
  836. auctionEvents.NewClosedAuctionSlots =
  837. append(auctionEvents.NewClosedAuctionSlots, newClosedAuctionSlots)
  838. case logAuctionNewOutbidding:
  839. var newOutbidding AuctionEventNewOutbidding
  840. if err := c.contractAbi.UnpackIntoInterface(&newOutbidding, "NewOutbidding",
  841. vLog.Data); err != nil {
  842. return nil, tracerr.Wrap(err)
  843. }
  844. auctionEvents.NewOutbidding = append(auctionEvents.NewOutbidding, newOutbidding)
  845. case logAuctionNewDonationAddress:
  846. var newDonationAddress AuctionEventNewDonationAddress
  847. newDonationAddress.NewDonationAddress = ethCommon.BytesToAddress(vLog.Topics[1].Bytes())
  848. auctionEvents.NewDonationAddress = append(auctionEvents.NewDonationAddress,
  849. newDonationAddress)
  850. case logAuctionNewBootCoordinator:
  851. var newBootCoordinator AuctionEventNewBootCoordinator
  852. if err := c.contractAbi.UnpackIntoInterface(&newBootCoordinator,
  853. "NewBootCoordinator", vLog.Data); err != nil {
  854. return nil, tracerr.Wrap(err)
  855. }
  856. newBootCoordinator.NewBootCoordinator = ethCommon.BytesToAddress(vLog.Topics[1].Bytes())
  857. auctionEvents.NewBootCoordinator = append(auctionEvents.NewBootCoordinator,
  858. newBootCoordinator)
  859. case logAuctionNewOpenAuctionSlots:
  860. var newOpenAuctionSlots AuctionEventNewOpenAuctionSlots
  861. if err := c.contractAbi.UnpackIntoInterface(&newOpenAuctionSlots,
  862. "NewOpenAuctionSlots", vLog.Data); err != nil {
  863. return nil, tracerr.Wrap(err)
  864. }
  865. auctionEvents.NewOpenAuctionSlots =
  866. append(auctionEvents.NewOpenAuctionSlots, newOpenAuctionSlots)
  867. case logAuctionNewAllocationRatio:
  868. var newAllocationRatio AuctionEventNewAllocationRatio
  869. if err := c.contractAbi.UnpackIntoInterface(&newAllocationRatio,
  870. "NewAllocationRatio", vLog.Data); err != nil {
  871. return nil, tracerr.Wrap(err)
  872. }
  873. auctionEvents.NewAllocationRatio = append(auctionEvents.NewAllocationRatio,
  874. newAllocationRatio)
  875. case logAuctionSetCoordinator:
  876. var setCoordinator AuctionEventSetCoordinator
  877. if err := c.contractAbi.UnpackIntoInterface(&setCoordinator,
  878. "SetCoordinator", vLog.Data); err != nil {
  879. return nil, tracerr.Wrap(err)
  880. }
  881. setCoordinator.BidderAddress = ethCommon.BytesToAddress(vLog.Topics[1].Bytes())
  882. setCoordinator.ForgerAddress = ethCommon.BytesToAddress(vLog.Topics[2].Bytes())
  883. auctionEvents.SetCoordinator = append(auctionEvents.SetCoordinator, setCoordinator)
  884. case logAuctionNewForgeAllocated:
  885. var newForgeAllocated AuctionEventNewForgeAllocated
  886. if err := c.contractAbi.UnpackIntoInterface(&newForgeAllocated,
  887. "NewForgeAllocated", vLog.Data); err != nil {
  888. return nil, tracerr.Wrap(err)
  889. }
  890. newForgeAllocated.Bidder = ethCommon.BytesToAddress(vLog.Topics[1].Bytes())
  891. newForgeAllocated.Forger = ethCommon.BytesToAddress(vLog.Topics[2].Bytes())
  892. newForgeAllocated.SlotToForge = new(big.Int).SetBytes(vLog.Topics[3][:]).Int64()
  893. auctionEvents.NewForgeAllocated = append(auctionEvents.NewForgeAllocated,
  894. newForgeAllocated)
  895. case logAuctionNewDefaultSlotSetBid:
  896. var auxNewDefaultSlotSetBid struct {
  897. SlotSet *big.Int
  898. NewInitialMinBid *big.Int
  899. }
  900. var newDefaultSlotSetBid AuctionEventNewDefaultSlotSetBid
  901. if err := c.contractAbi.UnpackIntoInterface(&auxNewDefaultSlotSetBid,
  902. "NewDefaultSlotSetBid", vLog.Data); err != nil {
  903. return nil, tracerr.Wrap(err)
  904. }
  905. newDefaultSlotSetBid.NewInitialMinBid = auxNewDefaultSlotSetBid.NewInitialMinBid
  906. newDefaultSlotSetBid.SlotSet = auxNewDefaultSlotSetBid.SlotSet.Int64()
  907. auctionEvents.NewDefaultSlotSetBid =
  908. append(auctionEvents.NewDefaultSlotSetBid, newDefaultSlotSetBid)
  909. case logAuctionNewForge:
  910. var newForge AuctionEventNewForge
  911. newForge.Forger = ethCommon.BytesToAddress(vLog.Topics[1].Bytes())
  912. newForge.SlotToForge = new(big.Int).SetBytes(vLog.Topics[2][:]).Int64()
  913. auctionEvents.NewForge = append(auctionEvents.NewForge, newForge)
  914. case logAuctionHEZClaimed:
  915. var HEZClaimed AuctionEventHEZClaimed
  916. if err := c.contractAbi.UnpackIntoInterface(&HEZClaimed, "HEZClaimed",
  917. vLog.Data); err != nil {
  918. return nil, tracerr.Wrap(err)
  919. }
  920. HEZClaimed.Owner = ethCommon.BytesToAddress(vLog.Topics[1].Bytes())
  921. auctionEvents.HEZClaimed = append(auctionEvents.HEZClaimed, HEZClaimed)
  922. }
  923. }
  924. return &auctionEvents, nil
  925. }